BME280 Driver 2.0.x
Driver for BME280 sensor
|
BME280 Driver. More...
Modules | |
Private Resources | |
only for internal library purposes | |
Library Configuration | |
Set library options here. | |
Public functions | |
Use these functions only. | |
BME280 Returnd Values | |
Values that can be returned by the driver's functions. | |
BME280 I2C Address | |
Address on I2C bus. | |
BME280 Registers | |
Definition of register addresses and lenghts. | |
BME280 Settings | |
Inernal sensor's settings that can be changed. | |
Function pointers | |
Platform speicific functions. | |
Public typedefs | |
Typedefs for internal calculations. | |
Data Structures | |
struct | BME280_calibration_data |
Keeps calibration data that were read from sensor. More... | |
struct | BME280_Driver_t |
Keeps all data specific for used platform. More... | |
struct | BME280_t |
Keeps all data related to a single sensor. More... | |
struct | BME280_Config_t |
Contains all sensor's settings. More... | |
struct | BME280_Data_t |
Contains result of measure (no floating points variables) More... | |
struct | BME280_DataF_t |
Contains result of measure (with floating points variables) More... | |
Functions | |
int8_t | BME280_Init (BME280_t *Dev, BME280_Driver_t *Driver) |
Function to initialize sensor and resources. | |
int8_t | BME280_ConfigureAll (BME280_t *Dev, BME280_Config_t *Config) |
Function to set all sensor settings at once. | |
int8_t | BME280_Reset (BME280_t *Dev) |
Function to perform sensor's software reset. | |
int8_t | BME280_GetMode (BME280_t *Dev, uint8_t *Mode) |
Function gets current Operating Mode from sensor. | |
int8_t | BME280_GetPOvs (BME280_t *Dev, uint8_t *POvs) |
Function gets current pressure Oversampling from sensor. | |
int8_t | BME280_GetTOvs (BME280_t *Dev, uint8_t *TOvs) |
Function gets current temperature Oversampling from sensor. | |
int8_t | BME280_GetHOvs (BME280_t *Dev, uint8_t *HOvs) |
Function gets current humidity Oversampling from sensor. | |
int8_t | BME280_GetTStby (BME280_t *Dev, uint8_t *TStby) |
Function gets current Standby Time from sensor. | |
int8_t | BME280_GetTFilter (BME280_t *Dev, uint8_t *Filter) |
Function gets current IIR Filter coeficient from sensor. | |
int8_t | BME280_Is3WireSPIEnabled (BME280_t *Dev, uint8_t *Result) |
Function checks if 3-wire SPI is enabled. | |
int8_t | BME280_SetMode (BME280_t *Dev, uint8_t Mode) |
Function sets sensor's Operating Mode. | |
int8_t | BME280_SetPOvs (BME280_t *Dev, uint8_t POvs) |
Function sets sensor's pressure Oversampling. | |
int8_t | BME280_SetTOvs (BME280_t *Dev, uint8_t TOvs) |
Function sets sensor's temperature Oversampling. | |
int8_t | BME280_SetHOvs (BME280_t *Dev, uint8_t HOvs) |
Function sets sensor's humidity Oversampling. | |
int8_t | BME280_SetTStby (BME280_t *Dev, uint8_t TStby) |
Function sets sensor's Standby Time. | |
int8_t | BME280_SetFilter (BME280_t *Dev, uint8_t Filter) |
Function sets sensor's IIR Filter coeficient. | |
int8_t | BME280_Enable3WireSPI (BME280_t *Dev) |
Function enables 3-wire SPI bus. | |
int8_t | BME280_Disable3WireSPI (BME280_t *Dev) |
Function disables 3-wire SPI bus. | |
int8_t | BME280_ReadAllLast (BME280_t *Dev, BME280_Data_t *Data) |
Function reads all measured data at once. | |
int8_t | BME280_ReadTempLast (BME280_t *Dev, int8_t *TempInt, uint8_t *TempFract) |
Function reads last measured temperature. | |
int8_t | BME280_ReadPressLast (BME280_t *Dev, uint16_t *PressInt, uint16_t *PressFract) |
Function reads last measured pressure. | |
int8_t | BME280_ReadHumLast (BME280_t *Dev, uint8_t *HumInt, uint16_t *HumFract) |
Function reads last measured humidity. | |
int8_t | BME280_ReadAllForce (BME280_t *Dev, BME280_Data_t *Data) |
Function forces single measure and returns all data as integers. | |
int8_t | BME280_ReadTempForce (BME280_t *Dev, int8_t *TempInt, uint8_t *TempFract) |
Function forces single measure and returns temperatrue as integers (forced mode) | |
int8_t | BME280_ReadPressForce (BME280_t *Dev, uint16_t *PressInt, uint16_t *PressFract) |
Function forces single measure and returns pressure as integers (forced mode) | |
int8_t | BME280_ReadHumForce (BME280_t *Dev, uint8_t *HumInt, uint16_t *HumFract) |
Function forces single measure and returns humidity as integers (forced mode) | |
int8_t | BME280_ReadAllLast_F (BME280_t *Dev, BME280_DataF_t *Data) |
Function reads all measured data at once. | |
int8_t | BME280_ReadTempLast_F (BME280_t *Dev, float *Temp) |
Function reads last measured temperature. | |
int8_t | BME280_ReadPressLast_F (BME280_t *Dev, float *Press) |
Function reads last measured pressure. | |
int8_t | BME280_ReadHumLast_F (BME280_t *Dev, float *Hum) |
Function reads last measured humidity. | |
int8_t | BME280_ReadAllForce_F (BME280_t *Dev, BME280_DataF_t *Data) |
Function forces single measure and returns all data as floats. | |
int8_t | BME280_ReadTempForce_F (BME280_t *Dev, float *Temp) |
Function forces single measure and returns temperatrue as floats (forced mode) | |
int8_t | BME280_ReadPressForce_F (BME280_t *Dev, float *Press) |
Function forces single measure and returns pressure as floats (forced mode) | |
int8_t | BME280_ReadHumForce_F (BME280_t *Dev, float *Hum) |
Function forces single measure and returns humidity as floats (forced mode) | |
BME280 Driver.
int8_t BME280_ConfigureAll | ( | BME280_t * | Dev, |
BME280_Config_t * | Config | ||
) |
Function to set all sensor settings at once.
Function writes all 3 config registers without reading them before. It can be usefull after power-up or reset. It sets current operating mode inside *Dev structure at the end.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | *Config | pointer to BME280_Config_t structure which contains all paramaters to be set |
int8_t BME280_Disable3WireSPI | ( | BME280_t * | Dev | ) |
Function disables 3-wire SPI bus.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
int8_t BME280_Enable3WireSPI | ( | BME280_t * | Dev | ) |
Function enables 3-wire SPI bus.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
int8_t BME280_GetHOvs | ( | BME280_t * | Dev, |
uint8_t * | HOvs | ||
) |
Function gets current humidity Oversampling from sensor.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *HOvs | pointer to vartiable where result will be stored |
int8_t BME280_GetMode | ( | BME280_t * | Dev, |
uint8_t * | Mode | ||
) |
Function gets current Operating Mode from sensor.
Function updates current operating mode inside *Dev structure as well.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Mode | pointer to vartiable where result will be stored |
int8_t BME280_GetPOvs | ( | BME280_t * | Dev, |
uint8_t * | POvs | ||
) |
Function gets current pressure Oversampling from sensor.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *POvs | pointer to vartiable where result will be stored |
int8_t BME280_GetTFilter | ( | BME280_t * | Dev, |
uint8_t * | Filter | ||
) |
Function gets current IIR Filter coeficient from sensor.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Filter | pointer to vartiable where result will be stored |
int8_t BME280_GetTOvs | ( | BME280_t * | Dev, |
uint8_t * | TOvs | ||
) |
Function gets current temperature Oversampling from sensor.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *TOvs | pointer to vartiable where result will be stored |
int8_t BME280_GetTStby | ( | BME280_t * | Dev, |
uint8_t * | TStby | ||
) |
Function gets current Standby Time from sensor.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *TStby | pointer to vartiable where result will be stored |
int8_t BME280_Init | ( | BME280_t * | Dev, |
BME280_Driver_t * | Driver | ||
) |
Function to initialize sensor and resources.
Init funtion performs sensor reset and checks BME280_ID. It doesn't set any sensor's parameters. Calibration data specific for each one sensor are read while Init function. If operation is completed with success function sets "initialized" value in BME280_t structure.
[in] | *Dev | pointer to BME280_t structure which should be initialized |
[in] | *Driver | pointer to BME280_Driver_t structure where all platform specific data are stored. This structure MUST exist while program is running - do not use local structures to init sensor! |
int8_t BME280_Is3WireSPIEnabled | ( | BME280_t * | Dev, |
uint8_t * | Result | ||
) |
Function checks if 3-wire SPI is enabled.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Result | pointer to vartiable where result will be stored, 0 - disabled, 1 - enabled |
int8_t BME280_ReadAllForce | ( | BME280_t * | Dev, |
BME280_Data_t * | Data | ||
) |
Function forces single measure and returns all data as integers.
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads all adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into BME280_Data_t structure.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Data | pointer to structure where result will be stored |
int8_t BME280_ReadAllForce_F | ( | BME280_t * | Dev, |
BME280_DataF_t * | Data | ||
) |
Function forces single measure and returns all data as floats.
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads all adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into BME280_DataF_t structure.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Data | pointer to structure where result will be stored |
int8_t BME280_ReadAllLast | ( | BME280_t * | Dev, |
BME280_Data_t * | Data | ||
) |
Function reads all measured data at once.
Function reads all adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into BME280_Data_t structure.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Data | pointer to structure where result will be stored |
int8_t BME280_ReadAllLast_F | ( | BME280_t * | Dev, |
BME280_DataF_t * | Data | ||
) |
Function reads all measured data at once.
Function reads all adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into BME280_DataF_t structure.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Data | pointer to structure where result will be stored |
int8_t BME280_ReadHumForce | ( | BME280_t * | Dev, |
uint8_t * | HumInt, | ||
uint16_t * | HumFract | ||
) |
Function forces single measure and returns humidity as integers (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperarure and humidity related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into integer (*HumInt) and fractial part (*HumFract).
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *HumInt | pointer to variable where integer part of humidity will be stored |
[out] | *HumFract | pointer to variable where fractial part of humidity will be stored |
int8_t BME280_ReadHumForce_F | ( | BME280_t * | Dev, |
float * | Hum | ||
) |
Function forces single measure and returns humidity as floats (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperature and humidity related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into float.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Hum | pointer to variable where humidity will be stored |
int8_t BME280_ReadHumLast | ( | BME280_t * | Dev, |
uint8_t * | HumInt, | ||
uint16_t * | HumFract | ||
) |
Function reads last measured humidity.
Function reads temperature and humidity related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated value is then converted into integer part and fractial part and stored in external variables
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *HumInt | pointer to variable where integer part of humidity will be stored |
[out] | *HumFract | pointer to variable where fractial part of humidity will be stored |
int8_t BME280_ReadHumLast_F | ( | BME280_t * | Dev, |
float * | Hum | ||
) |
Function reads last measured humidity.
Function reads temperature and humidity related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated value is then converted into floating point value and stored in external variable
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Hum | pointer to variable where temperature will be stored |
int8_t BME280_ReadPressForce | ( | BME280_t * | Dev, |
uint16_t * | PressInt, | ||
uint16_t * | PressFract | ||
) |
Function forces single measure and returns pressure as integers (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperarure and pressure related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into integer (*PressInt) and fractial part (*PressFract).
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *PressInt | pointer to variable where integer part of pressure will be stored |
[out] | *PressFract | pointer to variable where fractial part of pressure will be stored |
int8_t BME280_ReadPressForce_F | ( | BME280_t * | Dev, |
float * | Press | ||
) |
Function forces single measure and returns pressure as floats (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperature and pressure related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into float.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Press | pointer to variable where pressure will be stored |
int8_t BME280_ReadPressLast | ( | BME280_t * | Dev, |
uint16_t * | PressInt, | ||
uint16_t * | PressFract | ||
) |
Function reads last measured pressure.
Function reads temperature and pressure related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated value is then converted into integer part and fractial part and stored in external variables
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *PressInt | pointer to variable where integer part of pressure will be stored |
[out] | *PressFract | pointer to variable where fractial part of pressure will be stored |
int8_t BME280_ReadPressLast_F | ( | BME280_t * | Dev, |
float * | Press | ||
) |
Function reads last measured pressure.
Function reads temperature and pressure related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated value is then converted into floating point value and stored in external variable
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Press | pointer to variable where temperature will be stored |
int8_t BME280_ReadTempForce | ( | BME280_t * | Dev, |
int8_t * | TempInt, | ||
uint8_t * | TempFract | ||
) |
Function forces single measure and returns temperatrue as integers (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperature related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into integer (*TempInt) and fractial part (*TempFract).
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *TempInt | pointer to variable where integer part of temperature will be stored |
[out] | *TempFract | pointer to variable where fractial part of temperature will be stored |
int8_t BME280_ReadTempForce_F | ( | BME280_t * | Dev, |
float * | Temp | ||
) |
Function forces single measure and returns temperatrue as floats (forced mode)
Function reads sensor's configuration to check conditions and calculate max. delay time required for measure cycle. Then sends command to force single measurement and calls used-defined delay function. When delay function returns ir reads temperature related adc values from sensor, converts them into single variables and compensate with use BME280_calibration_data. Compensated values are then converted into float.
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Temp | pointer to variable where temperature will be stored |
int8_t BME280_ReadTempLast | ( | BME280_t * | Dev, |
int8_t * | TempInt, | ||
uint8_t * | TempFract | ||
) |
Function reads last measured temperature.
Function reads temperature related adc values from sensor, converts them into single variable and compensate with use BME280_calibration_data. Compensated value is then converted into integer part and fractial part and stored in external variables
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *TempInt | pointer to variable where integer part of temperature will be stored |
[out] | *TempFract | pointer to variable where fractial part of temperature will be stored |
int8_t BME280_ReadTempLast_F | ( | BME280_t * | Dev, |
float * | Temp | ||
) |
Function reads last measured temperature.
Function reads temperature related adc values from sensor, converts them into single variable and compensate with use BME280_calibration_data. Compensated value is then converted into floating point value and stored in external variable
[in] | *Dev | pointer to sensor's BME280_t structure |
[out] | *Temp | pointer to variable where temperature will be stored |
int8_t BME280_Reset | ( | BME280_t * | Dev | ) |
Function to perform sensor's software reset.
Function sends BME280_RESET_VALUE to BME280_RESET_ADDR. To perform this operation bme280_writeregister function must be set inside BME280_t *Dev structure. Function sets "sleep_mode" inside *Dev structure after reset.
[in] | *Dev | pointer to sensor's BME280_t structure |
int8_t BME280_SetFilter | ( | BME280_t * | Dev, |
uint8_t | Filter | ||
) |
Function sets sensor's IIR Filter coeficient.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | Filter | value to be set, must be in range of IIR Filter |
int8_t BME280_SetHOvs | ( | BME280_t * | Dev, |
uint8_t | HOvs | ||
) |
Function sets sensor's humidity Oversampling.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | HOvs | value to be set, must be in range of Oversampling |
int8_t BME280_SetMode | ( | BME280_t * | Dev, |
uint8_t | Mode | ||
) |
Function sets sensor's Operating Mode.
Function reads single register from sensor, and checks if current mode matches mode requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value, then sets correct operating mode inside *Dev structure.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | Mode | value to be set, must be in range of Operating Mode |
int8_t BME280_SetPOvs | ( | BME280_t * | Dev, |
uint8_t | POvs | ||
) |
Function sets sensor's pressure Oversampling.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | POvs | value to be set, must be in range of Oversampling |
int8_t BME280_SetTOvs | ( | BME280_t * | Dev, |
uint8_t | TOvs | ||
) |
Function sets sensor's temperature Oversampling.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | TOvs | value to be set, must be in range of Oversampling |
int8_t BME280_SetTStby | ( | BME280_t * | Dev, |
uint8_t | TStby | ||
) |
Function sets sensor's Standby Time.
Function reads single register from sensor, and checks if current value matches value requested by user. If matches, function skips write operation and returns BME280_OK. If doesnt, it prepares and sends new register value.
[in] | *Dev | pointer to sensor's BME280_t structure |
[in] | TStby | value to be set, must be in range of Standby Time |