0% found this document useful (0 votes)
22 views

Soni Projectfinal

This document is a project report submitted for the degree of Bachelor of Technology in Electrical and Electronics Engineering. It presents the design of an IoT-based air pollution monitoring system. The system is designed to monitor air quality parameters such as temperature, humidity, and concentrations of pollutants like carbon monoxide and particulate matter. It uses sensors like DHT11 and MQ-135 connected to a NodeMCU microcontroller. The sensor readings are sent to the ThingSpeak cloud platform for analysis and monitoring of air quality from a remote location using the internet. The system is expected to help monitor air quality and send alerts when pollution levels exceed certain thresholds.

Uploaded by

raushan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Soni Projectfinal

This document is a project report submitted for the degree of Bachelor of Technology in Electrical and Electronics Engineering. It presents the design of an IoT-based air pollution monitoring system. The system is designed to monitor air quality parameters such as temperature, humidity, and concentrations of pollutants like carbon monoxide and particulate matter. It uses sensors like DHT11 and MQ-135 connected to a NodeMCU microcontroller. The sensor readings are sent to the ThingSpeak cloud platform for analysis and monitoring of air quality from a remote location using the internet. The system is expected to help monitor air quality and send alerts when pollution levels exceed certain thresholds.

Uploaded by

raushan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

IoT-Based Air Pollution Monitoring System

A Project report submitted in partial fulfillment


of the requirements for the degree of B. Tech in Electrical And Electronics Engineering

By

Soni Kumari (21110110908)


Reema Kumari (20110110022)

Under the supervision of

Sanna Praveen
Professor & HOD
Department of Electrical and Electronics Engineering

Department of Electrical Electronics Engineering


Gaya college of engineering, Gaya
Srikrishna Nagar, P.O Nagariyawan , Via, Buniyaadganj Bridge, Khizarsarai, Bihar 823003
© 2024

DEPARTMENT OF EEE, GCE


CERTIFICATE
To whom it may concern
This is to certify that the project work entitled IOT Based Air Pollution Monitoring System
is the bonafide work carried out by Soni Kumari (21110110908), and Reema Kumari
(20110110022), students of B.Tech in the Dept. of Electrical and Electronics Engineering, GCE,
Gaya College of Engineering, Gaya Srikrishna Nagar, P.O Nagariyawan, Via, Buniyaadganj Bridge,
Khizarsarai, Bihar 823003 affiliated to Bihar Engineering University (BEU), Bihar, India, during the
academic year 2023-24, in partial fulfillment of the requirements for the degree of Bachelor of
Technology in Electrical and Electronics Engineering and this project has not submitted previously
for the award of any other degree, diploma, and fellowship.

_____________________________ ____________________________

Signature of the Guide Signature of the HOD, EEE

Name: Name: Sanna Praveen


Designation: Professor, EEE Dept. Designation: Professor & HOD, EEE Dept.

_______________________________

Signature of the External Examiner


Name:
Designation:

ACKNOWLEDGEMENT

It is our great fortune that we have had an opportunity to carry out this project work under
the supervision of Dr. Debasish Mondal in the Department of Electrical Engineering, RCC
Institute of Information Technology (RCCIIT), Canal South Road, Beliaghata, Kolkata-
700015, affiliated to Maulana Abul Kalam Azad University of Technology (MAKAUT),
West Bengal, India. We express our sincere thanks and deepest sense of gratitude to our guide
for his constant support, unparalleled guidance, and limitless encouragement.
We wish to convey our gratitude to Dr. Debasish Mondal, HOD, Department of Electrical
Engineering, RCCIIT, and the authority of RCCIIT for providing all kinds of infrastructural
facilities for the research work.

We would also like to convey our gratitude to all the faculty members and staff of the
Department of Electrical Engineering, RCCIIT for their wholehearted cooperation in making
this work turn into reality.

(Soni Kumari) (Reema Kumari)

Place: Gaya
Date: 25th Feb, 2024

TABLE OF CONTENTS

TOPICS PAGE NO.

List of figures ................................................................................................................................... i

List of acronyms ............................................................................................................................. ii

ABSTRACT ................................................................................................................................... ii

CHAPTER 1: Introduction ................................................................................................... 01-02

1.1 Aim……………………………………………………………………….......................01
DEPARTMENT OF EEE, GCE
1.2 Literature Survey…………………………………………………………………..01-02

CHAPTER 2: Theory & Description of the Components .................................................. 03-10

2.1 What is IoT?...............................................................................................................03-04

2.2 Components Used……………………………………………………………………...05

2.3 Brief Description of the Components……………………………………………...05-10

2.4 Working Procedures ……………………………………………...................................10

CHAPTER 3: Hardware Model .......................................................................................... 11-14

3.1 Hardware Model to Preheat DHT11 Sensor Module………………………………...11

3.2 Hardware Model to Preheat and Calibrate MQ-135 Gas Sensor Module………12-13

3.3 Final Hardware Model…...…………………………………………………………13-14

CHAPTER 4: Algorithm and Software Program ............................................................... 15-21

4.1 Working Algorithm………………………………………………………………….…15

4.2 Calibration of MQ-135 Gas Sensor Module……………………………………….16-19

4.3 Execution of the Main Program…………………………...……………………….19-21

CHAPTER 5: Results ........................................................................................................... 22-28

CHAPTER 6: Conclusion ...........................................................................................................29

REFERENCES .............................................................................................................................30

APPENDIX

A.1 Pin Description of NodeMCU ........................................................................................ 31-32

A.2 Description of Software Libraries Used..............................................................................33

