RocketLogger  1.1.6
bme280.c File Reference
#include "sensor.h"
#include "bme280.h"
+ Include dependency graph for bme280.c:

Go to the source code of this file.

Functions

int BME280_init (int sensor_identifier)
 
void BME280_close (int sensor_identifier)
 
int BME280_read (int sensor_identifier)
 
int32_t BME280_getValue (int sensor_identifier, int channel)
 
int BME280_getID (void)
 
int BME280_readCalibration (int sensor_identifier)
 
int BME280_setParameters (int sensor_identifier)
 
int BME280_getIndex (int sensor_identifier)
 
int32_t BME280_compensate_temperature_fine (int sensor_identifier, int32_t temperature_raw)
 
int32_t BME280_compensate_temperature (int sensor_identifier, int32_t temperature_raw)
 
uint32_t BME280_compensate_preasure (int sensor_identifier, int32_t preasure_raw, int32_t temperature_raw)
 
uint32_t BME280_compensate_humidity (int sensor_identifier, int32_t humidity_raw, int32_t temperature_raw)
 

Variables

const int BME280_sensors [] = BME280_I2C_ADDRESSES
 
int32_t BME280_temperature [sizeof(BME280_sensors)] = {0}
 
int32_t BME280_humidity [sizeof(BME280_sensors)] = {0}
 
int32_t BME280_preasure [sizeof(BME280_sensors)] = {0}
 
struct BME280_calibration_t BME280_calibration [sizeof(BME280_sensors)]
 

Function Documentation

void BME280_close ( int  sensor_identifier)

Close TSL sensor.

Parameters
sensor_identifierThe I2C address of the sensor

Definition at line 90 of file bme280.c.

uint32_t BME280_compensate_humidity ( int  sensor_identifier,
int32_t  humidity_raw,
int32_t  temperature_raw 
)

Get the compensated relative humidity in micros (0.0001 percents).

Parameters
sensor_identifierThe I2C address of the sensor
humidity_rawThe raw humidity reading
temperature_rawThe raw temperature reading
Returns
The compensated humidity in micros (0.0001 percents)

Definition at line 398 of file bme280.c.

References BME280_calibration, BME280_compensate_temperature_fine(), BME280_getIndex(), BME280_calibration_t::H1, BME280_calibration_t::H2, BME280_calibration_t::H3, BME280_calibration_t::H4, BME280_calibration_t::H5, and BME280_calibration_t::H6.

Referenced by BME280_read().

+ Here is the call graph for this function:

uint32_t BME280_compensate_preasure ( int  sensor_identifier,
int32_t  preasure_raw,
int32_t  temperature_raw 
)

Get the compensated preasure in milli Pascal.

Parameters
sensor_identifierThe I2C address of the sensor
preasure_rawThe raw preasure reading
temperature_rawThe raw temperature reading
Returns
The compensated preasure in 0.001 Pascal

Definition at line 353 of file bme280.c.

References BME280_calibration, BME280_compensate_temperature_fine(), BME280_getIndex(), BME280_calibration_t::P1, BME280_calibration_t::P2, BME280_calibration_t::P3, BME280_calibration_t::P4, BME280_calibration_t::P5, BME280_calibration_t::P6, BME280_calibration_t::P7, BME280_calibration_t::P8, and BME280_calibration_t::P9.

Referenced by BME280_read().

+ Here is the call graph for this function:

int32_t BME280_compensate_temperature ( int  sensor_identifier,
int32_t  temperature_raw 
)

Get the compensated temperature in milli degree centigrade.

Parameters
sensor_identifierThe I2C address of the sensor
temperature_rawThe raw temperature reading
Returns
The compensated temperature in 0.001 degree centigrade

Definition at line 338 of file bme280.c.

References BME280_compensate_temperature_fine().

Referenced by BME280_read().

+ Here is the call graph for this function:

int32_t BME280_compensate_temperature_fine ( int  sensor_identifier,
int32_t  temperature_raw 
)

Get fine grained temperature compensation value for further processing.

Parameters
sensor_identifierThe I2C address of the sensor
temperature_rawThe raw temperature reading
Returns
Fine grained, compensated temperature (arbritrary unit)

Definition at line 311 of file bme280.c.

