Environmental Monitoring Platform

Overview
A full-stack environmental monitoring system running on a Raspberry Pi 5 that captures real-time temperature, humidity, pressure, CO2, TVOC, and particulate matter data from five hardware sensors. All readings are stored in PostgreSQL, exposed via a GraphQL API, and displayed through a bilingual (English/Portuguese) web dashboard. A medication and wellbeing tracking module is deeply integrated, linking subjective health feelings to objective environmental data.
Connected Sensors
Five sensors are connected via I2C bus and UART serial. The BME280 measures temperature, humidity, and atmospheric pressure. The SCD41 provides direct NDIR CO2 readings along with temperature and humidity. The ENS160 + AHT21 combo measures Air Quality Index, Total Volatile Organic Compounds (TVOC), and equivalent CO2 — the ENS160 receives temperature/humidity compensation from the AHT21 before reading. Two particulate matter sensors (PMS5003 and PMS7003) measure PM1.0, PM2.5, and PM10 concentrations in micrograms per cubic metre.
Data Collection
APScheduler runs as a dedicated process, triggering sensor reading jobs at regular intervals. Jobs are staggered with jitter to avoid I2C bus collisions. Each job includes database safety mechanisms and runs within atomic transactions. Sensor reads execute in separate threads with timeouts to prevent scheduler blocking, and cached sensor connections are automatically re-created on failure.
Dashboard
The main dashboard displays environmental metrics in colour-coded threshold cards. BME280 data appears as three individual cards for temperature, humidity, and pressure. Air quality is shown in dual-comparison cards contrasting PMS5003 vs PMS7003 readings for PM1.0, PM2.5, and PM10. Below the real-time values, the dashboard presents daily, weekly, and monthly PM averages. Every card is colour-coded from green (good) through yellow, orange, red, to purple (hazardous) based on EPA-aligned threshold ranges.
Thresholds and Alerts
Comprehensive threshold ranges are defined for all metrics. Temperature uses a blue-to-red scale (cold below 16C, comfortable 20-24C, hot above 28C). Humidity is green at 30-60%, concerning above 80%. PM2.5 follows EPA ranges: good (0-12), moderate (12.1-35.4), unhealthy for sensitive groups (35.5-55.4), unhealthy (55.5-150.4), and hazardous (150.5+). CO2 thresholds range from good (0-600 ppm) to hazardous (1500+ ppm). AQI follows the UBA 1-5 scale. Even subjective feelings have thresholds, enabling visual correlation between wellbeing and air quality.
Medication Tracking
A full pharmacy-grade inventory system is integrated alongside environmental monitoring. Users can manage medications with name, brand, route of administration (oral, topical, inhalation, etc.), form (tablet, capsule, liquid, etc.), strength, and free-text tags. Each medication can have multiple tracked ingredients. The package inventory system tracks lot numbers, expiry dates, total and remaining units, acquisition cost, and reorder thresholds with low-stock alerts. Medication intakes are linked to wellbeing entries, enabling correlation between medications taken and subjective health feelings on a 1-10 scale.
Frontend
The Nuxt 3 frontend (SSR disabled, SPA mode) has 14 pages including the main dashboard, feeling/wellbeing history log, full medication CRUD management with inventory, individual sensor log pages for each of the five sensors, a combined log view, and about/contact pages. Eight components handle threshold display cards, dual-sensor comparisons, and modal forms for medications, packages, and wellbeing entries. Seven composables manage dashboard metrics, threshold resolution, feeling emoji mapping, medication/intake/wellbeing CRUD, and inventory calculations.
Deployment
Two deployment modes are supported. Docker Compose orchestrates the database, Django backend, APScheduler process, and the Nuxt frontend as containerised services, with the backend container configured for direct hardware access to the sensor buses. Alternatively, systemd services can run natively on Raspberry Pi OS. The system is accessible over a private VPN network.