Sei sulla pagina 1di 66

SMART IRRIGATION SYSTEM USING IOT

CHAPTER 1
INTRODUCTION
1.1 OBJECTIVE OF THE PROJECT:
Agribusiness makes utilization of eighty five percentage of to be had freshwater assets
worldwide, and this percent will keep on being overwhelming in water allow because of populace
increment and duplicated nourishment request. There is a squeezing need to make systems construct
absolutely with respect to innovation for maintainable utilization of water,comprehensive of
specialized, agronomic, administrative, and institutional updates.
There are numerous frameworks to procure water investment funds in differing plants,
from central ones to additional mechanically propelled ones. For instance, in a solitary gadget plant
water notoriety changed into checked and water system planned in light of shade temperature
dispersion of the plant, which end up noticeably gotten with warm imaging .moreover, unique
structures have been advanced to time table water system of yields and streamline water use by
utilizing a harvest water strain file (CWSI). This contraption utilizes sensors like stickiness, soil
dampness.
These sensors send qualities to small scale controller. Microcontroller sends qualities to
PC utilizing serial discussion. As indicated by constant sensors esteems relentless diagram is show
on PC and Android Based portable utilizing Internet and Android application. Here edge expense is
keep, if sensor esteems pass the edge charge at that point drip Irrigation segments can be control
mechanically through microcontroller.
1.2 INTRODUCTION TO EMBEDDED SYSTEMS:
An embedded system can be defined as a computing device that does a specific focused
job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine, mobile
phone etc. are examples of embedded systems. Each of these appliances will have a processor and
special hardware to meet the specific requirement of the application along with the embedded
software that is executed by the processor for meeting that specific requirement. The embedded
software is also called “firm ware”. The desktop/laptop computer is a general purpose computer. You
can use it for a variety of applications such as playing games, word processing, accounting, software
development and so on. In contrast, the software in the embedded systems is always fixed listed
below:

Department of ECE KKCT Page 1


SMART IRRIGATION SYSTEM USING IOT

Embedded systems do a very specific task, they cannot be programmed to do different


things. Embedded systems have very limited resources, particularly the memory. Generally, they do
not have secondary storage devices such as the CDROM or the floppy disk. Embedded systems have
to work against some deadlines. A specific job has to be completed within a specific time. In some
embedded systems called real-time systems, the deadlines are stringent. Missing a deadline may
cause a catastrophe-loss of life or damage to property. Embedded systems are constrained for power.
As many embedded systems operate through a battery, the power consumption has to be very low.
Some embedded systems have to operate in extreme environmental conditions such as very high
temperatures and humidity.

Figure 1.1: Embedded System

1.3 EMBEDDED SYSTEM APPLICATIONS:


Nearly 99% of the processors manufactured end up in embedded systems. The embedded
system market is one of the highest growth areas as these systems are used in very market segment
consumer electronics, office automation, industrial automation, biomedical engineering,wireless
communication,data communication, telecommunications, transportation, military and so on.
1.3.1 Consumer appliances:
At home we use a number of embedded systems which include digital camera, DVD player,
electronic toys, microwave oven, remote controls for TV and air-conditioner, VCO player, video
game consoles, video recorders etc. Today’s high-tech car has about 20 embedded systems for
transmission control, engine spark control, air-conditioning, navigation etc. Even wristwatches are
now becoming embedded systems. The palmtops are powerful embedded systems using which we
can carry out many general-purpose tasks such as playing games and word processing.

Department of ECE KKCT Page 2


SMART IRRIGATION SYSTEM USING IOT

1.3.2 Office automation:


The office automation products using an embedded system are copying machine, fax machine,
key telephone, modem, printer, scanner etc.
1.3.3 Industrial automation:
Today a lot of industries use embedded systems for process control. These include
pharmaceutical, cement, sugar, oil exploration, nuclear energy, electricity generation and
transmission. The embedded systems for industrial use are designed to carry out specific tasks such
as monitoring the temperature, pressure, humidity, voltage, current etc., and then take appropriate
action based on the monitored levels to control other devices or to send information to a centralized
monitoring station. In hazardous industrial environment, where human presence has to be avoided,
robots are used, which are programmed to do specific jobs. The robots are now becoming very
powerful and carry out many interesting and complicated tasks such as hardware assembly.
1.3.4 Medical electronics:
Almost every medical equipment in the hospital is an embedded system. These equipments
include diagnostic aids such as ECG, EEG, blood pressure measuring devices, X-ray scanners,
equipment used in blood analysis, radiation, colonoscopy, endoscopy etc. Developments in medical
electronics have paved way for more accurate diagnosis of diseases.
1.3.5 Computer networking:
Computer networking products such as bridges, routers, Integrated Services Digital Networks
(ISDN), Asynchronous Transfer Mode (ATM) and frame relay switches are embedded systems
which implement the necessary data communication protocols. For example, a router interconnects
two networks. The two networks may be running different protocol stacks. The router’s function is to
obtain the data packets from incoming pores, analyze the packets and send them towards the
destination after doing necessary protocol conversion.
1.3.6 Telecommunications:
In the field of telecommunications, the embedded systems can be categorized as subscriber
terminals and network equipment. The subscriber terminals such as key telephones, ISDN phones,
terminal adapters, web cameras are embedded systems. The network equipment includes
multiplexers, multiple access systems, Packet Assemblers Dissemblers (PADs), satellite modems etc.

Department of ECE KKCT Page 3


SMART IRRIGATION SYSTEM USING IOT

IP phone, IP gateway, IP gatekeeper etc. are the latest embedded systems that provide very low-cost
voice communication over the Internet.
1.3.7 Wireless technologies:
Advances in mobile communications are paving way for many interesting applications using
embedded systems. The mobile phone is one of the marvels of the last decade of the 20’th century. It
is a very powerful embedded system that provides voice communication while we are on the move.
The Personal Digital Assistants and the palmtops can now be used to access multimedia services
over the Internet.
1.3.8 Insemination:
Testing and measurement are the fundamental requirements in all scientific and engineering
activities. The measuring equipment we use in laboratories to measure parameters such as weight,
temperature, pressure, humidity, voltage, current etc. are all embedded systems. Test equipment such
as oscilloscope, spectrum analyzer, logic analyzer, protocol analyzer, radio communication test set
etc. are embedded systems built around powerful processors. Thank to miniaturization, the test and
measuring equipment are now becoming portable facilitating easy testing and measurement in the
field by field-personnel.
1.3.9 Security:
Security of persons and information has always been a major issue. We need to protect our
homes and offices and also the information we transmit and store. Developing embedded systems for
security applications is one of the most lucrative businesses nowadays. Security devices at homes,
offices, airports etc. for authentication and verification are embedded systems. Encryption devices
are nearly 99% of the processors that are manufactured end up in embedded systems. Embedded
systems find applications in biometric systems using fingerprint and face recognition are now being
extensively used for user authentication in banking applications as well as for access control in high
security buildings.
1.3.10 Finance:
Financial dealing through cash and cheques are now slowly paving way for transactions using
smart cards and ATM (Automatic Teller Machine, also expanded as Any Time Money) machines.
Smart card of the size of a credit card has a small micro-controller and memory and it interacts with
the smart card reader ATM machine and acts as an electronic wallet. Smart card technology has the

Department of ECE KKCT Page 4


SMART IRRIGATION SYSTEM USING IOT

