Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

IOT BASED AIR AND SOUND POLLUTION MONITORING SYSTEM

A
Project report submitted
In partial fulfillment of the requirements for the Degree of

Bachelor of Technology

Anand Mishra 201610101110105

Divyanshu Dwivedi 201610101110089

Piyush Dubey 201610101110117

Guide: Ms Shazia Afreen


To the
Faculty of Computer Science and Engineering Department
SHRI RAMSWAROOP MEMORIAL UNIVERSITY

APRIL 2020
DECLARATION

We, Anand Mishra (201610101110105), Divyanshu Dwivedi (201610101110089) and


Piyush Dubey (201610101110117) students of Bachelor of Technology, Computer Science &
Engineering department at Shri Ramswaroop Memorial University, Lucknow hereby declare that
the work presented in this project titled “IOT BASED AIR AND SOUND POLLUTION
MONITORING SYSTEM” is outcome of our own work, is bonafide, correct to the best of our
knowledge and this work has been carried out taking care engineering ethics.

We have completely taken care in acknowledging the contribution of others in this academic
work. We further declare that in case of any violation of intellectual property rights or
copyrights found at any stage, we as the candidates will be solely responsible for the same.

Date: 24 Nov 2019


Signature

Place: Barabanki Anand Mishra

(201610101110105)

Signature

Divyanshu Dwivedi
(201610101110089)
Signature

Piyush Dubey
(201610101110117)
ACKNOWLEDGEMENT

It gives me great pleasure to express my gratitude and heart full thanks to all those who are
helping me in complete this project.

I want to thank to “Ms Shazia Afreen”, who has always encouraged and help me in
making this project. In addition to this, I am grateful to other faculties too who made me in
right direction and gave me their precious time and expert guidance whenever necessary
through which I could achieve this extent.

At last but not the least I am feeling glad to say about my family whose wishes are
always with me, without which it was not possible for me to reach this extent.I hope my work
is praised and my efforts render fruitful result.
TABLE OF CONTENTS

CHAPTERS PAGE NO.

DECLARATION ⅰ

PROJECT PROGRESE REPORT ii

ACKNOWLEDGEMENT iii

CHAPTER 1: INTRODUCTION 6-7

1.1 Introduction about the project

1.2 Problem definition

1.3 Objective

CHAPTER 2: METHODOLOGY 8

2.1 Block Diagram

2.2 Working

CHAPTER 3: REQUIREMENTS 9

3.1 Hardware Requirements

3.2 Software Requirements


CHAPTER 4: SYSTEM ANALYSIS AND DESIGN 10-16

4.1Module of Project

4.2Data Flow Diagram

4.3E-R Diagram

4.4Arduino Microcontroller:

4.5 Wi-Fi Module - ESP8266

CHAPTER 5: TESTING 17-34

5.1 Test Plan

CHAPTER 6: ADVANTAGES AND FUTURE SCOPE 35

6.1 Advantages

6.2 Disadvantage

6.3 Future Scope

REFERENCE 36
CHAPTER 1: INTRODUCTION

The system proposed in this is an advanced solution for monitoring the environmental
conditions at a particular place and make the information visible anywhere in the world.
The technology behind this is Internet of Things (IOT), which is an advanced and
efficient solution for connecting the things to the internet and to connect the entire world
of things in a network. Here things might be whatever like electronic gadgets, sensors and
automotive electronic equipment. The system deals with monitoring and detection of air
and sound pollution and sends sensor data to the computer and android phone using IOT
link. The data updated from the implemented system can be accessible in the internet
from anywhere in the world using think speak plate form.

PROBLEM DEFINITION

OBJECTIVE

Objective of this project is to design and develop IOT based air and sound pollution. The
system consists of air quality sensor and sound sensor. And send sensors data to the
computer using IOT link. User can watch on think speak. The system will alert if any
sensors reading goes above pre-set level.

LITERATURE REVIEW

