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

ABSTRACT

Recent aggressive scientific and technological developments all these focus on a global
environmental issue considering air quality system, reveals the fact that India is facing
severe health hazards. In recent reports, more than 10 cities in India are listed on top. The
air quality index (AQI) in India launched in 2014 under Swachh Bharat Abhiyan
monitors air pollution on 10 scales ranging from low (green) to moderate (yellow) to
serious (red) through data analysis of various air contaminating matters like pm 2.5, O3,
NO2, SO2, CO. The present project develops an Internet of Things (IoT) that enabled air
quality monitoring system mobile in nature analyzing real-time surrounding data
measuring Carbon Monoxide, Smoke and PM level. The system can measure local area
air contamination and generate analyzed data based on which it alerts the people through
a buzzer device integrated into the system. The user-friendly and easy handling of the
system technology is such that it can be installed in houses and in small places.
Implementation of sensor module and other communication environment gives the proper
information.
Keywords: STM, AQI, IoT, MQ2, Air Monitoring, Air Quality Monitoring System
Objective:
1. To design and develop real time monitoring air quality index (AQI) in India t.
2. To develop statistical model for improving air quality in India.

1
CHAPTER-1
INTRODUCTION
1.1 INTRODUCTION TO EMBEDDED SYSTEM
An embedded system is a special-purpose computer system designed to perform
one or a few dedicated functions, sometimes with real-time computing constraints. It is
usually embedded as part of a complete device including hardware and mechanical parts.
In contrast, a general-purpose computer, such as a personal computer, can do many
different tasks depending on programming. Embedded systems have become very
important today as they control many of the common devices we use. Since the
embedded system is dedicated to specific tasks, design engineers can optimize it,
reducing the size and cost of the product, or increasing the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.
Physically embedded systems range from portable devices such as digital watches
and MP3 players, to large stationary installations like traffic lights, factory controllers, or
the systems controlling nuclear power plants. In general, "embedded system" is not an
exactly defined term, as many systems have some element of programmability. For
example, Handheld computers share some elements with embedded systems — such as
the operating systems and microprocessors which power them — but are not truly
embedded systems, because they allow different applications to be loaded and peripherals
to be connected. An embedded system is some combination of computer hardware and
software, either fixed in capability or programmable, that is specifically designed for a
particular kind of application device. Industrial machines, automobiles, medical
equipment, cameras, household appliances, airplanes, vending machines, and toys (as
well as the more obvious cellular phone and PDA) are among the myriad possible hosts
of an embedded system. Embedded systems that are programmable are provided with a
programming interface, and embedded systems programming is a specialized occupation.
Certain operating systems or language platforms are tailored for the embedded
market, such as Embedded Java and Windows XP Embedded. However, some low-end
consumer products use very inexpensive microprocessors and limited storage, with the
application and operating system both part of a single program. The program is written

2
permanently into the system's memory in this case, rather than being loaded into RAM
(random access memory), as programs on a personal computer.

1.2 APPLICATIONS OF EMBEDDED SYSTEM


We are living in the Embedded World. You are surrounded with many embedded
products and your daily life largely depends on the proper functioning of these gadgets.
Television, Radio, CD player of your living room, Washing Machine or Microwave Oven
in your kitchen, Card readers, Access Controllers, Palm devices of your work space
enable you to do many of your tasks very effectively. Apart from all these, many
controllers embedded in your car take care of car operations between the bumpers and
most of the times you tend to ignore all these controllers.
In recent days, you are showered with variety of information about these
embedded controllers in many places. All kinds of magazines and journals regularly dish
out details about latest technologies, new devices; fast applications which make you
believe that your basic survival is controlled by these embedded products. Now you can
agree to the fact that these embedded products have successfully invaded into our world.
You must be wondering about these embedded controllers or systems.
The computer you use to compose your mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.
You need to install the relevant software to get the required processing facility. So,
these desktop computers can do many things. In contrast, embedded controllers carryout
a specific work for which they are designed. Most of the time, engineers design these
embedded controllers with a specific goal in mind. So these controllers cannot be used in
any other place.
Theoretically, an embedded controller is a combination of a piece of
microprocessor based hardware and the suitable software to undertake a specific task.
These days designers have many choices in microprocessors/microcontrollers.
Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an
experienced designer. Selecting a right microprocessor may turn out as a most difficult
first step and it is getting complicated as new devices continue to pop-up very often.

3
In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to
develop something new based on this particular architecture. Even after 25 years of
existence, semiconductor manufacturers still come out with some kind of device using
this 8031 core.

1.3 MICROCONTROLLERS FOR EMBEDDED SYSTEMS


In the Literature discussing microprocessors, we often see the term Embedded
System. Microprocessors and Microcontrollers are widely used in embedded system
products. An embedded system product uses a microprocessor (or Microcontroller) to do
one task only. A printer is an example of embedded system since the processor inside it
performs one task only; namely getting the data and printing it. Contrast this with a
Pentium based PC. A PC can be used for any number of applications such as word
processor, print-server, bank teller terminal, Video game, network server, or Internet
terminal. Software for a variety of applications can be loaded and run. Of course the
reason a pc can perform myriad tasks is that it has RAM memory and an operating
system that loads the application software into RAM memory and lets the CPU run it.
In an Embedded system, there is only one application software that is typically
burned into ROM. An x86 PC contains or is connected to various embedded products
such as keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse,
and so on. Each one of these peripherals has a Microcontroller inside it that performs
only one task. For example, inside every mouse there is a Microcontroller to perform the
task of finding the mouse position and sending it to the PC.
CHAPTER-2
2.1 INTRODUCTION
The worldwide ongoing projects to mitigate environmental problems at present
are focusing more on the clean energy resources in order to meet the UN SDG goals to
cut down air pollution and improve the air quality to provide a safe environment for
human habitat . The recent reports by WHO show that 7 million people die each year
caused by air pollution . Thus, poor air quality causes several health hazards like heart
disease, lung cancer, and respiratory problems. The need of the hour is not only to

4
control air pollution but also materializing technologies, devices and software systems
to keep a close check on rapidly growing air pollution . The efforts in this project are
made to develop one of such systems by which the real time air quality monitoring
can be done to take preventative measures to make our living environment safe to live
a good life. Considering the complexities, operational difficulties, poor resource
management issues, and cost-efficiency, the proposed system provides a user-friendly
less complex a much cheaper solution that works as a preventative mechanism to
generate real-time alerts on air quality. Our main contribution is to develop a cost-
efficient air quality monitoring system that senses the real-time data of surrounding
various parameters like smoke, carbon monoxide, and PM level and alerts the people
when the quantity of these elements goes beyond a certain limit and shows the data in
an easily understandable format.