capability of ushering in a cashless society. Well, the list goes on. It is no exaggeration to say that
eyes wherever you go, you can see, or at least feel, the work of an embedded system
1.4 OVERVIEW OF EMBEDDED SYSTEM ARCHITECTURE:
Every embedded system consists of custom-built hardware built around a Central Processing
Unit (CPU). This hardware also contains memory chips onto which the software is loaded. The
software residing on the memory chip is also called the ‘firmware’. The embedded system
architecture can be represented as a layered architecture as shown in Fig.

Application Software

Operating
System
H/W

Figure 1.2:Interfacing components in an Embedded System

The operating system runs above the hardware and the application software runs above the
operating system. The same architecture is applicable to any computer including a desktop computer.
However, there are significant differences. It is not compulsory to have an operating system in every
embedded system. For small appliances such as remote control units, air conditioners, toys etc., there
is no need for an operating system and you can write only the software specific to that application.
For applications involving complex processing, it is advisable to have an operating system. In such a
case, you need to integrate the application software with the operating system and then transfer the
entire software on to the memory chip. Once the software is transferred to the memory chip, the
software will continue to run for a long time you don’t need to reload new software.

Department of ECE KKCT Page 5


SMART IRRIGATION SYSTEM USING IOT

Read-Only Random Access


Memory (ROM) Memory (RAM)

Input Central Processing Unit Output


Devices Devices
(CPU)

Communication
Application-Specific Security Interfaces

Figure 1.3: Embedded System architecture


Now, let us see the details of the various building blocks of the hardware of an embedded system. As
shown in Fig. the building blocks are;
 Central Processing Unit (CPU)
 Memory (Read-only Memory and Random Access Memory)
 Input Devices
 Output devices
 Communication interfaces
 Application-specific circuitry

1.4.1 Central Processing Unit (CPU):


The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-cost
processor. Its main attraction is that on the chip itself, there will be many other components such as
memory, serial communication interface, analog to digital converter etc. So, for small applications, a
micro-controller is the best choice as the number of external components required will be very less.
On the other hand, microprocessors are more powerful, but you need to use many external
components with them.
DSP is used mainly for applications in which signal processing is involved such as audio and
video processing.

Department of ECE KKCT Page 6


SMART IRRIGATION SYSTEM USING IOT

1.4.2 Memory:
The memory is categorized as Random Access Memory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas ROM
retains the contents even if the power is switched off. So, the firmware is stored in the ROM. When
power is switched on, the processor reads the ROM, The program is executed.
1.4.3 Input devices:
Unlike the desktops, the input devices to an embedded system have very limited capability.
There will be no keyboard or a mouse, and hence interacting with the embedded system is no easy
task. Many embedded systems will have a small keypad-you press one key to give a specific
command. A keypad may be used to input only the digits. Many embedded systems used in process
control do not have any input device for user interaction, they take inputs from sensors or transducers
find produce electrical signals that are in turn fed to other systems.
1.4.4 Output devices:
The output devices of the embedded systems also have very limited capability. Some
embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of the
system modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD) may also
be used to display some important parameters.
1.4.5 Communication interfaces:
The embedded systems may need to, interact with other embedded systems at they may have
to transmit data to a desktop. To facilitate this, the embedded systems are provided with one or a few
communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB), and IEEE
1394, Ethernet etc.
1.4.6Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required fat an
embedded system, depending on its application. This circuitry interacts with the processor to carry
out the necessary work. The entire hardware has to be given power supply either through the 230
volts main supply or through a battery. The hardware has to design in such a way that the power
consumption is minimized.

Department of ECE KKCT Page 7


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 2
EXISTING SYSTEM
In some of the water system contraption water system booking is done by means of following
soil, water prevalence with tension meters underneath trickle water system through the
computerization controller device in sandy soil.
It is exceptionally vital for the rancher to save the substance inside the subject. It is extremely
hard to gauge the substance material of the division. Presently a day there is no framework like this
to quantify.

Department of ECE KKCT Page 8


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 3
PROPOSED SYSTEM
The proposed gadget has exceptional sensors, a small scale controller, GPRS and quality
assets. A few WSUs might be conveyed in-zone to design a dispensed sensor group for the
programmed water system gadget. Every unit relies upon on the miniaturized scale controller that
controls the radio modem GPRS and tactics statistics from the dirt dampness sensor, temperature
sensor and water degree sensor. In this remote sensor unit or transmission unit the sensor information
from various sensors (Soil dampness, temperature, moistness and water degree) are amassed within
the primary controller. This fact is shown on transmission section LCD. Arduino controller is
changed to some restrict estimations of temperature and soil dampness
BLOCK DIAGRAM:

Power supply

DHT11 sensor

GPRS

Soil moisture ARDUINO


sensor LCD
Microcontroller

Pumping motor

Figure 3.1: Block diagram of proposed System

Department of ECE KKCT Page 9


SMART IRRIGATION SYSTEM USING IOT

WORKING:

By using DHT11 we can find the temperature and humidity and soil moisture sensor is used
to detect the condition of the soil. If soil moisture sensor is in dry condition the pumping motor will
on. Here LCD is used to display the temperature and humidity values. By using GPRS we can
transmit the data.

The AC mains are fed to the transformer, which steps down the 230 Volts to the desired
voltage. The bridge rectifier follows the transformer thus converting AC voltage into a DC output
and through a filtering capacitor feeds it directly into the input (Pin 1) of the voltage regulator. The
common pin (Pin 2) of the voltage regulator is grounded. The output (Pin 3) of the voltage regulator
is first filtered by a capacitor, and then the output is taken. Make the circuit on a general purpose
PCB and use a 2 Pin (5A) plug to connect the transformer input to the AC mains via insulated copper
wires.

Department of ECE KKCT Page 10


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 4

HARDWARE DESCRIPTION

4.1 POWER SUPPLY:

A power supply is a device which delivers an exact voltage to another device as per its needs.
There are many power supplies available today in the market like regulated, unregulated, variable
etc, and the decision to pick the correct one depends entirely on what device you are trying to operate
with the power supply.

Step down Rectifier Filter Regulator


transformer

Fig 4.1: Block Diagram of a Power Supply

Power supplies, often called power adapters, or simply adapters, are available in various
voltages, with varying current capacities, which is nothing but the maximum capacity of a power
supply to deliver current to a load (Load is the device you are trying to supply power to).

4.1.1 Need for Power Supply:


 Copper wires, with at least 1 A current carrying capacity for AC mains

 Step Down Transformer

 1N4007 Silica Diodes (x4)


 1000µF Capacitor
 10µF Capacitor
 Voltage regulator
 Soldering iron
 Solder
 General purpose PCB

Department of ECE KKCT Page 11


SMART IRRIGATION SYSTEM USING IOT

Optional:
 LED (for indication)
 Resistor (Value explained later)
 Heat Sink for The Voltage Regulator (For higher current outputs)
 SPST Switch
4.1.2 Transformers:

Transformers are devices which step down a relatively higher AC input Voltage into a lower AC
output voltage. To find the input and output terminals of a transformer is very tricky. Refer to the
following illustration or the internet to understand where what is.

Fig 4.2: I/O Terminals of a Transformer

Basically, there are two sides in a transformer where the coil winding inside the transformer
ends. Both ends have two wires each (unless you are using a center-tapped transformer for full wave
rectification).

On the transformer, one side will have three terminals and the other will have two. The one with
the three terminals is the stepped down output of the transformer, and the one with the two terminals
is where the input voltage is to be provided.