A.3 Cost Estimation .................................................................................................................... 34


DEPARTMENT OF EEE, GCE
List of Figures
Figure No. Figure Title
1 IoT-based air pollution monitoring system
2.1 Pinout Diagram of NodeMCU V3
2.2 Pinout Diagram of DHT11 sensor
2.3 The structure of the humidity sensor
2.4 Mq-135 Gas Sensor Module
2.5 Veroboard
2.6 AC-DC Adapter
2.7 LEDs
2.8 Resistors
2.9 Arduino IDE
2.10 ThingSpeak Cloud
3.1 Circuit Diagram to Pre-heat the DHT11 sensor module
3.2 Circuit Diagram to Pre-heat the MQ-135 gas sensor module
3.3 Circuit Diagram to Calibrate the MQ-135 Gas Sensor Module
3.4 Circuit Diagram of the Setup
5.1 Observations for Experiment 1
5.2 Setup for Experiment 1
5.3 Observations for Experiment 2 5.4
Setup for Experiment 2
5.5 Observations for Experiment 3
5.6 Setup for Experiment 3
5.7 Setup for Experiment 4
5.8 Observations for Experiment 4 5.9
Setup for Experiment 5
5.10 Observations for Experiment 5

i
List of Acronyms
DHT Digital Humidity and Temperature
IoT Internet of Things
PPM Parts Per Molecule
PM Particulate Matter
CO Carbon Monoxide
CO2 Carbon Dioxide
LED Light Emitting Diode
LPG Liquid Petroleum Gas
IDE Integrated Development Environment

ABSTRACT
Air pollution is one of the biggest threats to the present-day environment. Everyone is being
affected by air pollution day by day including humans, animals, crops, cities, forests, and
aquatic ecosystems. Besides that, it should be controlled at a certain level to prevent the
increasing rate of global warming. This project aims to design an IOT-based air pollution

ii
monitoring system using the internet from anywhere using a computer or mobile to monitor
the air quality of the surroundings and environment. There are various methods and
instruments available for the measurement and monitoring quality of air. The IoT-based air
pollution monitoring system would not only help us monitor the air quality but also be able
to send alert signals whenever the air quality deteriorates and goes down beyond a certain
level.

In this system, NodeMCU plays the main controlling role. It has been programmed in a
manner, such that, it senses the sensory signals from the sensors and shows the quality level
via LED indicators. Besides the harmful gases (such as CO2, CO, smoke, etc) temperature
and humidity can be monitored through the temperature and humidity sensor by this system.
Sensor responses are fed to the NodeMCU which displays the monitored data in the
ThingSpeak cloud which can be utilized for analyzing the air quality of that area. The
following simple flow diagram (as shown in Fig. 1) indicates the working mechanism of the
IoT-based Air Pollution Monitoring System.

Fig.1. IoT-based Air Pollution Monitoring System

iii
Chapter1

INTRODUCTION

1.1 Aim of the Project

Air is getting polluted because of the release of toxic gases by industries, vehicle emissions,
and increased concentration of harmful gases and particulate matter in the atmosphere.

The level of pollution is increasing rapidly due to factors like industries, urbanization,
increase in population, and vehicle use which can affect human health. Particulate matter is
one of the most important parameters having a significant contribution to the increase in air
pollution. This creates a need for measurement and analysis of real-time air quality
monitoring so that appropriate decisions can be taken in a timely period.

This paper presents real-time standalone air quality monitoring. The Internet of Things (IoT)is
nowadays finding profound use in every sector and plays a key role in our air quality
monitoring system too. The setup will show the air quality in PPM on the webpage so that
we can monitor it very easily.

In this IoT project, we can monitor the pollution level from anywhere using your computer
or mobile.

1.2 Literature Survey

The explanation of the Air Quality Index (AQI) and its standard ranges are described in [1].
From 0-100 ppm the atmosphere is safe for living. If the ppm level increases above 100 then
it moves out of the safety zone. If the ppm value rises above 200 then it becomes extremely
dangerous for human life.

The DHT11 sensor module is used to measure the temperature and the humidity of the
surroundings [2]. The MQ-135 gas sensor is used to measure the air quality of the
surroundings [3]. It can be calibrated concerning fresh air, alcohol, carbon dioxide, hydrogen,
and methane. In this project, it has been calibrated concerning fresh air [9], [10].
1|Page
In [4] the controlling action of NodeMCU has been described. This research has shown the
uses of C++ as the programming language for scripting the software code. It has an inbuilt
Wi-Fi module which allows the project to implement IoT easily. Arduino IDE is used to
implement the coding part of the project [5], [8]. ThingSpeak cloud is used for the cloud
service. It has a free version which requires a delay of 15 seconds to upload an entry in the
cloud [6], [7]. As this project uses two sensors, both of them have internal heater elements
and withdraws more power(P=V*I), so though both sensors are turned ON, their output
voltage levels vary and show unpredictable values due to insufficient power drive. So, we
used a separate power supply for the sensors as NodeMCU alone is not sufficient to drive two
sensors [9].

Chapter 2
THEORY & DESCRIPTION OF THE COMPONENTS

2.1 What is IoT?