2.2 EXISTING SYSTEM


For monitoring the air quality of the surroundings, innumerable works have
been done. One of the frameworks proposed by the author to monitor air quality on
various parameters like LPG, carbon monoxide(CO), humidity, smoke, temperature
and other perilous particulate matters such as PM2.5 and PM10 particles in the
atmosphere. Thing Speak was used in this system, which is an open-source cloud
platform for easily storing and retrieval of data through Hyper Text Transfer Protocol
i.e HTTP over the internet. It is used as a platform for plotting charts, graphs, create
plugin and apps of real-time sensing data. MQ2 sensors used in this system produce
analog output and for that purpose, ADC (analog to digital converter) has to be used.
Raspberry pie 3b used in the system has built in Wi-Fi modules, for large data that is
transferred over the internet . In this approach, several input-output pins of Raspberry
pie had been wasted.
Monitoring the air quality over the internet using ESP8266 with Arduino senses
the harmful gases and triggers the buzzer when air quality exceeds a certain limit. This
approach saves the wastage of input-output pins while neglects the PM level which
are major elements of air pollution.

5
In the project the authors provides real-time low rate monitoring system over
the use of low rate, low information rate, and little control wireless communication
technology. The projected monitoring system can be transferred to or shared by
different applications. Through IOT they can able to visualize the values from the
globe. In order to achieve cost efficiency and resource management, we have
proposed an IOT based air quality monitoring system that will sense and show the
real-time surrounding data of Carbon Monoxide, smoke, PM and helps to guard
against extreme events by alerting people and initiate actions regarding it.

2.3 PROPOSED SYSTEM


In this proposed system provides real-time low rate monitoring system over the
use of low rate, low information rate, and little control wireless communication
technology. The projected monitoring system can be transferred to or shared by
different applications. Through IOT they can able to visualize the values from the
globe. In order to achieve cost efficiency and resource management, we have
proposed an IOT based air quality monitoring system that will sense and show the
real-time surrounding data of Carbon Monoxide, smoke, PM and helps to guard
against extreme events by alerting people and initiate actions regarding it.
The model is designed using the IoT technology. It is inexpensive, mobile IoT
based Air quality monitoring system which senses the real-time surrounding data with
the help of three sensors these are MQ9 gas sensor which is used for sensing carbon
monoxide, MQ2 sensor which is used for sensing smoke and PMS3003 G3 particle
sensor for PM2.5 giving readings to Node MCU as a processing unit and sends this
detected data to the internet. Thing Speak, an open cloud platform, is used to store
data and retrieve it through hypertext transfer protocol (HTTP) over the Internet. With
the help of the Thing Speak platform, the sensed data can be plotted in graphical form
and can be seen on the LCD.

2.4 LITERATURE REVIEW


The system demonstrates the creation of innovative systems that facilitate
control and supervision regardless of distance and time. In regular, both temperature

6
and humidity levels should be monitored regularly in ensuring the system runs
smoothly.
It needs to be monitored 24/7 to avoid incidents that caused the temperature
rises too high. The environmental parameters like temperature, light intensity and
ammonia gas are monitored and controlled automatically. The person in-charge can
able to get the knowledge regarding the interior atmosphere. Based on the message
received the monitoring committee can take appropriate action to control the
parameters. This study intended to explore utilizing an Intelligent System which used
an Embedded Framework and Smart Phone for monitoring and control environmental
parameters using smart devices and technologies. This system will warn the person in-
charge about the various environmental parameters like temperature, humidity, etc. by
sending message to the registered mobile number. The person in charge can initiate a
required action by sending a message back and when the system doesn’t receive a
command in a particular time period it will initiate the action automatically. The
system could monitor surrounding weather conditions including humidity,
temperature, climate quality, and also the filter fan switch control in the farm.

CHAPTER-3
BLOCK DIAGRAM
3.1 PROPOSED SYSTEM

7
POWER LCD DISPLAY
SUPPLY (16*2 LINES)
ARDUINO

MQ2
Web Server

MQ9 BUZZER

PMS 3003

Fig 3.1 Block Diagram of the Project

3.2 DESCRIPTION
The model is designed using the IoT technology. It is inexpensive, mobile IoT
based Air quality monitoring system which senses the real-time surrounding data with
the help of three sensors these are MQ9 gas sensor which is used for sensing carbon
monoxide, MQ2 sensor which is used for sensing smoke and PMS3003 G3 particle
sensor for PM2.5 giving readings to STM as a processing unit and sends this detected
data to the internet. Thing Speak, an open cloud platform, is used to store data and
retrieve it through hypertext transfer protocol (HTTP) over the Internet. With the help
of the Thing Speak platform, the sensed data can be plotted in graphical form.

CHAPTER 4 Hardware Components


4.1MICROCONTROLLER (ATMEGA16)
A microcontroller is a small computer on a single integrated circuit containing
a processor core, memory, and programmable input/output peripherals. The one we

8
used is Arduino Uno. Arduino is a single-board microcontroller designed to make the
process of using electronics in multidisciplinary projects more accessible. The
hardware consists of a simple open source hardware board designed around an 8-bit
Atmel AVR microcontroller. An Arduino board consists of an Atmel 8-bit AVR
microcontroller with complementary components to facilitate programming and
incorporation into other circuits. An important aspect of the Arduino is the standard
way that connectors are exposed, allowing the CPU board to be connected to a variety
of interchangeable add-on modules known as shields. The software consists of a
standard programming language compiler and a boot loader that executes on the
microcontroller.

Features of ATMEGA 328P controller includes:


1) High performance, low power AVR® 8-bit microcontroller
2) Advanced RISC architecture
3) 131 powerful instructions – most single clock cycle execution
4) 32  8 general purpose working registers
5) Fully static operation
6) Up to 16MIPS throughput at 16MHz
7) On-chip 2-cycle multiplier
8) High endurance non-volatile memory segments
9) 32K bytes of in-system self-programmable flash program memory
10)1Kbytes EEPROM
11) 2Kbytes internal SRAM
12) Write/erase cycles: 10,000 flash /100,000 EEPROM
13)Optional boot code section with independent lock bits

9
14)In-system programming by on-chip boot program
15)True read-while-write operation
16)Programming lock for software security
17)Peripheral features includes
18) Two 8-bit Timer/Counters with separate prescaler and compare mode
19) One 16-bit Timer/Counter with separate prescaler, compare mode, and capture
mode
20) Real time counter with separate oscillator

