BMP280/BME280 temperature, pressure and humidity sensor¶
Device driver interface for the Bosch BMP280 and BME280 sensors.
BMP280 and BME280 measure temperature in centi °C and pressure in Pa. BME280 can also measure relative humidity in %.
For more information, see the datasheets:
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.
Usage¶
Add the following to your makefile:
1 2 3 4 5 6 7 8 | # For BME280
USEMODULE += bme280
# When using I2C, specify the default I2C device to use,
# and the BME280's address (see datasheet).
# The values below are the defaults:
CFLAGS += -DBMX280_PARAM_I2C_DEV=I2C_DEV\(0\)
CFLAGS += -DBMX280_PARAM_I2C_ADDR=0x77
|
This allows initialisation with the default parameters in BMX280_PARAMS_DEFAULT from bmx280_params.h.
-
enum
bmx280_t_sb_t¶ - BMX280_SB_0_5
= 0 - BMX280_SB_62_5
= 1 - BMX280_SB_125
= 2 - BMX280_SB_250
= 3 - BMX280_SB_500
= 4 - BMX280_SB_1000
= 5 - BMX280_SB_10
= 6 - BMX280_SB_20
= 7
- BMX280_SB_0_5
-
enum
bmx280_filter_t¶ - BMX280_FILTER_OFF
= 0 - BMX280_FILTER_2
= 1 - BMX280_FILTER_4
= 2 - BMX280_FILTER_8
= 3 - BMX280_FILTER_16
= 4
- BMX280_FILTER_OFF
-
enum
bmx280_mode_t¶ - BMX280_MODE_SLEEP
= 0 - BMX280_MODE_FORCED
= 1 - BMX280_MODE_FORCED2
= 2 - BMX280_MODE_NORMAL
= 3
- BMX280_MODE_SLEEP
-
enum
bmx280_osrs_t¶ - BMX280_OSRS_SKIPPED
= 0 - BMX280_OSRS_X1
= 1 - BMX280_OSRS_X2
= 2 - BMX280_OSRS_X4
= 3 - BMX280_OSRS_X8
= 4 - BMX280_OSRS_X16
= 5
- BMX280_OSRS_SKIPPED
-
enum
@115¶ - BMX280_OK
= 0 - everything was fine
- BMX280_ERR_NODEV
= -1 - did not detect BME280 or BMP280
- BMX280_ERR_NOCAL
= -2 - could not read calibration data
- BMX280_OK
-
int
bmx280_init(bmx280_t * dev, const bmx280_params_t * params)¶ Initialize the given BMX280 device.
Parameters
dev: Initialized device descriptor of BMX280 device params: The parameters for the BMX280 device (sampling rate, etc) Return values
- BMX280_OK on success
- BMX280_ERR_I2C
- BMX280_ERR_NODEV
- BMX280_ERR_NOCAL
-
int16_t
bmx280_read_temperature(const bmx280_t * dev)¶ Read temperature value from the given BMX280 device, returned in centi °C.
Parameters
dev: Device descriptor of BMX280 device to read from Return values
- The temperature in centi Celsius. In case of an error it returns INT16_MIN.
-
uint32_t
bmx280_read_pressure(const bmx280_t * dev)¶ Read air pressure value from the given BMX280 device, returned in PA.
This function should only be called after doing bmx280_read_temperature first.
Parameters
dev: Device descriptor of BMX280 device to read from Return values
- The air pressure in Pa
-
uint16_t
bme280_read_humidity(const bmx280_t * dev)¶ Read humidity value from the given BME280 device, returned in centi RH.
This function should only be called after doing bmx280_read_temperature first. It’s only available with BME280 sensor.
Parameters
dev: Device descriptor of BME280 device to read from Return values
- Humidity in centi RH (i.e. the percentage times 100)
-
struct
bmx280_calibration_t¶ Calibration struct for the BMX280 sensor.
This must be read from the device at startup.
-
uint16_t
dig_T1¶ T1 coefficient.
-
int16_t
dig_T2¶ T2 coefficient.
-
int16_t
dig_T3¶ T3 coefficient.
-
uint16_t
dig_P1¶ P1 coefficient.
-
int16_t
dig_P2¶ P2 coefficient.
-
int16_t
dig_P3¶ P3 coefficient.
-
int16_t
dig_P4¶ P4 coefficient.
-
int16_t
dig_P5¶ P5 coefficient.
-
int16_t
dig_P6¶ P6 coefficient.
-
int16_t
dig_P7¶ P7 coefficient.
-
int16_t
dig_P8¶ P8 coefficient.
-
int16_t
dig_P9¶ P9 coefficient.
-
uint8_t
dig_H1¶ H1 coefficient.
-
int16_t
dig_H2¶ H2 coefficient.
-
uint8_t
dig_H3¶ H3 coefficient.
-
int16_t
dig_H4¶ H4 coefficient.
-
int16_t
dig_H5¶ H5 coefficient.
-
int8_t
dig_H6¶ H6 coefficient.
-
uint16_t
-
struct
bmx280_params_t¶ Parameters for the BMX280 sensor.
These parameters are needed to configure the device at startup.
-
i2c.h::i2c_ti2c_dev¶ I2C device which is used.
-
uint8_t
i2c_addr¶ I2C address.
-
bmx280.h::bmx280_t_sb_tt_sb¶ standby
-
bmx280.h::bmx280_filter_tfilter¶ filter coefficient
-
uint8_t
spi3w_en¶ Enables 3-wire SPI interface.
-
bmx280.h::bmx280_mode_trun_mode¶ ctrl_meas mode
-
bmx280.h::bmx280_osrs_ttemp_oversample¶ ctrl_meas osrs_t
-
bmx280.h::bmx280_osrs_tpress_oversample¶ ctrl_meas osrs_p
-
bmx280.h::bmx280_osrs_thumid_oversample¶ ctrl_hum osrs_h
-
-
struct
bmx280_t¶ Device descriptor for the BMX280 sensor.
-
bmx280_params_t
params¶ Device Parameters.
-
bmx280_calibration_t
calibration¶ Calibration Data.
-
bmx280_params_t