The Internet of Things (IoT) describes the network of physical objects—“things”—that are
embedded with sensors, software, and other technologies to connect and exchange data with
other devices and systems over the Internet. These devices range from ordinary household
objects to sophisticated industrial tools.
The field has evolved due to the convergence of multiple technologies, including ubiquitous
computing, commodity sensors, increasingly powerful embedded systems, and machine
learning.
Traditional fields of embedded systems, wireless sensor networks, control systems, and
automation (including home and building automation), independently and collectively enable
the Internet of Things. In the consumer market, IoT technology is most synonymous with
products about the concept of the "smart home", including devices and appliances (such as
lighting fixtures, thermostats, home security systems, cameras, and other home appliances)
2|Page
that support one or more common ecosystems and can be controlled via devices associated
with that ecosystem, such as smartphones and smart speakers. IoT is also used in healthcare
systems.
There are several concerns about the risks in the growth of IoT technologies and products,
especially in the areas of privacy and security, and consequently, industry and governmental
moves to address these concerns have begun, including the development of international and
local standards, guidelines, and regulatory frameworks.
IoT devices are a part of the larger concept of home automation, which can include lighting,
heating and air conditioning, media and security systems, and camera systems. Long-term
benefits could include energy savings by automatically ensuring lights and electronics are
turned off or by making the residents in the home aware of usage.
A smart toilet seat that measures blood pressure, weight, pulse, and oxygen levels. A smart
home or automated home could be based on a platform or hubs that control smart devices and
appliances. For instance, using Apple's HomeKit, manufacturers can have their home
products and accessories controlled by an application in iOS devices such as the iPhone and
the Apple Watch. This could be a dedicated app or iOS native applications such as Siri. This
can be demonstrated in the case of Lenovo's Smart Home Essentials, which is a line of smart
home devices that are controlled through Apple's Home app or Siri without the need for a Wi-
Fi bridge. There are also dedicated smart home hubs that are offered as standalone platforms
to connect different smart home products and these include the Amazon Echo, Google Home,
Apple's HomePod, and Samsung's SmartThings Hub. In addition to the commercial systems,
there are many non-proprietary, open-source ecosystems; including Home Assistant,
OpenHAB, and Domoticz.
Significant numbers of energy-consuming devices (e.g. lamps, household appliances, motors,
pumps, etc.) already integrate Internet connectivity, which can allow them to communicate
with utilities not only to balance power generation but also to help optimize energy
consumption as a whole. These devices allow for remote control by users, or central
management via a cloud-based interface, and enable functions like scheduling (e.g., remotely
powering on or off heating systems, controlling ovens, changing lighting conditions,
etc.).The smart grid is a utility-side IoT application; systems gather and act on energy and
power-related information to improve the efficiency of the production and distribution of
electricity. Using advanced metering infrastructure (AMI) Internet-connected devices,

3|Page
electric utilities not only collect data from end-users but also manage distribution automation
devices like transformers.
Another example of integrating the IoT is Living Lab which integrates and combines research
and innovation processes, establishing a public-private-people-partnership. There are
currently 320 Living Labs that use the IoT to collaborate and share knowledge between
stakeholders to co-create innovative and technological products. For companies to implement
and develop IoT services for smart cities, they need to have incentives. The governments play
key roles in smart city projects as changes in policies will help cities to implement the IoT
which provides effectiveness, efficiency, and accuracy of the resources that are being used.
For instance, the government provides tax incentives and cheap rent, improves public
transport, and offers an environment where start-up companies, creative industries, and
multinationals may co-create, share a common infrastructure and labor markets, and take
advantage of locally embedded technologies, production processes, and transaction costs.
The relationship between the technology developers and governments who manage the city's
assets is key to providing open access to resources to users in an efficient way.
In this project, we have tried to implement the concept of IoT to monitor the temperature,
humidity, and air quality of the surroundings

2.2 Components Used


Hardware Components
1. NodeMCU V3
2. DHT11 Sensor Module
3. MQ-135 Gas Sensor Module
4. Veroboard(KS100)
5. Breadboard
6. Connecting Wires
7. AC-DC Adapters
8. LEDs emitting green, yellow, and red colors
9. Resistors

SOFTWARE COMPONENTS
1. ThinkSpeak Cloud
2. Arduino IDE

4|Page
2.3 Brief Description of the Components
NodeMCU V3
NodeMCU V3 is an open-source ESP8266 development kit, armed with the CH340G
USBTTL Serial chip. It has firmware that runs on ESP8266 Wi-Fi SoC from Espressif
Systems. Whilst cheaper, CH340 is super reliable even in industrial applications. It is tested
to be stable on all supported platforms as well. It can be simply coded in Arduino IDE. It has
a very low current consumption between 15 µA to 400 mA.
The pinout Diagram of NodeMC3 is shown in Fig. 2.1.

Fig. 2.1 (Pinout Diagram of NodeMCU V3)


DHT11 Sensor Module
The DHT11 is a temperature and humidity sensor that
gives digital output in terms of voltage. It uses a
capacitive humidity sensor and a thermistor to measure
the surrounding air.
As shown in Fig. 2.2, we need to supply a voltage of 5V
(DC) to the Vcc pin and ground it to the GND pin. The
sensor output can be easily read from the Data pin in
terms of voltage (in digital mode).
Fig 2.2 (Pinout Diagram of
Humidity Measurement: The humidity sensing capacitor DHT11sensor)
has two electrodes with a moisture-holding substrate as a
dielectric between them as shown in Fig 2.3. Change in the capacitance value occurs with the
change in humidity levels. The IC measure processes these changed resistance values and
then converts them into digital form.

5|Page
Temperature Measurement: For measuring the temperature, the DHT11 sensor uses a negative
temperature coefficient thermistor, which causes a decrease in its resistance value with an
increase in temperature. To get a wide range of resistance values, the sensor is made up of
semiconductor ceramics or polymers.