Six PWM channels


1) 8-channel 10-bit ADC in TQFP and QFN/MLF package
2) Temperature measurement
3) Programmable serial USART
4) Master/slave SPI serial interface
5) Byte-oriented 2-wire serial interface (Phillips I2 C compatible)
6) Programmable watchdog timer with separate on-chip oscillator
7) On-chip analog comparator
8) Interrupt and wake-up on pin change Special microcontroller features
1) Power-on reset and programmable brown-out detection
2) Internal calibrated oscillator
3) External and internal interrupt sources
4) Six sleep modes : Idle, ADC noise reduction, power-save, power-down,
standby, and extended standby I/O and packages
5) 23 programmable I/O lines
6) 32-lead TQFP, and 32-pad QFN/MLF
7) Operating voltage: 2.7V to 5.5V for ATmega328P 8) Temperature range:
9) Automotive temperature range: –40°C to +125°C
10)Speed grade: 0 to 8MHz at 2.7 to 5.5V (automotive temperature range: –40°C
to +125°C)
11)0 to 16MHz at 4.5 to 5.5V (automotive temperature range: –40°C to +125°C)
12)Low power consumption
13)Active mode: 1.5mA at 3V - 4MHz

10
14)Power-down mode: 1µA at 3V

11
Figure 4.1: Internal architecture of ATMEGA328P
The AVR® core combines a rich instruction set with 32 general purpose
working registers. All the 32 registers are directly connected to the arithmetic logic
unit (ALU), allowing two independent registers to be accessed in one single
instruction executed in one clock cycle.

12
The resulting architecture is more code efficient while achieving throughputs
up to ten times faster than conventional CISC microcontrollers. The Atmel®
ATmega328P provides the following features: 32K bytes of in-system programmable
flash with read-while-write capabilities, 1K bytes EEPROM, 2K bytes SRAM, 23
general purpose I/O lines, 32 general purpose working registers, three flexible
Timer/Counters with compare modes, internal and external interrupts, a serial
programmable USART, a byte oriented 2-wire serial interface, an SPI serial port, a 6-
channel 10-bit ADC (8 channels in TQFP and QFN/MLF packages), a programmable
watchdog timer with internal oscillator, and five software selectable power saving
modes. The idle mode stops the CPU while allowing the SRAM, Timer/Counters,
USART, 2-wire serial interface, SPI port, and interrupt system to continue
functioning. The power-down mode saves the register contents but freezes the
oscillator, disabling all other chip functions until the next interrupt or hardware reset.
In power-save mode, the asynchronous timer continues to run, allowing the user to
maintain a timer base while the rest of the device is sleeping. The ADC noise
reduction mode stops the CPU and all I/O modules except asynchronous timer and
ADC, to minimize switching noise during ADC conversions. In standby mode, the
crystal/resonator oscillator is running while the rest of the device is sleeping. This
allows very fast start-up combined with low power consumption. The device is
manufactured using Atmel high density non-volatile memory technology. The on-chip
ISP flash allows the program memory to be reprogrammed in-system through an SPI
serial interface, by a conventional non-volatile memory programmer, or by an on-chip
boot program running on the AVR core. The boot program can use any interface to
download the application program in the application flash memory. Software in the
boot flash section will continue to run while the application flash section is updated,
providing true read-while-write operation. By combining an 8-bit RISC CPU with in-
system self-programmable flash on a monolithic chip, the Atmel ATmega328P is a
powerful microcontroller that provides a highly flexible and cost effective solution to
many embedded control applications. The ATmega328P AVR is supported with a full
suite of program and system development tools including: C compilers, macro
assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits.

13
In order to maximize performance and parallelism, the AVR uses a harvard
architecture – with separate memories and buses for program and data. Instructions in
the program memory are executed with a single level pipelining. While one
instruction is being executed, the next instruction is pre-fetched from the program
memory.
This concept enables instructions to be executed in every clock cycle. The
program memory is in-system reprogrammable flash memory. The fast-access register
file contains 32  8-bit general purpose working registers with a single clock cycle
access time. This allows single-cycle arithmetic logic unit (ALU) operation. In a
typical ALU operation, two operands are output from the register file, the operation is
executed, and the result is stored back in the register file – in one clock cycle. Six of
the 32 registers can be used as three 16-bit indirect addresses register pointers for data
space addressing – enabling efficient address calculations. One of the address pointers
can also be used as an address pointer for look up tables in flash program memory.
These added function registers are the 16-bit X-, Y-, and Z-register, described later in
this section.
The ALU supports arithmetic and logic operations between registers or
between a constant and a register. Single register operations can also be executed in
the ALU. After an arithmetic operation, the status register is updated to reflect
information about the result of the operation. Program flow is provided by conditional
and unconditional jump and call instructions, able to directly address the whole
address space. Most AVR® instructions have a single 16-bit word format. Every
program memory address contains a 16- or 32-bit instruction. Program flash memory
space is divided in two sections, the boot program section and the application program
section. Both sections have dedicated lock bits for write and read/write protection. The
SPM instruction that writes into the application flash memory section must reside in
the boot program section. During interrupts and subroutine calls, the return address
program counter (PC) is stored on the stack. The stack is effectively allocated in the
general data SRAM, and consequently the stack size is only limited by the total
SRAM size and the usage of the SRAM. All user programs must initialize the SP in
the reset routine (before subroutines or interrupts are executed).
14
The stack pointer (SP) is read/write accessible in the I/O space. The data
SRAM can easily be accessed through the five different addressing modes supported
in the AVR architecture. The memory spaces in the AVR architecture are all linear and
regular memory maps. A flexible interrupt module has its control registers in the I/O
space with an additional global interrupt enable bit in the status register. All interrupts
have a separate interrupt vector in the interrupt vector table. The interrupts have
priority in accordance with their interrupt vector position. The I/O memory can be
accessed directly, or as the data space locations following those of the register file,
0x20 - 0x5F.
In addition, the ATmega328P has extended I/O space from 0x60 - 0xFF in
SRAM where only the ST/STS/STD and LD/LDS/LDD instructions can be used.

4.2 SERIAL COMMUNICATION


