Bosch BME280 topic
Classes for the Bosch BME280 environmental sensor.
Introduction
The BME280 is a humidity sensor especially developed for mobile applications and wearables where size and low power consumption are key design parameters. The unit combines high linearity and high accuracy sensors and is perfectly feasible for low current consumption, long-term stability and high EMC robustness. The humidity sensor offers an extremely fast response time and therefore supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range.
Although this sensor has the option of either I2C or SPI communication, this library only supports I2C. The default I2C address varies by manufacturer and is either 0x77 or 0x76. The Adafruit and Sparkfun defaults are both 0x77 and Seeed/Grove default is 0x76, though all can be changed by physical modification of the sensor, if necessary (by cutting the board connection for the manufacturer default and soldering the optional address jumpers). To connect two of these sensors to your system, you must ensure they are soldered so as to have different I2C addresses. No more than two can be attached. This module is likely to also work with the Bosch BMP280 Barometric Pressure Sensor, though it has not been tested on it. These sensors should be attached to a 1.7-3.6V power source and the power supply to the sensor can be stopped between measurements.
The Adafruit BME280 library is used internally for communication with the BME280.
Sensor Datasheet
Documentation for the sensor can be found at: https:/
Build flags
-D SEALEVELPRESSURE_HPA
- use to adjust the sea level pressure used to calculate altitude from measured barometric pressure
- if not defined, 1013.25 is used
- The same sea level pressure flag is used for both the BMP3xx and the BME280. Whatever you select will be used for both sensors.
Sensor Constructors
Construct a new Bosch BME280 object using the primary hardware I2C instance. The pin on the mcu controlling power to the BME280 Use -1 if it is continuously powered. Construct a new Bosch BME280 object using a secondary hardware I2C instance. The pin on the mcu controlling power to the BME280 Use -1 if it is continuously powered.
BoschBME280::
Parameters
powerPin
i2cAddressHex
The I2C address of the BME280; must be either 0x76 or 0x77. The default value is 0x76.
measurementsToAverage
The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
BoschBME280::
Parameters
theI2C
A TwoWire instance for I2C communication. Due to the limitations of the Arduino core, only a hardware I2C instance can be used. For an AVR board, there is only one I2C instance possible and this form of the constructor should not be used. For a SAMD board, this can be used if a secondary I2C port is created on one of the extra SERCOMs.
powerPin
i2cAddressHex
The I2C address of the BME280; must be either 0x76 or 0x77. The default value is 0x76.
measurementsToAverage
The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
Example Code
The BME280 is used in the menu a la carte example.
Classes
- class BoschBME280
- The Sensor sub-class for the Bosch BME280.
- class BoschBME280_Temp
- The Variable sub-class used for the temperature output from a Bosch BME280.
- class BoschBME280_Humidity
- The Variable sub-class used for the relative humidity output from a Bosch BME280.
- class BoschBME280_Pressure
- The Variable sub-class used for the atmospheric pressure output from a Bosch BME280.
- class BoschBME280_Altitude
- The Variable sub-class used for the altitude calculated from the measurements made by a Bosch BME280.
Sensor Variable Counts
The number of variables that can be returned by the BME280
- #define BME280_NUM_VARIABLES = 4
- Sensor::
_numReturnedValues; the BME280 can report 4 values. - #define BME280_INC_CALC_VARIABLES = 1
- Sensor::
_incCalcValues; altitude is calculted within the Adafruit library.
Configuration Defines
Defines to set the calibration of the calculated base pressure used to calculate altitude by the BME280.
- #define SEALEVELPRESSURE_HPA = (1013.25)
- The atmospheric pressure at sea level.
Sensor Timing
The sensor timing for a Bosch BME280
- #define BME280_WARM_UP_TIME_MS = 100
- Sensor::
_warmUpTime_ms; BME280 warms up in 100ms. - #define BME280_STABILIZATION_TIME_MS = 4000
- Sensor::
_stabilizationTime_ms; BME280 is stable after 4000ms. - #define BME280_MEASUREMENT_TIME_MS = 1100
- Sensor::
_measurementTime_ms; BME280 takes 1100ms to complete a measurement.
Temperature
The temperature variable from a Bosch BME280
- Range is -40°C to +85°C
- Accuracy is ±0.5°C
Construct a new BoschBME280_
BoschBME280_
Parameters
parentSense
The parent BoschBME280 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "BoschBME280Temp".
- #define BME280_TEMP_RESOLUTION = 2
- Decimals places in string representation; temperature should have 2 - resolution is 0.01°C.
- #define BME280_TEMP_VAR_NUM = 0
- Sensor variable number; temperature is stored in sensorValues[0].
- #define BME280_TEMP_VAR_NAME = "temperature"
- Variable name in ODM2 controlled vocabulary; "temperature".
- #define BME280_TEMP_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
- #define BME280_TEMP_DEFAULT_CODE = "BoschBME280Temp"
- Default variable short code; "BoschBME280Temp".
Humidity
The humidity variable from a Bosch BME280
Construct a new BoschBME280_
BoschBME280_
Parameters
parentSense
The parent BoschBME280 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "BoschBME280Humidity".
- #define BME280_HUMIDITY_RESOLUTION = 3
- Decimals places in string representation; humidity should have 3- resolution is 0.008 % RH (16 bit).
- #define BME280_HUMIDITY_VAR_NUM = 1
- Sensor variable number; humidity is stored in sensorValues[1].
- #define BME280_HUMIDITY_VAR_NAME = "relativeHumidity"
- Variable name in ODM2 controlled vocabulary; "relativeHumidity".
- #define BME280_HUMIDITY_UNIT_NAME = "percent"
- Variable unit name in ODM2 controlled vocabulary; "percent" - percent relative humidity (% RH)
- #define BME280_HUMIDITY_DEFAULT_CODE = "BoschBME280Humidity"
- Default variable short code; "BoschBME280Humidity".
Barometric Pressure
The barometric pressure variable from a Bosch BME280
- Range is 300 to 1100 hPa
- Absolute accuracy is ±1 hPa
- Relative accuracy is ±0.12 hPa
Construct a new BoschBME280_
BoschBME280_
Parameters
parentSense
The parent BoschBME280 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "BoschBME280Pressure".
- #define BME280_PRESSURE_RESOLUTION = 2
- Decimals places in string representation; barometric pressure should have 2.
- #define BME280_PRESSURE_VAR_NUM = 2
- Sensor variable number; pressure is stored in sensorValues[2].
- #define BME280_PRESSURE_VAR_NAME = "barometricPressure"
- Variable name in ODM2 controlled vocabulary; "barometricPressure".
- #define BME280_PRESSURE_UNIT_NAME = "pascal"
- Variable unit name in ODM2 controlled vocabulary; "pascal" (Pa)
- #define BME280_PRESSURE_DEFAULT_CODE = "BoschBME280Pressure"
- Default variable short code; "BoschBME280Pressure".
Altitude
The altitude variable from a Bosch BME280
Construct a new BoschBME280_
BoschBME280_
Parameters
parentSense
The parent BoschBME280 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "BoschBME280Altitude".
- #define BME280_ALTITUDE_RESOLUTION = 0
- Decimals places in string representation; altitude should have 0 - resolution is 1m.
- #define BME280_ALTITUDE_VAR_NUM = 3
- Sensor variable number; altitude is stored in sensorValues[3].
- #define BME280_ALTITUDE_VAR_NAME = "heightAboveSeaFloor"
- Variable name in ODM2 controlled vocabulary; "heightAboveSeaFloor".
- #define BME280_ALTITUDE_UNIT_NAME = "meter"
- Variable unit name in ODM2 controlled vocabulary; "meter".
- #define BME280_ALTITUDE_DEFAULT_CODE = "BoschBME280Altitude"
- Default variable short code; "BoschBME280Altitude".
Define documentation
#define BME280_NUM_VARIABLES = 4
#include <src/sensors/BoschBME280.h>
Sensor::
#define BME280_INC_CALC_VARIABLES = 1
#include <src/sensors/BoschBME280.h>
Sensor::
#define SEALEVELPRESSURE_HPA = (1013.25)
#include <src/sensors/BoschBME280.h>
The atmospheric pressure at sea level.
#define BME280_WARM_UP_TIME_MS = 100
#include <src/sensors/BoschBME280.h>
Sensor::
#define BME280_STABILIZATION_TIME_MS = 4000
#include <src/sensors/BoschBME280.h>
Sensor::
0.5 s for good numbers, but optimal at 4 s based on tests using bme280timingTest.ino
#define BME280_MEASUREMENT_TIME_MS = 1100
#include <src/sensors/BoschBME280.h>
Sensor::
1.0 s according to datasheet, but slightly better stdev when 1.1 s For details on BME280 stabilization time updates, include testing sketch and link to data in Google Sheet, see: https:/
#define BME280_TEMP_RESOLUTION = 2
#include <src/sensors/BoschBME280.h>
Decimals places in string representation; temperature should have 2 - resolution is 0.01°C.
#define BME280_TEMP_VAR_NUM = 0
#include <src/sensors/BoschBME280.h>
Sensor variable number; temperature is stored in sensorValues[0].
#define BME280_TEMP_VAR_NAME = "temperature"
#include <src/sensors/BoschBME280.h>
Variable name in ODM2 controlled vocabulary; "temperature".
#define BME280_TEMP_UNIT_NAME = "degreeCelsius"
#include <src/sensors/BoschBME280.h>
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define BME280_TEMP_DEFAULT_CODE = "BoschBME280Temp"
#include <src/sensors/BoschBME280.h>
Default variable short code; "BoschBME280Temp".
#define BME280_HUMIDITY_RESOLUTION = 3
#include <src/sensors/BoschBME280.h>
Decimals places in string representation; humidity should have 3- resolution is 0.008 % RH (16 bit).
#define BME280_HUMIDITY_VAR_NUM = 1
#include <src/sensors/BoschBME280.h>
Sensor variable number; humidity is stored in sensorValues[1].
#define BME280_HUMIDITY_VAR_NAME = "relativeHumidity"
#include <src/sensors/BoschBME280.h>
Variable name in ODM2 controlled vocabulary; "relativeHumidity".
#define BME280_HUMIDITY_UNIT_NAME = "percent"
#include <src/sensors/BoschBME280.h>
Variable unit name in ODM2 controlled vocabulary; "percent" - percent relative humidity (% RH)
#define BME280_HUMIDITY_DEFAULT_CODE = "BoschBME280Humidity"
#include <src/sensors/BoschBME280.h>
Default variable short code; "BoschBME280Humidity".
#define BME280_PRESSURE_RESOLUTION = 2
#include <src/sensors/BoschBME280.h>
Decimals places in string representation; barometric pressure should have 2.
#define BME280_PRESSURE_VAR_NUM = 2
#include <src/sensors/BoschBME280.h>
Sensor variable number; pressure is stored in sensorValues[2].
#define BME280_PRESSURE_VAR_NAME = "barometricPressure"
#include <src/sensors/BoschBME280.h>
Variable name in ODM2 controlled vocabulary; "barometricPressure".
#define BME280_PRESSURE_UNIT_NAME = "pascal"
#include <src/sensors/BoschBME280.h>
Variable unit name in ODM2 controlled vocabulary; "pascal" (Pa)
#define BME280_PRESSURE_DEFAULT_CODE = "BoschBME280Pressure"
#include <src/sensors/BoschBME280.h>
Default variable short code; "BoschBME280Pressure".
#define BME280_ALTITUDE_RESOLUTION = 0
#include <src/sensors/BoschBME280.h>
Decimals places in string representation; altitude should have 0 - resolution is 1m.
#define BME280_ALTITUDE_VAR_NUM = 3
#include <src/sensors/BoschBME280.h>
Sensor variable number; altitude is stored in sensorValues[3].
#define BME280_ALTITUDE_VAR_NAME = "heightAboveSeaFloor"
#include <src/sensors/BoschBME280.h>
Variable name in ODM2 controlled vocabulary; "heightAboveSeaFloor".
#define BME280_ALTITUDE_UNIT_NAME = "meter"
#include <src/sensors/BoschBME280.h>
Variable unit name in ODM2 controlled vocabulary; "meter".
#define BME280_ALTITUDE_DEFAULT_CODE = "BoschBME280Altitude"
#include <src/sensors/BoschBME280.h>
Default variable short code; "BoschBME280Altitude".