Fig 2.3(The structure of the humidity sensor)

MQ-135 Gas Sensor Module


The material of MQ135 is SnO2, it is a special material: when exposed to clean air, it is hardly
being conducted, however, when put in an environment with combustible gas, it has a pretty
performance of conductivity. Just make a simple electronic circuit, and convert the change of
conductivity to a corresponding output signal. MQ135 gas sensor is sensitive to Ammonia,
Sulphide, Benzene steam, smoke, and other harmful gases. Used for family, surrounding
environment noxious gas detection device, apply to ammonia, aromatics, sulfur, benzene
vapor, and other harmful gases/smoke, gas detection, tested concentration range: 10 to
1000ppm. In a normal environment, the environment that doesn’t have detected gas sets the
sensor’s output voltage as the reference voltage, the analog output voltage will be about 1V,
and when the sensor detects gas, harmful gas concentration increases by 20ppm per voltage
increase by 0.1V.

6|Page
Fig 2.4 (MQ-135 Gas Sensor Module)

Veroboard (KS100)
Veroboard is the original prototyping board.
Sometimes referred to as ‘stripboard’ or ‘matrix
board’ these offer total flexibility for hard wiring
discrete components. Manufactured from a
copper-clad laminate board or Epoxy-based
substrate, it is offered in both single and double-
sided formats. Vero boards are available in a wide
range of board sizes and both imperial and metric
pitch – Veroboard is an ideal base for circuit
construction and offers even greater adaptability
using our range of terminal pins and Fig 2.5 Veroboard assemblies. As with other
stripboards, in using
Veroboard, components are suitably positioned and soldered to the conductors to form the
required circuit. Breaks can be made in the tracks, usually around holes, to divide the strips
into multiple electrical nodes enabling increased circuit complexity. This type of wiring board
may be used for initial electronic circuit development, to construct prototypes for bench
testing, or in the production of complete electronic units in small quantities.
AC-DC Power Adapter
An AC-DC power supply or adapter is an electrical device that obtains electricity from a grid-
based power supply and converts it into a different
current, frequency, and voltage. AC-DC power
supplies are necessary to provide the right power that
an electrical component needs. The ACDC power

7|Page
supply delivers electricity to devices that would typically run on batteries or have no other
Fig 2.6 AC-DC Power Adapter
power source.

LED (Red, Green & Yellow)


A light-emitting diode (LED) is a semiconductor light source that emits light when current
flows through it. Electrons in the semiconductor recombine with electron holes, releasing
energy in the form of photons. The color of the light (corresponding to the energy of the
photons) is determined by the energy required for electrons to cross the band gap of the
semiconductor. White light is obtained by using multiple semiconductors or a layer of light-
emitting phosphor on the semiconductor device. LEDs have many advantages over
incandescent light sources, including lower power consumption, longer lifetime, improved
physical robustness, smaller size, and faster
switching. In exchange for these generally
favorable attributes, disadvantages of LEDs
include electrical limitations to low voltage and
generally to DC (not AC) power, inability to
provide steady illumination from a pulsing DC
or an AC electrical supply source, and lesser
maximum operating temperature and storage
temperature. In contrast to LEDs, incandescent
lamps can be made to intrinsically run at virtually
Fig 2.7LEDs
any supply voltage can utilize either AC or DC
current interchangeably, and will provide steady illumination when powered by AC or pulsing
DC even at a frequency as low as 50 Hz. LEDs usually need electronic support components
to function, while an incandescent bulb can and usually does operate directly from an
unregulated DC or AC power source.

Resistors

8|Page
A resistor is a passive two-terminal electrical
component that implements electrical resistance as
a circuit element. In electronic circuits, resistors
are used to reduce current flow, adjust signal
levels, divide voltages, bias active elements, and
terminate transmission lines, among other uses.
High-power resistors that can dissipate many watts
of electrical power as heat may be used as part of
motor controls, in power distribution systems, or as a test
Fig 2.8 Resistors
loads for generators. Fixed resistors have resistances that only change slightly
with temperature, time, or operating voltage.

Arduino IDE
The Arduino IDE is open-source
software, which is used to write
and upload code to Arduino
boards. The IDE application is
suitable for different operating
systems such as Windows, Mac
OS X, and Linux. It supports the
programming languages C and
C++. Here, IDE stands for

Integrated Development Fig 2.9Arduino IDE


Environment. The program or
code written in the Arduino IDE is often called sketching. We need to connect the Genuino
and Arduino board with the IDE to upload the sketch written in the Arduino IDE software.
The sketch is saved with the extension '.ino.'

ThingSpeak Cloud

9|Page
ThingSpeak is open-source software written in Ruby which allows users to communicate with
internet-enabled devices. It facilitates data
access, retrieval, and logging of data by
providing an API to both the devices and
social network websites. ThingSpeak was
originally launched by ioBridge in 2010 as a
service in support of IoT applications.
ThingSpeak has integrated support from the
numerical computing software MATLAB
Fig 2.10 ThingSpeak Cloud

from MathWorks, allowing ThingSpeak users


to analyze and visualize uploaded data using MATLAB without requiring the purchase of a
MATLAB license from MathWorks.

2.4 Working Procedures


NodeMCU plays the main controlling role in this project. It has been programmed in a
manner, such that, it senses the sensory signals from the sensors and shows the quality level
via LED indicators. The DHT11 sensor module is used to measure the temperature and the
humidity of the surroundings. With the help of the MQ-135 gas sensor module, air quality is
measured in ppm. These data are fed to the ThinkSpeak cloud over the internet. We have also
provided LED indicators to indicate the safety levels.
STEP 1. Firstly, the calibration of the MQ-135 gas sensor module is done. The sensor
is set to preheat for 24 minutes. Then the software code is uploaded to the
NodeMCU followed by the hardware circuit to calibrate the sensor has been
performed.

