px-lib  0.9.2
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers
px_bme280.h : Bosch BME280 Barometric pressure sensor driver

Description

File(s):

Reference:

Data Structures

struct  px_bme280_data_t
 Raw sensor data. More...
 

Macros

#define PX_BME280_I2C_SLA_ADR   0x77
 BME280 I2C Slave address. More...
 

Functions

bool px_bme280_init (px_i2c_handle_t *handle)
 Initialise BME280 and read calibration values. More...
 
bool px_bme280_read (px_bme280_data_t *data)
 Perform reading of raw temperature, pressure and humidty. More...
 
int32_t px_bme280_temperature (px_bme280_data_t *data)
 Calculate compensated temperature from raw data. More...
 
uint32_t px_bme280_pressure (px_bme280_data_t *data)
 Calculate compensated pressure from raw data. More...
 
uint32_t px_bme280_humidity (px_bme280_data_t *data)
 Calculate compensated humidity from raw data. More...
 

Data Structure Documentation

◆ px_bme280_data_t

struct px_bme280_data_t

Raw sensor data.

Definition at line 49 of file px_bme280.h.

Data Fields
int32_t temp Raw temperature reading.
int32_t press Raw pressure reading.
int32_t hum Raw humidity reading.
int32_t t_fine Calculated temperature compensation.

Macro Definition Documentation

◆ PX_BME280_I2C_SLA_ADR

#define PX_BME280_I2C_SLA_ADR   0x77

BME280 I2C Slave address.

Definition at line 45 of file px_bme280.h.

Function Documentation

◆ px_bme280_init()

bool px_bme280_init ( px_i2c_handle_t handle)

Initialise BME280 and read calibration values.

Parameters
handleI2C handle of device
Return values
trueBME280 detected and calibration values read
falseCommunication failure with BME280

Definition at line 344 of file px_bme280.c.

◆ px_bme280_read()

bool px_bme280_read ( px_bme280_data_t data)

Perform reading of raw temperature, pressure and humidty.

Parameters
dataPointer to structure to contain raw sensor data
Return values
trueSensor data succesfully read
falseCommunication failure

Definition at line 385 of file px_bme280.c.

◆ px_bme280_temperature()

int32_t px_bme280_temperature ( px_bme280_data_t data)

Calculate compensated temperature from raw data.

Returns temperature in deg C; Resolution is 0.01 deg C. For example "5123" equals 51.23 deg C.

The data->t_fine field is updated during this step and used subsequently for compensated pressure and humidity calculations.

Parameters
dataPointer to structure to contain raw sensor data
Returns
int32_t Compensated temperature.

Definition at line 438 of file px_bme280.c.

◆ px_bme280_pressure()

uint32_t px_bme280_pressure ( px_bme280_data_t data)

Calculate compensated pressure from raw data.

Returns pressure in Pa as unsigned 32-bit integer. For example "96386" represents 96386 Pa = 963.862 hPa

px_bme280_temperature() must be called first so that the data->t_fine is updated.

Parameters
dataPointer to structure to contain raw sensor data
Returns
int32_t Compensated pressure.

Definition at line 464 of file px_bme280.c.

◆ px_bme280_humidity()

uint32_t px_bme280_humidity ( px_bme280_data_t data)

Calculate compensated humidity from raw data.

Returns humidity in RH as unsigned 32-bit integer in Q22.10 format (22 integer bits and 10 fractional bits). For example "47445" represents 47445/1024 = 46.333 RH

px_bme280_temperature() must be called first so that the data->t_fine is updated.

Parameters
dataPointer to structure to contain raw sensor data
Returns
int32_t Compensated humidity.

Definition at line 517 of file px_bme280.c.