Computers can transfer data in two ways: parallel and serial. In parallel data
transfers, often 8 or more lines (wire conductors) are used to transfer data to a device
that is only a few feet away. Examples of parallel data transfer are printers and hard
disks; each uses cables with many wire strips. Although in such cases a lot of data can
be transferred in a short amount of time by using many wires in parallel, the distance
cannot be great. To transfer to a device located many meters away, the serial method is
used. In serial communication, the data is sent one bit at a time, in contrast to parallel
communication, in which the data is sent a byte or more at a time.

4.3 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.

15
4.4 MQ4 Gas sensor
It is a Metal Oxide Semiconductor (MOS) type Gas Sensor mainly used to
detect the Methane (CNG) gas concentration in the air either at home or in industry.
This sensor contains a sensing element, mainly aluminum-oxide based ceramic,
coated with Tin dioxide, enclosed in a stainless-steel mesh.
Whenever gas comes into contact with the sensing element, the resistivity of
the element changes. The change is then measured to get the concentration of the
gases present. Its sensing range of 300-10000 PPM is suitable for gas leak detection.
The combustion of Methane is highly exothermal means it will release a vast amount
of heat if ignited which when used in a controlled way is beneficial but if an accident
occurs it will be devastating.
Specifications :
10)Power requirements: VCC - 5V±0.1
11) DO output: TTL digital 0 and 1 (0.1 and 5V)
12)AO output: 0.1-0 .3 V (relative to pollution), for maximum concentration of a
voltage of about 4V
13)Detection Gas: Natural gas/Methane
14)Detection Concentration: 200-10000ppm (Natural gas / Methane)
15)Interface: 1 TTL compatible input (HSW), 1 TTL compatible output (ALR)
16)Heater consumption: less than 750mw
17)Operating temperature: 14 to 122 °F (-10 to 50°C)
18)Preheat time: Over 24 hours

16
Product Description

To use the Sensor Module, you have power the device with 5V supply and the
Power LED will start to glow. You should give it some time for its preheating period
before start reading the output. While measuring the gas present, the Output LED will
glow in a specific concentration of the gas. You can change it by using the
potentiometer. Else you can also use the Analog Output to see how your program
reacts to different concentrations of gases present.

4.5 MQ7 Carbon Monoxide sensor


It is another one of Metal Oxide Semiconductor (MOS) type Gas Sensor of MQ
Gas Sensors family involving MQ 2, MQ 4, MQ 3, MQ 8, MQ 135, etc. It is mainly
used to detect Carbon Monoxide. This sensor contains a sensing element, mainly
aluminum-oxide based ceramic, coated with Tin dioxide (SnO2), enclosed in a
stainless-steel mesh. Whenever CO gas comes into contact with the sensing element,
the resistivity of the element changes. The change is then measured to get the
concentration of the gases present. The MQ7 Sensor has a small heating element
present which is needed to preheat the sensor to get it in the working window. It can
detect Carbon Monoxide Gas in the range of 20 PPM to 2000 PPM in the air. It finds
uses in Alarm application in case of CO gas concentration build-up in the home or
your car as CO is a very harmful gas and can kill a person if present over 300PPM.
SPECIFICATIONS :

17
19)Operating Voltage is +5V
20)Can be used to Measure or detect CO
21)Analog output voltage: 0V to 5V
22)Digital Output Voltage: 0V or 5V
23)Stable, Long life and Low Cost
24)Fast Response time
25)Heater consumption about 350Mw
26)The Sensitivity of Digital Output pin can be varied using the potentiometer

PRODUCT DESCRIPTION :

To use the Sensor Module, you have power the device with 5V supply and the
Power LED will start to glow. To power it, you can use external supply or connect
+5V and GND pin of Arduino. You should give it some preheating time before start
reading the output. While measuring the gas present, the Output LED will glow in a
specific concentration of the gas. You can change it by using the potentiometer. Else
you can also use the Analog Output to see how your program reacts to different
concentrations of gases present.
4.6 PMS3003
PMS3003 is a kind of digital and universal particle concentration sensor, which
can be used to obtain the number of suspended particles in the air, i.e. the
concentration of particles, and output them in the form of digital interface. This sensor

18
can be inserted into variable instruments related to the concentration of suspended
particles in the air or other environmental improvement equipments to provide correct
concentration data in time. Laser scattering principle is used for such sensor, i.e.
produce scattering by using laser to radiate suspending particles in the air, then collect
scattering light in a certain degree, and finally obtain the curve of scattering light
change with time. In the end, equivalent particle diameter and the number of particles
with different diameter per unit volume can be calculated by microprocessor based on
MIE theory.

4.7 ESP 8266-01 Wi-Fi Module:


ESP-01 Wi-Fi encapsulates module is developed by module is developed by
Ai-thinker Team. core processor ESP8266 in smaller sizes of the module Tensilica
L106 integrates industry-leading ultra low power 32bit MCU micro, with the 16
Clock speed support 80 MHz, 160 MHz, supports the RTOS, integrated Wi-Fi MAC
The module supports standard IEEE802.11 Tensilica L106 integrates industry Clock
speed support 80 MHz, 160 MHz, supports the RTOS, integrated Wi The module
supports standard IEEE802.11 add modules to an existing device networking, or
building a separate network controller. ESP8266 is high integration core processor
ESP8266 in smaller sizes of the module bit MCU micro, with the 16-bit short
mode, /BB/RF/PA/LNA, on-board antenna. b/g/n agreement, complete TCP/IP
protocol stack. Users can use the /BB/RF/PA/LNA, on b/g/n agreement, complete
TCP/IP protocol. Fi capabilities within other systems, or to function as a standalone
unsurpassed ability to embed Wi application, with the lowest cost, and minimal space

19
requirement. Fi capabilities within other systems, or to function as a standalone
application, with the lowest cost, and minimal space requirement.
ESP8266EX offers a complete and or to offload Wiself self-contained WiFi
networking solution; it can be used to host Fi networking solution; it can be used to
host the application Fi networking functions from another application processor.
When ESP8266EX hosts the application, it boots up directly from an external flash.
In has Fi networking functions from another application processor When
ESP8266EX hosts the application, it boots up directly from an external flash. In has
improve the performance of the system in such applications. improve the performance
of the system in such applications. Alternately, serving as a integrated cache to Fi
adapter, wireless internet access can be added to any micro controller based design Fi
adapter, wireless internet access can be added to any micro controller based design with

simple connectivity (SPI/SDIO or I2C/UART interface).

4.8 LIQUID CRYSTAL DISPLAY :


