An Autonomous Institution Affiliated to Visvesvaraya Technological University, Belagavi Approved by
UGC/AICTE/Govt of Karnataka, accredited by NAAC - A+ Grade, Programs Accredited by NBA (Tier-1)
DEPARTMENT OF MECHANICAL ENGINEERING
Submitted in partial fulfillment of [Link] Degree
“ROBOTICS AND ARTIFICIAL INTELLIGENCE”
LA Report
On
AIR QUALITY MONITORING SYSTEM
SUBMITTED BY
STUDENT NAME SEMESTER USN
DEV VRAT TRIPATHI 2st 1NT23RAI02
GURU LAKSHMISHA 2st 1NT23RAI04
KALAIGAR ABDUL MUQEET 2st 1NT23RAI06
SUJITH KUMAR P H 2st 1NT23RAI12
Under the guidance of
Dr. VASANTH KUMAR
Department of Computer Science
NMIT, Bangalore
Date: 13th Sep 2024
ABSTRACT
Continuous and real-time monitoring is necessary to alleviate the deleterious impacts of air
pollution, since it constitutes a substantial danger to both human health and the environment. In
this project, an Internet of Things (IoT)-based air pollution monitoring system including an ESP32,
DHT11, MQ-135 Gas Sensor, and PMS5003 PM 2.5 sensor is developed. The device gathers
information on gas concentrations, temperature, humidity, and particulate matter (PM 2.5) levels—
all of which are important markers of air quality. Real-time visualization is made possible with the
Blynk mobile app, and the data is sent to the ThingSpeak cloud platform for analysis and storage.
With current monitoring and historical data insights, this device offers an affordable way to
monitor air quality. Future improvements can involve adding more sensors and utilizing machine
learning algorithms to do predictive analysis. The research offers a scalable method for real-time
air pollution assessment and showcases the potential of IoT in environmental monitoring.
Air Quality Monitoring System 2023-2024
TABLE OF CONTENTS
Chapter no. Descriptions Page No.
1. Introduction 1
2. Components and Specifications 2-6
2.1 ESP32 Micro-controller 2
2.2 MQ-135 Gas Sensor 3
2.3 DHT11 Sensor 4
2.4 PM 2.5 4
2.5 LCD Display 5
2.6 Thing Speak 6
3. System Design and Working 7-8
4. Set-up and Output 9
5. Code Implementation 10-14
6. Real-Time Visualization 15
7. Conclusion 16
8. References 17
Department of Mechanical Engineering, NMIT
Air Quality Monitoring System 2023-2024
LIST OF FIGURES
Figure No. Content Page no.
2.1 ESP 32 Module 2
2.2 MQ-135 sensor 3
2.3 DHT11 sensor 4
2.4 PM 2.5 sensor 5
2.5 LCD Display 5
2.6 Working of thingspeak 6
3.1 System Architecture 7
4 Figure 4 (a) , (b) , ( c), (d) are the working of the setup 9
and with Output where (a) is of O/p, rest all are
working of the setup
6.1 Serial monitor with the data sent to Blynk cloud 15
6.2 Alert Mail sent to Email Id 15
Department of Mechanical Engineering, NMIT
Air Quality Monitoring System 2023-2024
CHAPTER 1
INTRODUCTION
Continued exposure to environments with poor air quality is a major public health concern in
developed and developing countries. It is estimated that the pollutants responsible for poor air
quality cause nearly 2.5 million premature deaths per year world-wide. Significantly, around
1.5 million of these deaths are due to polluted indoor air, and it is suggested that poor indoor
air quality may pose a significant health risk to more than half of the world’s population. Due
to its link with industrialization, societal health problems associated with poor air quality
disproportionately affects developed and developing nations – it is estimated that air pollution
is responsible for the premature deaths. Remedial action to improve air quality is often easy
to implement once airborne pollutants have been detected.
This paper focuses on the design and implementation of an IoT based Air Quality Index
Monitoring System that we have intended to develop using ESP 32 microcontroller. The
setup is going to show the air quality in PPM, temperature, and humidity with the help of
various sensors and further, it would be displayed on the IoT Platform, ThingSpeak. The
dashboard of the platform is to be set to public so that everyone and anyone can keep a track
of the quality of air at the location where the system would be installed. In this way, we can
monitor it very easily by using our computer or mobile. The motivation behind our project is
to protect our environment by curbing the release of harmful gases emitted by industries,
vehicles, etc. We get to know about the quality of air on a real-time basis and hence
necessary precautions can be taken immediately whenever needed.
This report outlines the development of an air pollution monitoring system using ESP32,
DHT11, Gas Sensor, and PM 2.5 sensor, with data being sent to ThingSpeak and the Blynk
app.
Department of Mechanical Engineering, NMIT 1
Air Quality Monitoring System 2023-2024
CHAPTER 2
COMPONENTS AND SPECIFICATIONS
2.1 Microcontroller:
The microcontroller we have used in this project is ESP32. ESP32
microcontroller has a powerful chip with a dual processing core. This makes it faster than the
other controllers discussed above. It is a low-cost, lowpower microcontroller and it has an in-
built Wi-Fi module, on-chip Bluetooth Low Energy (BLE), good deep sleep modes. It
supports 18 channels for 12-bit ADC and 2 channels for 8-bit DAC. All the incoming data
from the sensors is processed by ESP32.
Pin Discription
18 Analog-to-Digital Converter (ADC) channels
3 SPI interfaces
3 UART interfaces
2 I2C interfaces
16 PWM output channels
2 Digital-to-Analog Converters (DAC)
2 I2S interfaces
10 Capacitive sensing GPIOs
Figure 2.1 ESP 32 Module
Department of Mechanical Engineering, NMIT 2
Air Quality Monitoring System 2023-2024
2.2 MQ135:
MQ135 is an air quality sensor that detects a wide variety of gases like
Ammonia (NH3), Nitrogen Oxide (NOx), benzene, alcohol, smoke, Carbon
dioxide, etc. For our project, we are measuring Carbon dioxide (CO2) with the
help of this sensor. Its measuring range is from 10-1000 PPM. This sensor gives
output in the form of voltage levels and hence it needs to be converted to PPM.
This can be done by writing appropriate code. Since it gives analog output, it is
connected to the analog pin of ESP32.
Pin Description:
1, the VDD power supply 5V DC
2, GND, used to connect the module to system ground
3, DIGITAL OUT, you can also use this sensor to get digital output from
this pin, by setting a threshold value using the potentiometer
4, ANALOG OUT, this pin outputs 0-5V analog voltage based on
the intensity of the gas
Figure 2.2 MQ-135 sensor
Department of Mechanical Engineering, NMIT 3
Air Quality Monitoring System 2023-2024
2.3 DHT11:
DHT11 is an extremely low power, low cost, ultra-small size digital
temperature, and humidity sensor. It gives digital output. It can measure
temperature from 0-50° C and humidity from 20-90% with an accuracy of ±1°C
and ±1% respectively.
Pin Description:
1, the VDD power supply 3.5~5.5V DC
2 DATA serial data, a single bus
3, NC, empty pin
4, GND, used to connect the module to system ground
Figure 2.3 DHT11 sensor
2.4 P M 2.5 Ssensor
The PMS5003 is a laser-based particulate matter (PM) sensor that is
commonly used in air quality monitoring systems. It measures the concentration
of particles in the air, particularly PM 2.5, which refers to fine particles that are
2.5 micrometers or smaller in diameter. These tiny particles can easily penetrate
the respiratory system and pose serious health risks, especially for the heart and
lungs.
Department of Mechanical Engineering, NMIT 4
Air Quality Monitoring System 2023-2024
Figure 2.4 PM 2.5 sensor
2.5 LCD Display
An LCD is a flat-panel display technology commonly used in many
devices such as computers, TVs, and embedded systems. In the context of
an air pollution monitoring system, an LCD display provides a simple, real-
time way to display data such as temperature, humidity, gas levels, and
particulate matter concentrations.
Figure 2.5 LCD Display
Department of Mechanical Engineering, NMIT 5
Air Quality Monitoring System 2023-2024
2.6 ThingSpeak:
ThingSpeak is an open-source IoT platform where one can combine,
picture, and examine live streams of data in the cloud. Graphs, charts, numeric
values of sensor data can be plotted on ThingSpeak. The sensor data is stored
and resolved over HTTP which works based on a request and response system.
Figure 2.6 Working of thingspeak
Department of Mechanical Engineering, NMIT 6
Air Quality Monitoring System 2023-2024
CHAPTER 3
SYSTEM DESIGN AND WORKING
Power Supply
DHT11
PM 2.5
ESP32
Figure 3.1 System Architecture
MQ 135
Blynk
Fig 4.1 demonstrates the block architecture of our air quality monitoring system. ESP32 is
serving as the main controlling unit in our system. Different environmental parameters like
Carbon Dioxide, Carbon Monoxide, particulate matter, Temperature, and Humidity are being
sensed by the sensors. The sensors are connected to ESP32. ESP32 gathers data sensed by the
sensors and continuously transmits it to the cloud over the internet. The sensor we have used
for detecting particulate matter is, GP2Y1010AU0F. It is a dust sensor module, which means
it can detect cigarette smoke, house dust present around us. Dust might not seem harmful but
in reality, it is small particles of 2.5um and 10um in diameter and these particles can easily
Department of Mechanical Engineering, NMIT 7
Air Quality Monitoring System 2023-2024
penetrate the lungs that can cause various health problems. The measurement of the particles
of diameter 2.5um and 10um is called 2.5PM and 10PM respectively. This sensor can sense
up to 2.5PM. It gives an analog output. Other analog sensors used in our system are MQ7
(Gas sensor) and MQ135 (air quality sensor) and they are used for measuring Carbon
Monoxide and Carbon Dioxide respectively. DHT11 is the sensor that is used for measuring
temperature and humidity sensor and it gives digital output. These sensor data are
continuously sent to an IoT platform for monitoring air quality on a real-time basis. The IoT
platform we have used is ThingSpeak. The sensor data is displayed in the form of graphs and
numeric values on ThingSpeak.
Department of Mechanical Engineering, NMIT 8
Air Quality Monitoring System 2023-2024
CHAPTER 4
SET-UP AND OUTPUT
(b)
(a)
(d)
(c)
Figure 4 (a) , (b) , ( c), (d) are the working of the setup and with Output where (a) is of O/p, rest all are
working of the setup
Department of Mechanical Engineering, NMIT 9
Air Quality Monitoring System 2023-2024
CHAPTER 5
CODE IMPLEMENTATION
#define BLYNK_TEMPLATE_ID "TMPL30WzUBh_B"
#define BLYNK_TEMPLATE_NAME "Air Quality Monitoring"
#define BLYNK_AUTH_TOKEN "qIJC9Kyag8-hBchahxWNzK0JAS0kJHf_"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "MQ135.h"
// ThingSpeak details
String apiKey = "G0XNASJAU42SJH2Q"; // Enter your Write API key from ThingSpeak
const char *ssid = "Zoro"; // replace with your WiFi SSID
const char *pass = "Qwerty12345"; // replace with your WiFi
password const char *server = "[Link]";
// Sensor Pins
#define MEASURE_PIN 34 // Connect dust sensor to ESP32 GPIO 34
#define LED_POWER 4 // Connect dust sensor LED driver pin to ESP32 GPIO 4
#define DHTPIN 2 // Connect DHT11 data pin to ESP32 GPIO 2
#define GAS_SENSOR_PIN 32 // Connect MQ135 gas sensor to ESP32 GPIO 32
// Sensor Timing
int samplingTime = 280; // Time required to sample signal from the dust sensor
int deltaTime = 40;
int sleepTime = 9680;
// Dust sensor variables
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
// DHT11 sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN,
DHTTYPE);
// LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);
byte degree_symbol[8] = {
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
Department of Mechanical Engineering, NMIT 10
Air Quality Monitoring System 2023-2024
0b00000,
0b00000,
0b00000
};
char auth[] = BLYNK_AUTH_TOKEN;
BlynkTimer timer;
WiFiClient client;
void sendToThingSpeak(float temperature, float humidity, int airQuality, float dustDensity) {
if ([Link](server, 80)) {
String postStr = apiKey;
postStr += "&field1=";
postStr += String(temperature);
postStr += "&field2=";
postStr += String(humidity);
postStr += "&field3=";
postStr += String(airQuality);
postStr += "&field4=";
postStr += String(dustDensity);
postStr += "\r\n\r\n";
[Link]("POST /update HTTP/1.1\n");
[Link]("Host: [Link]\
n"); [Link]("Connection: close\n");
[Link]("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
[Link]("Content-Type: application/x-www-form-urlencoded\n");
[Link]("Content-Length: ");
[Link]([Link]());
[Link]("\n\n");
[Link](postStr);
[Link]("Temperature: ");
[Link](temperature);
[Link](" °C, Humidity: ");
[Link](humidity);
[Link](" %, Air Quality: ");
[Link](airQuality);
[Link](" PPM, Dust Density: ");
[Link](dustDensity);
[Link](" µg/m³");
}
[Link]();
}
void sendSensor() {
float h = [Link]();
float t = [Link]();
int airQuality = analogRead(GAS_SENSOR_PIN);
Department of Mechanical Engineering, NMIT 11
Air Quality Monitoring System 2023-2024
// Dust sensor reading
digitalWrite(LED_POWER, LOW); // Power on the LED
delayMicroseconds(samplingTime);
voMeasured = analogRead(MEASURE_PIN); // Read the dust value
delayMicroseconds(deltaTime);
digitalWrite(LED_POWER, HIGH); // Turn the LED off
delayMicroseconds(sleepTime);
calcVoltage = voMeasured * (3.3 / 4095.0); // Recover voltage
dustDensity = 170 * calcVoltage - 0.1; // Calculate dust density
[Link](V2, airQuality);
[Link](V0, t);
[Link](V1, h);
[Link](V3, dustDensity); // Send dust density to Blynk
[Link]("Gas Value: ");
[Link](airQuality);
[Link]("Temperature: ");
[Link](t);
[Link](" °C, Humidity: ");
[Link](h);
[Link](" %, Dust Density: ");
[Link](dustDensity);
// Send data to ThingSpeak
sendToThingSpeak(t, h, airQuality, dustDensity);
// Check for alerts
if (t > 31 || h > 95 || airQuality > 600 || dustDensity > 590) {
[Link]("pollution_alert", "Alert! Bad Air Quality or High Temperature/Humidity
or High Dust Density.");
}
}
void setup() {
[Link](115200);
[Link](auth, ssid, pass);
[Link]();
[Link](2000L, sendSensor);
[Link]();
[Link](1, degree_symbol);
[Link](3, 0);
[Link]("Air Quality");
[Link](3, 1);
[Link]("Monitoring");
delay(1000);
Department of Mechanical Engineering, NMIT 12
Air Quality Monitoring System 2023-2024
[Link]();
[Link]("Connecting to WiFi...");
[Link](ssid, pass);
while ([Link]() != WL_CONNECTED) {
delay(500);
[Link](".");
}
[Link]("");
[Link]("WiFi connected");
}
void loop() {
[Link]();
[Link]();
float h = [Link]();
float t = [Link]();
int airQuality = analogRead(GAS_SENSOR_PIN);
// Dust sensor reading
digitalWrite(LED_POWER, LOW);
delayMicroseconds(samplingTime);
voMeasured = analogRead(MEASURE_PIN);
delayMicroseconds(deltaTime);
digitalWrite(LED_POWER, HIGH);
delayMicroseconds(sleepTime);
calcVoltage = voMeasured * (3.3 / 4095.0);
dustDensity = 170 * calcVoltage - 0.1;
// Display temperature and humidity
[Link](0, 0);
[Link]("Temperature ");
[Link](0, 1);
[Link](t);
[Link](1);
[Link](7, 1);
[Link]("C");
delay(1000);
[Link]();
[Link](0, 0);
[Link]("Humidity ");
[Link](h);
[Link]("%");
delay(1000);
[Link]();
// Display gas value
Department of Mechanical Engineering, NMIT 13
Air Quality Monitoring System 2023-2024
if (airQuality < 600)
{ [Link](0, 0);
[Link]("Gas Value: ");
[Link](airQuality);
[Link](0, 1);
[Link]("Fresh Air");
[Link]("Fresh Air");
} else
{ [Link](0,
0);
[Link]("Gas Value: ");
[Link](airQuality);
[Link](0, 1);
[Link]("Bad Air");
[Link]("Bad Air");
}
delay(1000);
[Link]();
// Display dust density
[Link](0, 0);
[Link]("Dust Density: ");
[Link](0, 1);
[Link](dustDensity);
[Link](" µg/m³");
delay(1000);
[Link]();
// Check for alerts
if (airQuality > 600 || t > 31 || h > 95 || dustDensity > 590) {
[Link]("pollution_alert", "Alert! Bad Air Quality or High Temperature/Humidity
or High Dust Density.");
}
}
Department of Mechanical Engineering, NMIT 14
Air Quality Monitoring System 2023-2024
CHAPTER 6
REAL-TIME VISUALIZATION
Figure 6.1 Serial monitor with the data sent to Blynk cloud
Figure 6.2 Alert Mail sent to Email Id
Department of Mechanical Engineering, NMIT 15
Air Quality Monitoring System 2023-2024
CHAPTER 7
CONCLUSION
The air pollution monitoring system developed in this project effectively collects and
analyzes real-time environmental data, including temperature, humidity, gas concentrations,
and PM 2.5 levels. Utilizing the ESP32 microcontroller and sensors, the system transmits
data to ThingSpeak for cloud storage and analysis while offering live visualization through
the Blynk app. This cost-effective solution demonstrates the potential of IoT in addressing air
quality challenges. Future improvements could include integrating additional sensors and
leveraging machine learning for predictive analysis. Overall, the system provides a scalable
platform for continuous air quality monitoring and environmental management.
Leveraging the concept of IoT, the air around the installed system can be monitored by
anyone and from anywhere using a phone or a computer. The continuous updating of data
enables the users to take timely actions immediately whenever needed. This helps in curbing
air pollution in the environment around us which is a big concern. Apart from being low in
cost and power consumption, it covers less space and can be installed anywhere.
Department of Mechanical Engineering, NMIT 16
Air Quality Monitoring System 2023-2024
REFERENCES
[1] Kennedy Okokpujie, Etinosa Noma-Osaghae, Odusami Modupe, Samuel John and Oluga
Oluwatosin, A Smart Air Pollution Monitoring System, International Journal of Civil
Engineering and Technology, 9(9), 2018, pp. 799–809.
[2] Rawal R. Air Quality Monitoring System. International Journal of Computational Science
and Engineering. 2019;9(1):1-9.
[3] Ali, Hassan & Soe, J. & Weller, Steven. (2015). A real-time ambient air quality
monitoring wireless sensor network for schools in smart cities. 1-6.
10.1109/ISC2.2015.7366163.
[4] Kumar S, Jasuja A. Air quality monitoring system based on IoT using Raspberry Pi.
In2017 International Conference on Computing, Communication and Automation (ICCCA)
2017 May 5 (pp. 1341-1346). IEEE.
[5] Gupta, Harsh & Bhardwaj, Dhananjay & Agrawal, Himanshu & Tikkiwal, Vinay &
Kumar, Arun. (2019). An IoT Based Air Pollution Monitoring System for Smart Cities. 173-
177. 10.1109/ICSETS.2019.8744949.
[6] Kumar A, Kumari M, Gupta H. Design and Analysis of IoT based Air Quality Monitoring
System. In2020 International Conference on Power Electronics & IoT Applications in
Renewable Energy and its Control (PARC) 2020 Feb 28 (pp. 242-245). IEEE.
[7] Asra Noorain F, Raju J, Varsha V, Nanditha HG. An IoT Based Approach To Minimize
And Monitor Air Pollution Using ESP32 and Blynk Platform.
[8] Jayaratne R, Liu X, Ahn KH, Asumadu-Sakyi A, Fisher G, Gao J, Mabon A, Mazaheri M,
Mullins B, Nyaku M, Ristovski Z. Low-cost PM2. 5 sensors: An assessment of their
suitability for various applications. Aerosol and Air Quality Research. 2020;20(3):520-32.
Department of Mechanical Engineering, NMIT 17