Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 33

A project report on

IOT Based Air Pollution Monitoring System


Using Node MCU
Submitted in partial fulfillment of the requirement for the award of the degree of

Bachelor of Technology
In
ELECTRONICS & COMMUNICATION ENGINEERING
By

Nandini J 20A95A0409
Ravi Teja A 19A91A0466
Siva Kumar K 19A91A0489
Aravind K 20A95A0404

Under the Esteemed guidance of

Mr. Shivam Singh, M.Tech(Ph.D.)


Assistant Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


ADITYA ENGINEERING COLLEGE(A)
(Approved by AICTE, Permanently Affiliated to JNTUK & Accredited by NBA,
NAAC with ‘A’ Grade.Recognized by UGC under the sections 2(f) and 12(B) of the
UGC act 1956)
Aditya Nagar, ADB Road, Surampalem – 533 437
(2017-2021)

ADITYA ENGINEERING COLLEGE (A)

1
(Affiliated to JNTUK, Kakinada and Approved by AICTE, New Delhi)
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

Certificate

This is to certify that the project report entitled “IOT BASED AIR POLLUTION
MONITORING SYSTEM USING NODEMCU” being submitted by

Nandini J 20A95A0409
Ravi Teja A 19A91A0466
Siva Kumar K 19A91A0489
Aravind K 20A95A0404

for the partial fulfillment of the requirements for the award of the degree of Bachelor of
Technology in DEPARTMENT OF ELECTRONICS & COMMUNICATION
ENGINEERING to the Jawaharlal Nehru Technological University, Kakinada is a
record of bonafide work carried out by them under the guidance and supervision.
To the best of our knowledge, the results embodied in this project report have not
been submitted to any other University or Institute for the award of degree.

Project Guide Head of the Department


Mr. Shivam Singh, M.Tech., Ph.D Dr. G. SRIDEVI, M.Tech., Ph.D
Assistant Professor Professor & HOD

ACKNOWLEDGEMENT

2
I am thankful to my guide Mr. Shivam Singh, Assistant professor who has spared
his/her valuable time. I am indebted to him/her without whom I would not have
successfully completed the project.

Likewise, I also wish to convey my sincere thanks to Dr. G. SRIDEVI, HOD of


Electronics and Communication Engineering Department for her technical support and
valuable suggestions. I also wish to convey my sincere thanks to all faculty of ECE
Department for their support and valuable suggestions.

I am thankful to Dr. M. SREENIVASA REDDY, Principal, Aditya Engineering


College for providing the appropriate environment required for this project.

We also thank all teaching and non-teaching staff of the Electronics and
Communication Engineering Department for their support in completion of the project
work. Finally, we thank everyone who directly or indirectly rendered their valuable
guidance and encouragement during any dissertation work.

Nandini J 20A95A0409
Ravi Teja A 19A91A0466
SivaKumar K 19A91A0489
Aravind K 20A95A0404

3
ABSTRACT

In today’s world, due to the fast growth in the number of motor vehicles and industrial
evolution, the surrounding environment is more polluted. The pollution majorly affects the
quality of air and causes major health issues to living beings. The major reason for atmosphere
contamination is due to the release of harmful gases like carbon dioxide, carbon monoxide etc.
from factories, vehicles and from combustion of fossil fuels. It is necessary to monitor the
percentage of pollutants present in the air which will lead to environmental issues. To overcome
this, we have designed a prototype using IoT technology. The air pollution monitoring tool
includes a Microcontroller and Sensors that provides the provision to monitor the quality of air
by detecting the harmful gases present in the atmosphere. The pollution level can be monitored
remotely using PC or smartphones. The data is stored in the cloud and can be accessed remotely.

Measuring Air Quality is an important element for bringing awareness to take care of the future
generations and for a healthier life. Based on this, the Government of India has already taken
4
certain measures to ban Single Stroke and Two-Stroke Engine based motorcycles, which emit
high pollution. We are trying to implement a system using IoT platforms like Thingspeak in
order to bring awareness to every individual about the harm we are doing to our environment.
Already, New Delhi is remarked as the most polluted city in the world, recording Air Quality
above 300 PPM.
We have used the easiest platform like Thingspeak and set the dashboard to the public such that
everyone can come to know the Air Quality at the location where the system is installed.
Machine Learning analysis brings us a lot of depth in understanding the information that we
obtained from the data. Moreover, we are providing an inducement of the cost of components
versus the state of the art.

Contents