LCD stands for Liquid Crystal Display. LCD is finding wide spread use
replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the
following reasons:
1) The declining prices of LCDs.
2) The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.
3) Incorporation of a refreshing controller into the LCD, thereby relieving the
CPU of the task of refreshing the LCD.
4) In contrast, the LED must be refreshed by the CPU to keep displaying the data.
5) Ease of programming for characters and graphics.
These components are “specialized” for being used with the microcontrollers, which
means that they cannot be activated by standard IC circuits. They are used for writing
different messages on a miniature LCD.

20
Fig:4.8 LCD Display
A model described here is for its low price and great possibilities most
frequently used in practice. It is based on the HD44780 microcontroller (Hitachi) and
can display messages in two lines with 16 characters each. It displays all the
alphabets, Greek letters, punctuation marks, mathematical symbols etc. In addition, it
is possible to display symbols that user makes up on its own. Automatic shifting
message on display (shift left and right), appearance of the pointer, backlight etc. are
considered as useful characteristics.
PINS FUNCTIONS
There are pins along one side of the small printed board used for connection to
the microcontroller. There are total of 14 pins marked with numbers (16 in case the
background light is built in). Their function is described in the table below:
Pin Logic
Function Name Description
Number State

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 – Vdd

0 D0 – D7 are interpreted as
4 RS 1 commands
D0 – D7 are interpreted as data

Write data (from controller to

21
of 0 LCD)
Control 5 R/W
1 Read data (from LCD to
operating controller)

0 Access to LCD disabled


1 Normal operating
6 E
From 1 to Data/commands are transferred
0 to LCD

/7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2

10 D3 0/1 Bit 3
Data
commands 11 D4 0/1 Bit 4

12 D5 0/1 Bit 5

13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB

Table 1: Pin Functions

LCD SCREEN:
LCD screen consists of two lines with 16 characters each. Each character
consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage
and whether messages are displayed in one or two lines. For that reason, variable
voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used
for that purpose.
Some versions of displays have built in backlight (blue or green diodes). When
used during operating, a resistor for current limitation should be used (like with any
LE diode).

22
Fig: 4.8.1 LCD Pin Connections
4.9 LCD BASIC COMMANDS
All data transferred to LCD through outputs D0-D7 will be interpreted as
commands or as data, which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed.
Built in processor addresses built in “map of characters” and displays
corresponding symbols. Displaying position is determined by DDRAM
address.
This address is either previously defined or the address of previously
transferred character is automatically incremented.RS = 0 - Bits D0 - D7 are
commands which determine display mode. List of commands which LCD
recognizes are given in the table below:
Command R R D D D D4 D3 D2 D1 D Executio
S W 7 6 5 0 n Time

Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS


Cursor home 0 0 0 0 0 0 0 0 1 X 1.64mS
Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS
Display 0 0 0 0 0 0 1 D U B 40uS
on/off
control

23
Cursor/Display 0 0 0 0 0 1 D/ R/L x X 40uS
Shift C
Function set 0 0 0 0 1 DL N F x X 40uS
Set CGRAM 0 0 0 1 CGRAM address 40uS
address
Set DDRAM 0 0 1 DDRAM address 40uS
address
Read “BUSY” 0 1 B DDRAM address -
flag (BF) F
Write to D D D D D 40uS
CGRAM or 1 0 7 6 5 D4 3 2 D1 D0

DDRAM
Read from D D D D4 D D D1 D0 40uS
CGRAM or 1 1 7 6 5 3 2
DDRAM

Table 2: LCD Commands


I/D 1 = Increment (by 1) R/L 1 = Shift right
0 = Decrement (by 1) 0 = Shift left
S 1 = Display shift on DL 1 = 8-bit interface
0 = Display shift off 0 = 4-bit interface
D 1 = Display on N 1 = Display in two lines
0 = Display off 0 = Display in one line
U 1 = Cursor on F 1 = Character format 5x10 dots
0 = Cursor off 0 = Character format 5x7 dots
B 1 = Cursor blink on D/C 1 = Display shift
0 = Cursor blink off 0 = Cursor shift
4.10 LCD Initialization:
Once the power supply is turned on, LCD is automatically cleared. This
process lasts for approximately 15mS. After that, display is ready to operate. The
mode of operating is set by default. This means that:
1. Display is cleared
2. Mode

24
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. Mainly but not
always! If for any reason power supply voltage does not reach full value in the course
of 10mS, display will start perform completely unpredictably. If voltage supply unit
cannot meet this condition or if it is needed to provide completely safe operating, the
process of initialization by which a new reset enabling display to operate normally
must be applied.
Algorithm according to the initialization is being performed depends on
whether connection to the microcontroller is through 4- or 8-bit interface. All left over
to be done after that is to give basic commands and of course- to display messages.

25
Fig 4.10: Procedure on 8-bit initialization

4.11 REGULATED POWER SUPPLY


The power supplies are designed to convert high voltage AC mains electricity
to a suitable low voltage supply for electronics circuits and other devices. A RPS
(Regulated Power Supply) is the Power Supply with Rectification, Filtering and
Regulation being done on the AC mains to get a Regulated power supply for
Microcontroller and for the other devices being interfaced to it.
A power supply can by broken down into a series of blocks, each of which
performs a particular function. A d.c power supply which maintains the output voltage
constant irrespective of a.c mains fluctuations or load variations is known as
“Regulated D.C Power Supply”

26
For example a 5V regulated power supply system as shown below:

Fig.4.11: Block Diagram of the Power Supply

27
CHAPTER 5
ARDUINO IDE TOOL
Arduino is an open-source electronics platform based on easy-to-use hardware
and software. Arduino boards are able to read inputs - light on a sensor, a finger on a
button, or a Twitter message - and turn it into an output - activating a motor, turning
on an LED, publishing something online. You can tell your board what to do by
sending a set of instructions to the microcontroller on the board. To do so you use the
Arduino programming language (based on Wiring), and the Arduino Software (IDE),
based on Processing.
Over the years Arduino has been the brain of thousands of projects, from
everyday objects to complex scientific instruments. A worldwide community of
makers - students, hobbyists, artists, programmers, and professionals - has gathered
around this open-source platform, their contributions have added up to an incredible
amount of accessible knowledge that can be of great help to novices and experts alike.
Why Arduino?
Thanks to its simple and accessible user experience, Arduino has been used in
thousands of different projects and applications. The Arduino software is easy-to-use
for beginners, yet flexible enough for advanced users. It runs on Mac, Windows, and
Linux. Teachers and students use it to build low cost scientific instruments, to prove
chemistry and physics principles, or to get started with programming and robotics.
Designers and architects build interactive prototypes, musicians and artists use it for
installations and to experiment with new musical instruments. Makers, of course, use
it to build many of the projects exhibited at the Maker Faire, for example. Arduino is a
key tool to learn new things.
Anyone - children, hobbyists, artists, programmers - can start tinkering just
following the step by step instructions of a kit, or sharing ideas online with other
members of the Arduino community.There are many other microcontrollers and
microcontroller platforms available for physical computing. Parallax Basic Stamp,
Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar
functionality. All of these tools take the messy details of microcontroller programming
and wrap it up in an easy-to-use package.
28
Arduino also simplifies the process of working with microcontrollers, but it
offers some advantage for teachers, students, and interested amateurs over other
systems:

