If you have read my blog and my postings on Facebook for a while you know that one of my hobbies is to play around with microcontrollers. I built environmental sensors for my house and also two solar powered weather stations for outside.
One of my inhouse sensors is already monitoring fine dust levels and also “air quality” (what the BME680 sensor reports, to be honest, I have no real clue what it actually monitors). With the current discussions about increasing air quality for the purpose of lowering infection risk by monitoring inhouse CO2 levels, I decided to test one of the cheap CO2 sensors and build myself a CO2 monitor.
Since I did not want to spend too much money on my very first attempt I decided for a cheap CCS811 sensor which I ordered directly in China (no complaints about “buying local” here please – these sensors are manufactured in China and everybody selling them here locally are also just importing them). As a plaform I used my own ESP8266 based sensor node I also use for inhouse environmental monitoring. I still had some PCBs and other stuff laying around.
Hardware
You can get all that from the usual places.
- Wemos D1 mini ESP8266 microcontroller
- WS2812 RGB LED
- (optional) BME280 enviromental sensor
- CCS811 CO2 sensor
- SH1106 or similar I2C bus display
- Circuit board
- Headers to solder and put things together
- 3d printed housing (yes, I now have a 3D printer)
This is what the completed module looks like. The CO2 sensor is on the lower right, above it the temperature/humidity sensor, the microcontroller is hidden below the display.
Software
I guess you can get better code than mine to run everything, but as I like to code I wrote the software myself. Check out the code on github, I just want to highlight some features it has:
- Scans I2C bus at startup and uses all available sensors
- Connects via Wifi to an MQTT-server
- Reports sensor data via MQTT
- Takes some commands (like reboot or what to display) via MQTT
Results
The sensor works and it shows some data. I am still puzzled how the CO2 level here at home changes over time. Sometimes it really makes a jump (I often can relate to events like cooking etc.). When I open a window it slowly goes down. So far so good. If I reboot the sensor it also goes down – and stays down. So I think the sensor I am using is not really 100% reliable. There are other sensors on the market like the Sensirion SCD30 (way more expensive – but perhaps worth it if they are more reliable). See below for a picture – I used Grafana to visualise the results.