List of Figures 8
5
List of Abbreviations 9
1. Introduction [10]
1.1 Motivation 10
1.2 Problem statement 10
1.3 Objective and Scope 10
2. Literature Survey [11]
3. Background [12-19]
3.1 Node MCU 12-13
3.2 MQ135 13
3.3 16X2 LCD 14
3.4 Breadboard 15
3.5 I2c Adapter 16
3.6 Arduino IDE 16-17
3.7 Thingspeak Cloud Platform 18
3.8 Jump Wires 18-19
4. Implementation [20-26]
4.1 Creating and setting up a Thingspeak account 20
4.2 Install ESP3266 Add-on in Arduino IDE 20-22
4.3 Circuit and Code 22-26
5. Results and Validations [27]
6 Conclusions [28]
6.1 Conclusion 28
References [29]
6 Appendix [31]
8.1 Prototype 31
Profile [32]

6
LIST OF FIGURES

Figure No Figure Name Page No


3.1 NodeMCU ESP8266 Pinout 3
3.2 MQ135 4
3.3 16X2 LCD Display 5
3.4 Breadboard 6
3.5 I2C LCD Adapter 7
3.6 Arduino IDE Interface 8
3.7 Thingspeak Cloud Platform 9
3.8 Jump Wires 10
4.1 Circuit Diagram of Prototype 14
5.1 Field Chart Results 18
7
Prototype
8.1 Final Prototype 31
8.2 31

LIST OF ABBREVIATIONS

MCU Micro Controller Unit


API Application Program Interface
REST Representational state transfer
AC Air Conditioner
Wi-Fi Wireless Fidelity
IOT Internet Of Things
LED Light Emitting Diode
ESP Espressif
SDK software development kit
SPIFFS Sales Program Incentive Funds
IDE Integrated Development Environment
IOT Internet Of Things
8
SoC System on a Chip
LCD Liquid Crystal Display
EPA Environmental Protection Agency
UCSD University of California San Diego
DIP Dual In-line Package
SDA Serial Data
MATLAB MATrix LABoratory
GNU GNU's Not Unix
VEE Voltage Emitter Emitter
I2C Inter-Integrated Circuit
SCL Serial Clock

Chapter 1
Introduction
1.1 Motivation
Air pollution occurs when toxic or harmful substances including gases, dust particles and
biological molecules are introduced into Earth’s atmosphere. It is caused by the rapid increase
and development in industrial revolution and transportation, air contamination has recently
become a serious problem for developing countries. It is one of the major issues in the
atmosphere. Air contamination should be controlled in order to overcome life threatening
diseases like cancer, respiratory diseases and much more which are faced by human beings.

1.2 Problem Statement


The Air pollution Monitoring System is designed using Node MCU and air quality sensors. The
automation is done using these hardware components, which enables wireless communication
and can control the behavior of sensors. Node Microcontroller Unit is responsible for controlling
sensors such as Temperature and Humidity sensor, Air quality Sensors and Gas Sensors. Node
MCU sends signals to each sensor to perform specific action or retrieve data from a specific
9
sensor. The data sent from the microcontroller is sent to the ThingSpeak cloud.

1.3 Objective and scope


To increase the air quality index. To detect toxic gasses caused due to vehicular emission and
ltration of those gasses. To analyze toxicity at signals in metropolitan cities and generate the
reports. To reduce the toxicity by purifying air and increase the life-span of living things. To
display real-time forecasting of Pollution.
A project presents a prototype to achieve accurate monitoring, which would be feasible, portable
and provide remote access to sensed data. Pollution monitoring should not be the sole
responsibility of the government and systems should be available to make citizens aware of the
pollution content in the area and take steps to reduce the pollution.

Chapter 2
Literature Survey

In the traditional approach, readings of air pollution are checked using different digital air quality
detectors and moisture meters which have to be taken to different locations every time to check
the values. It is time consuming and the risk of traveling from one location to another is high.
Collection of data has to be done manually.
At times the appliances are kept on unknowingly which directly affects the energy consumption,
Storage of data is not safe in existing systems and data cannot be fetched on time whenever
required.
There are different air quality identifiable meters available in retail shops such as Am probe
meter and Liquid petroleum gas leakage sensor alarm etc. also we have Bluetooth oriented
transmitting devices which have a very limited user to find the contamination level in
atmosphere.
[1] Monitors the pollution level in terms of parts per million and also adapts general packet
radio service using Arduino Uno board. Low power wide area technology is implemented to find
out to machine to machine communications and air quality index is computed by using the
concentration of gases.
[2]. To monitor the air pollution buzzer is implemented, buzzer intimates when air impurity
10
goes beyond a certain level and it will be displayed on liquid crystal display.
[3] The REST protocol is adapted to find out air conditioning control as well as AC split devices
through the network using Wi-Fi connection, Infra-red LED to transmit Infrared commands.
[4] Author discussed and represented A novel IoT access architecture for vehicle monitoring
systems.

