CO2/Humidity/Temperature Sensor

This project is a mashup of different experimentations. I wanted to try the SHT21 sensors and I was looking for a CO2 sensor at the same time accurate and not too expensive.

Working screen

CO2 Sensor

Until recently, gaz sensors were either analogue (and totally uncalibrated) or relatively expensive (when not both at the same time). Then came the MH-Z14 which is a affordable "Non-Dispersive InfraRed" sensor, in theory quite selective.

The MH-Z19 from the same company can be found for ~ $25. The main issue is the partial documentation. Some commands are still a bit obscure.

MH-Z19

A great source of information is the wiki https://revspace.nl/MHZ19 and there a quite a few examples on github to get started.

At first experimentations were a bit frustrating but after a while things started to stabilise a bit and sensor's readings from the past few month seem to make sense. The solution was to reject sub-standard readings and to average valid ones over a period of 5 minutes.

One quite annoying thing a bit this module when using breadboard or prototype PCB is that it has weird dimensions (not a multiple of 2.54mm) and won't fit nicely.

Calibration

Calibration can also be an issue, specially because of the ABC calibration every 24h. The system would be great if it spanned over let's say a week which would give you several chances to open the window but as it is (i.e. using the minimum value of previous day as base), reading were becoming strange day after day. It turns out that it works a lot better without ABC and a manual calibration from time to time.

Then manual calibration can be triggered by software or using the hardware pin. To avoid trying to fit a switch on the enclosure, the solution retained was to use a reed switch inside and to press a neodymium magnet on the cover once the air of the room has been well recycled.

Graphs

Wemos D1 mini

Although I initially planned to use nodemcu modules, I decided to try Wemos D1 mini which are smaller, cheaper and able to cope with higher speed communication via USB so firmware upload is twice as fast.

Besides this, there really behave like any other ESP8266 solution. Wemos offers a good selection of shields (power, relay, LED, sensor, ...) which I haven't tried as well as modules based on the more powerful ESP32.

It is probably best to use their official online shop as there seems to be quite a lot of fake modules around, and not necessarily cheaper.

I2C Oled

Having used a 0.96" Oled screen for the time bomb, I really thought that using a 0.91" 128x32 I2C SSD1306 screen would be trivial. As it turns out, library for the former is not compatible with the latter because they lack of a proper framebuffer. After digging around, I found that the Adafruit library was working (one parameter is of a different value) even if the hardware looks quite different (more pins).

OLED I2C 0.91"

To be perfectly honest, if I was to make another sensor, I would give up the screen and use coloured Led shinning through (the plastic is slightly translucent) as the physical fitting was probably the most challenging part of this project (even if simple by DIY standard).

A sprinkle of MQTT

Communication with base is, of course, via MQTT, nothing new or complicated here. There is a sampling every minute for the CO2. The average value as well as the current values of temperature and relative humidity are sent every 5 minutes.

Wifi off (really?)

Since this new sensor is installed in our bedroom, I wanted to switch the Wifi on only when needed MQTT communication to send the values. I basically used the dedicated function for this. Is is really switching off "radiations"? Who knows... as I discovered with the electricity meter project, electric consumption is not lowered by it.

Powering the sensor

I knew from the start that using battery would be a challenge and I didn't even bother. Between the screen, MH-Z19 and the Wifi, it is probably around 200mA anyway. The USB port of the Wemos D1 mini is plugged directly on a small power adapter. The usb cable can also be used to upgrade the firmware as no OTA was implemented on this project.

All in a "sensor box"

Like almost everything else, directly from China, I found an enclosure designed for sensors (or thermostat?) which was the right size to fit everything. The USB power adapter is external, the ESP8266 at the top and the thermometer at the bottom, by the vents in order to stay as accurate as possible. Despite this, the temperature appears 1.5°C higher than without cover. The offset can be corrected in software.

Work in progress

Starting screen

Code