A weather station is a facility, either on land or sea, with instruments and equipment for
measuring atmospheric conditions to provide information for weather forecasts and to
study the weather and climate. The measurements taken include temperature, atmospheric
pressure, humidity, wind speed, wind direction, and precipitation amounts. Wind
measurements are taken with as few other obstructions as possible, while temperature and
humidity measurements are kept free from direct solar radiation, or insolation. Manual
observations are taken at least once daily, while automated measurements are taken at
least once an hour. Weather conditions out at sea are taken by ships and buoys, which
measure slightly different meteorological quantities such as sea surface temperature

6
(SST), wave height, and wave period. Drifting weather buoys outnumber their moored
versions by a significant amount.

7
CHAPTER 2: METHODOLOGY

Think speak

Arduino
Air quality
sensor

Esp-8266 IOT
Sound sensor
module

Fig 1: Block Diagram

Working

 Air quality sensor for monitoring air quality.


 Condenser mic for sound monitoring.
 All the sensors are attached at the ADC pin (analog to digital) to the Arduino
microcontroller.
 Microcontroller will do some calculation and send data to IOT module.
 We will set the limit of every sensor if limit exceeded it will alert the user.by
displaying limit crossed.
 IOT module will transmit data so that computer will receive and display on
screen.
 Computer will display data on think speak plate form.

8
CHAPTER3: REQUIREMENT

Hardware Used:

 Arduino microcontroller.
 Esp8266 Iot module.
 Air quality
 Condenser mic
 Power supply.

Software

 AVR Studio 5

 Arduino IDE programming microcontroller

9
CHAPTER 4: SYSTEM ANALYSIS AND DESIGN

Modules of projects:

Modules
of project

Hardware Programming Creating Creating


development and data sites on graph and
transmission server tables

Fig 2: Modules of projects

Data flow diagram:

Upload Web User 1


download
Admin and server
Transmit View data User 2
data

Database User 3

Fig3: DFD

10
ER Diagram:

Admin Web Normal user


server

Login/s
ignup

View data
Upload
download
data
Create sites graph
and tables Contact Admin

Fig4: ER Diagram

Arduino Microcontroller:

It is a microcontroller board developed by Arduino.cc and based on Atmega328.

Electronic devices are becoming compact, flexible and cheap that are capable of doing
more function as compared to their predecessors that happened to cover more space,
turned out costly with the ability to perform fewer functions.

Experts always strive to introduce innovation in automation that requires minimum effort
and gives maximum output. The microcontroller was introduced in the electronics
industry with the purpose of making our tasks easy that come with even a remote
connection with automation in any way.
11
Microcontrollers are widely used in embedded systems and make devices work according
to our needs and requirements. We have already discussed the controllers like 8051,
Atmega16, Atmega328 and PIC16F877.
Arduino Uno is a very valuable addition in the electronics that consists of USB interface,
14 digital I/O pins, 6 analog pins, and Atmega328 microcontroller. It also supports serial
communication using Tx and Rx pins. You should also have a look at this UNO for
beginners.
There are many versions of Arduino boards introduced in the market like Arduino Uno,
Arduino Due, Arduino Leonardo, Arduino Mega, however, most common versions are
Arduino Uno and Arduino Mega. If you are planning to create a project relating to digital
electronics, embedded system, robotics, or IoT, then using Arduino Uno would be the
best, easy and most economical option.

It is an open-source platform, means the boards and software are readily available and
anyone can modify and optimize the boards for better functionality.

The software used for Arduino devices is called IDE (Integrated Development
Environment) which is free to use and required some basic skills to learn it. It can be
programmed using C and C++ language. Some people get confused
between Microcontroller and Arduino. While former is just an on system 40 pin chip
that comes with a built-in microprocessor and later is a board that comes with the
microcontroller in the base of the board, bootloader and allows easy access to input-
output pins and makes uploading or burning of the program very easy.

12
Fig5: Arduino UNO

13
Wi-Fi Module - ESP8266

Fig6: Wi-Fi Module