Chapter 3
Components and Modules
3.1 NodeMCU
NodeMCU is an open source firmware for which open source prototyping board designs are
available. The name "NodeMCU" combines "node" and "MCU" (micro-controller unit). The
term "NodeMCU" strictly speaking refers to the firmware rather than the associated development
kits. Both the firmware and prototyping board designs are open source.

The firmware uses the Lua scripting language. The firmware is based on the eLua project, and
built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-
cjson and SPIFFS. Due to resource constraints, users need to select the modules relevant for their
project and build a firmware tailored to their needs. Support for the 32-bit ESP32 has also been
implemented.

11
fig 3.1: NodeMCU ESP8266 Pinout

The prototyping hardware typically used is a circuit board functioning as a dual in-line package
(DIP) which integrates a USB controller with a smaller surface-mounted board containing the
MCU and antenna. The choice of the DIP format allows for easy prototyping on breadboards.
The design was initially based on the ESP-12 module of the ESP8266, which is a Wi-Fi SoC
integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications.

3.2 MQ135(Air Pollution Sensor)


Air pollution sensors are devices that monitor the presence of air pollution in the surrounding
area. They can be used for both indoor and outdoor environments. These sensors can be built at
home, or bought from certain manufacturers. Although there are various types of air pollution
sensors, and some are specialized in certain aspects, the majority focuses on five components:
ozone, particulate matter, carbon monoxide, sulfur dioxide, and nitrous oxide. The sensors were
very expensive in the past, but with technological advancements these sensors are becoming
more affordable and more widespread throughout the population. These sensors can help serve
many purposes and help bring attention to environmental issues beyond the scope of the human
eye.

12
fig 3.2: MQ135 Air Pollution Sensor

The EPA maintains a repository of air quality data through the Air Quality System (AQS), where
it stores data from over 10,000 monitors in the United States.

While use of these sensors was expensive in the past, the 2010s saw a recent trend towards the
development of cheaper portable air-quality sensors that can be worn by individuals to monitor
local air quality levels. These sensors can then, in turn, help measure t he spatiotemporal
coverage and variety of chemical species, and empower individuals and communities to better
understand their exposure environments and risks from air pollution.

A research group led by William Griswold at UCSD handed out portable air pollution sensors to
16 commuters, and found "urban valleys" where buildings trapped pollution. The group also
found that passengers in buses have higher exposures compared to those in automobiles.

3.3 16x2 LCD Display


An LCD (Liquid Crystal Display) screen is an electronic display module and has a wide
range of applications. A 16x2 LCD display is a very basic module and is very commonly used
in various devices and circuits.

13
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in a 5x7 pixel matrix. The 16 x 2 intelligent alphanumeric dot matrix
display is capable of displaying 224 different characters and symbols. This LCD has two
registers, namely, Command and Data.

fig 3.3: 16x2 LCD Display

Command register stores various commands given to the display. Data register stores data to be
displayed. The process of controlling the display involves putting the data that form the image of
what you want to display into the data registers, then putting instructions in the instruction
register.

In your arduino project Liquid Crystal Library simplifies this for you so you don't need to know
the low-level instructions. Contrast of the display can be adjusted by adjusting the potentiometer
to be connected across the VEE pin.

3.4 Breadboard
A breadboard, or protoboard, is a construction base for prototyping of electronics. Originally the
word referred to a literal bread board, a polished piece of wood used when slicing bread.In the
1970s the solderless breadboard (a.k.a. plugboard, a terminal array board) became available and
nowadays the term "breadboard" is commonly used to refer to these.
14
fig 3.4: Breadboard

Because the solderless breadboard does not require soldering, it is reusable. This makes it easy to
use for creating temporary prototypes and experimenting with circuit design. For this reason,
solderless breadboards are also popular with students and in technological education. Older
breadboard types did not have this property.

A stripboard (Veroboard) and similar prototyping printed circuit boards, which are used to build
semi-permanent soldered prototypes or one-offs, cannot easily be reused. A variety of electronic
systems may be prototyped by using breadboards, from small analog and digital circuits to
complete central processing units (CPUs).

3.5 I2C Adapter


The I2C Module has an inbuilt PCF8574 I2C chip that converts I2C serial data to parallel data
for the LCD display. These modules are currently supplied with a default I2C address of either
0x27 or 0x3F. To determine which version you have check the black I2C adaptor board on the
underside of the module.