• Inexpensive - Arduino boards are relatively inexpensive compared to other


microcontroller platforms. The least expensive version of the Arduino module
can be assembled by hand, and even the pre-assembled Arduino modules cost
less than $50
• Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh
OSX, and Linux operating systems. Most microcontroller systems are limited
to Windows.
• Simple, clear programming environment - The Arduino Software (IDE) is easy-
to-use for beginners, yet flexible enough for advanced users to take advantage
of as well. For teachers, it's conveniently based on the Processing programming
environment, so students learning to program in that environment will be
familiar with how the Arduino IDE works.
• Open source and extensible software - The Arduino software is published as
open source tools, available for extension by experienced programmers. The
language can be expanded through C++ libraries, and people wanting to
understand the technical details can make the leap from Arduino to the AVR C
programming language on which it's based. Similarly, you can add AVR-C code
directly into your Arduino programs if you want to.
• Open source and extensible hardware - The plans of the Arduino boards are
published under a Creative Commons license, so experienced circuit designers
can make their own version of the module, extending it and improving it. Even
relatively inexperienced users can build the breadboard version of the module
in order to understand how it works and save money.
CHAPTER-6
INTERNET OF THINGS
The Internet of Things (IoT) is a system of ‘connected things’. The things
generally comprise of an embedded operating system and an ability to communicate
29
with the internet or with the neighbouring things. One of the key elements of a generic
IoT system that bridges the various ‘things’ is an IoT service. An interesting
implication from the ‘things’ comprising the IoT systems is that the things by
themselves cannot do anything. At a bare minimum, they should have an ability to
connect to other ‘things’. But the real power of IoT is harnessed when the things
connect to a ‘service’ either directly or via other ‘things’. In such systems, the service
plays the role of an invisible manager by providing capabilities ranging from simple
data collection and monitoring to complex data analytics. The below diagram
illustrates where an IoT service fits in an IoT ecosystem

One such IoT application platform that offers a wide variety of analysis,
monitoring and counter- action capabilities is ‘ThingSpeak’. Let us consider
ThingSpeak in detail.
What is ThingSpeak
ThingSpeak is a platform providing various services exclusively targeted for
building IoT applications. It offers the capabilities of real-time data collection,
visualizing the form of charts, ability to create plugins and apps for collaborating with

30
web services, socialnetwork and other APIs. We will consider each of these features in
detail below.
The core element of ThingSpeak is a ‘ThingSpeak Channel’. A channel stores the data
that wesend to ThingSpeak and comprises of the below elements:
• 8 fields for storing data of any type - These can be used to store the data from a
sensor or froman embedded device.
• 3 location fields - Can be used to store the latitude, longitude and the elevation.
These are veryuseful for tracking a moving device.
• 1 status field - A short message to describe the data stored in the channel.
To use ThingSpeak, we need to signup and create a channel. Once we have a
channel, we can send the data, allow ThingSpeak to process it and also retrieve the
same. Let us start exploringThingSpeak by signing up and setting up a channel.
Getting Started
Open https://thingspeak.com/ and click on the ‘Get Started Now’ button on the
center of the page and you will be redirected to the sign-up page(you will reach the
same page when you click the ‘Sign Up’ button on the extreme right). Fill out the
required details and click on the ‘Create Account’ button

Now you should see a page with a confirmation that the account was successfully
created. The confirmation message disappears after a few seconds and the final page
should look as in the below screen:

31
Go ahead and click on ‘New Channel’. You should see a page like the below:

32
You can change the name to fit your need and you can add a description corresponding to
the channel. You can add any other useful description into the metadata field. In the same
page, you should see the fields for Latitude, Longitude and Elevation. Also, when you
scroll down you should see a check box that says ‘Make Public?’. Let us consider the
significance of the various fields and the tabs:
• Latitude, longitude and elevation - These fields correspond to the location of a
‘thing’ and areespecially significant for moving things.
• Make Public? - If the channel is made public, anyone can view the channel's data
feed and thecorresponding charts. If this check box is not checked, the channel is
private, which means for every read or write operation, the user has to pass a
corresponding API key.
• URL - This can be the URL of your blog or website and if specified, will appear
on the public viewof the channel.
• Video ID - This is the ID corresponding to your YouTube or Vimeo ID. If
specified, the videoappears on the public view of the channel.
• Fields 1 to 8 - These are the fields which correspond to the data sent by a sensor or
a ‘thing’. A field has to be added before it can be used to store data. By default,
Field 1 is added. In case you try posting to fields that you have not added, your
request will still be successful, but you will notbe able to see the field in the charts
and the corresponding data. You can click on the small box before the ‘add field’
text corresponding to each field to add it. Once you click the ‘add field’ box, a
default label name appears in the text box corresponding to each field and the ‘add
field’ text changes to ‘remove field’. You can edit the field text that appears by
default when a field is added to make more sense. For example, in the below
screen, I have modified the text for Field 2 to ‘SensorInput’. To remove a field
which is added, just check on the ‘remove field’ box. Once youclick this, the text
‘remove field’ changes back to ‘add field’ and the corresponding field text is
cleared.

33
Once you have edited the fields, click on ‘Save Channel’ button. You should now
see a page likethe below in which the ‘Private View’ tab is defaulted:

The Private View shows a chart corresponding to each of the fields that we
have added. Now clickon the ‘Public View’ tab. This should look exactly similar to

34
the what we see in the ‘Private View’ tab since our channel is public. In case your
channel is not public('make public' check box not checked in the ‘channel settings’
tab), the public view tab shows a message that ‘This channel is not public’.
Now click on the ‘API Keys’ tab. You should see a screen similar to the below.
The write API key is used for sending data to the channel and the read API key(s) is
used to read the channel data.
When we create a channel, by default, a write API key is generated. We
generate read API keys by clicking the ‘Generate New Read API Key’ button under
this tab.You can also add a note corresponding to each of the read API keys.
Note: Please note that clicking on the ‘Generate New Write API Key’ will
over-write the previous key. You will only have one Write API key at any point of
time. Also, in case your channel is private, others can only view the channel’s feed
and charts by using a Read API key. Please sharethe Read API keys with people who
are approved and authorized to view your channel.

