Kitchen air on an Arduino Uno
A BME680 learns the clean air’s gas reading, then calls out bad air when cooking smoke pulls it down, with the weather alongside. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Intermediate Runs in your browser. Free, and no account needed.
The parts retail for about $37. On Mokxi they're free.
Step by step, with the wiring and the common mistakes: Arduino BME680: Air Quality, Gas and Weather
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// Kitchen air: a BME680 heats a tiny plate and reads its resistance, which
// falls when the air carries cooking smoke or solvents. It learns the clean
// air's figure first, then calls out bad air when the reading drops well
// below it.
//
// BME680 SDA -> SDA SCL -> SCL VIN -> 5 V GND -> GND
//
// The gas figure means nothing on its own: every sensor reads a different
// resistance in the same air. What means something is the fall from the
// sensor's own clean-air baseline, so the sketch takes that as the first
// reading and compares against it.
//
// Things to try. Drag the gas slider on the BME680 down to half: the sketch
// calls out bad air. Drag the temperature and humidity sliders and watch the weather
// line follow.
#include <Wire.h>
#include "Adafruit_BME680.h"
Adafruit_BME680 bme;
uint32_t baseline = 0;
void setup() {
Serial.begin(9600);
if (!bme.begin()) {
Serial.println("No BME680");
while (1);
}
// The plate at 320 C for 150 ms each reading.
bme.setGasHeater(320, 150);
bme.performReading();
baseline = bme.gas_resistance;
Serial.print("Clean air: ");
Serial.print((baseline + 500) / 1000);
Serial.println(" kohm");
}
void loop() {
if (!bme.performReading()) {
return;
}
// Below two thirds of the baseline is worth a look.
bool bad = bme.gas_resistance < baseline / 3 * 2;
Serial.print(bme.temperature, 1);
Serial.print(" C ");
Serial.print(bme.humidity, 0);
Serial.print(" %RH ");
Serial.print(bme.pressure / 100.0, 1);
Serial.print(" hPa gas ");
Serial.print((bme.gas_resistance + 500) / 1000);
Serial.println(bad ? " kohm bad air" : " kohm");
delay(1000);
}
Parts list
3 parts, plus the jumper wires. They retail for about $37; on Mokxi they're free.
- 1 × Arduino Uno R3
- 1 × Gas and weather, BME680
- 1 × Power, 5 V
How it is wired
4 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- Arduino Uno R3 pin SCL; Gas and weather, BME680 pin SCL
- Arduino Uno R3 pin SDA; Gas and weather, BME680 pin SDA
- Ground: Arduino Uno R3 pin GND; Gas and weather, BME680 pin GND
- 5 V: Gas and weather, BME680 pin VIN
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.