A Portable Home Air Quality Meter With The ESP32

Around the world, rolling pandemic lockdowns have left many working from home. [kn100] is in just such a predicament, and while spending nearly 24 hour a day in a residential flat, got wondering about air quality. Thus, it was time to build some gear to keep an eye on things!

Grafana may require a database and some work to set up, but the results are to die for.

The build consists of an ESP32 hooked up to a Bosch BME680 air quality sensor. It measures pressure, temperature, humidity and gas resistance, and then with a closed source library, uses this to calculate an “Air Quality Index” as well as estimate CO2 and VOC levels in the air. Data is passed from the ESP32 over MQTT to a Raspberry Pi. This runs Mosquitto for handling the MQTT queries, saving the data in an Influxdb instance. Grafana is then used to query this database and produce attractive graphs of the data.

It’s a build that not only helps keep an eye on things in the flat, but is great practice for building solid Internet of Things devices with top-notch data visualisation. We’ve talked about how to do this before, too – so if you need this capability in your life, there’s no excuse not to get hacking!

18 thoughts on “A Portable Home Air Quality Meter With The ESP32

  1. I am doing almost exactly the same, but the BME680 has one disadvantage: It requires constant calibration. What the BOSCH library does is essentially sensing what is bad and what is good and storing that. So in a room with little fluctuation it starts drifting and the self measured IAQaccuracy drops. So in my house it works great in the kitchen, but not in the sleeping rooms, unless you regularly fart on it.
    I also wrote a framework for it which I called SHIT, but it’s not finished yet…

    1. not just that one. plenty of gas sensors do the same. it’s practically impossible to find a sensing element that does not drift in time by huge margins.
      A lot of the cheap stuff you can try has the automatic calibration to a known “fresh air” value which they expect to be periodically exposed to. if you don’t do that, the readout values will be very wrong.

    1. I recently tried similar Sparkfun’s BME280+CCS811 combo. VOC reading is probably fine but eCO2 is a party trick, it was drifting all the way up to 1500ppm when supplied with temperature from BME280 which was offset due to heat from CCS811. Maybe BME680 might be better but those would be best used for air purifiers with no display which is what these are made for.

    1. I’ve heard and read good things about the “SenseAir S8”, but still waiting for my order to arrive. Currently i’m using a MHZ-19B which is already better than the Bosch, but it has a very annoying auto calibration routine that sometimes messes everything up. That part should be much better on the SenseAir S8 from what i’ve read.

      1. As far as i can tell, the MHZ just figures out what was the lowest level during the day and assumes that was 400ppm. So if you leave it in a closed room without daily long time ventilation is will give false readings.
        I vaguely remember that some sensors will change into longer time calibration if they are powered for a longer time and I am tempted to say the MHZ19 might do the same, but not the MHZ14.
        By the datasheet, the S8 seems to be a bit smarter, limiting the drift of the zero point to a certain amount, so skipping some days without a 400ppm reference should have no impact.

        It seems that these sensors don’t work well enough for me in the bedroom, especially during the winter when it is very possible I will not open the window for long enough time to get that 400ppm exposure.

  2. We’ve built a sensor system that measures temp, humidity, PM 10 and PM 2.5 and sends it to maps.sensor as well as the Grafana site. Here’s their site – it’s in Europe. https://sensor.community/en/sensors/airrohr/ i really liked it bec. it was SIMPLE – even i, a 75 year old guy, with no electronic schooling, could put it together. i didn’t use the tubing, just cut a big plastic juice bottle and used the bottom half. Placed all the items inside with little double-sided tape tabs, turned it over and taped it to a post near an electrical outlet – outside. We registered 46.67 C today. Kinda warm here in sunny Mexico – lol.

    1. Hi Fred, i build one of those to. Indeed simple to build and looks pretty reliable, also i love the idea of citizen science so a better picture can be obtained of air quality in my country (and worldwide)

    1. no…i almost fell for that exact one too. Read the fine print in the datasheet: Maintenance free when ASC field calibration algorithm is used. For proper function of ASC field-calibration algorithm SCD30 has to be exposed to air with 400 ppm regularly.
      From another manual: To work properly SCD30 has to see fresh air on a regular basis. Optimal working conditions are given when the sensor sees fresh air for one hour every day so that ASC can constantly re-calibrate

      Source: https://cdn.sparkfun.com/assets/d/c/0/7/2/SCD30_Interface_Description.pdf

      I would think the sensor is more accurate than the cheaper ones, but i would not think it works without calibration.

      1. Uh, thanks for correction. I have to admit i read the datasheet quite some time ago…

        This makes me wonder if there actually is an affordable CO2-sensor that works without constant recalibration. Anybody?

  3. How often must one calibrate and how is the calibration carried out? I am very interested in measuring air quality. I have a grove dust detector which seems to work well. I’ll ned other sensors too – light, temperature and humdity – I have the sensors for that.

  4. Hey, What about using a MG811 sensor for the detection of CO2!! I don’t think it needs periodic calliberations.
    I have’nt used it yet but i think it will do the work.
    Do Comment Your Views.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.