Retro style CO2 sensing
TL;DR
- Printable 8-bit ghost shaped CO2 monitoring device
- Changes color according to CO2 level
- Works with Arduino
- Uses Sensirion SCD4x CO2 sensor
- Based on ESP32-C6 (WiFi, Bluetooth, IEEE802.15.4 capable)
- Custom PCB
- All open source / open hardware
- Files (Board, BOM, Sketch, etc.)
- Full list of required parts in assembly instructions
- File download here.
Introduction
I came across the topic of air quality measurement several times within the last couple of years (mainly on scientific or technical podcasts). As a developer I’m aware of the problem of bad air quality in the office without noticing it. If you’re busy problem solving, you might not have time to care about unimportant things like oxygen.
On a second though oxygen might help your brain solving the problem faster and keeps you awake. I came to the conclusion that a simple device which changes it’s color from green over yellow to red in order to signalize “hey dude, it’s time to open the window” would be the best for my use case.
I liked the idea that the device should fit nice on a desk and looks somewhat friendly (and maybe a bit nerdy). So an 8-bit ghost was the obvious solution.
Hardware
I wanted the device to be reproducible (as christmas presents), so I decided to design a custom PCB. Nothing fancy, just a controller, an LDO, some pixel LEDs and passives. I used four layers because it doesn’t cost much more and it speeds up the process. If somebody wants to I’m sure it can be reduced to 2-layers.
In order to allow expansion of the functionality and maybe some kind of integration into a smart home setup, the ESP32-C6 seemed like a good fit for the project. It offers the whole range of 2.4GHz standards (WiFi, Bluetooth, 802.15.4 –> ZigBee, Thread).
I tested some sensors (including VOC sensors) and came to the conclusion that only a real CO2-sensor delivers reliable results. The smallest and “cheapest” solution which is widely available is the Sensirion SCD40. You can get it for around 30$ from DigiKey.
The sensor is attached to the board using spring loaded pins in order to avoid damaging it or heat it up to much in the soldering process. Besides the spring loaded pin option, there is also a header which fits the boards available from ebay or aliexpress. I didn’t design any 3D parts for this, so you have to design it yourself.
The device uses 17 WS2812B RGB LEDs which should be driven on a low brightness level in order to avoid heat (and dazzling).
It doesn’t take expert level skills to solder the board, but a beginner might run into problems soldering the smaller components and finer pitch parts, especially the USB-C connector.
Firmware
I still don’t like the Arduino IDE and the “Arduino Sketch” style of programming. But I get the point that it should be easy for beginners and it allows non programmers to “get shit done”.
Anyways, I decided to write a basic firmware using Arduino to allow more people to have fun with the project.
The sketch should have enough comments and a sufficient naming scheme to make it understandable. In good Arduino style, a maximum of external libraries have to be imported:
- Sensirion I2C SCD4x (Sensirion) –> SCD4x sensor driver
- Sensirion Core (Sensirion) –> Required by Sensirion I2C SCD4x
- Adafruit NeoPixel (Adafruit) –> WS2812 Pixel LED handling
- Adafruit Debounce (Adafruit) –> Button handling
Assembly and programming
Partlist
- Printables (I used PETG but PLA etc. should be fine as well)
- 1 frontcover (needs to be transparent)
- 1 backcover
- 2 eyes
- 1 sensor holder
- 1 sensor cover
- 1 eye conector
- 1 button cover
- Nuts and Bolts
- 3 countersunk M3 x 16mm (e.g. DIN965)
- 2 M3 x 12mm (any flat headed screw will do)
- 5 M3 nuts
- Populated PCB (see board BOM and assembly pictures for details)
- Sensirion SCD4x Sensor (SCD40-D-R2)
Board assembly
You can order the board from anywhere you like. Gerbers are provided with the project files. The boards includes a holder for the springs. Before doing anything else you should remove it and put it aside. If you want to connect the ground pad of the ESP module, you should solder it first. I recommend to solder all LEDs and their decoupling caps afterwards. Remaining SMD components can be soldered in a small to large manner. As a last step the spring loaded pin assembly needs to be put together. It’s a bit tricky, so take your time. Make sure you dont solder the “springy” part. I provide some detail pictures as a reference.
For easy assembly you can use the “Interactive BOM” provided in the download archive.
Remember that you also have to buy the CO2 sensor: Sensirion SCD40-D-R2 which is seen as an external component and is therefore not part of the BOM.
Printing
Nothing special about this. I used a .4mm nozzle and a .2mm layer hight with 15% infill. My print was a bit stringy because of the slightly older PETG filament. PLA might be the better option here.
Case assembly
First screw the sensor to the board and slide the M3 nuts into the front cover. Continue with the eye assembly. Place the board into the case and add the sensor cover and the button cover. Add the back cover and tight it shut with the countersunk screws.
Compiling and flashing
Download a recent version of the Arduino IDE and install the following libraries (Tools -> Manage Libraries):
- Sensirion I2C SCD4x (Sensirion) –> SCD4x sensor driver
- Sensirion Core (Sensirion) –> Required by Sensirion I2C SCD4x
- Adafruit NeoPixel (Adafruit) –> WS2812 Pixel LED handling
- Adafruit Debounce (Adafruit) –> Button handling
As well as the board support package (Tools -> Board -> Boards manager)
- esp32 (Espressif Systems)
Select the board “esp32 -> ESP32C6 Dev Module” and make sure to enable “USB CDC On Boot” in order to get the println outputs on the serial monitor. It might also be neccessary to install pyserial (serial libraries for python) in order to get the ESP32 tools running.
Files
Please download from the link below. The archive contains all required files to build the project.
- Schematic
- Bill of Materials (BOM)
- Gerber files to order the PCB
- STL files for printing
- OpenSCAD source files
- Arduino demo sketch (basic functionality, buttons are not used)
AirGhost REV 1.2 DOWNLOAD
Contact
If you have any questions you can send a mail to info ‘at’ embedded-ideas.de or contact me via mastodon @DerTobi@mastodon.social