STEP 2. Then, the DHT11 sensor is set to preheat for 10 minutes.


STEP 3. The result of calibration found in STEP 1 is used to configure the final working
code.

STEP 4. The final working code is then uploaded to the NodeMCU.


STEP 5. Finally, the complete hardware circuit is implemented.
The software codes and the hardware circuits are described in the following chapters.

10 | P a g e
Chapter 3

HARDWARE MODEL

3.1 Hardware Model to Preheat DHT11 Sensor Module


As discussed earlier, we need to preheat the DHT11 sensor so that it can work accurately.
The following steps were performed to preheat the DHT11 sensor module:

STEP 1: The Vcc pin of the DHT11 sensor module was connected with the VU pin of
NodeMCU.
STEP 2: The Gnd pin of the DHT11 sensor module was connected with the Gnd pin
of NodeMCU.
STEP 3: The NodeMCU is powered with a 12V DC via AC-DC adapter for 20 minutes.
STEP 4: The setup was then disconnected.

Fig. 3.1 shown below describes the foresaid connections.

11 | P a g e
3.2 Hardware Model to Preheat and Calibrate MQ-135 Gas Sensor
Module
The following steps were performed to preheat the MQ-135 gas sensor module

STEP 1: The Vcc pin of the MQ-135 gas sensor module was connected with the VU pin
of NodeMCU.
STEP 2: The Gnd pin of the MQ-135 gas sensor module was connected with the Gnd pin
of NodeMCU.
STEP 3: The NodeMCU is powered with a 12V DC via AC-DC adapter for a day.
STEP 4: The setup was then disconnected.

Fig. 3.2 shown below describes the foresaid connections.

Fig. 3.2(Circuit Diagram to Preheat the MQ-135 Gas sensor module)

The following steps were performed to calibrate the MQ-135 gas sensor module

STEP 1: The Vcc pin of the MQ-135 gas sensor module was connected with the VU pin
of NodeMCU.
STEP 2: The Gnd pin of the MQ-135 gas sensor module was connected with the Gnd pin
of NodeMCU.
STEP 3: The analog DATA pin of the MQ-135 gas sensor module was connected with the
A0 Pin of the NodeMCU.

12 | P a g e
STEP 4: The software code to calibrate the sensor is then uploaded to the NodeMCU and
the value of R0in fresh air is collected from the serial monitor of the Arduino IDE.
STEP 5: The setup was then disconnected.

Fig. 3.3 shown below describes the foresaid connections.

Fig. 3.3(Circuit Diagram to Calibrate the MQ-135 Gas sensor module)

3.3 Final Hardware Model


The following steps were performed to execute the project

STEP 1: The Vcc pin of the MQ-135 gas sensor module and DHT11 sensor module was
connected via Veroboard with an adapter delivering around 5V.
STEP 2: The Gnd pin of the MQ-135 gas sensor module, DHT11 sensor module, and the
cathode of the LED indicators was connected via Veroboard with the Gnd pin of the
NodeMCU.
STEP 3: The analog DATA pin of the MQ-135 gas sensor module was connected with the
A0 Pin of the NodeMCU.
STEP 4: The DATA pin of the DHT11 sensor module was connected with the D0 pin of
the NodeMCU.
STEP 5: The anode of the three LED indicators (green, yellow, and red) were connected
to the D2, D3, and D4 pins of the NodeMCU respectively.
STEP 6: The software code to execute the project was then uploaded to the NodeMCU.

13 | P a g e
STEP 7: The setup was then powered with a 9V DC via AC-DC adapter.
It can be now turned ON/OFF as per the requirements. Fig 3.4 represents the circuit diagram
of the setup.

Fig. 3.4(Circuit Diagram of the setup)

14 | P a g e
Chapter 4
SOFTWARE IMPLEMENTATION

4.1 Working Algorithm

15 | P a g e
4.2 Calibration of MQ-135 Gas Sensor Module
Theory of Calibration [10]
The most important step is to calibrate the sensor in the fresh air and then draw an equation
that converts the sensor output voltage value into our convenient units PPM (parts per
million). Here are the mathematical calculations derived,

16 | P a g e
Fig. 4.1 (Internal Circuit diagram of MQ-135 sensor)

From Ohm’s Law, at a constant temperature, we can derive I as follows:

I = ……………………………………………………..(1)

From Fig 4.1, eqn. 1 is equivalent to

I= ……………………........................................... (2)

From Fig 4.1, we can obtain the output voltage at the load resistor using the value obtained
for me and Ohm’s Law at a constant temperature, V = I x R.

VRL = [ VC/ (RS + RL)] x RL ………….………………….… (3)

VRL = [(VC∗ RL)/(RS + RL)]................................................ (4)

So now we solve for RS:

VRLx (RS + RL) = VCx RL…………………………….……. (5)

(VRLx RS) + (VRL x RL) = VC x RL.…………………..…… (6)

VRLx RS = (VC∗ RL) − (VRL∗RL)....................................... (7)

