Intermediateesp32

IoT Air Quality Monitor

Build a comprehensive indoor air quality monitor measuring CO2, PM2.5, temperature, and humidity.

4-5 hours
$35-55
Marcus Johnson
IoT Air Quality Monitor

Parts List

  • ESP32 DevKit
  • SCD30 CO2 Sensor
  • PMS5003 PM2.5 Sensor
  • BME280 Environmental Sensor
  • OLED Display

Step-by-Step Instructions

1

Wire Sensors

Connect the SCD30 CO2 sensor to the ESP32 via I2C with SDA on GPIO 21 and SCL on GPIO 22, powering it from the 3.3V rail. Wire the PMS5003 PM2.5 sensor to the hardware serial port (TX to GPIO 16, RX to GPIO 17) for UART communication. Add the BME280 environmental sensor to the same I2C bus as the SCD30, assigning it a different address to avoid conflicts.

2

Install Libraries

Open the Arduino IDE Library Manager and install the SparkFun SCD30 library for CO2 readings, the Plantower PMS library for particulate matter, and the Adafruit BME280 library for temperature and humidity. Also install the Adafruit SSD1306 and Adafruit GFX libraries for the OLED display output. Verify all libraries compile together by including them in a blank sketch and uploading to the ESP32.

3

Read Sensor Data

Initialize all three sensors in the setup function and wait for the SCD30 to complete its automatic calibration period of approximately 10 minutes. Read CO2 in parts per million, PM2.5 in micrograms per cubic meter, and temperature/humidity from the BME280 every 5 seconds in the main loop. Map the CO2 levels to air quality categories: below 600ppm is excellent, 600-1000ppm is good, and above 1000ppm is poor.

4

Send to Cloud

Create a ThingSpeak account and obtain your API key and channel number for data logging. Add WiFi connection code using the WiFiMulti library to connect to your home network, then POST the sensor readings as numeric fields to the ThingSpeak API endpoint. Configure ThingSpeak MATLAB visualizations to create real-time charts and analytics dashboards that you can access from any device.