Description: The ESP8266 Wi-Fi Module is a self contained SOC with integrated
TCP/IP protocol stack that can give any microcontroller access to your Wi-Fi network.
The ESP8266 is capable of either hosting an application or offloading all Wi-Fi
networking functions from another application processor. Each ESP8266 module comes
pre-programmed with an AT command set firmware, meaning, you can simply hook this
up to your Arguing device and get about as much Wi-Fi-ability as a Wi-Fi Shield offers
(and that’s just out of the box)! The ESP8266 module is an extremely cost effective board
with a huge, and ever growing, community.

This module has a powerful enough on-board processing and storage capability that
allows it to be integrated with the sensors and other application specific devices through
its GPIOs with minimal development up-front and minimal loading during runtime. Its
high degree of on-chip integration allows for minimal external circuitry, including the
front-end module, is designed to occupy minimal PCB area. The ESP8266 supports
APSD for VoIP applications and Bluetooth co-existence interfaces; it contains a self-
calibrated RF allowing it to work under all operating conditions, and requires no external
RF parts.

14
There is an almost limitless fountain of information available for the ESP8266, all of
which has been provided by amazing community support. In the Documents section
below you will find many resources to aid you in using the ESP8266, even instructions on
how to transforming this module into an IoT (Internet of Things) solution!

Note: The ESP8266 Module is not capable of 5-3V logic shifting and will require an
external Logic Level Converter. Please do not power it directly from your 5V dev board.

Note: This new version of the ESP8266 Wi-Fi Module has increased the flash disk size
from 512k to 1MB.

Features:

 802.11 b/g/n
 Wi-Fi Direct (P2P), soft-AP
 Integrated TCP/IP protocol stack
 Integrated TR switch, baling, LNA, power amplifier and matching network
 Integrated PLLs, regulators, DCXO and power management units
 +19.5dBm output power in 802.11b mode
 Power down leakage current of <10uA
 1MB Flash Memory
 Integrated low power 32-bit CPU could be used as application processor
 SDIO 1.1 / 2.0, SPI, UART
 STBC, 1×1 MIMO, 2×1 MIMO
 A-MPDU & A-MSDU aggregation & 0.4ms guard interval
 Wake up and transmit packets in < 2ms
 Standby power consumption of < 1.0mW (DTIM3)

Working

This design is based around 4 main parts. A transformer, bridge rectifier, a smoothing
capacitor and the LM7805 chip which contains a 'linear voltage regulator'.
15
Transformer is used to convert 220 VAC to 18 VAC. Bridge rectifier is used to
convert AC to ripple DC. Capacitor is used to filter ripples from dc. 7805 voltage
regulator is used to regulate voltage to 5 VDC. LED is used for indication power
supply is working or not.

Software used:

Arduino IDE programming microcontroller.

Project modules:

 Module 1: Circuit designing and component selection.

 Module 2: PCB designing and components mounting.

 Module 3: Coding of firmware.

 Module 4: Integration of all module and testing

 Module 5: Documentation.

Action Plan:

S.no Description Date

1 Circuit designing and component selection 30Sep 19

2 PCB designs and components mounting 30oct 19

3 Coding of firmware 15Jan 20

4 Integration of all module 15Feb 20

5 Testing and Documentation 20Feb 20

16
CHAPTER5: TESTING

AVR programming

In this post I will walk you through the steps required to program an AVR chip using the
AVRISP mkII.

Fig7: AVR chip, programmer, adapter, breadboard and power supply

Hardware and Software Required:

Here is a list of things you’ll need

Hardware:

 4.7K resistor
 1k resistor
17
 LED
 AVR Chip: I’ll use the atmega328p
 Programmer: AVRISP mkII
 AVR Programmer Adapter (optional)
 Jumper Wires
 5V Power supply. You can of course use batteries if you prefer.

Software:

 AVR Studio 5

Circuit Set Up:

