22 Jun 2022categories: small-computers
tags: 3dp circuit-python i2c rp2040 stemma
Recently my partner bought an LCD resin 3D printer. That was kind of the last straw for a risk that has been growing in the last few months. I already had a filament 3D printer (so far just for PLA, but who knows!), and several weeks ago I hooked up a kegerator with a carbonation system. Oh, and all of these share the same airspace as my office.
The risk we’re concerned about is a buildup of VOCs, carbon dioxide and carbon monoxide. To mitigate this, I wanted to build a device that can sense these things, display their levels on a readout, and potentially make a loud noise if they go over a certain threshold.
Are there consumer devices that also do this? possibly. Are there even fancy filter fans that can show you what’s in the air on your smartphone? also yes. But this sounded simple enough to prototype that I could spend a little extra money on the parts and then have fun putting them together. (Also, I couldn’t find a consumer-grade device that would measure carbon dioxide, so I wanted to start there).
The main board I chose for this is the Adafruit Trinkey QT2040 (guide). I didn’t have a lot of criteria to match. I mostly wanted it to be easy to get running, and use I2C for the connections. Trinkey is easier than easy. Anything Adafruit makes that works with their Circuit Python libraries is very approachable, code-wise. And this board is based on the RP2040 chip, which is more than powerful enough to run the code I need.
It also happens that Adafruit maintains a hardware spec called “Stemma QT” that transmits I2C signals over premade JST PH wires (youtube intro). Trinkey has Stemma QT (hence “QT2040”), and a lot of the sensor breakout boards that Adafruit makes also use Stemma QT.
The star of the show is the CO2 sensor: that’s an Adafruit SCD-41 (guide) photoacoustic “true” CO2 sensor. It measures temperature, relative humidity, and CO2 (in parts-per-million). It transmits all of this over I2C, using Stemma, once every few seconds.
I had a Pi-Fan laying around from a past project, and figured the sensor wouldn’t do much good without a continuous supply of new air.
Finally, I 3d-printed a frame for all these parts to screw (or hot-glue) onto. The first attempt is always a little kludgy, but I really like it! Without further ado, here’s my first take of a CO2 sensor:
The code and 3d-printing files are available at https://github.com/spilliams/canary
Final Bill of Materials:
- (1) Adafruit Trinkey QT2040
- (1) Adafruit SCD-41
- (1) monochrome I2C OLED Display
- (1) Pi-fan
- (3) JST PH cables (socket-socket)
- (1) adapter cable (JST PH socket to breadboard plug)
- (12) M2.5 screws
- PLA filament
- hot glue
Next time I come back to this, maybe I’ll add a speaker and “hush” button, or CO and VOC sensors, or a battery for portable use!