References BME280_calibration, BME280_getIndex(), BME280_calibration_t::T1, BME280_calibration_t::T2, and BME280_calibration_t::T3.

Referenced by BME280_compensate_humidity(), BME280_compensate_preasure(), and BME280_compensate_temperature().

+ Here is the call graph for this function:

int BME280_getID ( void  )

Get the device ID

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Devie ID or negative status code

Definition at line 170 of file bme280.c.

References BME280_REG_ID, ERROR, rl_log(), sensor_bus, and Sensors_getSharedBus().

Referenced by BME280_init().

+ Here is the call graph for this function:

int BME280_getIndex ( int  sensor_identifier)

Get the index of the sensor with specified address.

Parameters
sensor_identifierThe sensor address used to look up the index
Returns
The index of the sensor, or if not found -1

Definition at line 294 of file bme280.c.

References BME280_sensors.

Referenced by BME280_compensate_humidity(), BME280_compensate_preasure(), BME280_compensate_temperature_fine(), BME280_getValue(), BME280_read(), and BME280_readCalibration().

int32_t BME280_getValue ( int  sensor_identifier,
int  channel 
)

Get the values read from the sensor

Parameters
sensor_identifierThe I2C address of the sensor
channelThe channel of the sensor to get
Returns
Channel value

Definition at line 147 of file bme280.c.

References BME280_CHANNEL_HUMIDITY, BME280_CHANNEL_PRESSURE, BME280_CHANNEL_TEMPERATURE, BME280_getIndex(), BME280_humidity, BME280_preasure, and BME280_temperature.

+ Here is the call graph for this function:

int BME280_init ( int  sensor_identifier)

Initialize the light sensor

Parameters
sensor_identifierThe I2C address of the sensor
Returns
return code

Definition at line 49 of file bme280.c.

References BME280_getID(), BME280_ID, BME280_readCalibration(), BME280_setParameters(), ERROR, FAILURE, rl_log(), sensor_bus, Sensors_getSharedBus(), Sensors_initSharedComm(), and SUCCESS.

+ Here is the call graph for this function:

int BME280_read ( int  sensor_identifier)

Read the sensor values.

Parameters
sensor_identifierThe I2C address of the sensor
Returns
Value in lux

Definition at line 99 of file bme280.c.

References BME280_compensate_humidity(), BME280_compensate_preasure(), BME280_compensate_temperature(), BME280_DATA_BLOCK_SIZE, BME280_getIndex(), BME280_humidity, BME280_preasure, BME280_REG_PREASURE_MSB, BME280_temperature, ERROR, FAILURE, rl_log(), sensor_bus, Sensors_getSharedBus(), Sensors_initSharedComm(), and SUCCESS.

+ Here is the call graph for this function:

int BME280_setParameters ( int  sensor_identifier)

Set the sensor parameter to default for continuous sensing.

Returns
Status code

Definition at line 253 of file bme280.c.

References BME280_FILTER_OFF, BME280_MODE_NORMAL, BME280_OVERSAMPLE_HUMIDITY_1, BME280_OVERSAMPLE_PREASURE_1, BME280_OVERSAMPLE_TEMPERATURE_1, BME280_REG_CONFIG, BME280_REG_CONTROL_HUMIDITY, BME280_REG_CONTROL_MEASURE, BME280_STANDBY_DURATION_250, ERROR, FAILURE, rl_log(), sensor_bus, Sensors_getSharedBus(), and SUCCESS.

Referenced by BME280_init().

+ Here is the call graph for this function:

Variable Documentation

int32_t BME280_humidity[sizeof(BME280_sensors)] = {0}

Definition at line 39 of file bme280.c.

Referenced by BME280_getValue(), and BME280_read().

int32_t BME280_preasure[sizeof(BME280_sensors)] = {0}

Definition at line 40 of file bme280.c.

Referenced by BME280_getValue(), and BME280_read().

const int BME280_sensors[] = BME280_I2C_ADDRESSES

Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 36 of file bme280.c.

Referenced by BME280_getIndex().

int32_t BME280_temperature[sizeof(BME280_sensors)] = {0}

Definition at line 38 of file bme280.c.

Referenced by BME280_getValue(), and BME280_read().