BME680 Element
The Element implementation uses the Bosch bme680 sensor library that comes with the element implementation and need no further installation. It uses the I2C bus for connection.
To make it available for configuration it needs to be included into the compilation by activating it using the macro
The Element is included in the standard firmware but can be excluded to save memory by removing the definition:
#define HOMEDING_INCLUDE_BME680
in the element register section of the sketch.
Sensor Connectivity
The sensor chip uses a 3.3 V Supply voltage on VCC and GND and needs to be connected to the SDA and SCL line of the I2C bus. The I2C pins are configured using the properties of the device element and the I2C bus is normally shared by multiple elements e.g. sensors.
{
"device": {
"0": {
"i2c-scl": "D2",
"i2c-sda": "D1"
}
}
}
The I2C address of the sensor is 0x77 = 119 by default and is configured using the element configuration. The chip offers the possibility using an alternate address. Please refer to the documentation of your sensor board.
Using the default I2C bus pins:
Signal | ESP8266 | ESP32 | Sensor | Description |
---|---|---|---|---|
GND | GND | GND | GND | Ground for I2C and Power Supply |
VCC | 3.3v | 3.3v | VCC/VDD | Power Supply |
SDA | GPIO4(D2) | IO21 | SDA | I2C Data Signal |
SCL | GPIO5(D1) | IO22 | SCL | I2C Clock Signal |
- | - | SDD | not used | |
- | - | CS | not used in I2C Mode |
Element Configuration
These properties can be configured:
address The I2C Address of the sensor. The default value is 0x77 the other possible value is 0x76.
readTime Time between 2 probes from the sensor are fetched. The default value is 1 minute.
Configuration Example
This example shows how to configure this element:
{
"bme680": {
"bd": {
"address": "0x77",
"readtime": "10s",
"ontemperature": "device/0?log=temp=$v",
"onhumidity": "device/0?log=humidity=$v",
"onpressure": "device/0?log=pressure=$v",
"ongas": "device/0?log=gas=$v"
}
}
}
Outbound Actions
The actions emitted by the BME680 Element has read some new data (with changed value) from the sensor.
onTemperature - These actions are send when a new temperature value has been read. The value given in the actions is actual temperature in Celcius.
onHumidity - These actions are send when a new temperature value has been read. The value given in the actions is actual Humidity in percentage.
onPressure - These actions are send when a new pressure value has been read. The value given in the actions is actual pressure in hPA.
onGas - These actions are send when a new gas resistance value has been read. The value given in the actions is actual gas resistance value in kOhm.
State
{
"bme680/0": {
"active":"true",
"temperature":"21.21",
"humidity":"43.48",
"pressure":"99784",
"gas":"72724"
}
}
Interpreting the GAS-OHM values
There are some discussions about how to interpret the values from the gas sensor.
The number is not related directly to quality of the air and Bosch supports a (closed source) library to calculate a proprietary Air Quality Index (IAQ).
Here is a link on how to integrate the algorithm from BOSCH that can be found in the the BSEC SDK:
- https://www.bosch-sensortec.com/bst/products/all_products/bsec Bosch Sensortec Software Downloads
- https://wolfgangklenk.wordpress.com/2017/11/05/indoor-air-quality-iaq-measurement-with-bosch-bme680-and-stm32f103c8t6/ A example using the BOSCH SDK directly.
I avoid this huge library for now.
However there is a table driven and a formula driven approach for some mapping of the sensor values to a Quality Indicator available. The humidity of the air might be a good factor for the calculation of “good” air quality.
range | quality |
---|---|
521177 - 431331 | good |
297625 - 213212 | average |
148977 - 108042 | little bad |
75010 - 54586 | bad |
37395 - 27080 | worse |
18761 - 13591 | very bad |
9008 - 8371 | totally bad |
- https://forums.pimoroni.com/t/bme680-observed-gas-ohms-readings/6608
- https://github.com/G6EJD/BME680-Example Here you find an example for BME680 that calculates a quality index by combining a quality from gas and humidity.
See also
- Using the I2C bus
- https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001.pdf The official DataSheet
- https://www.bosch-sensortec.com/bst/products/all_products/bme680 Product description
- https://github.com/boschsensortec/Bosch-BME68x-Library Bosch, the manufacturer of the sensor has published an sdk for this sensor
- https://myesp8266.blogspot.com/2016/12/bmp280-and-esp8266.html Another illustrated example using the Adafruit library.