Department of ECE KKCT Page 12


SMART IRRIGATION SYSTEM USING IOT

4.1.3 Voltage Regulators:

The78XX series of voltage regulators is a widely used range of regulators all over the world.
The XX denotes the voltage that the regulator will regulate as output, from the input voltage. For
instance, 7805 will regulate the voltage to 5V.

Similarly, 7812 will regulate the voltage to 12V. The thing to remember with these voltage
regulators is that they need at least 2 volts more than their output voltage as input. For instance, 7805
will need at least 7V, and 7812, at least 14 volts as inputs. This excess voltage which needs to be
given to voltage regulators is called Dropout Voltage.

Fig4.3: Voltage Regulator Schematic

4. 1. 4 Diode Bridge:

A bridge rectifier consists of an assembly of four ordinary diodes, by means of which we can
convert AC Voltage into DC conversion, over Full wave and half wave rectifiers. You can use any
model you want, but I use this for the sake of high efficiency (If you are using the full wave rectifier
model, you’ll need a center-tapped transformer, and you will only be able to use half of the
transformer voltage).One thing to note about diodes is that they drop about 0.7V each when operated
in forward bias. So, in bridge rectification we will drop 1.4V because at one instant two diodes are
conducting and each will drop 0.7V. In case of Full wave rectifier, only 0.7V will be dropped.

So how does this drop affect us? Well, this comes handy while choosing the correct step down
voltage for the transformer. See, our voltage regulator needs 2 Volts more than its output voltage.
For the sake of explanation, let’s assume that we are making a 12V adapter. So the voltage regulator
needs at least 14 Volts as input.

Department of ECE KKCT Page 13


SMART IRRIGATION SYSTEM USING IOT

So the output of the diodes (which goes into the voltage regulator) will have to be more than or equal
to 14 Volts. Now for the diodes input voltage. They’ll drop 1.4 Volts in total, so the input to them
has to be greater than or equal to 14.0 + 1.4 = 15.4 Volts. So I would probably use a 220 to 18 Volt
step down transformer for that. So basically, the transformer step down voltage should be at least 3.4
V more than the desired Power Supply output.

DIODE

Fig 4.4: Schematic and Illustration of a Diode

4.1.5 Filter Circuit:

We filter, both the input and output of the voltage regulator in order to get the smoothest DC
Voltage as possible, from our adapter, for which we use capacitors. Capacitors are the simplest
current filters available, they let AC current pass through and block DC, so they are used in parallel
to the output. Furthermore, if there is a ripple in the input or output, a capacitor rectifies it by
discharging the charge stored in it

Fig 4.5: Capacitive Filter

Department of ECE KKCT Page 14


SMART IRRIGATION SYSTEM USING IOT

4.1.6 Rectifier:

A rectifier is a circuit which converts AC to DC. It is made up of diodes. There are three types
of rectifier circuits.

 Half Wave
 Full Wave
 Bridge Rectifier
A rectifier is generally followed by a filter circuit to improve the quality of output. Rectifiers
play an important part of the power supplies for electronic appliances operating at DC voltages. The
half wave rectifier uses only one diode whereas the full wave and bridge uses two and four diodes
respectively.

Half Wave Rectifier Circuit:

Fig4.6 : Half Wave Rectifier

Full Wave Rectifier Circuit:

Fig 4.7: Full Wave Rectifier circuit using two diodes

Department of ECE KKCT Page 15


SMART IRRIGATION SYSTEM USING IOT

Bridge Wave Rectifier Circuit:

AC
voltage
Load
source
Fig 4.8: Bridge Wave Rectifiers

Working of Rectifiers:
The AC mains are fed to the transformer, which steps down the 230 Volts to the desired voltage.
The bridge rectifier follows the transformer thus converting AC voltage into a DC output and
through a filtering capacitor feeds it directly into the input (Pin 1) of the voltage regulator.
The common pin (Pin2) of the voltage regulator is grounded. The output (Pin3) of the voltage
regulator is first filtered by a capacitor, and then the output is taken. Make the circuit on a general
purpose PCB and use 2 Pin (5A) plug to connect the transformer input to the Ac mains via insulated
copper wires.
4. 1. 7 Circuit Diagram for the Power Supply:

Fig 4.9: circuit diagram of power supply

Department of ECE KKCT Page 16


SMART IRRIGATION SYSTEM USING IOT

4. 2 ARDUINO:
The Arduino microcontroller is an easy to use yet powerful single board computer that has
gained considerable traction in the hobby and professional market. The Arduino is open-source,
which means hardware is reasonably priced and development software is free. This guide is for
students in ME 2011, or students anywhere who are confronting the Arduino for the first time. For
advanced Arduino users, prowl the web; there are lots of resources.
This is what the Arduino board looks like.

Figure 4.10: Arduino UNO Board


The Arduino programming language is a simplified version of C/C++. If you know C,
programming the Arduino will be familiar. If you do not know C, no need to worry as only a few
commands are needed to perform useful functions. An important feature of the Arduino is that you
can create a control program on the host PC, download it to the Arduino and it will run
automatically. Remove the USB cable connection to the PC, and the program will still run from the
top each time you push the reset button. Remove the battery and put the Arduino board in a closet for
six months. When you reconnect the battery, the last program you stored will run. This means that
you connect the board to the host PC to develop and debug your program, but once that is done, you
no longer need the PC to run the program.

Department of ECE KKCT Page 17


SMART IRRIGATION SYSTEM USING IOT

4. 2. 1 Arduino Hardware:

The power of the Arduino is not its ability to crunch code, but rather its ability to interact with
the outside world through its input-output (I/O) pins. The Arduino has 14 digital I/O pins labeled 0 to
13 that can be used to turn motors and lights on and off and read the state of switches.

Each digital pin can sink or source about 40mA of current. This is more than adequate for interfacing
to most devices, but does mean that interface circuits are needed to control devices other than simple
LED's. In other words, you cannot run a motor directly using the current available from an Arduino
pin, but rather must have the pin drive an interface circuit that in turn drives the motor. A later
section of this document shows how to interface to a small motor.

To interact with the outside world, the program sets digital pins to a high or low value using C code
instructions, which corresponds to +5 V or 0 V at the pin. The pin is connected to external interface
electronics and then to the device being switched on and off. The sequence of events is shown in this
figure.

To determine the state of switches and other sensors, the Arduino is able to read the voltage
value applied to its pins as a binary number. The interface circuitry translates the sensor signal into a
0 or +5 V signal applied to the digital I/O pin. Through a program command, the Arduino
interrogates the state of the pin. If the pin is at 0 V, the program will read it as a 0 or LOW. If it is at

Department of ECE KKCT Page 18


SMART IRRIGATION SYSTEM USING IOT

+5 V, the program will read it as a 1 or HIGH. If more than +5 V is applied, you may blow out your
board, so be careful. The sequence of events to read a pin is shown in this figure.

Interacting with the world has two sides. First, the designer must create electronic interface circuits
that allow motors and other devices to be controlled by a low (1-10 mA) current signal that switches
between 0 and 5 V, and other circuits that convert sensor readings into a switched 0 or 5 V signal.

Second, the designer must write a program using the set of Arduino commands that set and
read the I/O pins. Examples of both can be found in the Arduino resources section of the ME2011
web site.

4. 2. 2 Physical Characteristics:

The Arduino Uno can be powered via the USB connection or with an external power supply. The
power source is selected automatically. External (non-USB) power can come either from an AC-to-
DC adapter or battery.

