Professional Documents
Culture Documents
2.iot Based Air Quality Index Monitoring
2.iot Based Air Quality Index Monitoring
2.iot Based Air Quality Index Monitoring
Submitted by
Certified that the candidate was examined by using the Project Viva-Voce examination
Held on _____________
ABSTRACT
As winter sets in, the air hanging over us thickens with smoke and
gaseous emissions from burning fields, industrial factories, and vehicular
traffic, blocking out the sun and making it hard to breathe. Experts say that
the high levels of air pollution and COVID-19 pandemic can be a dangerous
mix that can have serious consequences. The necessity for real-time
monitoring of Air Quality is very glaring. So in this project, we are going
to build an ESP32 Air Quality Monitoring System using Nova PM SDS011
sensor, MQ-7 sensor, and DHT11 sensor. We will also be using an OLED
Display module to display Air Quality Values.
The Air Quality Index (AQI) in India is based on eight pollutants,
PM10, PM2.5, SO2 and NO2, CO, Ozone, NH3, and Pb. However, it is not
necessary to measure all of the pollutants. So we are going to measure the
concentration of PM2.5, PM10, and Carbon Monoxide to calculate the Air
Quality Index. The AQI values will be published on Adafruit IO so that we
can monitor it from anywhere. Previously we have also measured the
concentration of LPG, Smoke, and Ammonia gas using Arduino.
v
ACKNOWLEDGEMENT
convey our sincere thanks and gratitude to the management of our college and our beloved
Chairman Mr. V.NARAYANASAMY, who has provided all the facilities to us.
We would like to express our sincere thanks to our beloved Vice Chairman
for his constructive suggestions & encouragement during our project which leads to the
With deep sense of gratitude, we extend our earnest & sincere thanks to our guide
TABLE OF CONTENTS
CHAPTER PAGE
TITTLE
NO NO
ABSTRACT iv
LIST OF FIGURES viii
LIST OF ABBREVATIONS x
1 INTRODUCTION 1
2 PROPOSED SYSTEM 3
3 BLOCK DIAGRAM 5
4 COMPONENTS DESCRIPTION 7
4.1 POWER SUPPLY 8
4.2 TYPES OF BRIDGE RECTIFIERS 10
4.3 IC VOLTAGE REGULATORS 13
4.3.1 TREE-TERMINAL VOLTAGE REGULATORS 14
4.3.2 FIXED POSITIVE VOLTAGE REGULATORS 14
4.4 TRANSFORMER 15
4.5 ARDUINO 16
4.5.1 HARDWARE 17
4.5.2 ARCHITECTURE 19
4.6 LCD 22
4.7 LED 23
4.8 GAS SENSOR 23
4.9 DHT11 TEMPERATURE AND HUMIDITY SENSOR 25
4.10 SDS 011 SENSOR 26
4.11 CLOUD COMPUTING 28
4.12 INTERNET OF THINGS (IOT) 29
5 CIRCUIT DIAGRAM 31
5.1 CIRCUIT DIAGRAM 32
6 PROGRAM 34
7 SOFTWARE 43
vii
LIST OF FIGURES
FIGURE
TITLE PAGE NO
NO
3.1 Block Diagram 6
4.1.1 Power Supply Diagram 8
4.1.2 Bridge Rectifier Diagram 9
4.2.1 Single Phase & Three Phase Rectifier Diagram 10
4.2.2 Uncontrolled Bridge Rectifier Diagram 10
4.2.3 Controlled Bridge Rectifier Diagram 11
4.2.4 Bridge Rectifier Diagram 12
4.3.2 Fixed Positive Voltage Regulators Diagram 14
4.4.1 Transformer Diagram 15
4.5.1 Arduino Hardware front view 16
4.5.1 (A) Arduino Hardware back view 17
4.5.1 (B) Arduino with serial port 17
4.5.1 C) Arduino Uno R2 with descriptions 19
4.5.2 Arduino Architecture 20
4.6 LCD Diagram 22
4.7 LED Diagram 23
4.8 GAS sensors 24
4.9 DHT11 Sensor 25
4.10.1 SDS 011 Sensor 26
4.10.2 Block Diagram of SDS 011 Sensor 27
4.11 Cloud Computing 28
5.1 Circuit Diagram 33
7.1.1 PCB Board Diagram 45
10.1 Photography 54
ix
LIST OF ABBREVIATIONS
DC - DIRECT CURRENT
AC - ALTERNATING CURRENT
SCR - SILICON CONTROLLER RECTIFIER
METAL–OXIDE–SEMICONDUCTOR FIELD-EFFECT
MOSFET -
TRANSISTOR
IGBT - INSULATED GATE BIPOLAR TRANSISTOR
V - VOLTAGE
PIV - PEAK INVERSE VOLTAGE
D - DIODE
IC - INTEGRATED CIRCUIT
VI - INPUT VOLTAGE
VO - OUTPUT VOLTAGE
GND - GROUND
IN - INPUT
OU - OUTPUT
PIC - PERIPHERAL INTERFACE CONTROLLER
CPU - CENTRAL PROCESSING UNIT
RISC - REDUCED INSTRUCTION SET COMPUTER
MHZ - MEGA HERTZ
RAM - RANDOM ACCESS MEMORY
MA - MICRO AMPS
PWM - PULSE WITH MODULATION
CCP - CAPTURE, COMPARE, PULSE WITH MODULATION
SSP - SYNCHRONOUS SERIAL PORT
BOR - BROWN-OUT RESET
POR - POWER-ON RESET
PWRT - POWER-UP TIMER
x
2
CHAPTER – 2
PROPOSED SYSTEM
3
2.1 PROPOSED SYSTEM
Temperature & humidity sensor, the production count circuit,
illumination intensity circuit and power consumption circuit are used to percept
the environment and object conditions. Analog signals are provided to Arduino
device produced by sensors and circuits. The digital equivalent of these signals
is transmitted to the database server by virtue of the Wi-Fi module interfaced
with the Arduino. The data stored on the database server is transferred to the
website time to time and the status of the alarm is checked continuously for any
uneven conditions observed by the industry person on the website. Then
adequate steps can be taken to solve the problems. This can be possible through
past experience and similar previous condition stored in database. In this we use
LAN as database for scalability. The industry person who will check the status
of the industry through the website will have to login using a user id and
password to get access to the website, this ensures security of the data.
4
CHAPTER – 3
BLOCK DIAGRAM
5
3.1 BLOCK DIAGRAM
6
CHAPTER – 4
COMPONENTS DESCRIPTION
7
4.1 POWER SUPPLY
A power supply is an electronic device that supplies electric energy to
an electrical load. The primary function of a power supply is to convert one
form of electrical energy to another and, as a result, power supplies are
sometimes referred to as electric power converters. Some power supplies are
discrete, stand-alone devices, whereas others are built into larger devices along
with their loads. Examples of the latter include power supplies found in desktop
computers and consumer electronics devices.
Every power supply must obtain the energy it supplies to its load, as well
as any energy it consumes while performing that task, from an energy source.
Depending on its design, a power supply may obtain energy from various types
of energy sources, including electrical energy transmission systems, energy
storage devices such as a batteries and fuel cells, electromechanical systems
such as generators and alternators, solar power converters, or another power
supply.
8
Bridge Rectifier Circuit with Working Operation and Their Types A
bridge rectifier circuit is a common part of the electronic power supplies. Many
electronic circuits require rectified DC power supply for powering the various
electronic basic components from available AC mains supply. We can find this
rectifier in a wide variety of electronic AC power devices like home appliances,
motor controllers, modulation process, welding applications, etc.
10
This bridge rectifier uses diodes for rectifying the input as shown in the
figure. Since the diode is a unidirectional device that allows the current flow in
one direction only. With this configuration of diodes in the rectifier, it doesn’t
allow the power to vary depending on the load requirement. So this type of
rectifier is used in constant or fixed power supplies.
11
regulators. Generally all these blocks combination is called as regulated DC
power supply that powers various electronic appliances.
The first stage of the circuit is a transformer which is a step-down type that
changes the amplitude of the input voltage. Most of the electronic projects uses
230/12V transformer to step-down the AC mains 230V to 12V AC supply.
12
Bridge Rectifier Operation
As we discussed above, a single-phase bridge rectifier consists of four
diodes and this configuration is connected across the load. For understanding
the bridge rectifier’s working principle, we have to consider the below circuit
for demonstration purpose. During the Positive half cycle of the input AC
waveform diodes D1 and D2 are forward biased and D3 and D4 are reverse
biased. When the voltage, more than the threshold level of the diodesD1 and
D2, starts conducting – the load current starts flowing through it, as shown as
red lines path in the diagram below.
13
4.3.1 TREE-TERMINAL VOLTAGE REGULATORS
Fig shows the basic connection of a three-terminal voltage regulator IC to
load. The fixed voltage regulator has on unregulated DC input voltage, VI,
applied to one input terminal, a regulator output DC voltage, VO, from a second
terminal, with the third terminal connected to ground.
For a selected regulator, IC device specifications list a voltage range over
which the input voltage can vary to maintain a regulator output voltage over a
range of load current. The specification also lists the amount of output voltage
change resulting from a change in load current (load regulator) or in input
voltage
14
4.4 TRANSFORMER
A transformer is a static electrical device that transfers electrical energy
between two or more circuits. A varying current in one coil of the transformer
produces a varying magnetic flux, which, in turn, induces a varying
electromotive force across a second coil wound around the same core. Electrical
energy can be transferred between the two coils, without a metallic connection
between the two circuits. Faraday's law of induction discovered in 1831
described the induced voltage effect in any coil due to changing magnetic flux
encircled by the coil.
16
cost and easy way for novices and professionals to create devices that interact
with their environment using sensors and actuators.
4.5.1 HARDWARE
17
An early Arduino board with an RS-232 serial interface (upper left) and
an Atmel ATmega8 microcontroller chip (black, lower right); the 14 digital I/O
pins are at the top, the 6 analog input pins at the lower right, and the power
connector at the lower left.
Most Arduino boards consist of an Atmel 8-bit AVR
microcontroller (ATmega8, ATmega168, ATmega328, ATmega1280,
ATmega2560) with varying amounts of flash memory, pins, and features. The
32-bit Arduino Due, based on the Atmel SAM3X8E was introduced in
2012. The boards use single or double-row pins or female headers that facilitate
connections for programming and incorporation into other circuits. These may
connect with add-on modules termed shields. Multiple and possibly stacked
shields may be individually addressable via an I²C serial bus. Most boards
include a 5 V linear regulator and a 16 MHz crystal oscillator or ceramic
resonator. Some designs, such as the LilyPad, run at 8 MHz and dispense with
the onboard voltage regulator due to specific form-factor restrictions.
Arduino microcontrollers are pre-programmed with a boot loader that
simplifies uploading of programs to the on-chip flash memory. The default
bootloader of the Arduino UNO is the optiboot bootloader. Boards are loaded
with program code via a serial connection to another computer. Some serial
Arduino boards contain a level shifter circuit to convert between RS-232 logic
levels and transistor–transistor logic (TTL) level signals. Current Arduino
boards are programmed via Universal Serial Bus (USB), implemented using
USB-to-serial adapter chips such as the FTDI FT232. Some boards, such as
later-model Uno boards, substitute the FTDI chip with a separate AVR chip
containing USB-to-serial firmware, which is reprogrammable via its
own ICSP header. Other variants, such as the Arduino Mini and the unofficial
Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or
other methods. When used with traditional microcontroller tools, instead of the
18
Arduino IDE, standard AVR in-system programming (ISP) programming is
used.
The Arduino board exposes most of the microcontroller's I/O pins for use
by other circuits. The Diecimila, Duemilanove, and current Uno provide 14
digital I/O pins, six of which can produce pulse-width modulated signals, and
six analog inputs, which can also be used as six digital I/O pins. These pins are
on the top of the board, via female 0.1-inch (2.54 mm) headers. Several plug-in
application shields are also commercially available. The Arduino Nano, and
Arduino-compatible Bare Bones Board and Boarduino boards may provide
male header pins on the underside of the board that can plug into
solderless breadboards.
4.5.2 ARCHITECTURE
Here Architecture is of Arduino or precisely the IC of Arduino
(ATmega328p). The ATmega328/P is a low-power CMOS 8-bit microcontroller
19
based on the AVR® enhanced RISC (reduced instruction set computer)
architecture. In Order to maximize performance and parallelism, the AVR
uses Harvard architecture – with separate memories and buses for program and
data. Instruction in the program memory are executed with a single level of
pipelining. The clock is controlled by an external 16MHz Crystal Oscillator.
20
functions.
4. EEPROM stores data permanently even if the power is cut out.
Programming inside a EEPROM is slow.
5. Interrupt Unit checks whether there is an interrupt for the execution of
instruction to be executed in ISR (Interrupt Service Routine).
6. Serial Peripheral Interface (SPI) is an interface bus commonly used to send
data between microcontrollers and small peripherals such as Camera, Display,
SD cards, etc. It uses separate clock and data lines, along with a select line to
choose the device you wish to talk to.
7. Watchdog timer is used to detect and recover from MCU malfunctioning.
8. Analog comparator compares the input values on the positive and negative
pin, when the value of positive pin is higher the output is set.
9. Status and control are used to control the flow of execution of commands by
checking other blocks inside the CPU at regular intervals.
10. ALU (Arithmetic and Logical unit) The high performance AVR ALU
operates in direct connection with all the 32 general purpose working registers.
Within a single clock cycle, arithmetic operations b/w general purpose registers
are executed. The ALU operations are divided into 3 main categories –
arithmetic, logical and bit-function.
11. I/O pins The digital inputs and outputs (digital I/O) on the Arduino are what
allow you to connect the Arduino sensors, actuators, and other ICs. Learning
how to use them will allow you to use the Arduino to do some really useful
things, such as reading switch inputs, lighting indicators, and controlling relay
outputs.
EXTRA:
1. Automatic (Software) Reset: Rather than requiring a physical press of the
reset button before an upload, the Arduino is designed in a way that allows it to
be reset by software running on a connected computer. The Arduino Software
(IDE) uses this capability to allow you to upload code by simply pressing the
21
upload button in the Arduino environment. This means that the bootloader can
have a shorter timeout, as the lowering of DTR (Data Terminal Ready) can be
well-coordinated with the start of the upload.
2.Firmware: Firmware is a software program or set of instructions
programmed on a hardware device. It provides the necessary instructions for
how the device communicates with the other computer hardware. Firmware is
held in non-volatile memory devices such as ROM.
3.To check whether the firmware is installed in your Arduino or not just press
the reset button and if the inbuilt LED flickers (on pin 13) the firmware is
present.
4.6 LCD
A liquid-crystal display (LCD) is a flat panel display, electronic visual
display, or video display that uses the light modulating properties of liquid
crystals. Liquid crystals do not emit light directly. LCDs are available to display
arbitrary images (as in a general-purpose computer display) or fixed images
which can be displayed or hidden, such as preset words, digits, and 7-segment
displays as in a digital clock. They use the same basic technology, except that
arbitrary images are made up of a large number of small pixels, while other
displays have larger elements.
22
LCDs are used in a wide range of applications including computer
monitors, televisions, instrument panels, aircraft cockpit displays, and signage.
They are common in consumer devices such as DVD players, gaming devices,
clocks, watches, calculators, and telephones, and have replaced cathode ray tube
(CRT) displays in most applications. The LCD screen is more energy efficient
and can be disposed of more safely than a CRT. Its low electrical power
consumption enables it to be used in battery-powered electronic equipment.
4.7 LED
A light-emitting diode (LED) is a two-lead semiconductor light source. It
is a pn-junction diode, which emits light when activated.]When a suitable
voltage is applied to the leads, electrons are able to recombine with electron
holes within the device, releasing energy in the form of photons. This effect is
called electroluminescence, and the color of the light (corresponding to the
energy of the photon) is determined by the energy band gap of the
semiconductor.
23
also sensitive to smoke and other harmful gases. It is with low cost and
particularly suitable for Air quality monitoring application.
24
4.9 DHT11 (TEMPERATURE AND HUMIDITY SENSOR)
This DHT11 Temperature and Humidity Sensor features a calibrated
digital output temperature and humidity sensor module. Its technology ensures
high reliability and excellent long-term stability. A high-performance 8-bit
microcontroller is connected. This sensor includes a resistive element and wet
NTC temperature measuring devices. It has excellent quality, fast response,
anti-interference ability and high cost performance advantages.
25
4.10 SDS 011 (AIR QUALITY MONITORING SENSOR)
The SDS 011 Sensor is a quite recent Air Quality Sensor developed
by Nova Fitness, a spin-off from the university of Jinan (in Shandong). With its
size, it is probably one of the best sensor in terms of accuracy: While other
sensors tend to focus on shrinking the sensor size, the SDS 011 has opted for a
size tradeoff allowing it to use a larger fan. And the larger the fan, the better the
quality. The clever engineering in the SD011 is to use the PCB as one side of
the casing (allowing to reduce the BOM cost). The diode is mounted on the
PCB side (this is mandatory as any noise between the doide and the LNA
should be avoided). The laser mounted on the plastic box and connected to the
PCB via flying wire.
26
This is the specification for the SDS011. One should not consider all those
values for granted as there is quite often a big difference between what is said to
be possible and what is actually possible (and this is why we are setting up all
our experiments).
28
unpredictable demand, providing the burst computing capability: high
computing power at certain periods of peak demand.
Cloud providers typically use a "pay-as-you-go" model, which can lead to
unexpected operating expenses if administrators are not familiarized with cloud-
pricing models. The availability of high-capacity networks, low-cost computers
and storage devices as well as the widespread adoption of hardware
virtualization, service-oriented architecture and autonomic and utility computing has led
to growth in cloud computing. By 2019, Linux was the most widely used
operating system, including in Microsoft's offerings and is thus described as
dominant. The Cloud Service Provider (CSP) will screen, keep up and gather
data about the firewalls, intrusion identification or/and counteractive action
frameworks and information stream inside the network.
30
CHAPTER – 5
CIRCUIT DIAGRAM
31
5.1 CIRCUIT DIAGRAM
The Arduino UNO is a widely used open-source microcontroller board
based on the ATmega328P microcontroller and developed by Arduino.cc. The
board is equipped with sets of digital and analog input/output (I/O) pins that
may be interfaced to various expansion boards (shields) and other circuits. The
board features 14 Digital pins and 6 Analog pins. It is programmable with the
Arduino IDE (Integrated Development Environment) via a type B USB cable. It
can be powered by a USB cable or by an external 9 volt battery, though it
accepts voltages between 7 and 20 volts. Wi-Fi Module (ESP8266) ESP8266
offers a complete and self-contained Wi-Fi networking solution, allowing it to
either host the application or to offload all Wi-Fi networking functions from
another application processor. When ESP8266 hosts the application, and when
it is the only application processor in the device, it is able to boot up directly
from an external flash.
It has integrated cache to improve the performance of the system in such
applications, and to minimize the memory requirements. Temperature &
Humidity Sensor (DHT11) This DHT11 Temperature & Humidity Sensor
features a temperature & humidity sensor complex with a calibrated digital
signal output. By using the exclusive digital-signal-acquisition technique and
temperature & humidity sensing technology, it ensures high reliability and
excellent long-term stability. This sensor includes a resistive-type humidity
measurement component and an NTC temperature measurement component,
and connects to a high performance 8-bit microcontroller, offering excellent
quality, fast response, anti-interference ability and cost-effectiveness.
32
Figure No. 5.1 Circuit Diagram
33
CHAPTER – 6
PROGRAM
34
6.1 PROGRAM
#include <SDS011.h>
#include <SPI.h>
#include <WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "DHT.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "esp32-hal-adc.h" // needed for adc pin reset
#include "soc/sens_reg.h" // needed for adc pin reset
uint64_t reg_b; // Used to store Pin registers
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI 23
#define OLED_CLK 18
#define OLED_DC 4
#define OLED_CS 5
#define OLED_RESET 2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
const int numReadingsPM10 = 24;
const int numReadingsPM25 = 24;
const int numReadingsCO = 8;
WiFiClient client;
SDS011 my_sds;
const char *ssid = "Galaxy-M20"; // Enter your WiFi Name
const char *pass = "ac312124"; // Enter your WiFi Password
#define MQTT_SERV "io.adafruit.com"
#define MQTT_PORT 1883
#define MQTT_NAME "choudharyas" // Your Adafruit IO Username
#define MQTT_PASS "988c4e045ef64c1b9bc8b5bb7ef5f2d9" // Adafruit IO AIO key
#define DHTTYPE DHT11 // DHT 11
uint8_t DHTPin = 27;
35
DHT dht(DHTPin, DHTTYPE);
int error;
unsigned long interval = 3600000;
unsigned long previousMillis = 0;
int temperature, humidity, AQI;
float p10,p25;
int iMQ7 = 25;
int MQ7Raw = 0;
int MQ7ppm = 0;
double RvRo;
int ConcentrationINmgm3;
int readingsPM10[numReadingsPM10]; // the readings from the analog input
int readIndexPM10 = 0; // the index of the current reading
int totalPM10 = 0; // the running total
int averagePM10 = 0; // the average
int readingsPM25[numReadingsPM25]; // the readings from the analog input
int readIndexPM25 = 0; // the index of the current reading
int totalPM25 = 0; // the running total
int averagePM25 = 0; // the average
int readingsCO[numReadingsCO]; // the readings from the analog input
int readIndexCO = 0; // the index of the current reading
int totalCO = 0; // the running total
int averageCO = 0; // the average
Adafruit_MQTT_Client mqtt(&client, MQTT_SERV, MQTT_PORT, MQTT_NAME, MQTT_PASS);
Adafruit_MQTT_Publish AirQuality = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/AirQuality");
Adafruit_MQTT_Publish Temperature = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/Temperature");
Adafruit_MQTT_Publish Humidity = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME
"/f/Humidity");
Adafruit_MQTT_Publish PM10 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME "/f/PM10");
Adafruit_MQTT_Publish PM25 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME "/f/PM25");
Adafruit_MQTT_Publish CO = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME "/f/CO");
//Adafruit_MQTT_Publish NH3 = Adafruit_MQTT_Publish(&mqtt,MQTT_NAME "/f/NH3");
void setup()
{
my_sds.begin(16,17);
36
Serial.begin(9600);
dht.begin();
display.begin(SSD1306_SWITCHCAPVCC);
delay(10);
pinMode(DHTPin, INPUT);
pinMode(iMQ7, INPUT);
Serial.println("Connecting to ");
Serial.println(ssid);
reg_b = READ_PERI_REG(SENS_SAR_READ_CTRL2_REG);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(550);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
for (int thisReading1 = 0; thisReading1 < numReadingsPM10; thisReading1++) {
readingsPM10[thisReading1] = 0;
}
for (int thisReading2 = 0; thisReading2 < numReadingsPM25; thisReading2++) {
readingsPM25[thisReading2] = 0;
}
for (int thisReading3 = 0; thisReading3 < numReadingsCO; thisReading3++) {
readingsCO[thisReading3] = 0;
}
display.clearDisplay();
display.display();
}
void loop()
{
unsigned long currentMillis = millis();
MQTT_connect();
if ((unsigned long)(currentMillis - previousMillis) >= interval) {
WRITE_PERI_REG(SENS_SAR_READ_CTRL2_REG, reg_b);
MQ7Raw = analogRead( iMQ7 );
37
Serial.print("MQ Raw: ");
Serial.println(MQ7Raw);
RvRo = MQ7Raw * (3.3 / 4095);
MQ7ppm = 3.027*exp(1.0698*( RvRo ));
Serial.print("CO: ");
Serial.println(MQ7ppm);
//Serial.println();
error = my_sds.read(&p25,&p10);
if (! error) {
Serial.println("P2.5: "+String(p25));
Serial.println("P10: "+String(p10));
}
}
temperature = dht.readTemperature();
humidity = dht.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println();
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println();
ConcentrationINmgm3 = MQ7ppm* (28.06/24.45); //Converting PPM to mg/m3. Where
28.06 is Molecular mass of CO and 24.45 is the Molar volume
Serial.print("mg/m3: "); // for more inforation on this follow:
https://www.markes.com/Resources/Frequently-asked-questions/How-do-I-convert-
units.aspx
Serial.println(ConcentrationINmgm3);
totalPM10 = totalPM10 - readingsPM10[readIndexPM10];
readingsPM10[readIndexPM10] = p10;
totalPM10 = totalPM10 + readingsPM10[readIndexPM10];
readIndexPM10 = readIndexPM10 + 1;
if (readIndexPM10 >= numReadingsPM10) {
readIndexPM10 = 0;
}
averagePM10 = totalPM10 / numReadingsPM10;
Serial.print("PM10 Average: ");
Serial.println(averagePM10);
38
totalPM25 = totalPM25 - readingsPM25[readIndexPM25];
readingsPM25[readIndexPM25] = p25;
totalPM25 = totalPM25 + readingsPM25[readIndexPM25];
readIndexPM25 = readIndexPM25 + 1;
if (readIndexPM25 >= numReadingsPM25) {
readIndexPM25 = 0;
}
averagePM25 = totalPM25 / numReadingsPM25;
Serial.print("PM2.5 Average: ");
Serial.println(averagePM25);
totalCO = totalCO - readingsCO[readIndexCO];
readingsCO[readIndexCO] = ConcentrationINmgm3;
totalCO = totalCO + readingsCO[readIndexCO];
readIndexCO = readIndexCO + 1;
if (readIndexCO >= numReadingsCO) {
readIndexCO = 0;
}
averageCO = totalCO / numReadingsCO;
Serial.print("CO Average: ");
Serial.println(averageCO);
if (averagePM10 > averagePM25){
AQI = averagePM10;
}
else {
AQI = averagePM25;
}
if (! Temperature.publish(temperature))
{
delay(30000);
}
if (! Humidity.publish(humidity))
{
delay(30000);
}
if (! PM10.publish(averagePM10))
{
39
delay(30000);
}
if (! PM25.publish(averagePM25))
{
delay(30000);
}
if (! CO.publish(MQ7ppm))
{
delay(30000);
}
if (! AirQuality.publish(AQI))
{
delay(30000);
}
displayvalues();
delay(10000);
//delay(3000);
}
void displayvalues()
{
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,15);
display.println("CO: ");
display.setCursor(40,15);
display.println(averageCO);
display.setTextSize(1);
display.setCursor(68,35);
display.println("mg/m3");
display.display();
delay(2000);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,5);
display.println("Temp:");
display.setCursor(75,5);
40
display.println(temperature);
display.setCursor(101,5);
display.println("C");
display.setCursor(0,28);
display.println("Humid:");
display.setCursor(75,28);
display.println(humidity);
display.setCursor(101,28);
display.println("%");
display.display();
display.clearDisplay();
delay(2000);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,5);
display.println("PM2.5: ");
display.setCursor(75,5);
display.println(averagePM25);
display.setCursor(0,28);
display.println("PM10: ");
display.setCursor(75,28);
display.println(averagePM10);
display.setTextSize(1);
display.setCursor(90,49);
display.println("ug/m3");
display.display();
delay(2000);
}
void MQTT_connect()
{
int8_t ret;
// Stop if already connected.
if (mqtt.connected())
{
return;
}
41
uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) // connect will return 0 for connected
{
mqtt.disconnect();
delay(5000); // wait 5 seconds
retries--;
if (retries == 0)
{
// basically die and wait for WDT to reset me
while (1);
}
}
}
42
CHAPTER – 7
SOFTWARE
43
7.1 PCB DESIGN
A printed circuit board (PCB) mechanically supports and electrically
connects electronic components or electrical components using conductive
tracks, pads and other features etched from one or more sheet layers of copper
laminated onto and/or between sheet layers of a non-conductive substrate.
Components are generally soldered onto the PCB to both electrically connect
and mechanically fasten them to it. Printed circuit boards are used in all but the
simplest electronic products. They are also used in some electrical products,
such as passive switch boxes.
Alternatives to PCBs include wire wrap and point-to-point construction,
both once popular but now rarely used. PCBs require additional design effort to
layout the circuit, but manufacturing and assembly can be automated.
Specialized CAD software is available to do much of the work of layout. Mass-
producing circuits with PCBs is cheaper and faster than with other wiring
methods, as components are mounted and wired in one operation. Large
numbers of PCBs can be fabricated at the same time, and the layout only has to
be done once. PCBs can also be made manually in small quantities, with
reduced benefits.
PCBs can be single-sided (one copper layer), double-sided (two copper
layers on both sides of one substrate layer), or multi-layer (outer and inner
layers of copper, alternating with layers of substrate). Multi-layer PCBs allow
for much higher component density, because circuit traces on the inner layers
would otherwise take up surface space between components. The rise in
popularity of multilayer PCBs with more than two, and especially with more
than four, copper planes was concurrent with the adoption of surface mount
technology. However, multilayer PCBs make repair, analysis, and field
modification of circuits much more difficult and usually impractical.
A basic PCB consists of a flat sheet of insulating material and a layer of
copper foil, laminated to the substrate. Chemical etching divides the copper into
44
separate conducting lines called tracks or circuit traces, pads for connections,
visa to pass connections between layers of copper, and features such as solid
conductive areas for EM shielding or other purposes. The tracks function as
wires fixed in place, and are insulated from each other by air and the board
substrate material. The surface of a PCB may have a coating that protects the
copper from corrosion and reduces the chances of solder shorts between traces
or undesired electrical contact with stray bare wires. For its function in helping
to prevent solder shorts, the coating is called solder resist. A printed circuit
board can have multiple copper layers. A two-layer board has copper on both
sides; boards sandwich additional copper layers between layers of insulating
material. Conductors on different layers are connected with visas, which are
copper-plated holes that function as electrical tunnels through the insulating
substrate. Through-hole component leads sometimes also effectively function as
After two-layer PCBs, the next step up is usually four-layer. Often two layers
are dedicated as power supply and ground planes, and the other two are used for
signal wiring between components.
45
component footprints increased efficiency. Traces were made with self-adhesive
Tape. Pre-printed non-reproducing grids on the assisted in layout. The finished
was onto a photoresist coating on the blank copper-clad boards. Modern PCBs
are designed with dedicated layout software, generally in the following steps:
1. Schematic capture through an electronic design automation (EDA) tool.
2. Card dimensions and template are decided based on required circuitry and
case of the PCB.
3. The positions of the components and heat sinks are determined.
4. Layer stack of the PCB is decided, with one to tens of layers depending on
complexity. Ground and power planes are decided. A power plane is the
5. Counterpart to a ground plane and behaves as an AC signal ground while
providing DC power to the circuits mounted on the PCB. Signal
interconnections are traced on signal planes. Signal planes can be on the outer
as well as inner layers. For optimal EMI performance high frequency signals are
routed in internal layers between power or ground planes.
6. Line impedance is determined using dielectric layer thickness, routing copper
thickness and trace-width. Trace separation is also taken into account in case of
differential signals. Micro strip, strapline or dual strip line can be used to route
signals.
7. Components are placed. Thermal considerations and geometry are taken into
account. Visa and lands are marked.
8. Signal traces are routed. Electronic design automation tools usually create
clearances and connections in power and ground planes automatically.
9. Gerber files are generated for manufacturing.
7.3 SOFTWARE
A program for Arduino hardware may be written in any programming
language with compilers that produce binary machine code for the target
processor. Atmel provides a development environment for their 8-bit AVR and
46
32-bit ARM Cortex-M based microcontrollers: AVR Studio (older) and Atmel
Studio (newer).
7.3.1 IDE
The Arduino integrated development environment (IDE) is a cross-
platform application (for Windows, macOS, Linux) that is written in the
programming language Java. It originated from the IDE for the
languages Processing and Wiring. It includes a code editor with features such as
text cutting and pasting, searching and replacing text, automatic
indenting, brace matching, and syntax highlighting, and provides simple one-
click mechanisms to compile and upload programs to an Arduino board. It also
contains a message area, a text console, a toolbar with buttons for common
functions and a hierarchy of operation menus. 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. 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.
48
CHAPTER – 8
CONCLUSION
49
8.1 CONCLUSION
With the advancement in technology, it is expected that the availability of
internet is everywhere. We are developing an industrial application using
internet of things (IOT) technology. In this project we have proposed to provide
an application for air monitoring and to inform the responsible person to take
appropriate measures. This project aims to serve as an efficient backbone for
achieving a network of sensors and actuators which can help for improving the
performance of the day to day activities of the society.
50
CHAPTER – 9
BIBLIOGRAPHY
51
9.1 BIBLIOGRAPHY
[1].Ashwini Deshpande, Prajakta Pitale, Sangita Sanap, “Industrial Automation
using Internet of Things (IOT)”, IJARCET Volume 5 Issue 2, February 2016.
[2]. Geetesh Chaudhari, Sudarshan Jadhav, Sandeep Batule, Sandeep Helkar,
“Industrial Automation using Sensing based Applications for Internet of
Things”, IARJSET Vol. 3, Issue 3, March 2016.
[3]. Keyur K. Patel, Sunil Patel, “IOT Based Data Logger for Monitoring and
Controlling Equipment Working Status and Environmental Conditions”,
IJIRCCE Vol. 4, Issue 4, April 2016.
[4]. Mahesh Jivanii, Sharon Panth, “Wireless IEEE 802.11 Based Device
Control Ad-Hoc Network Using Responsive Web Design (RWD)”, IJ-ETA-
ETS Volume 7 Issue 1, Jan‟14 – Jun‟14.
[5]. IoT: https://dzone.com/articles/the-internet-of-thingsgateways -and-next-
generation.
52
CHAPTER – 10
PHOTO GRAPHY
53
10.1 PHOTO GRAPHY
54
CHAPTER – 11
PROJECT ESTIMATION
55
11.1 PROJECT ESTIMATION
Arduino 01 Rs.550
IOT 01 Rs.1,500
56
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of P.LOGANATHAN (Reg. No. 22309010),
M.LOGESHWARAN (Reg. No. 22309011), S.NISHANTH (Reg. No. 22309013),
N.RAMAKRISHNAN (Reg. No. 22309017), C.SRIDHAR (Reg. No. 22309024),
S.SUJITH (Reg. No. 22309027) who carried out the work under my supervision.
Certified further that to the best of my knowledge the work reported here in does not
form part of any other thesis or dissertation on the basis of which a degree or award
was conferred on an earlier occasion on this or any other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of N.RAMAKRISHNAN (Reg. No. 22309017) who
carried out the work under my supervision. Certified further that to the best of my
knowledge the work reported here in does not form part of any other thesis or
dissertation on the basis of which a degree or award was conferred on an earlier
occasion on this or any other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of S.NISHANTH (Reg. No. 22309013) who carried out
the work under my supervision. Certified further that to the best of my knowledge the
work reported here in does not form part of any other thesis or dissertation on the
basis of which a degree or award was conferred on an earlier occasion on this or any
other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of M.LOGESHWARAN (Reg. No. 22309011) who
carried out the work under my supervision. Certified further that to the best of my
knowledge the work reported here in does not form part of any other thesis or
dissertation on the basis of which a degree or award was conferred on an earlier
occasion on this or any other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of P.LOGANATHAN (Reg. No. 22309010) who
carried out the work under my supervision. Certified further that to the best of my
knowledge the work reported here in does not form part of any other thesis or
dissertation on the basis of which a degree or award was conferred on an earlier
occasion on this or any other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of S.SUJITH (Reg. No. 22309027) who carried out the
work under my supervision. Certified further that to the best of my knowledge the
work reported here in does not form part of any other thesis or dissertation on the
basis of which a degree or award was conferred on an earlier occasion on this or any
other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,
ii
iii
BONAFIDE CERTIFICATE
Certified that this Report titled “IOT BASED AIR QUALITY INDEX
MONITORING SYSTEM – MONITOR PM2.5, PM10, AND CO USING NODE
MCU” is the bonafide work of C.SRIDHAR (Reg. No. 22309024) who carried out
the work under my supervision. Certified further that to the best of my knowledge the
work reported here in does not form part of any other thesis or dissertation on the
basis of which a degree or award was conferred on an earlier occasion on this or any
other candidate.
Signature of the Guide with date Signature of the HOD with date
Ms.AMIRTHAMADHURI, M.E., Mr.P. THIRUMOORTHY M.E.,