CO2 Indoors

Sam Myres
3 min readFeb 9, 2024

A few years ago now and again recently I was introduced to the effects of CO2 on cognitive abilities by a couple of youtubers and as a software engineer I found this especially worrying and interesting because I spend very long stretches of time in my home (previously school, work) in a single spot. I rely entirely on the central air systems in buildings or fans of all types to make sure I’m not actually losing the ability to do my job by just concentrating for long periods of time.

In fact, I wanted to use my Raspberry Pi for something because it had been sitting around collecting dust, and so I bought a CO2 sensor and plugged it in, dusted off a chip that does temp/pressure/humidity and an infrared motion sensor that I’m still not sure is working to this day. I put this all in the other side of the house where the levels would be less affected by activity (including me turning on a fan, which is now frequent). I set up storage in SQLite and I hooked up Grafana, requisite sqlite plugin and tinkered with the weird, constrictive language of sqlite until I could get the data into a format that Grafana would accept.

A lot of the code (written in go) is on Github here

<link to battery> <link to buck converter> <link to rpi locator> <link to co2 sensor> <link to bosch bme280> <link to PIR sensor>

20 amp hour lifepo4 battery (left) DC-to-DC buck converter (bottom center), raspberry pi (right) and CO2 Sensor (gold white and green top center)
A week of CO2 ppm, pressure hPA, temp farenheit and % relative humidity
280 days or so of atmospheric readings

As you can see over long stretches of time, especially during the summer, the 95th+ percentile can be up around 1200/1500 and that’s just where the cognitive decline kicks in, though research results on the effects of CO2 vary. One place where this can be a real problem is motorcycle helmets at a stop light. Our bodies turn over their supply of oxygen quickly, and contending with one to 40 ton vehicles on the road with a foggy mindset is flat out stupid. You can buy hybrid open/closed face helmets to combat this problem.

One of the most profound changes you see there is relative humidity. I’m convinced this house holds a lot of water. I wish that weren’t the case but for at least part of the roof we know was incorrectly constructed at a low angle for the materials used.

If you live or work in a tightly confined or densely populated space or building where you suspect the air is stale, you don’t have to go the lengths I did to find out about your situation. Instead, they make handy dandy standalone USB-powered versions of this thing I made and all you have to do is pay a small premium on what is effectively the price of the sensor.

Finally, if you want to know how this thing works, basically, that CO2 sensor is a standalone board that controls a lamp inside of a dark box with a porous paper-like screen. It lights up the incandescent bulb through a screen inside that filters out just one of the frequencies in the infrared light bands obscured by carbon dioxide, and it measures the amount of light that makes it through. There’s a whole calibration methodology I haven’t totally worked out but the sensor communicates over I2C to report the current measured density of CO2 in PPM every second.

Thanks for reading!

--

--

I'm a Software Engineer, FAA 107 Drone Pilot and Radio Amateur. I write about things related to SWE and Tech and my own projects.