Select your language

Co2 Detector
Co2 Detector

After reading this article (ES) I started to think about creating my own sensor board. I searched which sensor to use and the SGP30 seemed a good option to me. Then, I did a few tests, I modified the code of another project and then I designed a PCB and later on I  built two prototypes which are currently working in my house. The device uses a mqtt queue to send data to an IoT gateway (a minipc running Home Assistant in my case). In addition to that, there are three LEDs to show what is the current state of the air based on CO2 PPMs:

  • Green light is shown if there are less than 600 PPM of CO2.
  • Yellow light if there are between 600 and 800 PPM.
  • Red when the CO2 is greater than 800.

The source code and the PCB design (made in Kicad) can be found here. In January, the project was certified by as open source hardware by the OSHWA

How it works

All LEDs will be turned on when the device starts. After configuring the device, it will try to connect to the configured network. After that, only one LED will be lighted.

The CO2 sensor takes a measurement every second and sends an average of the last 60 CO2 and TVOC values every minute. The temperature and humidity sensor is used to correct the obtained data as explained in the SGP30 data sheet.

Device's LEDs are also useful to know the current state in case of error:

  1. If you see all them lighted on, the board is unable to connect to your WiFi.
  2. If the yellow LED blinks, your co2-detector is connected to the WiFi but cannot reach the MQTT queue.
  3. If the SGP30 sensor is not detected, the red LED blinks.

DHT22 (humidity and temperature sensor) errors are detected but not reported through the LEDs as this sensor is used to improve the accuracy of the CO2 readings but it is not critical if it doesn't work. It is possible to detect a malfunction in the DHT22 finding the last temperature and humidity readings in Homa Assistant (for instance if both values are not updated for many hours).

I use Home Assistant to collect all the data and display the information. The software runs in a miniPC (a SolidRun CuBox-i) which is a small home IoT server and also has the Mosquitto mqtt broker. The device sends sensors data to the mqtt broker and Home Assistant reads it and stores everything in a data base. In addition to that Home Assistant has a frontend application that shows the current status of all your sensors and historical graphs of a selected day. You can use any other similar software with the capability of subscribing to read from mqtt.

Project repository and license

The project is currently hosted at GitHub. You will find the hardware schematics and design files in the board directory. The hardware is distributed under the Cern Open Source Hardware License 1.2. The software is available unde Apache 2.0 license and can be found in the co2-detector directory. Finally, all documents found in this project are distrubuted under Creative Commons CC0 license.