Indoor air quality (IAQ) and local environmental conditions (CO₂, PM, VOCs, temperature, humidity, UV, light) strongly affect comfort, productivity and health. Many consumer devices report only one metric (CO₂ or PM), giving an incomplete picture. People need an easy-to-understand, actionable device that senses multiple environmental signals, fuses them with TinyML, and gives simple, practical advice (e.g., “Open a window”, “Turn on purifier”, “Avoid sunlight”).
Goal: build a compact, edge-first device that fuses multi-sensor data, classifies environment state (healthy / stale / polluted / chemical / hot / dry / etc.), and gives clear suggestions — no cloud required.
As this device can connect with WiFi, you can directly fetch all the outdoor weather data for further analytics.
Why we are building this
- Holistic awareness: combine multiple sensors to avoid false alarms (e.g., PM spike vs VOC spike).
- Edge privacy & latency: run ML locally (TinyML) so decisions are immediate and private.
- Actionable guidance: translate sensor values into simple, helpful recommendations for non-expert users.
Features
- Continuous sensing of: CO₂, temperature, humidity, pressure, VOC index, PM1/2.5/10, lux, UV (UVI), battery & SOC.
- Robust binary UART transport from STM32 (sensor hub) → ESP32 (inference/UI).
- TinyML model (Edge Impulse) performing multi-class environment classification from fused features.
- Real-time recommendations printed on-screen.
- Fetch weather data over WiFi.
Components used (Hardware)
- MCU (sensor hub): STM32G4 (reads sensors, packages data, transmits via UART)
- Edge device (inference + UI): ESP32-C6 (receives packets, runs Edge Impulse model, displays suggestions)
- Sensors:
- SCD4x (SCD40/SCD41) — CO₂, temperature, humidity (I²C)
- BME688 — pressure, raw gas resistance / VOC index (I²C)
- PMS7003T — particulate matter (PM1/2.5/10) (UART)
- BH1750 — ambient light (lux) (I²C)
- LTR-390 — UV index (I²C)
- Power: Li-ion battery + MAX17048 fuel gauge (I²C) or USB power
- Display : 2.8inch LCD with Touch panel driven by ESP32 (LVGL)
Components (Software & Cloud)
- Edge Impulse Studio — dataset, model design, training, and code export
- Edge Impulse Arduino runtime (exported library) — inference on ESP32
- STM32Cube HAL drivers for sensors (I²C, UART)
- ESP32 Arduino environment
- LVGL Library
PCB Design
We have designed a custom PCB using ESP32-C6 and STM32G4.

.png)
3D File

.png)
Full Assembled PCBs
.jpeg)
.jpeg)
System Architecture & Data flow
- Sensing (STM32 sensor hub)
- Poll sensors and compute derived values.
- Package as packed binary frame:
AA 55 [payload fields...] CRCand transmit over UART.
- Transport (UART)
- Binary framed packet with header + payload + CRC (CRC8) to ensure integrity.
- Inference & UI (ESP32)
- ESP32 reads and re-synchronizes on header, validates CRC, unpacks fields.
- Build feature array in the exact order used for training:
Co2, Temp, Hum, Pressure, Lux, UVI, VOC, PM1.0, PM2.5, PM10 - Call
run_classifier()(Edge Impulse exported library) and interpretei_impulse_result_t. - Display suggestion text on screen.
Data & ML pipeline (Edge Impulse)
- Define classes for demo (e.g.,
GOOD_AIR,POLLUTED) - Collect CSV logs from ESP32 (Serial) at 1 Hz, with columns matching features + label. Use short labeled sessions (60–120 samples per class).
- Upload CSV to Edge Impulse → create an Impulse (flattened features) → train a small dense NN (32/16/8 + softmax).
- Test & validate (confusion matrix, accuracy). If insufficient, add more labeled samples or more discriminative features.
- Export Arduino Library from Edge Impulse and import into ESP32 project.
- Deploy inference on ESP32 and test in real-world scenarios.
Dataset Preparation
We are transferring all the sensor data to esp32-c6 over UART. Then formatting data in csv format. Take the sensor data in well vantilated room and label it as GOOD AIR, and then other set will be Polluted air label. As shown below:

Edge Impulse Studio Setup
Create account on EI Studio and create a project, Go to dashboard.

2. Now, we need to upload all the csv files using csv wizard.



3. Make sure you have enough train and test data shown on the window, approx 80/20%.

4. Create Impulse, Add Flatten and Classification as shown below. And Train the dataset.


5. For proper model output, make sure the accuracy is more than 90%.

6. Select deployment as Arduino Library, build the model and the library will automatically downloaded on your system.


Arduino IDE & Library Setup
- Install the Edge Impulse library in Arduino IDE from Sketch -> Include .zip file.
- Make sure you have installed esp32 board files.
- Also , install LVGL library version 8.3.10 and TFT_eSPI version 2.5.34

You can check the full ESP32-C6 code on Github.
To Program STM32G4 MCU, install STM32Cube IDE and CubeMx, code for this MCU is also available on the same Github Link.

SquareLine Studio
We have used Squareline Studio to design screens for the touch display. It supports LVGL library which is easy to port in ESP32 code. We have designed Welcome , Indoor and Outdoor Screen.