4.2.3 POWER:

The adapter can be connected by plugging a 2.1mm center-positive plug into the board's
power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER
connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than
7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using

Department of ECE KKCT Page 19


SMART IRRIGATION SYSTEM USING IOT

more than 12V, the voltage regulator may overheat and damage the board. The recommended range
is 7 to 12 volts. The power pins are as follows:

 VIN:

The input voltage to the Arduino board when it's using an external power source (as opposed
to 5 volts from the USB connection or other regulated power source). You can supply voltage
through this pin or if supplying voltage via the power jack, access it through this pin.

 5V:

This pin outputs a regulated 5V from the regulator on the board. The board can be supplied
with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the
board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage
your board. We don't advise it.

 3V:

A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

 GND:

Ground pins.

4. 2. 4 Input and Output:

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode (),
digitalWrite (), and digitalRead () functions. They operate at 5 volts. Each pin can provide or receive
a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.
In addition, some pins have specialized functions:

 Serial: 0 (RX) and 1 (TX:.

Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the
corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

 External Interrupts: 2 and 3:

Department of ECE KKCT Page 20


SMART IRRIGATION SYSTEM USING IOT

These pins can be configured to trigger an interrupt on a low value, a rising or falling edge,
or a change in value. See the attachInterrupt() function for details.

 PWM: 3, 5, 6, 9, 10, and 11:

Provide 8-bit PWM output with the analogWrite() function.

 SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK):

These pins support SPI communication using the SPI library.

 LED: 13:

There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is
on, when the pin is LOW, it's off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values).

 TWI:

A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

 AREF:

Reference voltage for the analog inputs. Used with analogReference ()

 Reset:

Bring this line LOW to reset the microcontroller.

Typically used to add a reset button to shields which block the one on the board.

See also the mapping between Arduino pins and ATmega328 ports. The mapping for the Atmega8,
168, and 328 is identical.

Department of ECE KKCT Page 21


SMART IRRIGATION SYSTEM USING IOT

4. 2. 5 Communication:

 The Arduino Uno has a number of facilities for communicating with a computer, another
Arduino, or other microcontrollers.
 The ATmega328 provides UART TTL (5V) serial communication, which is available on digital
pins 0 (RX) and 1 (TX).
 An ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer.
 The '16U2 firmware uses the standard USB COM drivers, and no external driver is needed.
However, on Windows, a.inf file is required.
 The Arduino software includes a serial monitor which allows simple textual data to be sent to
and from the Arduino board.
 The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-
serial chip and USB connection to the computer (but not for serial communication on pins 0 and
1).
 A SoftwareSerial library allows for serial communication on any of the UNO's digital pins. The
ATmega328 also supports I2C (TWI) and SPI communication

4. 3 MICRO CONTROLLER ATMEGA328P:-

4. 3. 1 Features:

 High Performance, Low Power AVR® 8-Bit Microcontroller


 Advanced RISC Architecture

– 131 Powerful Instructions

– Most Single Clock Cycle Execution

– 32 x 8 General Purpose Working Registers

– Fully Static Operation

– Up to 20 MIPS Throughput at 20 MHz

– On-chip 2-cycle Multiplier

Department of ECE KKCT Page 22


SMART IRRIGATION SYSTEM USING IOT

 High Endurance Non-volatile Memory Segments

– 4/8/16/32K Bytes of In-System Self-Programmable Flash program memory


(ATmega48PA/88PA/168PA/328P)

– 256/512/512/1K Bytes EEPROM (ATmega48PA/88PA/168PA/328P)

– 512/1K/1K/2K Bytes Internal SRAM (ATmega48PA/88PA/168PA/328P)

– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

– Data retention: 20 years at 85°C/100 years at 25°C(1)

– Optional Boot Code Section with Independent Lock Bits In-System Programming by
On-chip Boot Program True Read-While-Write Operation

– Programming Lock for Software Security

 Peripheral Features

– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode

– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode

– Real Time Counter with Separate Oscillator

– Six PWM Channels – 8-channel 10-bit ADC in TQFP and QFN/MLF package
Temperature Measurement – 6-channel 10-bit ADC in PDIP Package
Temperature Measurement

– Programmable Serial USART

– Master/Slave SPI Serial Interface

– Byte-oriented 2-wire Serial Interface (Philips I2 C compatible)

– Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

Department of ECE KKCT Page 23


SMART IRRIGATION SYSTEM USING IOT

– Interrupt and Wake-up on Pin Change

 Special Microcontroller Features

– Power-on Reset and Programmable Brown-out Detection

– Internal Calibrated Oscillator

– External and Internal Interrupt Sources

– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby,
and Extended Standby

 I/O and Packages


– 23 Programmable I/O Lines
– 28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLF and 32-pad QFN/MLF
 Operating Voltage:
– 1.8 - 5.5V for ATmega48PA/88PA/168PA/328P
 Temperature Range:
– -40°C to 85°C
 Speed Grade:
– 0 - 20 MHz @ 1.8 - 5.5V
 Low Power Consumption at 1 MHz, 1.8V, 25°C for ATmega48PA/88PA/168PA/328P:
– Active Mode: 0.2 mA
– Power-down Mode: 0.1 µA
– Power-save Mode: 0.75 µA (Including 32 kHz RTC)

Department of ECE KKCT Page 24


SMART IRRIGATION SYSTEM USING IOT

4.3.2PinDiagram:

Fig 4.11: Pin diagram of Microcontroller

Department of ECE KKCT Page 25


SMART IRRIGATION SYSTEM USING IOT

4. 3. 3 Pin Descriptions:
VCC:

Digital supply voltage.

GND:

Ground.

Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2:

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if
the clock is not running.

Depending on the clock selection fuse settings, PB6 can be used as input to the inverting
Oscillator amplifier and input to the internal clock operating circuit. Depending on the clock
selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier.

