Device driver interface for the BME280 sensor. More...

Detailed Description

Files

file  bme280_internals.h
 Internal addresses, registers, constants for the BME280 sensor.
 
file  bme280.h
 Device driver interface for the BME280 sensor.
 

Data Structures

struct  bme280_calibration_t
 Calibration struct for the BME280 sensor. More...
 
struct  bme280_params_t
 Parameters for the BME280 sensor. More...
 
struct  bme280_t
 Device descriptor for the BME280 sensor. More...
 

Enumerations

enum  bme280_t_sb_t {
  BME280_SB_0_5 = 0, BME280_SB_62_5 = 1, BME280_SB_125 = 2, BME280_SB_250 = 3,
  BME280_SB_500 = 4, BME280_SB_1000 = 5, BME280_SB_10 = 6, BME280_SB_20 = 7
}
 Values for t_sb field of the BME280 config register.
 
enum  bme280_filter_t {
  BME280_FILTER_OFF = 0, BME280_FILTER_2 = 1, BME280_FILTER_4 = 2, BME280_FILTER_8 = 3,
  BME280_FILTER_16 = 4
}
 Values for filter field of the BME280 config register.
 
enum  bme280_mode_t { BME280_MODE_SLEEP = 0, BME280_MODE_FORCED = 1, BME280_MODE_FORCED2 = 2, BME280_MODE_NORMAL = 3 }
 Values for mode field of the BME280 ctrl_meas register.
 
enum  bme280_osrs_t {
  BME280_OSRS_SKIPPED = 0, BME280_OSRS_X1 = 1, BME280_OSRS_X2 = 2, BME280_OSRS_X4 = 3,
  BME280_OSRS_X8 = 4, BME280_OSRS_X16 = 5
}
 Values for oversampling settings. More...
 
enum  { BME280_OK = 0, BME280_ERR_I2C = -1, BME280_ERR_NODEV = -2, BME280_ERR_NOCAL = -3 }
 Status and error return codes. More...
 

Functions

int bme280_init (bme280_t *dev, const bme280_params_t *params)
 Initialize the given BME280 device. More...
 
int16_t bme280_read_temperature (bme280_t *dev)
 Read temperature value from the given BME280 device, returned in centi °C. More...
 
uint16_t bme280_read_humidity (bme280_t *dev)
 Read humidity value from the given BME280 device, returned in centi RH. More...
 
uint32_t bme280_read_pressure (bme280_t *dev)
 Read air pressure value from the given BME280 device, returned in PA. More...
 
const saul_driver_t bme280_temperature_saul_driver
 export SAUL endpoints
 
const saul_driver_t bme280_relative_humidity_saul_driver
 
const saul_driver_t bme280_pressure_saul_driver
 

Enumeration Type Documentation

anonymous enum
Enumerator
BME280_OK 

everything was fine

BME280_ERR_I2C 

error initializing the I2C bus

BME280_ERR_NODEV 

did not detect BME280

BME280_ERR_NOCAL 

could not read calibration data

Definition at line 155 of file bme280.h.

These values are used for:

  • osrs_h field of the BME280 ctrl_hum register
  • osrs_t field of the BME280 ctrl_meas register
  • osrs_p field of the BME280 ctrl_meas register

Definition at line 111 of file bme280.h.

Function Documentation

int bme280_init ( bme280_t dev,
const bme280_params_t params 
)
Parameters
[out]devInitialized device descriptor of BME280 device
[in]paramsThe parameters for the BME280 device (sampling rate, etc)
Returns
BME280_OK on success
BME280_ERR_I2C
BME280_ERR_NODEV
BME280_ERR_NOCAL
uint16_t bme280_read_humidity ( bme280_t dev)

This function should only be called after doing bme280_read_temperature first.

Parameters
[in]devDevice descriptor of BME280 device to read from
Returns
Humidity in centi RH (i.e. the percentage times 100)
uint32_t bme280_read_pressure ( bme280_t dev)

This function should only be called after doing bme280_read_temperature first.

Parameters
[in]devDevice descriptor of BME280 device to read from
Returns
The air pressure in Pa
int16_t bme280_read_temperature ( bme280_t dev)
Parameters
[in]devDevice descriptor of BME280 device to read from
Returns
The temperature in centi Celsius. In case of an error it returns INT16_MIN.