Working
The system is designed as a smart multi-sensor environmental monitoring and recommendation device, combining embedded sensing, wireless communication, TinyML, and an interactive display interface. The operation happens in the following sequential stages:

1. Sensor Interfacing on STM32G4 (Data Acquisition Layer)
All environmental sensors are physically connected to the STM32G4 microcontroller, including:
- SCD40 → CO₂, Temperature, Humidity
- BME688 → Gas Index (VOC), Temperature, Humidity, Pressure
- PMS7003 → PM1.0, PM2.5, PM10
- BH1750 → Ambient Light (Lux)
- LTR390 → UV Index + UV Raw
The STM32G4 is chosen for its analog precision, fast sampling rate, and deterministic real-time processing.
2. On-board Data Filtering and Preprocessing (STM32G4)
Before sending anything to ESP32, the STM32 performs:
- Noise filtering (moving average, low-pass smoothing)
- Range validation (removing sensor glitches)
- Consistency checks (e.g., removing outliers from PM/VOC data)
- Unit conversion (Pa → hPa, Lux scaling, VOC index normalization)
- Packet structuring using a fixed-size C struct
- CRC checksum for reliable UART transmission
This ensures only clean, stable, high-quality data reaches the ESP32.
3. Compact CSV/Packet Transfer Over UART (STM32 → ESP32)
Once filtered, the STM32 converts all sensor values into a single CSV-style string or packed binary structure, and sends it to ESP32 via UART1.
Example packet:
CO2,Temp,Hum,Pressure,Lux,UVI,VOC,PM1,PM2.5,PM10
This separation keeps STM32 dedicated to real-time sensing while ESP32 handles connectivity and intelligence.
4. ESP32 Handles High-Level Features
A. WiFi Connectivity
- Automatically connects to WiFi
- Shows connection popup on-screen
- Syncs NTP time
- Fetches outdoor weather and AQI
- Handles API requests and JSON parsing
B. LVGL Graphical Interface
- ESP32 manages all display rendering
- Indoor screen, Outdoor screen, Alerts, Popups
- Smooth screen transitions (welcome → indoor → outdoor)
- Warning popups
C. Outdoor Weather & AQI Fetching
ESP32 fetches:
- City, Country (via IP Geolocation)
- Outdoor temperature, humidity, wind, rain
- AQI and pollution category
- Date & Time via NTP
All displayed on the Outdoor Screen.
D. Running the Edge Impulse TinyML Model
ESP32 runs a TinyML classifier (Edge Impulse model) that uses the sensor data:
Inputs
CO₂, Temp, Humidity, Pressure, Lux, UV, VOC Index, PM1/PM2.5/PM10
Output
- “Good Air”
- “Polluted Air”
The decision is displayed instantly.
Conclusion
Traditional air quality monitors typically measure only one or two parameters, such as PM2.5 or CO₂, and merely display raw numbers to the user—without interpreting what those numbers actually mean or offering actionable guidance.
This project goes far beyond traditional monitoring in multiple ways:
1. Multi-Sensor Fusion (10+ Environmental Metrics)
Traditional monitors = limited sensors
This device = integrates CO₂, PM1/PM2.5/PM10, VOC, Temp, Humidity, Pressure, Lux, UV
This gives a complete 360° understanding of the environment.
2. On-Device Intelligence (TinyML at the Edge)
Unlike traditional devices that only display values, this device:
- Learns environmental patterns
- Understands combined pollution sources
- Classifies air quality into Good vs Polluted
- Provides real-time recommendations
Everything happens locally on ESP32, without cloud.
3. Real-Time User Suggestions (Actionable Insights)
This device gives clear actions:
- “Turn ON air purifier”
- “Increase ventilation”
- “Avoid spray products”
- “Open windows for fresh air”
It transforms data → decisions.
4. Cloud-Independent and Low Latency
Traditional IoT monitors rely heavily on:
- Mobile Apps
- Cloud dashboards
- Internet connectivity
But this device:
- Works even offline
- Shows live data on device
- Zero cloud cost
- Instant response (<100 ms)
5. Outdoor + Indoor Context Awareness
Most monitors measure only indoor values.
This device fetches:
- Outdoor AQI
- Outdoor temperature
- Weather changes
And compares them with indoor readings for smart decisions, like:
- “Outdoor pollution high — keep windows closed”
- “Outdoor air clean — open windows now”
6. Beautiful Interactive User Interface (LVGL)
Modern UI:
- Screen navigation
- Animated transitions
- Popups for alerts
- Weather screen
- Clear icons & colors
Much better than simple LED or 7-segment screens.
8. Customizable & Extensible
Because the system is open and programmable:
- Add more sensors
- Add BLE / GPS
- Add predictions for asthma risk, mold growth, or pollen
- Update firmware with OTA
Traditional devices are closed systems.
This device is not just a monitor — it is an intelligent environmental assistant.
It senses, learns, understands, and guides the user with meaningful suggestions to improve health and indoor living quality.
By combining STM32-based sensor fusion, ESP32-based TinyML processing, LVGL visual interface, and live internet data, it offers capabilities far beyond any standard air quality monitor.