As usual the code and schematics are available (AS IS) on github. It includes a SHT library and MH-Z19 library.

    Foobot

    Pollution & Sensors

    Having started with pollution sensors which turned out to be almost unusable because of the lack of calibration and because I live in Paris which can sometimes have Air Crisis I wanted to carry on with new sensors.

    Trouble is, most of them tend to be very expensive or uncalibrated (and sometimes both!).

    I was in particular interested in particle sensors (like PPD42NS, PM2.5 laser dust sensor, ...) and CO2 sensors. Each were, at the end of 2015, around $50.

    Alima & Foobot

    I was aware of the Alima prototype which evolved to become Foobot (honestly how did they come with this crazy name? Sounds really like foobar)

    They had a successful campaign on Indiegogo (Indiegogo sounds crazy in French too since gogo means dupe/naive person. That said maybe it is appropriate to crowdfunding after all!).

    There are not cheap but they measure (according to the specifications):

    • VOC: total Volatile Organic Compounds, including gases such as Formaldehyde, Benzene, Toluene, Ethylene glycol, etc.)
    • PM: Particulate Matter (PM2.5)
    • CO2: Carbon Dioxide
    • CO: Carbon Monoxide
    • T: Temperature
    • H: Humidity

    Foobot

    And once you add the price of all the sensors and components, maybe having a calibrated system with apps and support for $199 is worth it.

    Cloud business

    The main problem with this kind of gadgets/toys/appliances/things is that they rely on the "Cloud" which mean that they are basically dead the day the company shuts down or decides they want to "refocus". There are countless examples of these, a very famous one being the Nabaztag/Karotz.

    There is also the danger of data traveling to US or China without knowledge of what is done with it. At least foobot is based in Europe (Luxembourg) so I assume EU related privacy laws apply.

    Openness?

    I also discovered that there were some info/code published about their prototype, renamed airboxlab so I would hope that in case of problem the foobot could be updated to talk to a private server.

    Installation

    With all this in mind, I took the plunge and ordered one. The installation can be done in minutes (as long as you have a phone/tablet on the same Wifi Network and that your Wifi SSID is visible).

    At first the application wasn't neither intuive nor reliable. Newest version seem stable and easy to use.

    It takes about a week for the Foobot to settle. At first I thought it was busted because all readings were bizarre but after a while they started to make sense.

    Notifications

    At the begining, I had the notifications on but after a while they become quite annoying and frankly there is not much you can do if the air is not good in the middle of the night! You can also tell the system what the event was but honnestly I don't understand how that works.

    Note that you also receive reports by email on a regular basis.

    API

    There is a API (via the Cloud, unfortunately not a direct connection to the appliance) with historical data. It can be called up to 200 times (odd number even if mathematically even) so I download latest data every 15 minutes (96 times a day).

    The API has been pretty stable/reliable so far.

    Sensors

    The Good?

    The sensors "don't like" cooking (or maybe cooking = polluting?). A few month ago, we made some crêpes and the Foobot became all orange (= bad atmosphere). Graphs when to the roof! It is about the same if the oven is turn on.

    I assume anything with oil will create loads of "particulate matters"... At least that what the readings say!

    The less good

    Looking at the component list of the Airboxlab or at the current datasheet, there is something bizarre.

    Yes! There is no proper CO2 sensor! The MQ135 is a generic Air Quality Sensor and it is the one used for the Volatile Organic Compounds.

    Some people tried to use it to measure CO2 but it looks a bit nonplussing.

    And because of this, the graphs for VOC and CO2 have exactly the same shape and it impossible to say if CO2 or Non-CO2 VOC are the ones triggering the sensor :-(

    This wasn't clearly advertised when I bought it and this is a bit of a disappointment.

    CO2 graph

    For CO, it is not even returned by the API. That said the Foobot is not an Carbon Monoxide detector and there should not be much CO around in a room so I am OK with that one.

    IAQ

    Calculated value

    Foobot computes an Index which represents the Air Quality (Indoor air quality (IAQ). The lower the better. The colours (shades of blue & orange varies according to this index).

    Breezometer

    They recently added a outdoor value. Data is computed by Breezometer (how? who knows) and the result is shown on the app. Data is also available directy from Breezometer but there is a small catch:

    • Breezometer index via Foobot API is also the lower the better (to keep data consistant)
    • Breezometer native index is the higher the better!

    Foobat App AQI Foobat App PM

    Conclusion

    First, it works! Seems a bit bizarre said like this but I came across so many dysfunctional stuff that it is worth mentioning that this simple fact.

    It measures values which seems in line with my other sensors (Temperature/Humidity) and activities (PM/VOC) even if I can't compare how well calibrated they are.

    API is rather stable. The App (IOS/iPhone version but used on an iPad) a bit less depending on releases.

    So as I pure sensor, I believe it can be recommended.

    I am far more skeptical about the "better air" all the marketing, blog and website seem to be based on. OK knowledge is the be first step towards improvement but I still haven't understood "the magic" about "Predictive data [and] how Foobot learns about your habits and is able to detect pollution peaks before they actually happen".

    Apart from opening the window (or stop breething), there is little which can be done in case of pollution alert!

    Page 1 / 1