DIY Carbon Dioxide (CO2) Detector

by droiddiy in Circuits > Sensors

6764 Views, 91 Favorites, 0 Comments

DIY Carbon Dioxide (CO2) Detector

IMG_0735.png

A couple of weeks ago, I read an article about CO2 levels and how they may indicate higher transmission of COVID-19 in an indoor space. After reading this article, I wanted to take a crack at designing a simple CO2 detector that could visually display carbon dioxide levels in the air.

The assembly consists of a neopixel ring to display different colors to indicate the CO2 levels. I will use an SCD-41 CO2 sensor to detect the CO2 levels. I have also included a couple of other sensors to display temperature, pressure, and humidity in later iterations. An RP2040 board is set up to read these sensors and control the neopixel ring.

The following steps will walk through the assembly and programming of the CO2 detector.

Supplies

Install RP2040 Board and Sensors Onto Frame

IMG_0714.png
IMG_0715.png
IMG_0718.png
IMG_0719.png
IMG_0721.png

Before installing the sensor and microcontroller board to the component frame, we need to solder the headers onto the RP2040 board and the propmaker feather wing. Take the female headers and install them into the positions on the RP2040 board. Solder one pin of the header to the board. Use the soldering iron to reheat the solder joint and straighten the header so that it is perpendicular to the face of the board. Once the header is straight, solder the remaining header pins.

To install the male header pins onto the propmaker feather wing, place the male header pins into the female header. This will guarantee everything is aligned when the headers are soldered to the board. Once the headers are in place, align the holes on the feather wing with the header pins. Solder each of the header pins to the feather wing.

Install the RP2040 feather board onto the frame in the position shown in the picture below. Use the M2.5 screws and the nuts to secure the RP2040 board to the frame.

Next, install the SCD-41 CO2 sensor in the frame position shown in the picture below. The #4-40 x 3/8 machine screws and #4-40 hex bolts are used to attach the SCD-41 sensor to the CO2 detector frame.

Next, install the DPS310 barometric sensor and the DS3231 RTC onto the CO2 detector frame. The RTC board sits on top of the barometric sensor using the small RTC frame spacer. First, install the coin cell battery into the RTC board and attach the RTC board to the small frame, as shown in the picture below, using the 2.5M x 20mm screws.

Attach the two boards to the main frame using the 2.5M hex nuts.

Once all the sensor boards are attached to the frame, connect each board using the 100mm and 200mm stemma cables. Make sure each board is in series and all the boards are connected to the RP2040 feather.

Assemble Slide Switch

IMG_0703.png
IMG_0704.png
IMG_0706.png
IMG_0708.png

The slide switch assembly will sit between the battery and the RP2040 board. It will allow the assembly to run on battery power when not plugged into a USB power source. To prepare the slide switch, remove one of the leads on the edge of the slide switch, like in the picture below. The other two leads of the switch can also be trimmed down slightly.

Take the socket JST wire and the plug JST wire and trim them to the length of the enclosure. Tin the leads of the cables for both. Before soldering the wires together, have heat shrink tubing threaded on the wire so it can be placed over the solder joint. Solder the black wire from the socket JST connector and plug JST connector together. Slide the heat shrink tubing over the solder joint and shrink it in place.

Thread heat shrink tubing over each red wire of the JST sock and plug connectors. Connect the red wire of the socket and plug JST wire to the two leads on the switch. Place heat shrink tubing over the solder joints and shrink in place.

Assemble Neopixel Ring

IMG_0709.png
IMG_0710.png
IMG_0724.png
IMG_0726.png
IMG_0727.png
IMG_0725.png

The neopixel ring has three inputs, signal, power, and return. To power the neopixel ring, the 3-wire JST cable needs to be connected to these inputs. Take the 3-wire JST cable and solder the following wires to the following inputs:

  • VCC - red wire
  • GND - black wire
  • DATA IN - white wire

For the neopixel ring to fit properly in the bracket, the wires should be soldered on the front of the ring, as shown below.

Once the connector harness is soldered to the neopixel ring, place the ring onto the bracket and thread the connector harness through the frame. Place the square #4-40 nuts into the bracket slots. Place the bracket into the enclosure's lid and insert the #4-40 x 3/8 fasteners into the holes in the top. Fasten the frame to the cover using the screws.

Putting Everything Together

IMG_0712.png
IMG_0713.png
IMG_0722.png
IMG_0723.png
IMG_0728.png
IMG_0730.png
IMG_0734.png

All the major parts have been assembled, and it is time to place everything together in the final assembly. First, we will install the switch assembly into the enclosure. Place the switch into the switch location on the enclosure. Hold the switch in place with some hot glue.

Insert the battery into the enclosure and connect the cable to the switch assembly socket.

Fasten the board bracket assembly into the enclosure using the M3 x 12mm fasteners and hex nuts. Thread the fastener through the underside of the enclosure and place the nut on top of the bracket.

Connect the neopixel wire harness to the propmaker feather wing connector. Lastly, connect the switch assembly plug to the connector on the RP2040 board. If the board powers up, slide the switch to the opposite location to turn off the board. The CO2 detector assembly is now complete!

Upload Code to CO2 Detector

The CO2 detector uses circuit python code loaded on the RP2040 feather board. You can download the code and the necessary libraries from my GitHub here. Feel free to make any modifications to the code to suit your purposes.