RS = {(VC∗ RL − (VRL∗ RL)} / VRL..…………………..….. (8)

RS = {(VC∗ RL) VRL} – RL ..….…………………………….. (9)

Eqn. 9 helps us to find the internal sensor resistance for fresh air.

17 | P a g e
Fig. 4.2 (Graph representing ratio vs ppm variations)

From the graph shown in Fig 4.2, we can see that the resistance ratio in fresh air is a
constant:

RS / R0 = 3.6…………………………..………… (10)

Value 3.6 which is mentioned ineqn. 10 is depicted in the datasheet shown in Fig 4.2. To
calculate R0, we will need to find the value of the RS in the fresh air. This will be done by
taking the analog average readings from the sensor and converting them to voltage. Then we
will use the RS formula to find R0. First of all, we will treat the lines as if they were linear.
This way we can use one formula that linearly relates the ratio and the concentration. By
doing so, we can find the concentration of a gas at any ratio value even outside of the graph’s
boundaries. The formula we will be using is the equation for a line but for a log-log scale.
From above Figure 4.2, we try to derive the following calculations.

y = mx + b…………………..…………………….(11)

For a log-log scale, the formula looks like this:

log10y = m ∗ log10x + b…………………………….. (12)

Let’s find the slope. To do so, we need to choose 2 points from the graph. In our case, we
chose the points (200,2.6) and (10000,0.75). The formula to calculate slope m(here) is the
following:

18 | P a g e
m = {logy − log(y0)} / { log − log(x0)} ...........................(13)

If we apply the logarithmic quotient rule, we get the following:

m = log( ) / log( ) ..............................................................(14)

Now we substitute the values for x, x0, y, and y0:

m = log(0.75/2.6) / log(10000/200).................................. (15)

m = −0.318…………………………………………………….
(16)

Now that we have m, we can calculate the y-intercept. To do so, we need to choose one
point from the graph (once again from the CO2 line). In our case, we chose (5000,0.9)

log(y) = m ∗ log(x) + b…………………………………………


(17)

b = log(0.9) − (−0.318) ∗ log(5000)............................................ (18)

b=
1.13…………………………………………………………(19)

Now that we have m and b, we can find the gas concentration for any ratio with the
following formula:

log(x) = {log(y) − b} / m……………………………………....


(20)

However, to get the real value of the gas concentration according to the log-log plot we
need to find the inverse log of x:

x = 10 ^ [{log(y)−b] / m]
………………………………………(21)

Using eq. 9 and 21, we will be able to convert the sensor output values into PPM (Parts per
Million). Now we developed the Code and flashed it into the NodeMCU giving proper
connections.

SOFTWARE CODE for Calibration of MQ135 Sensor:

void setup()
{
19 | P a g e
Serial.begin(9600); //Baud rate
pinMode(A0,INPUT);
}

void loop()
{ float sensor_volt; //Define variable for sensor
voltage float RS_air; //Define variable for sensor
resistance float R0; //Define variable for R0
float sensorValue=0.0; //Define variable for analog readings
Serial.print("Sensor Reading = ");
Serial.println(analogRead(A0));

for(int x = 0 ; x < 500 ; x++) //Start for loop


{
sensorValue = sensorValue + analogRead(A0); //Add analog values of sensor 500 times
}
sensorValue = sensorValue/500.0; //Take average of readings
sensor_volt = sensorValue*(5.0/1023.0); //Convert average to voltage
RS_air = ((5.0*1.0)/sensor_volt)-1.0; //Calculate RS in fresh air
R0 = RS_air/3.7; //Calculate R0

Serial.print("R0 = "); //Display "R0"


Serial.println(R0); //Display value of R0
delay(1000); //Wait 1 second

4.3 Execution of the Main Program


#include <ESP8266WiFi.h>
#include <DHT.h>
#include <ThingSpeak.h>

DHT dht(D5, DHT11);


#define LED_GREEN D2
#define LED_YELLOW D3
#define LED_RED D4
#define MQ_135 A0 int
ppm=0; float m = -0.3376;
//Slope float b = 0.7165; //Y-
Intercept
float R0 = 3.12; //Sensor Resistance in fresh air from previous code

WiFiClient client;

long myChannelNumber = 123456; // Channel id

20 | P a g e
const char myWriteAPIKey[] = "API_Key";

void setup() {
//Put your setup code here, to run once: Serial.
begin(9600);
pinMode(LED_GREEN,OUTPUT);
pinMode(LED_YELLOW,OUTPUT);
pinMode(LED_RED,OUTPUT);
pinMode(MQ_135, INPUT);
WiFi.begin("WiFi_Name", "WiFi_Password");
while(WiFi.status() != WL_CONNECTED)
{
delay(200);
Serial.print(".");
}
Serial.println();
Serial.println("NodeMCU is
connected!");
Serial.println(WiFi.localIP());
dht.begin();
ThingSpeak.begin(client);
}

void loop() { float sensor_volt; //Define a variable for sensor voltage float
RS_gas; //Define a variable for sensor resistance float ratio; //Define a
variable for ratio int sensor value;//Variable to store the analog values from
MQ-135 float h; float t; float ppm_log; //Get ppm value in linear scale
according to the ratio value float ppm; //Convert ppm value to log scale h =
dht. read humidity(); delay(4000); t = dht. read temperature(); delay(4000);

sensor value = analogRead(gas_sensor); //Read analog values of sensor


sensor_volt = sensor value*(5.0/1023.0); //Convert analog values to
voltage RS_gas = ((5.0*1.0)/sensor_volt)-1.0; //Get value of RS in a gas
ratio = RS_gas/R0; // Get ratio RS_gas/RS_air
ppm_log = (log10(ratio)-b)/m; //Get ppm value in linear scale according to the ratio value
ppm = pow(10, ppm_log); //Convert ppm value to log scale

Serial.println("Temperature: " + (String) t);


Serial.println("Humidity: " + (String) h);
Serial.println("Our desired PPM = "+ (String) ppm);

ThingSpeak.writeField(myChannelNumber, 1, t, myWriteAPIKey);
delay(20000);
ThingSpeak.writeField(myChannelNumber, 2, h, myWriteAPIKey);
delay(20000);
21 | P a g e
ThingSpeak.writeField(myChannelNumber, 3, ppm, myWriteAPIKey);
delay(20000);

if(ppm<=100)
{
digitalWrite(LED_GREEN,HIGH);
digitalWrite(LED_YELLOW,LOW);
digitalWrite(LED_RED,LOW);
}
else if(ppm<=200)
{
digitalWrite(LED_GREEN,LOW);
digitalWrite(LED_YELLOW,HIGH);
digitalWrite(LED_RED,LOW);
}
else
{
digitalWrite(LED_GREEN,LOW);
digitalWrite(LED_YELLOW,LOW);
digitalWrite(LED_RED,HIGH);
}
delay(2000);}

22 | P a g e
Chapter 5

RESULTS

The working of the designed prototype has been investigated for the 5 sets of experiments as
described in the following sections

EXPERIMENT 1:

Aim: To demonstrate the working of the system in a warm and humid outdoor atmosphere.

Experimental Condition: The experiment was performed on a warm sunny day in a local
outdoor area.

Observations in ThingSpeak Cloud:

23 | Page
Fig: 5.1 Observations for Experiment 1

Setup:

Fig: 5.2 Setup for Experiment 1

Conclusion: We have taken the reference from the Samsung mobile weather app for
verifying the values. It matched with a +1.20 error with the temperature data, +5 error with
the humidity data, and +0.11 error with the PPM data. Hence, we can conclude that the setup
has measured the temperature and humidity around the setup area successfully.

EXPERIMENT 2:

Aim: To demonstrate the working of the system in the presence of alcoholic gases.

Experimental Condition: The experiment was performed indoors in the presence of


alcoholic gases. Drops of an alcoholic mixture (hand sanitizer) were used to produce
alcoholic vapors.

Observations in ThingSpeak Cloud:

24 | Page
Fig: 5.3 Observations for Experiment 2

Conclusion:

We can observe from the results that the presence of alcohol vapors near the setup can be
easily detected by the system. We have taken the reference from the Samsung mobile weather
app for verifying the values. It matched with a +1.30 error with the temperature data, +5 error

25 | Page
with the humidity data, and +0.25 error with the PPM data. Hence, it can be concluded that
we can detect the presence of alcoholic vapors with the help of this monitoring system.

EXPERIMENT 3:

Aim: To demonstrate the working of the system in smoky conditions.

Experimental Condition: The experiment was performed in the presence of smoke coming
from an incense stick placed near the setup.

Observations in ThinkSpeak Cloud

Fig: 5.5 Observations for Experiment 3

26 | Page
Setup:

Conclusion:

We can observe from the results that the presence of smoke near the setup can be easily
detected by the system. We have taken the reference from the Samsung mobile weather app
for verifying the values. It matched with a +1.80 error with the temperature data, a +4 error
with the humidity data, and a -0.7 error with the PPM data. Hence, it can be concluded that
we can detect the presence of smoke with the help of this monitoring system.

EXPERIMENT 4:

Aim: To demonstrate the working of the system in a warm and humid outdoor atmosphere.

Experimental Condition: The experiment was performed at night.

Observations in ThingSpeak Cloud:

27 | Page
Fig: 5.7 Observations for Experiment 4

Setup:

Fig: 5.8 Setup for Experiment 4

Conclusion:

We have taken the reference from the Samsung mobile weather app for verifying the values.
It matched with a +1.20 error with the temperature data, a +5 error with the humidity data,
and a 0.08 error with the PPM data. Hence, we can conclude that the setup has measured the
temperature and humidity around the setup area successfully.

EXPERIMENT 5:

Aim: To demonstrate the working of the system in an air-conditioned indoor atmosphere.

Experimental Condition: The experiment was performed at room temperature.

Observations in ThingSpeak Cloud:

28 | Page
Fig: 5.9 Observations for Experiment 5

Setup:

Fig: 5.10 Setup for Experiment 5

Conclusion:

We have taken the reference from the Samsung mobile weather app for verifying the values.
It matched with a +0.6 error with the temperature data, a +2 error with the humidity data, and
a -0.03 error with the PPM data. Hence, we can conclude that the setup has measured the
temperature and humidity around the setup area successfully.

Table 5.1: Experimental Results


Temperature (in Celsius) Humidity (in %) Air Quality (in ppm)

29 | Page
Expt. Samsung Samsung
No. Weather Samsung Weather
Project Project Project
App Error Weather App Error App Error
Reading Reading Reading
Reading Reading Reading

1 34.2 33 1.2 70 65 5 8.61 8.5 0.11


2 33.3 32 1.3 70 65 5 42.25 42 0.25
3 33.8 32 1.8 74 70 4 52.3 53 -0.7
4 34.2 33 1.2 74 69 5 4.26 4.34 -0.08
5 22.6 22 0.6 59 57 2 0.67 0.7 -0.03

30 | Page
Chapter 6
CONCLUSION

In this project, IoT based on the measurement and display of Air Quality Index (AQI),
Humidity, and Temperature of the atmosphere has been performed. From the information
obtained from the project, it is possible to calculate Air Quality in PPM. The disadvantage of
the MQ135 sensor is that specifically, it can’t tell the Carbon Monoxide or Carbon Dioxide
level in the atmosphere, but the advantage of MQ135 is that it can detect smoke, CO, CO2,
NH4, etc harmful gases.

After performing several experiments, it can be easily concluded that the setup can measure
the air quality in ppm, the temperature in Celsius, and humidity in percentage with
considerable accuracy. The results obtained from the experiments are verified through
Google data. Moreover, the LED indicators help us to detect the air quality level around the
setup. However, the project experiences a drawback that is it cannot measure the ppm values
of the pollutant components separately. This could have been improved by adding gas sensors
for different pollutants. But eventually, it would increase the cost of the setup and not be a
necessary provision to monitor the air quality. Since it’s an IOT-based project, it will require
a stable internet connection for uploading the data to the ThinkSpeak cloud. Therefore, it is
possible to conclude that the designed prototype can be utilized for air quality, humidity, and
temperature of the surrounding atmosphere successfully.

31 |
Page

REFERENCES

[1] https://gaslab.com/blogs/articles/carbon-monoxide-levels
[2] https://www.instructables.com/Measuring-Humidity-Using-Sensor-DHT11
[ 3 ] https://pdf1.alldatasheet.com/datasheet-pdf/view/1307647/WINSEN/MQ135.html
[4] https://components101.com/development-boards/nodemcu-esp8266-pinout-
featuresand-datasheet
[5] https://www.arduino.cc
[6] https://thingspeak.com
[ 7 ] Pasha, S. (2016). ThingSpeak-based sensing and monitoring system for IoT with Matlab
Analysis. International Journal of New Technology and Research, 2(6).
[ 8 ] Kumar, N. S., Vuayalakshmi, B., Prarthana, R. J., & Shankar, A. (2016, November). IOT-
based smart garbage alert system using Arduino UNO. In 2016 IEEE Region 10
Conference (TENCON) (pp. 1028-1034). IEEE.
[ 9 ] IoT-based Air Quality monitoring system using MQ135 & MQ7 with Machine Learning
analysis by Kinnera Bharath Kumar Sai M.Tech CSE VIT University, Vellore Subhaditya
Mukherjee B.Tech CSE VIT University, Vellore Dr. Parveen Sultana H Associate
Professor Department of CSE, VIT University.
[ 10 ] https://www.codrey.com/electronic-circuits/how-to-use-mq-135-gas-sensor

32 |
Page

Appendix

A.1 PIN DESCRIPTION OF NODEMCU


Pinout diagram of the NodeMCU:

Description:

Pin Category Name Description

33 | P a g e
Power Micro-USB, Micro-USB: NodeMCU can be powered through the
3.3V, GND, Vin USB port

3.3V: Regulated 3.3V can be supplied to this pin to


power the board

GND: Ground pins

Vin: External Power Supply

34 |
Control Pins EN, RST The pin and the button reset the microcontroller

Analog Pin A0 Used to measure analog voltage in the range of 0-3.3V

GPIO Pins GPIO1 to NodeMCU has 16 general-purpose input-output pins on


GPIO16 its board

SPI Pins SD1, CMD, NodeMCU has four pins available for SPI
SD0, CLK communication.

UART Pins TXD0, RXD0, NodeMCU has two UART interfaces, UART0 (RXD0
TXD2, RXD2 & TXD0) and UART1 (RXD1 & TXD1). UART1 is
used to upload the firmware/program.

I2C Pins NodeMCU has I2C functionality support but due to the
internal functionality of these pins, you have to find
which pin is I2C.

35 | P a g e
A.2 DESCRIPTION OF SOFTWARE LIBRARIES USED
ESP8226WiFi Library

The ESP8266WiFi library provides a wide collection of C++ methods (functions) and
properties to configure and operate an ESP8266 module.

The commands used are as follows:

• WiFi.begin(“ WiFi Name”, “WiFiPassword”); Command to connect with WiFi


network.
• WiFi.status(); To check the status of the connection.
If it returns – WL_CONNECTED WiFi is connected
If it returns – WL_IDLE_STATUS WiFi is connected but no internet found
If it returns – WL_CONNECT_FAILED WiFi is not connected

DHT11 sensor Library

The DHT sensor library provides a wide collection of C++ methods (functions) and properties
to configure and operate the DHT11 sensor module.

The commands used are as follows:

• DHT dht(D5, DHT11); Set the pin for reading data.


• dht.begin(); Command to connect with DHT11 sensor module.
• dht.readTemperature(); Returns the value of the temperature in Celsius.
• dht. read humidity (); Returns the value of humidity in percentage.

ThinkSpeak Library

The ThinkSpeak library provides a wide collection of C++ methods (functions) and properties
to configure and operate the ThinkSpeak cloud.

The commands used are as follows:

36 | P a g e
• ThingSpeak.writeField(myChannelNumber, 1, t, myWriteAPIKey); To upload data in
the ThinkSpeak Field.

A.3 COST ESTIMATION OF THE PROJECT


For making the project we have used the following components (as mentioned in Table 2).
As per the pricing on the online websites for electronic components, we have formulated a
cost estimation.

Table 2: Cost Estimation of the Project


Components Price (in Rs)
NodeMCU V3 288
DHT11 Sensor Module 120
MQ135 Gas Sensor Module 135
Connecting Wires 60
LEDs (Red, Green & Yellow) 9
AC-DC Power Adapter 120
Female PCB Berg Terminal and cable 80
Veroboard 100
Breadboard 70

Total 982

37 | P a g e

You might also like