The idea
A small sensor pod that sits on your nightstand and logs bedroom conditions all night: temperature, humidity, CO2/VOC levels, ambient light, and noise (as a dB level, not recorded audio). Each morning it pulls your sleep score from Oura, Apple Health, or Fitbit and lines it up against the overnight readings, so you can see whether the night you slept badly also happened to be the night the room hit 74°F or CO2 climbed past 1200ppm.
Why build this
Sleep trackers tell you the outcome (poor sleep score, low deep sleep) but not the cause. Most people never connect a bad night to a hot room, a stuffy space, or a noisy street, because nobody is logging the environment at the same resolution as the sleep data. Consumer smart displays (Nest, Awair) show live readings but don't retain history in a form you can query against your own sleep export, and their apps rarely let you overlay two datasets. Cheap, accurate sensors (SHT31, SGP30, BH1750) plus a $6 microcontroller make a purpose-built logger cheaper and more hackable than any commercial air-quality gadget, and correlation is now a weekend script instead of a research project.
Stack sketch
- ESP32-C3 (Wi-Fi, cheap, low power) with SHT31 (temp/humidity), SGP30 (CO2 equivalent/VOC), BH1750 (lux), and an INMP441 I2S mic for a running dB average — no raw audio ever leaves the device
- Firmware in MicroPython or Arduino C++, posting a JSON reading every 60s to a local endpoint over Wi-Fi
- FastAPI backend on a Raspberry Pi or small VPS, writing readings to SQLite (one row per minute is nothing at this scale)
- A daily cron job that pulls last night's sleep score via the Oura API or an Apple Health auto-export shortcut, and stores it against the matching date
- A small web dashboard (FastAPI + HTMX or a static Chart.js page) showing overnight overlays: sleep stages on one axis, temp/CO2/noise on the other
Scope for v1
- Single sensor node, single bedroom, single user
- Local network only — device posts to a backend on the same LAN, no cloud relay
- Manual CSV import for sleep score if API access isn't set up yet (Oura/Fitbit OAuth can come later)
- One dashboard view: last night's overlay chart plus a 30-day trend of average nightly CO2 and temperature
- No alerting, no automated humidifier/thermostat control, no mobile app — browser dashboard is enough for v1
Where it could go
The natural next step is closing the loop: once you know 68°F and CO2 under 800ppm correlates with your best deep-sleep nights, wire the node to a smart plug controlling a fan or a Wi-Fi thermostat and let it nudge conditions toward your personal optimum automatically. A second expansion is multi-room support for households — kids' rooms, guest rooms — with a shared dashboard, which mostly means giving each node an ID and adding a room selector to the UI. Longer term, aggregate anonymized correlation data across users (opt-in) to answer general questions like "does CO2 above 1000ppm reliably hurt deep sleep" with a real sample size instead of one person's nightstand.
Watch out for
Cheap VOC/CO2 sensors like the SGP30 estimate CO2-equivalent from VOC readings rather than measuring CO2 directly, so treat absolute values as trends, not lab-grade numbers, and recalibrate expectations accordingly. The microphone must only ever compute and transmit a dB level on-device — storing or transmitting raw audio from a bedroom is a privacy problem you don't want to own, even for a personal project.