Embedded · Raspberry Pi 5
Pi Air Monitor
An indoor air-quality monitor: C drivers read a BME280 over SPI and an MH-Z19 CO₂ sensor over UART, and a FastAPI service stores the readings in PostgreSQL and serves a live dashboard with CO₂ danger alerts, history and CSV export.
- BME280 + MH-Z19
- SPI / UART
- C drivers
- FastAPI
- PostgreSQL
- Dashboard
CO₂ danger alerts
Know when to open a window
Every CO₂ reading is placed in one of five bands, from Good to Dangerous, based on published health guidance up to the OSHA 8-hour exposure limit. The dashboard labels the current band and draws the thresholds on the chart. At Unhealthy or above it raises a banner with advice and logs a warning.
- Good
- 800
- 1200
- 2000
- 5000 ppm
Hysteresis: a level drops only once CO₂ is 50 ppm below the boundary, so readings near a threshold don't flicker.
-
01
Two drivers written in C
SPI driver with the BME280's calibration and compensation math, and a termios UART driver for the MH-Z19 with framing, checksums and timeouts. Each ships as a CLI and a shared library loaded from Python.
-
02
Fault tolerant
Reopens a sensor after a failed read so unplugging either one recovers without a restart, rejects out-of-range and bad-checksum data, and prunes old readings hourly.
-
03
Tested and shipped like a product
Unit tests check the math against the Bosch datasheet and drive the UART code through a simulated sensor. CI builds with -Werror for x86_64 and aarch64 and publishes ARM64/AMD64 Docker images.