Air quality monitor: Why I sleep better at night
Sleep is a tricky thing to get right. Sometimes I wake up with headaches and sore muscles, sometimes I wake up with a stuffy nose, sometimes with dry skin, and yet other times I wake up feeling great.
Why can't I feel great every morning? As an engineer, I decided to get to the bottom of this using both data and science.
Building a Device to Gather Data
Research has shown that indoor air quality plays a significant role in sleep quality. With this in mind, my first step was to measure the air quality in my bedroom.
I began by wiring a FeatherS2 microcontroller with just about every air sensor I could find: pressure sensors, temperature sensors, humidity sensors, electrochemical sensors, ozone sensors, infrared CO2 sensors, and particulate matter and dust sensors.
I even included a Geiger counter on the off-chance a truck transporting radioactive materials drove by my house.
Fortunately, each sensor I compiled used the I2C communication protocol, so wiring them up was relatively simple, as was housing them in a 3D-printed enclosure. My air quality monitor was complete. Building it required a few hours of my time and roughly $300, although a basic version with sensors for only the typical air quality culprits could be built for around $120.
Once I Gathered the Data, How Would I Log and Analyze it?
Next, I had to determine how I would log and analyze the monitor's data.
In full disclosure, as I work for Freedom Robotics, I found that the robot monitoring tools that we were building were not only useful for recording ROS topics on robots, but also for monitoring, recording, replaying, and streaming IoT device data. You can also build your own monitoring solution, I just found that what we had built as a company was already ideally re-purposed for this use case.
Although designed for robots, I knew it would provide the perfect user interface and experience for recording and reviewing arbitrary sensors collected from Internet of Things (IoT) devices like my air quality monitor. To support future work like this, we built the MicroLink, a library to publish data from microcontrollers that run on CircuitPython or MicroPython.
Indoor Carbon Dioxide Levels
The air quality monitor paid for itself after a single night of collecting data. As high CO2 levels are known to adversely affect sleep quality, I was surprised to find my bedroom measuring over 1200 ppm — easily crossing the 1000 ppm threshold, which is known to induce drowsiness, headaches, and other symptoms detrimental to a good night's sleep.
My solution? Crack my bedroom window open at night and watch the CO2 levels plummet. But how wide should I open it each night to keep the levels optimal without sacrificing heat? A few days of experimenting gave me my answer.
Do Humidifiers Even Work? If They Do, Are They Reliable?
Another problem I sought to solve was waking up thirsty with dry skin. Further, my bedroom plants were not faring well and were prone to dry out rather quickly.
I had recently bought a humidifier to address my dryness woes, but was it working? Two sensors in my air quality monitor proved that it was.
The periodic behavior detailed in the readout below is due to the humidifier regularly turning off according to its set point, and shortly after 10 a.m., running out of water. When these instances occurred, humidity levels started to drop back to their natural dry levels.
I also discovered that the humidity levels in my room reported by the humidifier were nowhere near what my air quality monitor was reporting.
When the humidifier reported 57 percent, actual levels were between 35-40 percent. One might think this was due to miscalibrated sensors, but the discrepancy was actually caused by the humidifier sitting in a pool of its own fog.
Humidity levels near the humidifier will always be higher than elsewhere in the room. As such, one cannot possibly get an accurate measure of the room's humidity when near it. This is a fairly standard concept that is accounted for when temperature control systems are designed for laboratory equipment, but not when it comes to consumer products. With this in mind, the variance made sense.
Building your own
Head over to the Github repo for plans and code.