15
fig 3.5: I2C LCD Adapter

If there are 3 sets of pads labeled A0, A1, & A2 then the default address will be 0x3F. If there
are no pads the default address will be 0x27. The module has a contrast adjustment pot on the
underside of the display. This may require adjusting for the screen to display text correctly.

3.6 Arduino IDE


The Arduino Integrated Development Environment (IDE) is a cross-platform application (for
Windows, macOS, Linux) that is written in functions from C and C++. It is used to write and
upload programs to Arduino compatible boards, but also, with the help of third-party cores, other
vendor development boards.

The source code for the IDE is released under the GNU General Public License, version 2. The
Arduino IDE supports the languages C and C++ using special rules of code structuring. The
Arduino IDE supplies a software library from the Wiring project, which provides many common
input and output procedures.

User-written code only requires two basic functions, for starting the sketch and the main
program loop, that are compiled and linked with a program stub main() into an executable cyclic
executive program with the GNU toolchain, also included with the IDE distribution.

16
fig 3.6: Arduino IDE interface

The Arduino IDE employs the program avrdude to convert the executable code into a text file in
hexadecimal encoding that is loaded into the Arduino board by a loader program in the board's
firmware. By default, avrdude is used as the uploading tool to flash the user code onto official
Arduino boards.

3.7 Thingspeak cloud platform


ThingSpeak is an 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
17
ioBridge in 2010 as a service in support of IoT applications.

fig 3.7: Thingspeak cloud platform

ThingSpeak has integrated support from the numerical computing software MATLAB from
MathWorks, allowing ThingSpeak users to analyze and visualize uploaded data using MATLAB
without requiring the purchase of a MATLAB license from MathWorks.

3.8 Jump Wire


A jump wire (also known as jumper, jumper wire, jumper cable, DuPont wire or cable) is an
electrical wire, or group of them in a cable, with a connector or pin at each end (or sometimes
without them – simply "tinned"), which is normally used to interconnect the components of a
breadboard or other prototype or test circuit, internally or with other equipment or components,
without soldering.

18
fig 3.8: Jump Wires

Individual jump wires are fitted by inserting their "end connectors" into the slots provided in a
breadboard, the header connector of a circuit board, or a piece of test equipment.

Chapter 4
19
Implementation
4.1 Creating and setting up a Thingspeak account
1. Visit www.thingspeak.com.
2. Click "Sign Up".
3. Fill the following mandatory fields: User ID, E-mail, Time Zone, Password.
4. Click "Create Account".
5. Click "Create New Channel".
6. Click the "Channel Settings" tab.
7. Fill Fields 1 and 2 with the following values: Percentage, Date.
8. Click "Update Channel".
9. Click the "API Key" tab to get the API key required by the installer.

4.2 Install ESP8266 Add-on in Arduino IDE


1. In your Arduino IDE, go to File> Preferences

2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into the


“Additional Boards Manager URLs” field as shown in the figure below. Then, click the “OK”
button:
20
Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma.

3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

4. Search for ESP8266 and press install button for the “ESP8266 by ESP8266
Community“:

21
5. That’s it. It should be installed after a few seconds.

4.3 Circuit and Code


4.3.1 Circuit
NodeMCU can do many of the functions of an Arduino board and it has a built-in ESP8266
based Wi-Fi module too. The program code for analog to digital conversion of MQ135 sensor
data and sending the collected data to Thingspeak can be written in a single program code.

22
fig 4.1: Circuit Diagram of Prototype

The circuit is self-explanatory just wire the circuit as shown in the above schematic. In this
circuit also will be using an I2C adapter module for LCD display to reduce the number of wire
connections.
NodeMCU’s I2C pins are D1 which is SCL and D2 which is SDA are connected to I2C adapter
module.The MQ135 sensor need 5V supply, you can connect its Vcc pin to “VU” pin of
NodeMCU which outputs 5V. If you have a NodeMCU from a different manufacturer you can
connect the Vcc of MQ135 to “Vin” pin of NodeMCU which can supply 5V.
4.3.2 Code
How to upload code to NodeMCU?
●Connect the NodeMCU to your computer using USB cable
●Go to Tools > Board > NodeMCU 1.0
●Go to Tools > Upload speed > 115200.
●Press and hold the on-board flash button.
●Press the reset button once and release it.
●After releasing the reset button, release the flash button.
●Click upload.

Program code for NodeMCU:

23
// -----------(c) Electronics-project-hub ----------//
#include <LiquidCrystal_I2C.h>
#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

