BME680 gas and weather sensor
The Bosch BME680 reads temperature, humidity, pressure and the resistance of a heated gas plate, over I2C at 0x77 or 0x76.
Aliases: BME688, BME68x, Adafruit BME680, GY-BME680, air quality sensor. It is a BME280 with a tiny hot plate added: volatile compounds in the air lower the plate's resistance, so a falling gas reading means worse air.
Pins
| Pin | What it does |
|---|---|
VIN |
Supply, 3 to 5 V on the board. |
GND |
Ground. |
SCL, SDA |
I2C. The board carries the pull-ups. |
Properties
address is 0x77 or 0x76. temperature, humidity, pressure (hPa) and gas
(kilohms) are the air; the four sliders change them while the circuit runs.
Reading it on an Arduino
With Adafruit's library, which Mokxi ships as Adafruit_BME680.h:
#include <Wire.h>
#include <Adafruit_BME680.h>
Adafruit_BME680 bme;
void setup() {
Serial.begin(9600);
if (!bme.begin()) Serial.println("No BME680");
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setGasHeater(320, 150); // 320 C for 150 ms
}
void loop() {
if (bme.performReading()) {
Serial.print(bme.temperature);
Serial.print(" C ");
Serial.print(bme.gas_resistance / 1000.0);
Serial.println(" kohm");
}
delay(2000);
}
Bosch's own bme68xLibrary.h (the Bme68x class) reads the same part.
How it talks
- Power on and the soft reset (
0xB6to0xE0) take 2 ms.chip_id(0xD0) reads0x61. - Writing forced mode to
ctrl_meas(0x74) runs one cycle: temperature, pressure and humidity at their oversampling, then withrun_gasset the heater step held for its wait and the gas reading.measuringin0x1Dreads 1 until it ends, thennew_data_0is set and the mode goes back to sleep. - The results are raw counts at
0x1Fto0x2B. The library turns them into the weather with the calibration words at0x8Ato0xA0and0xE1to0xF0, so the arithmetic is the library's own.
What it does not model
The IIR filter, the heater's real temperature, and the gas resistance's dependence on it and on humidity: the gas reading is the slider's resistance.
Common mistakes
Expecting a gas reading the moment the sketch starts: the heater has to run for the wait the sketch sets, and the reading comes at the end of the cycle. Comparing gas readings across boards: the figure only means something against the same sensor's baseline.