(If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as
TOSC2.1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. The various
special features of Port B are elaborated in “Alternate Functions of Port B” and ”System Clock and
Clock Options” .

Port C (PC5:0):
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The PC5..0 output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if
the clock is not running.

Department of ECE KKCT Page 26


SMART IRRIGATION SYSTEM USING IOT

 PC6/RESET:
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical
characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is un
programmed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum
pulse length will generate a Reset, even if the clock is not running. The minimum pulse length is
given in Table 28-3 on page 308. Shorter pulses are not guaranteed to generate a Reset. The various
special features of Port C are elaborated in”Alternate Functions of Port C” .
 Port D (PD7:0):
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port D output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if
the clock is not running. The various special features of Port D are elaborated in”Alternate Functions
of Port D”.
 AVCC:
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter. Note that PC6.4 use digital supply voltage, VCC.
 AREF:
AREF is the analog reference pin for the A/D Converter
 ADC7:6 (TQFP and QFN/MLF Package Only):
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to the A/D converter.
These pins are powered from the analog supply and serve as 10-bit ADC channels.

Department of ECE KKCT Page 27


SMART IRRIGATION SYSTEM USING IOT

4. 3. 4 BLOCK DIAGRAM:

Fig 4.12: Block diagram of ATMEGA328P Microcontroller

Department of ECE KKCT Page 28


SMART IRRIGATION SYSTEM USING IOT

4. 3. 5 DESCRIPTION:
The ATmega328P provides the following features: 4/8/16/32K bytes of In System
Programmable Flash with Read-While-Write capabilities, 256/512/512/1K bytes EEPROM,
512/1K/1K/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’s 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
ATmega48PA/88PA/168PA/328P is a powerful microcontroller that provides a highly flexible and
cost effective solution to many embedded control applications.

Department of ECE KKCT Page 29


SMART IRRIGATION SYSTEM USING IOT

4. 3. 6 Memory:

The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of
SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

4. 3. 7 Register File:

 32 8-bit GP registers
 Part of SRAM memory space

Fig 4.13: Register file of microcontroller

4. 3. 8 AVR Memory:

 Program memory – Flash Data memory – SRAM


 F
i
g

4
.
F
i
g
4.14: Data Memory of AVR

Department of ECE KKCT Page 30


SMART IRRIGATION SYSTEM USING IOT

4. 3. 9 Addressing Modes:

The AVR Enhanced RISC microcontroller supports powerful and efficient addressing modes for
access to the program memory (Flash) and data memory (SRAM,Register file, I/O memory, and
extended I/O memory).

Types:
 Direct register addressing
 Direct I/O addressing
 Direct data memory addressing
 Direct data memory with displacement addressing
Direct Register Adressing:
 The operand is contained in register d (Rd).

Fig 4.15: Direct Register Addressing mode

Department of ECE KKCT Page 31


SMART IRRIGATION SYSTEM USING IOT

Direct I/O addressing:

Operand are contained in register r (Rr) and d (Rd). The result is stored in register d (Rd).

Fig 4.16: Direct I/O Addressing Mode

Direct Data Memory Addressing:

A 16-bit Data Address is contained in the 16 LSBs of a two-word instruction.Rd/Rr specifies the
destination or source register.

Fig 4.17: Direct Data Memory Addressing Mode

Department of ECE KKCT Page 32


SMART IRRIGATION SYSTEM USING IOT

Direct Data Memory with Displacement Addressing:

Operand addressing is the result of the Y- or Z-register contents added to the address contained
in six bits of the instruction word. Rd/Rr specifies the destination or source register.

Fig 4.18 : Direct Data Memory with Displacement Addressing Mode

4. 3. 10 Stack Pointer Register:

 Special register in I/O space [3E,3D]


 Enough bits to address data space
 Initialized to RAMED(address of highest memory address)

Table 1: Description of Stack Pointer

Department of ECE KKCT Page 33


SMART IRRIGATION SYSTEM USING IOT

4.3.11 Program Status Register (PSR):

4. 4 LCD (Liquid Crystal Display):-

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide
range of applications. A 16x2 LCD display is very basic module and is very commonly used in
various devices and circuits. These modules are preferred over seven segments and other multi
segment LEDs.

LCDs are economical; easily programmable; have no limitation of displaying special &
even custom characters (unlike in seven segments), animations and so on.

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command
and Data.
The command register stores the command instructions given to the LCD. A command is
an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the LCD.
The data is the ASCII value of the character to be displayed on the LCD. Click to learn more about
internal structure of a LCD.

Department of ECE KKCT Page 34


SMART IRRIGATION SYSTEM USING IOT

4. 4. 1 Pin Diagram:

Fig 4.19: Pin Diagram of LCD

4. 4. 2 Pin Description:
Pin
Function Name
No
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
Register
4 Selects command register when low; and data register when high
Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-

Table2: Pin description of LCD

Department of ECE KKCT Page 35


SMART IRRIGATION SYSTEM USING IOT

4. 4. 3 Block Diagram of LCD Display:-

Fig 4.20: Block Diagram of LCD Display

4. 4. 4 Control and display commands:


Instr Instruction Code Instructio Exe
uctio R R D D D D D D D D n Code cuti
n S / B B B B B B B B Descriptio on
W 7 6 5 4 3 2 1 0 n tim
e
Read 1 1 D D D D D D D D Read data 1.53
Data 7 6 5 4 3 2 1 0 from -
Fro internal 1.64
m RAM ms
RA
M
Writ 1 0 D D D D D D D D Write data 1.53
e 7 6 5 4 3 2 1 0 into -
data internal 1.64
to RAM ms
RA (DDRAM/
M CGRAM)
Busy 0 1 B A A A A A A A Busy flag 39
flag F C C C C C C C (BF: 1→ µs
& 6 5 4 3 2 1 0 LCD
Addr Busy) and
ess contents

Department of ECE KKCT Page 36


SMART IRRIGATION SYSTEM USING IOT

of address
counter in
bits AC6-
AC0.
Set 0 0 1 A A A A A A A Set 39
DDR C C C C C C C DDRAM µs
AM 6 5 4 3 2 1 0 address in
Addr address
ess counter.
Set 0 0 0 1 A A A A A A Set 39
CGR C C C C C C CGRAM µs
AM 5 4 3 2 1 0 Address in
Addr address
ess counter.
Func 0 0 0 0 1 D N F X X Set 39
tion L interface µs
Set data
length
(DL:
4bit/8bit),
Numbers
of display
line (N: 1-
line/2-
line)
display
font type
(F:0→
5×8 dots,
F:1→
5×11 dots)
Curs 0 0 0 0 0 1 S R X X Set cursor 39
or or / / moving µs
Disp C L and
lay display
Shift shift
control bit,
and the
direction
without

Department of ECE KKCT Page 37


SMART IRRIGATION SYSTEM USING IOT

changing
DDRAM
data
Disp 0 0 0 0 0 0 1 D C B Set 39
lay Display(D µs
& ),Cursor(C
Curs ) and
or cursor
On/ blink(b)
Off on/off
control
Entr 0 0 0 0 0 0 0 1 I S Assign 0µs
y / H cursor
Mod D moving
e Set direction
and enable
shift entire
display.
Retu 0 0 0 0 0 0 0 0 1 X Set 43µ
rn DDRAM s
Hom Address to
e “00H”
from AC
and return
cursor to
its original
position if
shifted.
Clea 0 0 0 0 0 0 0 0 0 1 Write 43µ
r “20H” to s
Disp DDRAM
lay and set
DDRAM
Address to
“00H”
from AC
AC –ADDRESS COUNTER:

Table 3: Control and Display commands

Department of ECE KKCT Page 38


SMART IRRIGATION SYSTEM USING IOT

Outline

Now the instruction can be divided mainly in four kinds

1) Function set instructions


2) Address set instructions
3) Data transfer instructions with internal RAM
4) Others

4. 4. 5 Details of the Instructions:


1) Read Data from RAM
R R/ DB DB DB DB DB DB DB DB
S W 7 6 5 4 3 2 1 0

1 1 D7 D6 D5 D4 D3 D2 D1 D0

Read 8bit binary data from DDRAM/CGRAM:


The selection of RAM is set by the previous address set instruction. If the address set instruction
of RAM is not performed before this instruction, the data that is read first is invalid, because the
direction of AC is not determined. If the RAM data is read several times without RAM address set
instruction before read operation,

The correct RAM data from the second, but the first data would be incorrect, as there is no time
to transfer RAM data. In case of DDRAM read operation, cursor shift instruction plays the same role
as DDRAM address set instruction; it also transfers RAM data to the output data registers.

After read operation, the data address counter is automatically increased or decreased by 1
according to the entry mode. After CGRAM read operation, display shift may not be executed
properly.

In case of RAM write operation, AC is increased or decreased by 1 like that of the read
operation. In this time AC indicates the next address position, but the previous data can only by the
read instruction.

2) Write Data to RAM:

RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

Department of ECE KKCT Page 39


