This project is WiFi-enabled real-time environmental monitoring system built on ESP32 WROOM 32D microcontroller. It captures and displays key atmospheric parameters such as temperatureπ‘οΈ, humidityπ§, PM2.5 dust densityπ«οΈ, dust levelsπ¨, air PPM levelsπ and air quality index(AQI)
- π‘ WiFi Based Server: ESP32 hosts a dynamic webpage accessible to any device on the same network acting as a webserver
- π‘οΈ Temperature monitoring: Captures accurate ambient temperature using digital temperature sensor
- π§ Humidity Monitoring: uses humidity sensor for relative humidity data
- π«οΈ PM2.5 Air Quality Measurement: Uses dust density sensor to estimate PM2.5 levels
- π¨ Dust Level: Based on PM2.5 level, it classifies the value into dust density levels
- π Air PPM Levels: Uses air quality/gas detector sensor to estimate PPM levels
β οΈ AQI Level: Based on PPM level, it categorizes the value into Air Quality Index- π Live Clock with NTP: Fetches real time date and time using NTP(Network Time Protocol)
- πΊ OLED Display Output: Display the readings on a OLED screen
- π Timed sensor Updates: Reads and updates sensor values after every 60 seconds
- π Responsive Web Dashboard: Presents clean and styled HTML output of live data
| π§© Component | π Description | π¦ Model/Type |
|---|---|---|
| π§ Microcontroller | Main controller of the system - with WiFi & Bluetooth | ESP32 WROOM 32D IoT development board |
| π§ Secondary Microcontroller | Main controller - To calibrate air quality/dust detector sensor | Arduino UNO Rev3 development board |
| π‘οΈ Temperature Sensor | To measure ambient temperature | Dallas Semiconductors DS18B20 Digital Temperature Sensor (Breakout Board) |
| π§ Humidity Sensor | To measure ambient humidity | DHT11 Sensor (Breakout Board) |
| π«οΈ Dust Sensor | To measure suspended 2.5um particulate matter in air | PM2.5 GP2Y1010AU0F Dust Smoke Particle Sensor |
| π«οΈ Air Quality/Gas Detection Sensor | To measure air quality & Parts Per Million in Air | MQ-135 Air Quality/Gas Detection Sensor (Breakout Board) |
| πΊ Display Screen | To display sensor readings locally | SSD1306 driver based 0.96" 7Pin 128x64 monochromatic(Blue) SPI/I2C OLED display (Breakout Board) |
| 150Ξ© resistor + 220Β΅F Capacitor | Resistor to limit current in IR LED, Capacitor for signal smoothening | For PM2.5 GP2Y1010AU0F Dust Smoke Particle Sensor |
| 2x 10kΞ© resistor | Resistors act as voltage divider to protect ESP32 Analog pins from voltage surge from analog pin of the sensor | For MQ-135 Air Quality/Gas Detection Sensor |
| π Electrical Components | Prototyping components | Dupont Jumper wires(M-M, M-F, F-F), Breadboard, Acrylic board |
| π Power Supply | To power the whole system | Laptop USB adapter |
| π οΈ Multimeter | For voltage, current & continuity testing | Kaiweets HT118E 20000 count Digital Multimeter |
| πͺ Soldering Iron | For assembling and soldering components | 25W soldering iron |
| Module | Pin Name | ESP32 GPIO |
|---|---|---|
| OLED Display (SPI) | VCC | 5V |
| GND | GND | |
| MOSI | GPIO 23 | |
| CLK(SCK) | GPIO 18 | |
| DC | GPIO 4 | |
| CS | GPIO 5 | |
| RESET | GPIO 16 | |
| DHT11 Sensor | VCC | 3.3V |
| GND | GND | |
| DATA | GPIO 13 | |
| DS18B20 Sensor | VCC | 3.3V |
| GND | GND | |
| DATA | GPIO 15 | |
| PM2.5 Sensor | V-LED | 5V (**through 150ohm resistor & 220uF capacitor) |
| LED-GND | GND | |
| LED Control | GPIO 25 | |
| S-GND | GND | |
| Vo(Analog Output) | GPIO 34 | |
| VCC | 5V | |
| MQ135 Sensor | VCC | 5V |
| GND | GND | |
| DO | ||
| AO | GPIO 32 (**Voltage Divider with 2x 10 kilo-ohm resistors) |
**Please Note: Make the electrical connections for PM2.5 and MQ135 sensors as shown in pictures in datasheets folder since it includes extra components such as capacitors & resistors
β Setup
- Sets designated esp32 gpio pins as inputs/outputs
- Configures humidity sensor, temperature sensor, MQ135 sensor
- Configures the oled display to default settings
- Connects ESP32 to WiFi with given credentials having a retry logic for 30sec to establish a connection
- Setup ESP32 as a server to listen to requests sent by other devices on the same network
- Configures time to be fetched from NTP server
β Sensor Reading Cycle (every 60 seconds)
- DHT11: Reads Humidity
- DS18B20: Reads temperature with retry logic to avoid invalid readings
- PM2.5 (GP2Y1010AU0F):
- Activates LED
- Reads analog voltage
- Converts voltage into Β΅g/mΒ³
- Categorizes dust density level
- MQ-135 Sensor:
- Reads analog voltage
- Converts voltage into ppm level
- Categorizes air quality level
π₯οΈ Display Output (OLED)
- Day, Date, Time
- Humidity(%)
- Temperature(Β°C)
- PM2.5 Dust Density (Β΅g/mΒ³)
- Air PPM Level
- AQI Level (e.g., Clean Air, Moderate, Unhealthy, Hazardous)
π Web Server Output
- Styled HTML web page accessible at
http://<ESP32_IP>showing all live sensor readings
π₯οΈ Serial Output Monitor
- Day, Date, Time
- Humidity(%)
- Temperature(Β°C)
- PM2.5 Dust Density (Β΅g/mΒ³)
- PM2.5 Dust Level
- Air PPM Level
- AQI Level (e.g., Clean Air, Moderate, Unhealthy, Hazardous)
- NTP Server:
pool.ntp.org - Timezone: GMT + 5:30(Indian Standard Time)
- Displays synchronized date, time, and day of the week
| PM2.5 Range (Β΅g/mΒ³) | Air Quality Level |
|---|---|
| 0 - 12 | π’ Clean Air |
| 12.1 - 35.4 | π‘ Moderate |
| 35.5 - 55.4 | π Unhealthy for Sensitive Groups |
| 55.5 - 150.4 | π΄ Unhealthy |
| 150.5 - 250.4 | π£ Very Unhealthy |
| 250.5+ | π€ Hazardous |
| Air PPM Level | Air Quality Level |
|---|---|
| 0 - 50.0 | π’ Clean Air |
| 50.1 - 100.0 | π‘ Moderate |
| 100.1 - 150.0 | π Unhealthy for Sensitive Groups |
| 150.1 - 200.0 | π΄ Unhealthy |
| 200.1 - 300.0 | π£ Very Unhealthy |
| 300.1+ | π€ Hazardous |
MQ135 air quality/dust detector sensor requires an initial burn-in time of 24-48hrs(brand new sensor). For that purpose, please connect the following mentioned pins of the sensor to arduino UNO, powering UNO through PC and burn in for atleast 24hrs to get stable results.
| Module | Pin Name | Arduino UNO GPIO |
|---|---|---|
| MQ135 Sensor | VCC | 5V |
| GND | GND |
Once preheat is complete, perform calibration through arduino UNO to determine RO value of the sensor:
- Install Arduino IDE and Arduino UNO board support via board manager
- Make the necessary electrical connections(VCC, GND and analog input)
| Module | Pin Name | Arduino GPIO |
|---|---|---|
| MQ135 Sensor | VCC | 5V |
| GND | GND | |
| A0 | A0 (No voltage divider required) |
- Select the correct port and board(Arduino UNO)
- Upload the code from
sensor_calibrationfolder to Arduino UNO - Open Serial Monitor -> Get the RO values displayed
- Open the project code from
srcfolder and make the following changes to RO and RL
void setup_MQ135()
{
delay(10000);
MQ135.setRegressionMethod(1);
MQ135.init();
MQ135.setRL(20); // Look up this value from the datasheet
MQ135.setR0(28.8); // Punch the RO value received from sensor calibration
MQ135.setA(110.47);
MQ135.setB(-2.862);
}- Once finished, proceed with main project execution
- Install Arduino IDE and ESP32 board support via board manager
- Make the necessary electrical connections
- Install required libraries
WiFi.hDHT.hOneWire.hDallasTemperature.hAdaFruit_SSD1306.hAdaFruit_GFX.hMQUnifiedsensor.h
- Configure WiFi credentials in the code:
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";- Select the correct port and board
- Upload the code from
srcfolder to ESP32 - Open Serial Monitor -> Get the ESP32 IP Address -> Open in Browser(ensure you are on same netowrk as ESP32)
ESP32-Environmental-Monitoring/
|--- sensor_calibration/
| |--- mq135_sensor_calibrate.ino
|--- Datasheets/
| |--- ESP32-WROOM-32D_Pinout.png
| |--- DHT11_Pinout.png
| |--- Dust_Sensor_Pinout.png
| |--- OLED_Display_Pinout.png
| |--- ESP32_DevBoard_Pinout.png
| |--- Dust_Sensor_Connection.png
| |--- MQ135_sensor_pinout.png
| |--- MQ135_sensor_voltagedivider.png
| |--- DS18B20_Pinout.png
| |--- DS18B20_Datasheet.pdf
| |--- ESP32_Datasheet.pdf
| |--- PM2.5_Datasheet.pdf
| |--- DHT11_Datasheet.pdf
| |--- MQ135_datasheet.pdf
|--- images/
| |--- OLED_Display.jpeg
| |--- SerialOutput1.png
| |--- Setup1.jpeg
| |--- Setup2.jpeg
| |--- WebInterface.jpeg
|--- src/
| |--- environmental_monitoring_system.ino
|--- LICENSE
|--- README.md
- Battery powered deployment
- Mobile notification for threshold breach
- Data logging on a server like Raspberry Pi/PC for storage and data analysis
- Integration with IoT cloud based dashboards like Blynk, ThingsBoard, Home Assistant
- Accessing ESP32 webserver from around the world(outside home/local network)
- Inspired by practical environmental IoT monitoring solutions - targeted for deployment in a household setup
- Thanks to extensive libraries by Adafruit, Dallas Semiconductors
This project is open souce under MIT License
π§βπ» Anmol Singh
π Pune, India




