The problem
This TinyML-Based Air Quality Prediction system using ESP32-S3 and Sensor Fusion is a compact indoor and campus air monitor that predicts the next hour's air quality instead of only reporting the present reading. Most low-cost air monitors display a live PM2.5 number and stop there, so a student, warden or lab in-charge learns the air is bad only after it already is. This project closes that gap: an ESP32-S3 reads a PMS5003 particle sensor, an MQ-135 gas sensor and a BME280 temperature-humidity-pressure sensor, fuses the three streams, and runs a quantized TensorFlow Lite Micro model on the chip itself to forecast the next-hour AQI category. The live reading, the prediction and a 24-hour trend appear on a Wi-Fi dashboard with buzzer and LED alerts, and the whole prediction happens on-device, so the forecast keeps working even when the internet drops.
The sensing itself is first-principles physics, not a black box. Inside the PMS5003, a small fan draws air through a laser beam; each particle crossing the beam scatters light, and a photodiode turns those flashes into pulses that are counted and sized — more and larger pulses mean a higher particle mass concentration, which the sensor reports as PM1.0, PM2.5 and PM10 in µg/m³. One builder note from the actual build matters for every reading that follows: the PMS5003 fan needs a settling delay after power-up, because the first readings are unstable while the fan spins up and the chamber purges stale air, so the firmware discards the first readings and only starts logging once the stream is stable. The MQ-135 adds a relative gas index for combustion and gas events that particles alone miss, and it too needs a warm-up period before its baseline settles. The BME280 explains drift the other two cannot: humid air makes optical particle counters read high, so humidity and pressure are fed into the model as correction features rather than displayed as decoration.
| Feature | This build | Cloud-only AQI monitor | Single-sensor monitor |
|---|---|---|---|
| Next-hour AQI forecast | Yes, on-device TinyML | Sometimes, needs internet | No |
| Works without internet | Yes, prediction + OLED keep running | No | Yes, but no forecast |
| Sensors fused | PM + gas + temperature/humidity/pressure | Usually PM only | One sensor only |
| Early warning before a peak | Yes, predicted-AQI alert | Rarely | No |
| Data logging | Yes, CSV log on device | Cloud account required | Usually none |
PMS5003 particle sensor, MQ-135 gas sensor and BME280 environmental sensor on one board.
Follow the working sequence
How it works
End to end, the system moves from air to answer in six stages: sense, fuse, infer, display, alert and log. The PMS5003 fan draws room air through a laser beam, the MQ-135 heater warms its sensing layer, and the BME280 samples the room's temperature, humidity and pressure, all on a fixed schedule set in firmware. The ESP32-S3 time-aligns the three streams, discards the unstable first readings after power-up while the PMS5003 fan settles, and assembles a 60-minute window of fused features. That window feeds a quantized TensorFlow Lite Micro model running on the chip, which outputs the predicted AQI category for the next hour with a confidence value. The live AQI, the prediction, the confidence and the 24-hour trend are served to a Wi-Fi dashboard and a small OLED, a buzzer and LED fire when the current or predicted AQI crosses the Poor threshold, and every reading is appended to a CSV log for the student's own analysis.
- The PMS5003 fan draws air through its laser chamber and reports PM1.0, PM2.5 and PM10 in µg/m³ over UART, while the MQ-135 reports a relative gas index over ADC and the BME280 reports temperature, humidity and pressure over I2C.
- Firmware samples all three sensors on a fixed schedule (approximately every 10 seconds, configurable) and time-aligns the readings into one fused record.
- The first readings after power-up are discarded while the PMS5003 fan settles and the MQ-135 baseline stabilises, so logging starts from a stable baseline.
- A rolling 60-minute window of fused features (particle levels, gas index, humidity, pressure and their trends) is assembled as the model input.
- The quantized TensorFlow Lite Micro model runs on the ESP32-S3 and outputs the predicted AQI category for the next hour with a confidence value (design target: inference in approximately 12 ms).
- The live AQI, prediction, confidence and 24-hour trend are served to the Wi-Fi dashboard and the OLED; a buzzer and red LED fire on current or predicted AQI above 200.
- Every fused reading and every prediction is appended to a timestamped CSV log for analysis, retraining and the project report.
Tech stack:
- ESP32-S3 · Arduino IDE
- TensorFlow Lite Micro (quantized model)
- PMS5003 · MQ-135 · BME280 sensors
- Wi-Fi · HTTP dashboard
- HTML · CSS · JavaScript dashboard
- Python · TensorFlow (training + quantization)
- CSV data logging
Dataset & model details
- Dataset: Student-collected sensor log recorded by this prototype — timestamped PMS5003 (PM1.0/PM2.5/PM10), MQ-135 gas index and BME280 (temperature, humidity, pressure) readings sampled approximately every 10 seconds over multi-day indoor and campus runs; the next-hour AQI category is derived from the logged PM2.5 series using CPCB AQI bands.
- Task: Next-hour AQI-category forecasting; input = 60-minute window of fused sensor features, output = predicted AQI category (Good / Satisfactory / Moderate / Poor / Very Poor / Severe) with a confidence value.
- Model: Quantized 2-layer dense neural network in TensorFlow Lite Micro, trained in Python with TensorFlow and converted to an approximately 18 KB quantized model (design target) for on-device inference on the ESP32-S3.
- Metrics: Next-hour category accuracy, per-category precision/recall and confusion matrix. Development target: approximately 75% next-hour category accuracy — a target for the built-to-order training run, not a measured result; the report documents the actual achieved figure after training on the student's own logged data.
| Parameter | Value |
|---|---|
| Controller | ESP32-S3 development board (dual-core Xtensa LX7, Wi-Fi + Bluetooth) |
| Particle sensor | PMS5003 — particle range 0.3–10 µm, PM2.5 effective range 0–500 µg/m³, resolution 1 µg/m³ (datasheet values) |
| Gas sensor | MQ-135 — relative gas index (NH3, NOx, alcohol, benzene, smoke), analog output, warm-up required |
| Environmental sensor | BME280 — temperature −40 to +85 °C (±0.5 °C at 25 °C), humidity 0–100 %RH (±3 %RH), pressure 300–1100 hPa (±1.0 hPa) (datasheet values) |
| Model | Quantized 2-layer dense network, TensorFlow Lite Micro, approximately 18 KB (design target) |
| Inference time | Approximately 12 ms per prediction on ESP32-S3 (design target) |
| Input window | Last 60 minutes of fused readings (configurable) |
| Forecast horizon | Next 1 hour, AQI category + confidence |
| Display | 0.96-inch OLED + Wi-Fi dashboard with 24-hour trend |
| Alerts | Buzzer + red LED at current or predicted AQI above 200 (CPCB Poor band) |
| Sampling interval | Approximately every 10 seconds (configurable in firmware) |
| Power | 5 V USB supply, approximately 1–2 W expected draw |
| Logging | Timestamped CSV log of fused readings and predictions |
Project features
The build's three strongest capabilities are its on-device next-hour AQI forecast, its three-sensor fusion, and its live dashboard with early-warning alerts. The TinyML model runs entirely on the ESP32-S3, so the prediction is produced locally from the last hour of fused readings with no cloud round-trip and no internet dependency. Fusion is what makes the forecast credible: the PMS5003 supplies particle mass concentration, the MQ-135 adds a gas-event signal that particles alone miss, and the BME280 supplies temperature, humidity and pressure that explain why particle readings drift — humid air, for example, makes optical particle counters read high. Around those three capabilities sit the supporting features: a 24-hour trend chart with the forecast overlaid, an on-device OLED readout, Wi-Fi telemetry with CSV logging, and a buzzer plus LED that warn before the air crosses into the Poor band rather than after.
- [On-device next-hour AQI prediction] A quantized TensorFlow Lite Micro model runs on the ESP32-S3 and predicts the next-hour AQI category from the last 60 minutes of fused sensor history, with a confidence value shown on the dashboard. No cloud call is needed for the forecast.
- [Three-sensor fusion] PMS5003 (PM1.0/PM2.5/PM10), MQ-135 (relative gas index) and BME280 (temperature, humidity, pressure) are time-aligned in firmware, so the model sees particles, gases and the weather conditions that distort particle readings together.
- [Live AQI dashboard] A Wi-Fi dashboard shows the live AQI gauge, PM2.5, PM10, gas index, temperature, humidity and pressure, plus a 24-hour trend chart with the model forecast overlaid as a dashed line.
- [Early-warning alerts] A buzzer and red LED fire when the current AQI or the predicted next-hour AQI crosses the Poor threshold (AQI above 200, CPCB bands), so the warning arrives before the peak, not after it.
- [On-device OLED readout] A 0.96-inch OLED shows temperature, humidity, PM2.5 and live AQI at the node itself, so the system stays readable even when Wi-Fi or the dashboard is unavailable.
- [Fan-settling and warm-up handling] Firmware discards the unstable first PMS5003 readings while the fan settles after power-up and waits for the MQ-135 baseline to stabilise, so logged data starts from a trustworthy baseline.
- [CSV data logging] Every fused reading is appended to a timestamped CSV log, giving the student their own dataset for the report, for retraining experiments and for viva discussion.
What is included
- Working prototype: ESP32-S3 board, PMS5003, MQ-135, BME280, OLED, buzzer and LED on breadboard with wiring
- Complete firmware (sensor drivers, fusion, fan-settling handling, TinyML inference, dashboard server)
- Trained quantized TensorFlow Lite Micro model with training notebook and quantization steps
- Single-file working dashboard demo (live readings, AQI gauge, prediction, 24-hour trend chart)
- CSV logging and the student's own logged dataset template
- Circuit and wiring documentation with component list
- Project abstract PDF, project report, PPT presentation and viva Q&A document
Limitations & prerequisites
- The MQ-135 gives a relative gas index, not calibrated gas concentrations in ppm — it signals gas events but cannot identify a specific gas or its exact concentration.
- The PMS5003 is an optical particle counter: high humidity inflates particle readings, which is why humidity is fused in as a correction feature rather than ignored.
- Forecast skill depends on the training data: a model trained on a few days of indoor logs will not generalise to outdoor or seasonal conditions without retraining on local data.
- The 75% next-hour category accuracy figure is a development target, stated honestly — the report documents the actual achieved figure after training.
- The prototype is an academic build, not a certified air-quality monitoring station, and its readings are not a substitute for reference-grade instruments.
- Wi-Fi range and dashboard access depend on the local network; prediction and OLED display keep working offline, but remote viewing needs connectivity.
Frequently Asked Questions
Is this project suitable for a final-year project?
Yes — for Electronics, E&TC, IoT and AI & Machine Learning programs, because it combines embedded firmware, three-sensor interfacing, sensor fusion and a real on-device TinyML model with a Wi-Fi dashboard in one demonstrable build that a student can explain end to end in a viva. The viva story is strong: why fusion beats a single sensor, how laser-scattering particle counting works, and how the model was trained and quantized for the ESP32-S3.
How does the TinyML model predict air quality?
It is a small quantized neural network trained on the prototype's own logged sensor history, and it takes the last 60 minutes of fused readings — particle levels, gas index, humidity, pressure and their trends — and outputs the most likely AQI category for the next hour with a confidence value. Training happens in Python with TensorFlow; only the quantized model runs on the ESP32-S3.
Does the prediction work without internet?
Yes — the model runs entirely on the ESP32-S3, so the next-hour forecast, the OLED readout and the buzzer and LED alerts all keep working with no internet connection at all, and only the remote dashboard view needs Wi-Fi to view readings remotely. If the network drops, prediction keeps running and readings keep logging to CSV.
Why three sensors instead of just a PM2.5 sensor?
Because one sensor cannot see the whole picture: the PMS5003 measures particles but misses gas events, the MQ-135 catches combustion and gas events the particle sensor cannot see, and the BME280 explains drift — humid air inflates optical particle readings. Fusing all three gives the model the context it needs to forecast rather than just report.
What will I receive with the project?
The working prototype with all three sensors, the complete firmware, the trained quantized model with its training notebook, the working dashboard demo, wiring documentation, the CSV logging setup, and the full documentation kit: abstract PDF, project report, PPT and viva Q&A.
Can this project be customized?
Yes — realistic options include adding a CO2 or formaldehyde sensor, switching the dashboard to MQTT with a cloud backend, adding a mobile alert via Telegram, extending the forecast horizon, or retraining the model on outdoor data collected at the student's own campus.
Components & software requirements
- ESP32-S3 · Arduino IDE
- TensorFlow Lite Micro (quantized model)
- PMS5003 · MQ-135 · BME280 sensors
- Wi-Fi · HTTP dashboard
- HTML · CSS · JavaScript dashboard
- Python · TensorFlow (training + quantization)
- CSV data logging
Dataset & model details
- Dataset: Student-collected sensor log recorded by this prototype — timestamped PMS5003 (PM1.0/PM2.5/PM10), MQ-135 gas index and BME280 (temperature, humidity, pressure) readings sampled approximately every 10 seconds over multi-day indoor and campus runs; the next-hour AQI category is derived from the logged PM2.5 series using CPCB AQI bands.
- Task: Next-hour AQI-category forecasting; input = 60-minute window of fused sensor features, output = predicted AQI category (Good / Satisfactory / Moderate / Poor / Very Poor / Severe) with a confidence value.
- Model: Quantized 2-layer dense neural network in TensorFlow Lite Micro, trained in Python with TensorFlow and converted to an approximately 18 KB quantized model (design target) for on-device inference on the ESP32-S3.
- Metrics: Next-hour category accuracy, per-category precision/recall and confusion matrix. Development target: approximately 75% next-hour category accuracy — a target for the built-to-order training run, not a measured result; the report documents the actual achieved figure after training on the student's own logged data.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.