Now click on the ‘Data Import/Export’ tab and you should see a screen similar to the
below. This tab is used to import the ‘Comma Separated Values(CSV)’ data from a
file into the channel. You can also download the channel’s feed from here in CSV
format. This tab also outlines how to send and view data by providing the URIs to
the send and view APIs.

35
After a series of updates, the charts in the private view tab for each of the fields will look
like thebelow:

36
Each of the dots correspond to the value and the time at which the value was
posted to the channel. Place the mouse over a dot to get more details on the exact
date and the GMT offsetfrom which the value was posted.
Please note that in the above example, I have sent some sample values to the
channel. You cansend any data here, say the periodic readings from a temperature
sensor or RPM values from amotor. The Y-axis show the names.

37
I have used Internet Explorer 11 to run this example. After running this, to check
whether the feed got updated, run the below URL:
http://api.thingspeak.com/channels/YOUR_CHANNEL_ID/feed.json?key=YOUR_K
EY&location=tru e
NOTE: As mentioned above, you have to replace YOUR_KEY with your write API
key and replace YOUR_CHANNEL_ID with the ID corresponding to your channel.
Also, if you invoke the above URLwithout specifying location=true, you will not be
able to see the latitude, longitude and altitude fields.
The below is a screen after running the above URL after updating my location details for
fewtimes:

ThingSpeak Apps
ThingSpeak provides apps that allow us for an easier integration with the web
services, social networks and other APIs. Below are some of the apps provided by
Things peak:
• Thing Tweet - This allows you to post messages to twitter via ThingSpeak. In
essence, thisis a Twitter Proxy which re-directs your posts to twitter.

38
• Thing HTTP - This allows you to connect to web services and supports GET,
PUT, POSTand DELETE methods of HTTP.
• Tweet Control - Using this, you can monitor your Twitter feeds for a specific key
word and then process the request. Once the specific keyword is found in the
twitter feed, you can then use Thing HTTP to connect to a different web service
or execute a specific action.
• React - Send a tweet or trigger a Thing HTTP request when the Channel meets a
certaincondition.

39
CHAPTER-7
7.1 SCHEMATIC DESCRIPTION
ARUDUINO UNO ATmega328p power supply,ESP-01 updating farm information
to the owner, TEMPERATURE SENSOR to detect the temperature and humidity, Sensors
such as MQ2, MQ6 used to measure the various threshold values .
SCHEMATIC

The major advantage of this system is that it is portable, small and cost-efficient.
The proposed system uses ‘ThingSpeak’, with the help of which data can be shown in
graphical format and it also supports the latest technologies like Node, Ruby, etc. In this

40
project, we have presented the implementation of a low-cost IoT based air quality
monitoring system. Apart from its low cost and low power consumption, it takes less
space and can be installed anywhere and provide operational efficiency and flexibility
than traditional wired methods. Applications
1) Industrial perimeter monitoring 2)
Indoor air quality monitoring.
3) Site selection for reference monitoring
stations. 4) Making data available to users.
Advantages
1) Easy to Install
2) Updates On mobile phone directly
3) Accurate Pollution monitoring 4) Remote location monitoring

7.2 CONCLUSION
We have proposed a cost-efficient air quality monitoring system that senses the real-time
data of surrounding various parameters like smoke, carbon monoxide, and PM level and alerts
the people when the quantity of these elements goes beyond a certain limit and shows the data in
an easily understandable format. In the future, more sensing nodes can be added to extend the
system.

7.3 REFERENCES
1. Poonam Pal et al., “IoT Based Air Pollution Monitoring System Using Arduino”,
IRJET Journal, Vol 4 Issue 10, October, 2017.
2. Saikumar, C. V., Reji, M., & Kishoreraja, P. C. (2017). IOT Based Air Quality
Monitoring System. International Journal of Pure and Applied Mathematics,
117(9), 53-
57.
3. K.A. Delin, and S.P. Jackson, “The Sensor Web: A New InstrumentConcept,”
SPIE Symposium on Integrated Optics, San Jose, CA. Jan 2003.

41
4. Völgyesi, P., Nádas, A., Koutsoukos, X., and Lédeczi, Á. 2008, “AirQuality
Monitoring with SensorMap”, In Proceedings of the 7thinternational Conference
on information Processing in Sensor Networks, pp.529-530, April 2008.
5. Sonal A. Mishra ,Dhanashree S. Tijare and Dr. G. M. Asutkar, “Design of Energy
Aware Air pollutionMonitoring System using WSN “, International Journal of Advances
in Engineering & Technology, Vol.1,Issue 2, May 2011,pp.107-116.
6. R.A.Roseline, Dr.M.Devapriya, Dr.P.Sumathi, “Pollution Monitoring using
Sensors and Wireless Sensor Networks: A Survey”, International Journal of
Application or Innovation in Engineering & Management (IJAIEM), vol.2, issue7,
July 2013, pp.119- 124.
7. Nikheel A. Chourasia, Surekha P. Washimkar,” ZigBee Based Wireless Air
Pollution Monitoring” International Conference on Computing and Control Engineering
(ICCCE 2012), 12 & 13 April, 2012
8. F. Tsow, E Forzani, A. Rai, R. Wang, R. Tsui, S.Mastroianni, C. Knobbe, A. J.
Gandolfi, and N. J. Tao,“ A wearable and wireless sensor system for real-time monitoring
of toxic environmental volatile organic compounds,” IEEE Sensors J., vol. 9, pp. 1734–
1740,Dec.
2009.
9. Y.J. Jung, Y.K.Lee, D.G. Lee, K.H. Ryu, and S. Nittel,“ Air pollution monitoring
system based on geo sensor network,” in Proc. IEEE Int. Geo science Remote
Sensing Symp., 2008, vol. 3, pp. 1370–1373.
10. W. Chung and C.H. Yang, “Remote monitoring system with wireless sensors
module for room environment,”Sens. Actuators B, vol. 113 no. 1, pp. 35–42, 2009.
Appendix Code

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

