Skip to the content
2 layers37.5 × 51.4 mmCo2-detector, the printed circuit board in 3D

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.

Size
37.5 × 51.4 mm
Copper layers
2
Thickness
1.6 mm
Parts
13
Nets
20
Pads
41
Tracks, vias
66, 0
Pours
2
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
21 Oct 2020
Updated
8 Dec 2022

Overview

Co2-detector is an open-source printed circuit board by deuteros76, from the deuteros76/co2-detector repository on GitHub. It is a 2-layer board of 37.5 × 51.4 mm with 13 parts on 20 nets, routed with 66 tracks and 0 vias.

It is built around the WEMOS D1 MINI and SGP30. Its parts include 4 resistors and 2 ICs. It belongs with the sensors and measurement and home automation and IoT boards and the ESP8266 boards of this library.

Main components

2

README

README.md

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. After a few tests, I modified the code of another project and then 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.

Prototype

Features

  • Configuration of WiFi network and MQTT through a web portal.
  • Temperature, humidity and air qualiity (CO2 and TVOC) sensors.
  • Possibility of being used with Home Assistant or any software capable of reading a mqtt queue.

License

Hardware

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.

Software

The software is available unde Apache 2.0 license and can be found in the co2-detector directory.

Documentation

Documents found in this project are distrubuted under Creative Commons CC0 license.

Hardware components

  • Wemos D1 mini
  • DHT22 sensor
  • SGP30 sensor
  • Wires, tools...
  • Green, yellow and red LEDs
  • ... (See bill of materials below)

Software requirements

  • This source uses Arduino IDE and its standard libraries
  • Additional libraries: WiFiManager, Arduino Json, PubSubClient, DHT and Adafruit SGP30
  • A computer running MQTT
  • [Optional] A computer running Home Assistant

Device configuration

During the first execution, the device will launch a WiFi access point. Using your PC or mobile device, check the available networks and connect to the network whose name starts with "CO2-detector". After that, point your browser to http://192.168.4.1 and the configuration page will be displayed.

Home

Choose the first option ("Configure WiFi") and select your WiFi network from the list of detected access points then, write your WiFi password. If your wifi network is open, leave the password field empty.

Available networks

Now configure you network settings.

Network

The device will publish all sensor data through mqtt so, the information is sent to another machine such as a minipc used as an IoT gatway. To do that, you have to introduce the data of the mqtt server.

Network

Then, fill all the fields related to your MQTT topic names and save your configuration. If you have several devices in different places you can change the prefix (room1/Temperature, room2/Temperature and so on).

Network

After saving the settings the device will be reset and then it will run in its normal mode, gathering data from all sensors.

Usage

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).

Home Assistant

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.

Home Assistant

Bill of materials

ReferenceValueFootprintDatasheet
D1RedLEDs:LED_D5.0mm
R390Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal
R410KResistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal
TH1DHT22_Temperature_HumiditySensors:DHT22_Temperature_Humidity
U2SGP30Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm
D2YellowLEDs:LED_D5.0mm
D3GreenLEDs:LED_D5.0mm
R1160Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal
R2160Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal
U1WeMos_D1_miniwemos-d1-mini:wemos-d1-mini-with-pin-header

Example of a configuration for Home Assistant

The following Home Assistant configuration file is an example of two CO2 detectors placed at different rooms within a house. One is in a dinner room while the second is monitoring a sleeping room. Each device sends the data provided by the SGP20 (CO2 and TVOC) and DHT22 (temperature, humidity and heat index) sensors to a mqtt queue which is installed in the computer hosting Home Assistant.

text
homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Impacts weather/sunrise data
  elevation: 50
  # C for Celsius, F for Fahrenheit
  temperature_unit: C
  # 'metric' for the metric system, 'imperial' for the imperial system
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Madrid

# Show links to resources in log and frontend
#introduction:

system_health:


group:
  kids:
    name: Kids room
    entities:
      - sensor.kids_temperature
      - sensor.kids_humidity

Parts

13
QtyValueFootprintReferences
2160Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2
110KResistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR4
190Resistors_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR3
1DHT22_Temperature_HumiditySensors:DHT22_Temperature_HumidityDHT22
1GreenLEDs:LED_D5.0mmG
1RedLEDs:LED_D5.0mmR
1SGP30Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mmU2
1WeMos_D1_miniwemos-d1-mini:wemos-d1-mini-with-pin-headerU1
1YellowLEDs:LED_D5.0mmY

The 10 most common of 13 parts.

Similar boards

  • 2 layers70.1 × 43.2 mmIaq device, the printed circuit board in 3D

    Iaq device

    nkitanov/iaq_board

    IAQ Board is a DIY (Do-It-Yourself) device for measuring internal air quality

    19 parts396
  • 2 layers30 × 62 mmWiFIR, the printed circuit board in 3D

    WiFIR

    Duckle29/WiFIR

    A WiFi connected IR blaster to control heatpumps

    34 partsBSD-3-Clause
  • 4 layers42 × 42 mmDynossat edu obc, the printed circuit board in 3D

    Dynossat edu obc

    BHDynamics/dynossat-edu-obc

    DynOSSAT-EDU, educational PocketQube satellite On-Board Computer files

    60 parts14
  • 2 layers40 × 98 mmAirquality, the printed circuit board in 3D

    Airquality

    LukasLendvorsky/airquallity-esphome

    WIFI airquality sensor with ESP32

    59 parts3GPL-3.0
  • 2 layers20 × 49 mmIndicator fun V3s, the printed circuit board in 3D

    Indicator fun V3s

    vrubel/indicator-fun-V3s

    "indicator.fun" device implementation on the processor Allwinner V3s

    168 parts2MIT
  • 2 layers72 × 121 mmTeebeutel, the printed circuit board in 3D

    Teebeutel

    entropia/Teebeutel-Hardware

    Teebeutel (eng. Teabag) is an electronic, Entropia themed con-badge for the GPN20, featuring an ESP32 microprocessor running micropython.

    201 parts1
  • 2 layers63 × 109 mmCansat pcb, the printed circuit board in 3D

    Cansat pcb

    samvandenabeele/CanSat

    SBC CanSat

    21 parts1MIT
  • 2 layers134.6 × 127 mmSensors Course Project, the printed circuit board in 3D

    Sensors Course Project

    dustpot/indoor-air-monitor

    A battery-powered ESP32 monitor for the non-particulate qualities of indoor air: temperature, humidity, pressure, eCO₂, and TVOC.

    28 parts

Questions

How big is the Co2-detector PCB?

It measures 37.5 × 51.4 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Co2-detector use?

13 parts, built around the WEMOS D1 MINI and SGP30. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Co2-detector KiCad files?

From the deuteros76/co2-detector repository on GitHub, at the commit this page was made from: the board is board/co2-detector.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Co2-detector design in my own project?

Its repository states no licence, so its author keeps all rights: ask deuteros76 before reusing the design.