upm
0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
|
API for the BME280 Digital Humidity, Pressure, and Temperature Sensor. More...
The BME280 is as combined digital humidity, pressure and temperature sensor based on proven sensing principles. The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 2.5 × 2.5 mm2 with a height of 0.93 mm. Its small dimensions and its low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches. The BME280 is register and performance compatible to the Bosch Sensortec BMP280 digital pressure sensor
Public Types | |
enum | BME280_REGS_T : uint8_t { REG_CALIB_DIG_H1 = 0xa1, REG_CALIB_DIG_H2_LSB = 0xe1, REG_CALIB_DIG_H2_MSB = 0xe2, REG_CALIB_DIG_H3 = 0xe3, REG_CALIB_DIG_H4_0 = 0xe4, REG_CALIB_DIG_H4_1 = 0xe5, REG_CALIB_DIG_H5_0 = 0xe5, REG_CALIB_DIG_H5_1 = 0xe6, REG_CALIB_DIG_H6 = 0xe7, REG_CTRL_HUM = 0xf2, REG_HUMIDITY_MSB = 0xfd, REG_HUMIDITY_LSB = 0xfe } |
enum | CTRL_HUM_T { CTRL_HUM_OSRS_H0 = 0x01, CTRL_HUM_OSRS_H1 = 0x02, CTRL_HUM_OSRS_H2 = 0x04, _CTRL_HUM_OSRS_H_MASK = 3, _CTRL_HUM_OSRS_H_SHIFT = 0 } |
enum | OSRS_H_T { OSRS_H_SKIPPED = 0, OSRS_H_OVERSAMPLING_1 = 1, OSRS_H_OVERSAMPLING_2 = 2, OSRS_H_OVERSAMPLING_4 = 3, OSRS_H_OVERSAMPLING_8 = 4, OSRS_H_OVERSAMPLING_16 = 5 } |
Public Types inherited from BMP280 | |
enum | BMP280_REGS_T : uint8_t { REG_CALIB00 = 0x88, REG_CALIB01 = 0x89, REG_CALIB02 = 0x8a, REG_CALIB03 = 0x8b, REG_CALIB04 = 0x8c, REG_CALIB05 = 0x8d, REG_CALIB06 = 0x8e, REG_CALIB07 = 0x8f, REG_CALIB08 = 0x90, REG_CALIB09 = 0x91, REG_CALIB10 = 0x92, REG_CALIB11 = 0x93, REG_CALIB12 = 0x94, REG_CALIB13 = 0x95, REG_CALIB14 = 0x96, REG_CALIB15 = 0x97, REG_CALIB16 = 0x98, REG_CALIB17 = 0x99, REG_CALIB18 = 0x9a, REG_CALIB19 = 0x9b, REG_CALIB20 = 0x9c, REG_CALIB21 = 0x9d, REG_CALIB22 = 0x9e, REG_CALIB23 = 0x9f, REG_CALIB24 = 0xa0, REG_CALIB25 = 0xa1, REG_CHIPID = 0xd0, REG_RESET = 0xe0, REG_STATUS = 0xf3, REG_CTRL_MEAS = 0xf4, REG_CONFIG = 0xf5, REG_PRESSURE_MSB = 0xf7, REG_PRESSURE_LSB = 0xf8, REG_PRESSURE_XLSB = 0xf9, REG_TEMPERATURE_MSB = 0xfa, REG_TEMPERATURE_LSB = 0xfb, REG_TEMPERATURE_XLSB = 0xfc } |
enum | CONFIG_BITS_T { CONFIG_SPI3W_EN = 0x01, CONFIG_FILTER0 = 0x04, CONFIG_FILTER1 = 0x08, CONFIG_FILTER2 = 0x10, _CONFIG_FILTER_MASK = 7, _CONFIG_FILTER_SHIFT = 2, CONFIG_T_SB0 = 0x20, CONFIG_T_SB1 = 0x40, CONFIG_T_SB2 = 0x80, _CONFIG_T_SB_MASK = 7, _CONFIG_T_SB_SHIFT = 5 } |
enum | FILTER_T { FILTER_OFF = 0, FILTER_2 = 1, FILTER_4 = 2, FILTER_8 = 3, FILTER_16 = 4 } |
enum | T_SB_T { T_SB_0_5 = 0, T_SB_62_5 = 1, T_SB_125 = 2, T_SB_250 = 3, T_SB_500 = 4, T_SB_1000 = 5, T_SB_2000 = 6, T_SB_4000 = 7 } |
enum | CTRL_MEAS_T { CTRL_MEAS_MODE0 = 0x01, CTRL_MEAS_MODE1 = 0x02, _CTRL_MEAS_MODE_MASK = 3, _CTRL_MEAS_MODE_SHIFT = 0, CTRL_MEAS_OSRS_P0 = 0x04, CTRL_MEAS_OSRS_P1 = 0x08, CTRL_MEAS_OSRS_P2 = 0x10, _CTRL_MEAS_OSRS_P_MASK = 7, _CTRL_MEAS_OSRS_P_SHIFT = 2, CTRL_MEAS_OSRS_T0 = 0x04, CTRL_MEAS_OSRS_T1 = 0x08, CTRL_MEAS_OSRS_T2 = 0x10, _CTRL_MEAS_OSRS_T_MASK = 7, _CTRL_MEAS_OSRS_T_SHIFT = 5 } |
enum | MODES_T { MODE_SLEEP = 0, MODE_FORCED = 1, MODE_NORMAL = 3 } |
enum | OSRS_P_T { OSRS_P_SKIPPED = 0, OSRS_P_OVERSAMPLING_1 = 1, OSRS_P_OVERSAMPLING_2 = 2, OSRS_P_OVERSAMPLING_4 = 3, OSRS_P_OVERSAMPLING_8 = 4, OSRS_P_OVERSAMPLING_16 = 5 } |
enum | OSRS_T_T { OSRS_T_SKIPPED = 0, OSRS_T_OVERSAMPLING_1 = 1, OSRS_T_OVERSAMPLING_2 = 2, OSRS_T_OVERSAMPLING_4 = 3, OSRS_T_OVERSAMPLING_8 = 4, OSRS_T_OVERSAMPLING_16 = 5 } |
enum | STATUS_T { STATUS_IM_UPDATE = 0x01, STATUS_MEASURING = 0x08 } |
enum | USAGE_MODE_T { USAGE_MODE_HANDHELD_LOW_POWER = 0, USAGE_MODE_HANDHELD_DYNAMIC = 1, USAGE_MODE_WEATHER_MONITOR = 2, USAGE_MODE_FLOOR_CHG_DETECT = 3, USAGE_MODE_DROP_DETECT = 4, USAGE_MODE_INDOOR_NAV = 5 } |
Public Member Functions | |
BME280 (int bus=BME280_DEFAULT_I2C_BUS, int addr=BME280_DEFAULT_ADDR, int cs=-1, uint8_t theChipID=BME280_DEFAULT_CHIPID) | |
virtual | ~BME280 () |
virtual void | update () |
float | getHumidity () |
virtual void | setUsageMode (USAGE_MODE_T mode) |
void | setOversampleRateHumidity (OSRS_H_T rate) |
const char * | getModuleName () |
int | getHumidityRelative () |
Public Member Functions inherited from BMP280 | |
BMP280 (int bus=BMP280_DEFAULT_I2C_BUS, int addr=BMP280_DEFAULT_ADDR, int cs=-1, uint8_t theChipID=BMP280_DEFAULT_CHIPID) | |
virtual | ~BMP280 () |
uint8_t | getChipID () |
void | reset () |
float | getTemperature (bool fahrenheit=false) |
float | getPressure () |
float | getAltitude (float seaLevelhPA=1013.25) |
void | setOversampleRateTemperature (OSRS_T_T rate) |
void | setOversampleRatePressure (OSRS_P_T rate) |
void | setTimerStandby (T_SB_T tsb) |
void | setFilter (FILTER_T filter) |
void | setMeasureMode (MODES_T mode) |
const char * | getModuleName () |
int | getTemperatureCelsius () |
int | getPressurePa () |
Protected Member Functions | |
virtual void | readCalibrationData () |
Protected Member Functions inherited from BMP280 | |
uint8_t | getStatus () |
uint8_t | readReg (uint8_t reg) |
int | readRegs (uint8_t reg, uint8_t *buffer, int len) |
void | writeReg (uint8_t reg, uint8_t val) |
void | clearData () |
void | csOn () |
void | csOff () |
Protected Attributes | |
float | m_humidity |
Protected Attributes inherited from BMP280 | |
mraa::I2c * | m_i2c |
mraa::Spi * | m_spi |
mraa::Gpio * | m_gpioCS |
uint8_t | m_addr |
float | m_temperature |
float | m_pressure |
int32_t | m_t_fine |
MODES_T | m_mode |
Additional Inherited Members | |
Data Fields inherited from BMP280 | |
const uint8_t | BMP280_RESET_BYTE = 0xb6 |
const int | CALIBRATION_BYTES = 26 |
enum BME280_REGS_T : uint8_t |
BMP280 registers
enum CTRL_HUM_T |
REG_CTRL_HUM bits
enum OSRS_H_T |
CTRL_HUM_OSRS_H values
BME280 | ( | int | bus = BME280_DEFAULT_I2C_BUS , |
int | addr = BME280_DEFAULT_ADDR , |
||
int | cs = -1 , |
||
uint8_t | theChipID = BME280_DEFAULT_CHIPID |
||
) |
BME280 constructor.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin, then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.
bus | I2C or SPI bus to use. |
address | The address for this device. -1 for SPI. |
cs | The gpio pin to use for the SPI Chip Select. -1 for I2C or for SPI with a hardware controlled pin. |
theChipID | The chip ID used for validation |
|
virtual |
Update the internal stored values from sensor data.
Reimplemented from BMP280.
float getHumidity | ( | void | ) |
Return the current measured relative humidity. update() must have been called prior to calling this method.
|
virtual |
Set a general usage mode. This function can be used to configure the filters and oversampling for a particular use case. These settings are documented in the BMP280 and BME280 datasheets.
mode | One of the USAGE_MODE_T values. |
Reimplemented from BMP280.
void setOversampleRateHumidity | ( | OSRS_H_T | rate | ) |
Set the humidity sensor oversampling parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for setUsageMode().
mode | One of the OSRS_H_T values. |
|
inlinevirtual |
Returns name of module. This is the string in library name after libupm_
Implements IModuleStatus.