Simply find the pins in your programmer, match them to the pins in your chip and
connect them. Also connect the resistor from pin 7 to power.

ATmega328p pin out

Now because the programmer doesn’t have one squared hole, or at least mine doesn’t, it
has many, let me show how how that looks in real life, and yes it is like a mirror image of
the image above (weird right?).

18
AVRispmk II holes

Now that we have everything connected…

AVRISP mkII: circuit to program


19
..let’s move on to the software. Check out the picture at the very top of this page to see
how much neater your circuit will be with the programming adapter.

Your First AVR Program

Let me go ahead and walk you through the steps of using AVR Studio 5.

Once you have opened AVR Studio click on File ->New -> Project.

Creating a new project in AVR Studio 5

Name your project, I named mine first program. Now click the OK button.

20
naming your project

Next you will be greeted with an almost blank C file.

21
AVR Studio blank template C file

So what software are we going to write? how about we make an led blinker. Connect an
LED to port C5 of your microcontroller through the 1k resistor and then to ground.

22
red led connected to port C5 (pin 28) of the ATmega328p

Now back to AVR Studio. Replace the text in the file with the following.

1. #include<avr/io.h>
2. #include<avr/delay.h>// has some delay functions you can use
3.
4. int main(void)
5. {
6. DDRC=0xff;// all C ports as output
7. while(1)
8. {
9. //TODO:: Please write your application code
10.
11. PORTC=0xff;// turn on all C porst
12. _delay_ms(200);// wait 200 milliseconds
23
13. PORTC=0x00;// turn off all c ports
14. _delay_ms(200);// wait 200 milliseconds
15.
16.
17. }
18. }

The code that gets uploaded to the microcontroller is actually a HEX file, but we have to
tell AVR Studio to make this file. To do that right click on your project’s name on the
right in the solution explorer window and click on The code that gets uploaded to the
microcontroller is actually a HEX file, but we have to tell AVR Studio to make this file.
To do that right click on your project’s name on the right in the solution explorer window
and click on properties.

24
25
26
27
hex file checkbox, make sure it's checked.
28
Now to actually generate the hex file click Build->Build Solution

avr studio build menuthis will compile the program and generate the hex file we need.

You should not get any errors, as shown below.

program compilation errors no compilation errors Upload The Code to The


Microcontroller

At last, we are done with all the software developing stuff, uploading is just as easy.

Click on Tools->AVR Programming avr studio tools menu

You’ll get the programming window. Make sure that your device is selected.

avr programming window the programming window Now in the following order, click on
the Apply button, then the voltage button (recycling/refresh looking icon) will become
active now click it, you should get some value close to 5 volts. Then click on the Read
button. If you didn’t get any error window you are good to go.

Clicking the Read and Voltage buttons is not necessary actually, but the Apply button
is.avr studio programming window: 5 volts and device idprogramming window after
clicking buttonslastly click on Memories and select your hex file then click Program, the
programmer will start blinking and stop when your program is done uploading.avr studio
memories window, hex file ready to uploadhex file ready for upload

Coding:

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#define RX 2
#define TX 3
String AP = "12345678"; // CHANGE ME
29
String PASS = "12345678"; // CHANGE ME
String API = "NQO35G33EPXE8CQ3";
////String API = "JKITVF78EBWM0TKW"; // CHANGE ME
String HOST = "api.thingspeak.com";
String PORT = "80";

String field1 = "field1";


String field2 = "field2";
String field3 = "field3";