SMART IRRIGATION SYSTEM USING IOT

1 0 D7 D6 D5 D4 D3 D2 D1 D0

Write binary 8bit data to DDRAM/CGRAM. The selection of CGRAM or DRAM is set by
the previous address set instruction; DDRAM address set, CGRAM address set. RAM set instruction
can also determine the AC direction to RAM.

After write operation, the address is automatically increased or decreased by 1 according to the entry
mode.

3) Read Busy Flag and Address:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 1 BF AC6 AC5 AC4 AC3 AC2 AC1 AC0

By making this read out operation, it can be determined if the LCD is performing some
internal operation or not. If Busy Flag (BF) is high, some internal operation is going inside the LCD
at that particular moment. To perform further operation the data source (e.g. micro controller) must
wait for the BF to go low. Here, the address counter value can also be read.

4) Set DDRAM Address:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 1 AC6 AC5 AC4 AC3 AC2 AC1 AC0

Set DDRAM address to AC, this instruction makes DDRAM data available from MPU. In 1-
line display mode, DDRAM address rangers from “00H” to “4FH”. In 2-line display mode, DDRAM
address in the first line ranges from “00H” to “27H”, and DDRAM address in the 2 nd line is from
“40H” to “67H”.

5) Set CGRAM address


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 1 AC5 AC4 AC3 AC2 AC1 AC0

Set CGRAM address to AC. This instruction makes CGRAM data available from MPU.

Department of ECE KKCT Page 40


SMART IRRIGATION SYSTEM USING IOT

6) Function Set:

RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 1 DL N F X X

DL: Interface Data Length Control Bit


 DL=’1’ means 8bit mode of data transfer.
 DL=’0’ means 4bit mode of data transfers
When 4 bit mode is activated, the data needs to be transferred in two parts, first higher 4bits, and
then lower 4 bits.

N: Display Line Number Control Bit


 N=’1’ will allows to characters to display in 2-lines
 N=’0’ will allows to characters to display in the first line only

F: Display Font Control Bit


 F=’0’ will use 5×8 dots format display mode
 F=’1’ will use 5×11 dots format display mode

7) Cursor or display Shift:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 0 1 S/C R/L X X

Without writing or reading the display data, shifting right/left cursor position or display. This
instruction is made to correct or search or display data. During 2-line display mode, cursor moves to
the 2nd line after the 40th digit of the 1st line. When displayed data is shifted repeatedly, each line
shifts individually. When display shift is performed, the contents of the address counter are not
changed.

8) Display On/Off Control:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 0 0 1 D C B

This instruction controls Display, Cursor and cursor blink

Department of ECE KKCT Page 41


SMART IRRIGATION SYSTEM USING IOT

D: Display On/Off Control Bit


 D=’1’ means entire display is turned on
 D=’0’ means entire display is turned off. But Display data remains in DDRAM.

C: Cursor On/Off Control Bit:


 C=’1’ turns on the cursor
 C=’0’ turns off the cursor. But I/D register retains the data

B: Cursor Blink On/Off Control Bit:


 B=’1’ makes cursor blink periodically.
 B=’0’ stops the cursor to blink and cursor looks steady if the Cursor is turned on.

9) Entry Mode Set:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 0 0 0 1 I/D SH

This instruction sets the moving direction of cursor and display.


 When I/D= ’1’ cursor moves to the right and DDRAM address is increased by 1.
 When I/D= ’0’ cursor moves to the left and DDRAM address is decreased by 1.
CGRAM operates in the same way in this setting.

10) Return Home:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 0 0 0 0 1 X

This instruction sets the address counter to ‘00H’, and returns the cursor to the first column of
first line. And if display is shifted previously, this instruction shifts this too. The DDRAM contents
don’t change in this instruction.

11) Clear display:


RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

0 0 0 0 0 0 0 0 0 1

Clear all the display data by writing “20H” (ASCII code of ‘space’ character) to all DDRAM
address, AND set value DDRAM address counter (AC) to “00H”. It returns the cursor to the first
column of first line and sets the entry mode to increment mode (I/D=’1’).

Department of ECE KKCT Page 42


SMART IRRIGATION SYSTEM USING IOT

4. 4. 6 8-bit and 4-bit interfacing of LCD:


Now the question is how to display data in the LCD or give command to it. There is two
modes of data transfer are supported by LCD displays.

 4 BIT MODE
 8 BIT MODE

4. 4. 7 8 BIT MODE:

There is lot of stuff that can be done with the LCDs, to start with we will simple display a
couple of strings on the 2 lines of the LCD as shown in the image.

Schematic description

 Data Lines:
In this mode, all of the 8 data lines DB0 to DB7 are connected from the microcontroller to a LCD
module as shown the schematic.
 Control Lines:
The RS, RW and E are control lines, as discussed earlier.
 Power & contrast: Apart from that the LCD should be powered with 5V between PIN 2(VCC) and
PIN 1(gnd). PIN 3 is the contrast pin and is output of center terminal of potentiometer (voltage
divider) which varies voltage between 0 to 5v to vary the contrast.
 Back-light:
The PIN 15 and 16 are used as backlight. The led backlight can be powered through a simple
current limiting resistor as we do with normal leds
.
4. 4. 8 4 BIT MODE:

Schematic

There are following differences in 4 bit mode.

 Only data lines D4 to D7 are used as shown in the schematic below.

Department of ECE KKCT Page 43


SMART IRRIGATION SYSTEM USING IOT

 In code, we need to send the command to select 4 bit mode as shown in the instruction set
above.
4. 4. 9 LCD Display Interfacing – Flowchart:-

Fig 4.21: Flow chart of interfacing LCD display

4. 4. 10 Interfacing 16X2 LCD to Arduino UNO:

Fig 4.22: Interfacing of LCD to Arduino UNO

Department of ECE KKCT Page 44


SMART IRRIGATION SYSTEM USING IOT

RS pin of the LCD module is connected to digital pin12 of the Arduino .R/W pin of the
LCD is grounded .Enable pin of the LCD module is connected to digital pin 11 of the Arduino .In
this project, the LCD module and Arduino are interfaced in the 4-bit mode. This means only four of
the digital input lines of the LCD are used. This method is very simple, requires less connections and
you can almost utilize the full potential of the LCD module .Digital lines DB4, DB5, DB6 and DB7
are interfaced to digital pins 5, 4, 3 and 2 of the Arduino. The 10k potentiometer is used for adjusting
the contrast of the display.560 ohm resistor R1limits the current through the LED. The Arduino can
be powered through the external power jack provided on the board.+5v required in some other parts
of the circuit can be tapped from the 5v source on the Arduino board. The Arduino can be also
powered from the PC through the USB port.

4.5 Soil Moisture sensor:


Soil dampness sensors degree the volumetric water content in soil. Since the direct
gravimetric estimation of free soil dampness calls for wiping out, drying, and weighting of an
example, soil dampness sensors degree the volumetric water content material roundabout by utilizing
some different resources of the dirt, comprising of electric resistance, dielectric relentless, or
transaction with neutrons, as an intermediary for the dampness content material. The connection
among the planned belongings and soil dampness have to be aligned and can range contingent upon
ecological additives, for example, soil type, temperature, or electric conductivity. Reflected
microwave radiation is stimulated by using the dirt dampness and is utilized for detecting in
hydrology and farming. Versatile take a look at devices can be utilized by agriculturists or
cultivators.

Fig 4.23: soil moisture sensor