42
#include <Wire.h>
#include "RTClib.h"
#include <EEPROM.h>
//int temp = A5; int
val=0;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
SoftwareSerial mySerial(A0, A1);
RTC_DS1307 rtc;
/*void time_set();
void time_disp();
void
feed_time_set();
*/ uint16_t rawHumidity = 0;
uint16_t rawTemperature = 0;
uint8_t checkSum = 0;
uint16_t data = 0; uint8_t
humi; uint8_t humd; uint8_t
tempi;
if ( live > 90 ) {
;//Serial.println("ERROR_TIMEOUT");
return;
} } while ( digitalRead(dht11_pin) == (i & 1) ? HIGH :
LOW ); if ( i >= 0 && (i & 1) ) { data <<= 1;

43
// TON of bit 0 is maximum 30 usecs and of bit 1 is at least 68 usecs.
if ( live > 30 ) {
data |= 1; // we got a one
} } switch
(i){
case 31:
rawHumidity =
data; break;
case 63:
rawTemperature = data;
case 79: checkSum =
data; data = 0; break;
rawTemperature = rawTemperature << 8;
tempd = rawTemperature >> 8; //tempd =
(byte)rawTemperature; dec2bin8(tempd);
//Serial.print("\t");
//Serial.print(tempi);
//Serial.print(".");
//Serial.print(tempd);
//Serial.print("C");
//Serial.println("");
//Serial.println("Checksum Byte: ");
dec2bin8(checkSum);

44
//Serial.println(""); dec2bin8(tempi +
tempd + humi + humd);
//Serial.println(""); if((byte)checkSum == (byte)(tempi +
tempd + humi + humd))
{;//Serial.print("CHECKSUM_OK");
} else
{
;//Serial.print("CHECKSUM_ERROR");
} } int
a1 = 0;
const int
dec = A1;
const int
ent = A2;
int
time_get(
)
{ b1 = 0;
while (1)
{ if (digitalRead(inc) ==
0)
{

45
b1 = b1 + 1; lcd.setCursor(9,
1); lcd.print(b1); lcd.print("
"); while (digitalRead(inc) ==
0);
} if (digitalRead(dec) ==
0)
{ b1 = b1 - 1; lcd.setCursor(9,
1); lcd.print(b1); lcd.print("
"); while (digitalRead(dec) ==
0);
}
h = h | 0x30; //
Serial.write(a);
//Serial.write(c);
Serial.write(e);
Serial.write(g);
Serial.write(h); } void
convertl(unsigned int value)
{ unsigned int a, b, c, d, e, f, g,
h; a = value / 10000; b = value
% 10000; c = b / 1000; d = b %
1000; e = d / 100; f = d % 100;
g = f / 10; h = f % 10; a = a |

46
0x30; c = c | 0x30; e = e |
0x30; g = g | 0x30; h = h |
0x30;
} if (a1 ==
1)
{ lcd.clear();
lcd.setCursor(0, 0);
lcd.print("feed2 time");
lcd.setCursor(0, 1);
lcd.print("Hours :");
lcd.setCursor(9, 1);
feed2 = time_get(); } if
(a1 == 2)
{ lcd.clear();
lcd.setCursor(0, 0);
lcd.print("feed3
time");
lcd.setCursor(0, 1);
lcd.print("Hours :");
lcd.setCursor(9, 1);
feed3 = time_get();
}
}

47
}
delay(1500);
Serial.write("GET https://api.thingspeak.com/update?
api_key=CKLQ71SSJ3S5OSNF&");
} void
things_rcv()
{
Serial.write("AT+CIPSTART=4,\"TCP\",\"184.106.153.149\",80\r\n");
delay(1500);
Serial.write("AT+CIPSEND=4,73\r\n");delay(1500);
Serial.write("GET
https://api.thingspeak.com/channels/1743609/fields/1.json?results=2");
} void
things_done()
{
Serial.write("\r\n\r\n"); delay(1000);
} void
setup()
{ mySerial.begin(9600); // Setting the baud rate of Software Serial
Library Serial.begin(115200); //Setting the baud rate of Serial Monitor
pinMode(relay1,OUTPUT); pinMode(m1a,OUTPUT);
pinMode(m1b,OUTPUT);

48
Serial.write("AT+CWJAP=\"jagruthi\",\"jagruthi@123\"\r\n");
delay(500); okcheck();
Serial.write("AT+CIPMUX=1\r\n"); delay(500); okcheck();
delay(1000); lcd.clear(); lcd.setCursor(0, 0);
lcd.print("Connected"); delay(1000); lcd.clear();
// gsminit();
lcd.clear(); if (!
rtc.begin())
{ lcd.print("Couldn't find
RTC"); while (1);
}
//rtc.adjust(DateTime(F( DATE__), F( TIME__)));//auto update from
computer time
//rtc.adjust(DateTime(2021, 6, 9, 10, 26, 0));// to set the time manualy
lcd.clear();
} void
loop()
{ /*if (digitalRead(ent) == 0)
{ while (digitalRead(ent) == 0); lcd.setCursor(0, 0); lcd.print("Inc:
clock Time "); lcd.setCursor(0, 1); lcd.print("Dec: Feed Time ");
while ((digitalRead(inc) == HIGH) && (digitalRead(dec) ==
HIGH)); if (digitalRead(inc) == LOW)

49
{ while (digitalRead(inc) ==
0); lcd.cursor(); time_set();
lcd.noCursor();
} if (digitalRead(dec) ==
LOW)
{ while (digitalRead(dec) ==
0); feed_time_set();
}
lcd.clear();
}*/
DateTime now = rtc.now();
time_disp();
if ((now.hour() == 12) && (now.minute() == 00) && (now.second() ==
0))
{ digitalWrite(m1a,HIGH)
;
digitalWrite(m1b,LOW);
lcd.setCursor(0, 1);
lcd.print("Feed 1 Time");
things_send();
Serial.write("field2=1");
things_done();

50
delay(5000);
things_send();
Serial.write("field2=1");
things_done();
delay(5000);
digitalWrite(m1a,LOW);
digitalWrite(m1b,LOW);
lcd.clear();
time_disp();
} if ((now.hour() == 16) && (now.minute() == 00) && (now.second() ==
0))
{
digitalWrite(relay1,HIGH);
digitalWrite(m2a,LOW);
digitalWrite(m2b,LOW); things_send();
Serial.write("field3=0");
things_done();
delay(5000); things_send();
Serial.write("field4=0");
things_done();
delay(5000);
things_send();

51
Serial.write("field5=0");
things_done();
delay(5000);
delay(2000);
lcd.clear();
} lcd.clear();
time_disp();
}

52

You might also like