int countTrueCommand;
int countTimeCommand;
boolean found = false;
float valSensor = 1;
SoftwareSerial esp8266(RX,TX);
int sensorValue = 0;
int outputValue = 0;
int sensorValue1 = 0;
int outputValue1= 0;
const int rs = 9, en = 8, d4 = 7, d5 = 6, d6 = 5, d7 = 4;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup()
{
//set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(1, 0);
lcd.print("Air and sound ");
delay(10);
lcd.setCursor(0, 1);
lcd.print("pollution monit..");
delay(1000);
Serial.begin(9600);
esp8266.begin(9600);
sendCommand("AT",5,"OK");
sendCommand("AT+CWMODE=1",5,"OK");
sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}
void loop() {

////////////////////////////////////////////////////////////////////// //FOR AIR QUALITY


// read the analog in value:
sensorValue = analogRead(A0);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
30
// print the results to the Serial Monitor:
// Serial.print("sensor = ");
// Serial.print(sensorValue);
// Serial.print("\t output = ");
// Serial.println(outputValue);
valSensor=sensorValue;
delay(500);
lcd.begin(16 2);
// Print a message to the LCD.
lcd.setCursor(1, 0);
lcd.print("Air quality ");
delay(10);
lcd.setCursor(0, 1);
lcd.print("counts : ");
lcd.print(valSensor);
delay(500);

String getData1 = "GET /update?api_key="+ API +"&"+ field1 +"="+String(valSensor);


sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData1.length()+4),4,">");
esp8266.println(getData1);
delay(1500);
countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");

sensorValue1 = analogRead(A1);
// map it to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 0, 255);
// change the analog out value:

// print the results to the Serial Monitor:


////Serial.print("sensor1 = ");
// Serial.print(sensorValue1);
// Serial.print("\t output1 = ");
// Serial.println(outputValue1);

valSensor=sensorValue1;
delay(500);

lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(1, 0);
lcd.print("Sound intensity ");
delay(10);
lcd.setCursor(0, 1);
lcd.print("counts : ");
lcd.print(valSensor);
31
delay(500);

String getData2 = "GET /update?api_key="+ API +"&"+ field2 +"="+String(valSensor);


sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData2.length()+4),4,">");
esp8266.println(getData2);
delay(1500);
countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}
void sendCommand(String command, int maxTime, char readReplay[]) {
Serial.print(countTrueCommand);
Serial.print(". at command => ");
Serial.print(command);
Serial.print(" ");
while(countTimeCommand < (maxTime*1))
{
esp8266.println(command);//at+cipsend
if(esp8266.find(readReplay))//ok
{
found = true;
break;
}

countTimeCommand++;
}

if(found == true)
{
Serial.println("OYI");
countTrueCommand++;
countTimeCommand = 0;
}

if(found == false)
{
Serial.println("Fail");
countTrueCommand = 0;
countTimeCommand = 0;
}

found = false;
}
32
33
34
CHAPTER 6: ADVANTAGES AND FUTURE SCOPE

 The system can be used to monitor air quality and sound.


 Data can used in researches and data mining.
 It is easy to use safe and reliable.

Disadvantage:

 The device is not water resistant keep away from moisture.


 System may not work during extreme weather condition of IOT.

Future scope:

 In future we will add more accurate sensors for accurate analysis of data.
 We will work on the power supply and replace existing system with solar based
power supply.

35
REFERENCES

1. Augarten, Stan (1983). The Most Widely Used Computer on a Chip: The TMS
1000. State of the Art: A Photographic History of the Integrated Circuit (New
Haven and New York: Ticknor & Fields). ISBN 0-89919-195-9.Retrieved 2009-
12-23.
2. "Oral History Panel on the Development and Promotion of the Intel 8048
Microcontroller" (PDF). Computer History Museum Oral History,
2008.p. 4.Retrieved 2011-06-28.
3. "Atmel’s Self-Programming Flash Microcontrollers" (PDF). 2012-01-24.
Retrieved 2008-10-25.by Odd JosteinSvendsli 2003
4. Jim Turley. "The Two Percent Solution" 2002.
5. Tom Cantrell "Microchip on the March". Circuit Cellar.
1998.http://www.semico.com
6. Momentum Carries MCUs Into 2011 http://semico.com/content/momentum-
carries-mcus-2011
7. "MCU Market on Migration Path to 32-bit and ARM-based Devices". April 25,
2013. It typically takes a global economic recession to upset the diverse

36

You might also like