Department of ECE KKCT Page 45


SMART IRRIGATION SYSTEM USING IOT

4.6 DHT11 SENSOR (TEMPERATURE/HUMIDITY SENSOR):

This DHT11 Temperature and Humidity Sensor include an adjusted advanced flag yield with
the temperature and mugginess sensor complex. Its innovation guarantees the high dependability and
magnificent long haul solidness. An elite 8-bit microcontroller is associated. This sensor incorporates
a resistive component and a feeling of wet NTC temperature measuring gadgets. It has superb
quality, quick reaction, hostile to impedance capacity and high cost execution points of interest.

Each DHT11 sensors highlights to a great degree exact adjustment of dampness alignment
chamber. The adjustment coefficients put away in the OTP program memory, inner sensors identify
motions all the while, we should call these alignment coefficients. The single-wire serial interface
framework is coordinated to end up noticeably snappy and simple. Little size, low power, flag
transmission remove up to 20 meters, making it an assortment of utilizations and even the most
requesting applications. The item is 4-stick single column stick bundle. Advantageous association,
uncommon bundles can be given by clients require.

Specification

 Supply Voltage: +5 V
 Temperature range :0-50 °C error of ± 2 °C
 Humidity :20-90% RH ± 5% RH error
 Interface: Digital

Fig 4.24: Humidity sensor

Department of ECE KKCT Page 46


SMART IRRIGATION SYSTEM USING IOT

4.7 GPRS:
It is a standard set created by the European Telecommunications Standards Institute (ETSI) to
portray conventions for second era (2G) computerized cell systems utilized by cell phones. A
Modem is a gadget which tweaks and demodulates motions as required to meet the correspondence
necessities. It regulates a simple transporter flag to encode computerized info, and furthermore
demodulates such a bearer flag to interpret the transmitted data.
A GPRS Modem is a device that modulates and demodulates the GPRS signals and in this
particular case 2.5G signals. The modem we are using is SIMCOM SIM900. It is a Tri-band GPRS
Modem as it can detect and operate at three frequencies (EGPRS 900 MHz DCS1800 MHz and PCSI
1900 MHz). Default operating frequencies are EGPRS 1900 MHz DCS1800 MHz

Sim900 is a widely used in many projects and hence many variants of development boards for
this have been developed. These development boards are equipped with various features to make it
easy to communicate with the SIM900 module. Some boards provide only TTL interface while some
boards include an RS232 interface and some others include an USB interface. If your PC has an
serial port (DB9) you can buy a GPRS Modem that has both TTL and RS232 interfacing in
economy.

Sim900 GPRS module used here, consists of a TTL interface and an RS232 interface. The TTL
interface allows us to directly interface with a micro controller while the RS232 interface includes a
MAX232 IC to enable communication with the PC. It also consists of a buzzer, antenna and SIM
slot. Sim300 in this application is used as a D0CE(Data Circuit-terminating Equipment) and PC has
a DTE(Data Terminal Equipment).

4.7.1 Function of GPRS:

The GPRS core network is the central part of the general packet radio service (GPRS) which allows
2G, 3G and WCDMA mobile networks to transmit IP packets to external networks such as the Internet.
The GPRS system is an integrated part of the GSM network switching subsystem.

4.7.2 USE OF GPRS:

GPRS Technology has frown so much, that literally there isn’t a place on earth where there is
known a GPRS signal. In such a scenario ‘GPRS provides us wide scope in controlling things

Department of ECE KKCT Page 47


SMART IRRIGATION SYSTEM USING IOT

remotely from any place just with our finger tips. GPRS also provides ease to easily communicate in
a more robust way.

A GPRS module has an RS232 interface for serial communication with an external peripheral.
In this case , the transmit pin(TX) of a computer’s Serial port is connected with the receive pin(RX)
of the GPRS modules RS-232 interface. The transmit pin(TX) of the RS-232 of GPRS module is
connected to receive pin(RX) of microcontroller serial transmission pin. And the serial transmit pin
of the microcontroller is connected to the receive pin of the computer’s Serial port. Therefore the
commands and their results are transmitted and received in a triangular fashion as depicted below.

Fig 4.25: GPRS module

In subsequent projects (see MC075 and MC076), the HyperTerminal will be replaced by the
microcontroller itself; thus avoiding the need of using a Computer to establish an interface. This
would lead to an independent GPRS based system

The microcontroller is programmed to receive and transmit data at a baud rate of 9600. For
more details on setting the baud rate of microcontroller, refer serial communication with 8051.

The controller can receive data signals either by polling or by making use of serial
interrupt(ES). Serial interrupt has been explained in interrupt programming. In polling, the controller
continuously scans serial port for incoming data from the GPRS module.

4.8 SERIAL COMMUNICATION

4.8.1 UART:
UART (Universal Asynchronous Receiver Transmitter) or USART (Universal Synchronous
Asynchronous Receiver Transmitter) are one of the basic interfaces which you will find in almost all

Department of ECE KKCT Page 48


SMART IRRIGATION SYSTEM USING IOT

the controllers available in the market till date. This interface provides a cost effective simple and
reliable communication between one controller to another controller or between a controller and PC.
4.8.2 RS- 232 BASICS:
RS-232 (Recommended Standard 232) is a standard for serial binary data signals connecting
between a DTE (Data terminal equipment) and a DCE (Data Circuit-terminating Equipment).
Voltage levels:
The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels.
Valid signals are plus or minus 3 to 25 volts. The range near zero volts is not a valid RS-232 level; logic
one is defined as a negative voltage, the signal condition is called marking, and has the functional
significance of OFF. Logic zero is positive; the signal condition is spacing, and has the function ON. So
a Logic Zero represented as +3V to +25V and Logic One represented as -3V to -25V.

Department of ECE KKCT Page 49


SMART IRRIGATION SYSTEM USING IOT

4.8.3 RS-232 LEVEL CONVERTER:


Usually all the digital ICs work on TTL or CMOS voltage levels which cannot be used to
communicate over RS-232 protocol. So a voltage or level converter is needed which can convert TTL to
RS232 and RS232 to TTL voltage levels. The most commonly used RS-232 level converter is MAX232.
This IC includes charge pump which can generate RS232 voltage levels (-10V and +10V) from 5V
power supply.

It also includes two receiver and two transmitters and is capable of full-duplex UART/USART
communication.

Fig 4.26: MAX232 Pin Description

Department of ECE KKCT Page 50


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 5
SOFTWARE DESCRIPTION
5.1Arduino IDE:

The Arduino IDE software is a open source software, where we can have the example codes
for the beginners. In the Present world there are lot of version in the Arduino IDE in which present
usage is Version1.0.5. It is very easy to connect the PC with Arduino Board.

First we have to install the Arduino IDE software according to the below instructions:

 Insert the CD-ROM or PENDRIVE which contains the software and then Copy the Setup File
to your desired location.
 After Copying, now click on the setup you will see an window shown below
 Click On NO, not this time. Then after NEXT

FIG 5.1: INSTALLATION WIZARD

 Another Window opens –select Install from a list of specific location and NEXT
 Select “include this location in the search” and then click Browse option available in it
 Now it will Automatically check the USB driver and the software is installed click Finish

Department of ECE KKCT Page 51


SMART IRRIGATION SYSTEM USING IOT

FIG 5.2: INSTALLATION PROCESS


 Now click Finish, the Software will be downloaded.
 Now click on the Arduino IDE icon present on your Desktop. A window will appear like this.