//----------- Enter you Wi-Fi Details---------//


char ssid[] = "ECE-2 DEPT"; // your network SSID (name)
char pass[] = "Password"; // your network password
//-------------------------------------------//

//----------- Channel Details -------------//


unsigned long Channel_ID = 1627852; // Channel ID
const char * WriteAPIKey = "3Y1RUKB3RHB5UGDS"; // Your write API Key
// ----------------------------------------//

const int Field_number = 1;


float value;
int raw;
WiFiClient client;
void setup()
{
Serial.begin (115200);
WiFi.mode(WIFI_STA);
Wire.setClock(10000);
ThingSpeak.begin(client);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("IoT Air Quality");
lcd.setCursor(0, 1);
lcd.print("Monitor System");
delay(200);
internet();
lcd.clear();

24
lcd.setCursor(0, 0);
lcd.print("MQ135 sensor");
lcd.setCursor(0, 1);
lcd.print("is heating up...");
for (int i = 0; i < 3; i++)
{
delay(20000);
delay(20000);
delay(20000);
}
}

void loop()
{
get_value();
upload();
}

void get_value()
{
float sensor_volt;
float RS_air;
float R0;
float sensorValue;
for(int x = 0 ; x < 500 ; x++)
{
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue/500.0;
sensor_volt = sensorValue*(5.0/1023.0);
RS_air = ((5.0*10.0)/sensor_volt)-10.0;
R0 = RS_air/4.4;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Air Pollution(%)");
lcd.setCursor(0, 1);
//raw = (analogRead(A0)/1024.0)*100.0;

25
value = map(R0, 0, 1024, 1, 100);
lcd.print(value);
lcd.print(" %");
delay(5000);
}

void internet()
{
if (WiFi.status() == WL_CONNECTED)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connected to");
lcd.setCursor(0, 1);
lcd.print("internet!");
delay(2000);
}
if (WiFi.status() != WL_CONNECTED)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connecting to");
lcd.setCursor(0, 1);
lcd.print(ssid);
lcd.print(" SSID...");
for (int i = 0; i < 5; i++)
{
WiFi.begin(ssid, pass);
delay(5000);
}
if (WiFi.status() != WL_CONNECTED)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("No internet");
lcd.setCursor(0, 1);
lcd.print("connection !");

26
delay(3000);
}
else if (WiFi.status() == WL_CONNECTED)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connected to");
lcd.setCursor(0, 1);
lcd.print("internet!");
delay(2000);
}
}
}

void upload()
{
ThingSpeak.writeField(Channel_ID, Field_number, value, WriteAPIKey);
}
//—--------------- end of program —---------------//

Note: We need to install two libraries to do this prototype. They are Thingspeak and LCD I2C
libraries into Arduino IDE.

Chapter 5
Result and Validations

27
This is the output as a result in the Thingspeak cloud platform. The analysis we get from it is
everyday analysis.

Chapter 6
Conclusion

28
The System is integrated with other modern tools such as Air Quality Sensors, Gas Sensors,
Node microcontroller unit Boards for making the process of automation more interactive. By placing
our equipment in different locations we can collect the readings of different gases present in the air and
updated on cloud.
This tool displays the details of polluted air in the developed mobile app and the same
information is updated to the cloud. The data stored in the cloud can be further analyzed to know the
air quality according to the recorded region. This helps in knowing the major cause and pollutants
contributing to the polluted air and suitable precautionary measures can be taken to overcome and
minimize the air pollution.

Chapter 7
References

29
1. https://en.wikipedia.org/wiki/NodeMCU
2. https://en.m.wikipedia.org/wiki/Breadboard
3. https://en.m.wikipedia.org/wiki/ThingSpeak
4. https://www.thingbits.in/products/standard-lcd-16x2-display
5. https://nodemcu.readthedocs.io/en/release/modules/i2c/
6. https://en.wikipedia.org/wiki/Arduino_IDE
7. https://www.roboticapp.com/thingspeakaccountcreation.html

Chapter 8
Appendix
Prototype

30
Fig: 8.1: Prototype

Fig :8.2: Final Prototype

Chapter 9
Profile
Nandini Jami
20A95A0409
31
20A95A0409@aec.edu.in
Ph.no: 8309371491

Aravind kocherla
20A95A0404
20A95A0404@aec.edu.in
Ph.no: 8106416979

Ravi Teja Akella


19a91A0466
19a91A0466@aec.edu.in
Ph.no: 7036389255

Siva Kumar kurumella


19a91A0489
19a91A0489@aec.edu.in
Ph.no: 7569954949

32

You might also like