/co2sensor

Arduino sketch for an ESP32C3 & Senseair Sunrise & Adafruit E-Ink Friend based CO2 sensor

Primary LanguageC

DIY CO2 Sensor

This is a hobby and learning project.

Parts list:

Sensor

I experimented with other sensors, but ultimately picked SenseAir Sunrise because it has low standby power usage, has no warm-up time, and tolerates unregulated input current. It has good documentation too:

I found an Arduino library on Github that implements I2C communication with Sunrise, and got it to work with a couple small tweaks. My fork is here.

Display

I bought the display on AliExpress, and am not entirely sure precisely what model I got, or what IC is inside. Adafruit's EPD library comes with different display drivers. I tried every driver until I found one that seemed to work.

Black/white displays are a better choice than tri-color displays, as they take significantly less time to refresh.

TPL5110

TPL5110 is a timer and power management chip. It turns on power every 5 minutes (the time period can be tweaked), and cuts power when the ESP32 sends an "I'm done" signal over GPIO. I am using it as a brute-force way of making sure there is no power drain between CO2 measurements (aside from the always-on power that the Sunrise CO2 sensor needs).

PCB

PCB

I designed the PCB in EasyEDA. There is a jumper on the board to switch between USB and battery power.

Case

Case

I designed the case in Fusion 360. The case consists of three parts: the front part, a piece that the PCB and screen mounts on, and a backplate. The case snaps together with no screws. There is no transparent protective layer for the screen.

Code

The Arduino sketch:

  • reads sensor state from ESP32 flash
  • reads battery voltage from ADC GPIO pin
  • Measures CO2 level
  • Writes the measurement to an append-only file on flash filesystem
  • saves sensor state to flash
  • displays CO2 measurement, battery level and measurement history graph on the eInk display
  • sends a signal to TPL5110 to cut power

Here's how the UI currently looks:

UI