Department of ECE KKCT Page 52


SMART IRRIGATION SYSTEM USING IOT

5.2 SKETCH BOOK:

FIGURE 5.3: SKETCH BOOK


 For any sample programs, select FILE optionExamples.

FIG 5.4: EXAMPLE PROGRAMS


 After Entering the Sample Code in the file, it would look like this

Department of ECE KKCT Page 53


SMART IRRIGATION SYSTEM USING IOT

5.3 UPLOADING:
 Before Connecting we have to select which Board is used by the user, Basically UNO. By selecting
TOOLSBoardARDUINO UNO

FIG 5.5: UPLOADING

Department of ECE KKCT Page 54


SMART IRRIGATION SYSTEM USING IOT

 Now to dump the in the board Connect the Arduino to the PC through the USB port available in it.
Like this TOOLSSERIAL PORTCOMM4,COMM8 etc;

5.4 SERIAL MONITOR:


 To verify the written Program select COMPILE option available in the software (√).
 Now Connect the Board and select the COMM port and then UPLOAD the file in
ARDUINO()
 To OPEN the Previous ARDUINO FILE selects (↑) option.
 To enter new files select NEW option.
 To Save the Existing File, Click on the(↓).
 To Send the Data Through Serial Monitor, Click on the (Ǫ).

Department of ECE KKCT Page 55


SMART IRRIGATION SYSTEM USING IOT

FIG 5.6: SERIAL MONITOR


 Here we can see the Serial Data.

Department of ECE KKCT Page 56


SMART IRRIGATION SYSTEM USING IOT

5.5 PROJECT CODE:

#include <dht.h>

#include <String.h>

#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11 ,5 ,4 ,3 ,2);

dht DHT;

int v;

int x=0;

#define DHT11_PIN 7

int gas,f1,f3;

void setup()

Serial.begin(9600); // the GPRS baud rate

pinMode(8,OUTPUT);

pinMode(A0,INPUT);

lcd.begin(16,2);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("SMART IRRIGATION");

lcd.setCursor(0,1);

lcd.print("SYSTEM USING IOT");

delay(2000);

//ShowSerialData()

Department of ECE KKCT Page 57


SMART IRRIGATION SYSTEM USING IOT

//ShowSerialData();

void loop()

// delay(10);

lcd.clear();

x=analogRead(A0);

v=map(x,340,1023,100,0);

int chk = DHT.read11(DHT11_PIN);

f1= DHT.temperature;

f3= DHT.humidity;

lcd.setCursor(0,0);

lcd.print("T:");

lcd.print(f1);

lcd.setCursor(4,0);

lcd.print((char)223);

lcd.print("H:");

lcd.print(f3);

lcd.setCursor(9,0);

lcd.print("%");

lcd.setCursor(10,0);

lcd.print("S:");

lcd.setCursor(12,0);

Department of ECE KKCT Page 58


SMART IRRIGATION SYSTEM USING IOT

lcd.print(v);

delay(2000);

if(v<30)

lcd.setCursor(0,1);

lcd.print("Motor ON");

delay(1000);

digitalWrite(8,HIGH);

Send2Pachube();

if(v>80)

lcd.setCursor(0,1);

lcd.print("Motor OFF");

delay(1000);

digitalWrite(8,LOW);

Send2Pachube();

// Send2Pachube();

void Send2Pachube()

Serial.println("AT");

Department of ECE KKCT Page 59


SMART IRRIGATION SYSTEM USING IOT

delay(1000);

Serial.println("AT+CPIN?");

delay(1000);

Serial.println("AT+CREG?");

delay(1000);

Serial.println("AT+CGATT?");

delay(1000);

Serial.println("AT+CIPSHUT");

delay(1000);

Serial.println("AT+CIPSTATUS");

delay(2000);

Serial.println("AT+CIPMUX=0");

delay(2000);

Serial.println("AT+CSTT=\"Airtal Internet\"");//start task and setting the APN,

delay(1000);

Serial.println("AT+CIICR");//bring up wireless connection

delay(6000);

Serial.println("AT+CIFSR");//get local IP adress

delay(1000);

Serial.println("AT+CIPSPRT=0");

delay(3000);

Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the
connection

Department of ECE KKCT Page 60


SMART IRRIGATION SYSTEM USING IOT

lcd.clear();

lcd.setCursor(0,0);

lcd.print("data sending...");

lcd.setCursor(0,1);

lcd.print("to servar");

delay(10000);

Serial.println("AT+CIPSEND");//begin send data to remote server

delay(10000);

Stringstr="GET
https://api.thingspeak.com/update?api_key=PNCJVQ2DGVI7QOWJ&field1=" +
String(f1)+ "&field2="+ String(f3)+ "&field3="+ String(v);

Serial.println(str);//begin send data to remote server

delay(6000);

Serial.write(26);//sending

lcd.clear();

lcd.setCursor(0,0);

lcd.print("data sent");

lcd.setCursor(0,1);

lcd.print("to servar");

delay(6000);//waiting for reply,

Serial.println ();

Serial.println ("AT+CIPSHUT");//close the connection

delay (1000); }

Department of ECE KKCT Page 61


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 6
MERITS AND DEMERITS

MERITS:

 Provides a healthy, beautiful landscape


 Reduces water waste
 Saves money
 Provides convenience

DEMERITS:

 System fails when there is no network.


 Graphical representation cannot be displayed

Department of ECE KKCT Page 62


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 7

APPLICATIONS

Applications:
 In Fields we use this to prevent the water wastage and human intervention.
 In Gardens we use this as sprinklers.
 In Nurseries we use this for proper growth in plants.

Department of ECE KKCT Page 63


SMART IRRIGATION SYSTEM USING IOT

CHAPTER 8
EXPERIMENTAL RESULTS

FIG 8.1: CIRCUIT DIAGRAM

Fig 8.2 INTIAL CONDITIONS

Department of ECE KKCT Page 64


SMART IRRIGATION SYSTEM USING IOT

FIG 8.3 MESSAGE DISPLAYING ON LCD AS MOTOR ON

FIG 8.4: MESSAGE DISPLAYING ON LCD AS MOTOR OFF

FIG 8.5 :OUT PUT WAVE FORM

Department of ECE KKCT Page 65


SMART IRRIGATION SYSTEM USING IOT

CONCLUSION AND FUTURE SCOPE


CONCLUSION:
The small scale water system device done wind up plainly resolved to be reasonable and
fetched capable for enhancing water valuable asset for rural creation. This water system framework
lets in development in areas with water shortage subsequently improving maintainability. The
miniaturized scale water system framework created demonstrates that the utilization of water might
be dwindled for a given measure of crisp biomass generation. The utilization of sun control on this
water system gadget is correlated and obviously imperative for natural plants and other farming stock
which can be geologically insolated, in which the interest in electric vitality supply could be
exorbitant. The water system machine might be changed in accordance with a spread of particular
product craves and requires least upkeep. The particular setup of the smaller scale water system
machine lets in it to be scaled up for bigger nurseries or open fields. Likewise, unique projects which
incorporate temperature observing in compost assembling might be effortlessly done.

FUTURE SCOPE:

Our project can be improvised by using a sensor to note the soil PH value such that usage of
unnecessary fertilizers can be reduced. A water meter can be installed to estimate the amount of
water for irrigation and thus giving cost estimation. Further, it also reduces the investment of our
farmers.

Department of ECE KKCT Page 66

Potrebbero piacerti anche