Contents
Why Monitor Air Quality?
Indoor air can be 2-5x more polluted than outdoor air. Monitoring helps identify issues and improve health.
Key Pollutants:
- PM2.5: Fine particles (<2.5Ξm) from cooking, smoking
- CO2: Ventilation indicator (>1000ppm = poor)
- VOC: Volatile compounds from cleaners, paints
- Formaldehyde: Off-gassing from furniture
Air Quality Sensors
- PMS5003: PM1.0, PM2.5, PM10 (laser scattering)
- SCD30: CO2, temperature, humidity (NDIR)
- SGP30: TVOC, eCO2 (metal oxide)
- BME680: Gas, temp, humidity, pressure
Hardware Setup
ESP32 â PMS5003 (Particle Sensor)
5V â 5V, GND â GND
TX â GPIO17, RX â GPIO16
ESP32 â SCD30 (CO2 Sensor)
3.3V â 3.3V, GND â GND
SDA â GPIO21, SCL â GPIO22
ESP32 â OLED Display
VCC â 3.3V, GND â GND
SDA â GPIO21, SCL â GPIO22
ESP32 Firmware
#include
#include
#include
#include
PMS pms(Serial2);
SCD30 scd30;
void setup() {
Serial2.begin(9600, SERIAL_8N1, 17, 16);
scd30.begin();
scd30.startContinuousMeasurement();
WiFi.begin(ssid, password);
client.setServer(mqtt_server, 1883);
}
void loop() {
// Read PM2.5
pms.read();
float pm25 = pms.readPM2_5();
// Read CO2
if (scd30.dataAvailable()) {
float co2 = scd30.getCO2();
float temp = scd30.getTemperature();
float humidity = scd30.getHumidity();
}
// Publish
publishAirQuality(pm25, co2, temp, humidity);
delay(5000);
}
Dashboard Setup
Air Quality Index (AQI) calculation:
// AQI Categories
Good: PM2.5 0-12, CO2 400-800
Moderate: PM2.5 12-35, CO2 800-1000
Unhealthy (Sensitive): PM2.5 35-55, CO2 1000-1500
Unhealthy: PM2.5 55-150, CO2 1500-2000
Very Unhealthy: PM2.5 150-250, CO2 >2000
Health Guidelines:
- CO2 > 1000ppm: Increase ventilation
- PM2.5 > 35: Run air purifier
- VOC High: Remove source, ventilate
- Humidity 40-60%: Ideal range
Next Steps
- Add formaldehyde sensor
- Integrate with HVAC system
- Create mobile notifications
- Log data for trend analysis
Related: Weather Station | Smart Home Monitoring