Vous êtes sur la page 1sur 46

ABSTRACT

The project we have undertaken is “Automatic Irrigation System Using Moisture Sensor”. This
project is taken up as India is an agriculture oriented country and the rate at which water
resources are depleting is a dangerous threat hence there is a need of smart and efficient
way of irrigation. In this project we have implemented sensors which detect the humidity in
the soil (agricultural field) and supply water to the field which has water requirement. The
project is 8051 microcontroller based design which controls the water supply and the field to
be irrigated. There are sensors present in each field which are not activated till water is
present on the field.
Once the field gets dry sensors sense the requirement of water in the field and
send a signal to the microcontroller. Microcontroller then supply water to that particular
field which has water requirement till the sensors is deactivated again. In case, when there is
more than one signal for water requirement then the microcontroller will prioritize the first
received signal and irrigate the fields accordingly. The development of the automated
irrigation system based on microcontrollers and wireless communication at experimental
scale within rural areas is presented. The aim of the implementation was to demonstrate
that the automatic irrigation can be used to reduce water use. A microcontroller for data
acquisition, and transceiver; the sensor measurements are transmitted to a microcontroller
based receiver. This gateway permits the automated activation of irrigation when the
threshold values of soil moisture and temperature is reached.

1|Page
Contents
 1.1 INTRODUCTION ______________________________________
4
 1.2 OBJECTIVE OF THE PROJECT__________________________
4
 1.3 ORGANIZATION OF THESIS____________________________
5
 2.1 HARDWARE REQUIREMENTS__________________________
7
 2.2 SOFTWARE REQUIREMENTS___________________________
8
 3.0 HARDWARE DESCRIPTION_____________________________
8
 3.1.1 INTRODUCTION TO
8051_____________________________ 8
 3.1.2 DESCRIPTION OF ATMEGA32
MICROCONTROLLER_____ 9
 3.1.3 BLOCK DIAGRAM OF
CIRCUIT________________________10
 3.1.4 PIN CONFIGURATION_______________________________
11
 3.1.5 PIN DESCRIPTION__________________________________
12
 3.2 DC
MOTOR___________________________________________24
 3.3 RELAY_______________________________________________
26
 3.4
LCD_________________________________________________28
 3.5 SOIL MOISTURE
SENSOR______________________________29
 3.6 VOLTAGE
REGULATOR________________________________31
 3.7
POTENTIOMETER____________________________________32
 3.8 CRYSTAL____________________________________________33
 3.9 BATTERY____________________________________________33
 3.10
PCB________________________________________________34

2|Page
 4.0 SOFTWARE
DESCRIPTION____________________________36
 4.1 PROGRAM
COMPILATION_____________________________40
 5.0
CONCLUSION________________________________________43
 6.0 FUTURE
SCOPE______________________________________43
 REFERENCE_____________________________________________4
4

CHAPTER 1
INTRODUCTION

3|Page
1.1

INTRODUCTION
Embedded systems [1] are finding increasing application not only in Domestic applications
but also in areas of industrial automation, automobiles, power electronics, defence and
space equipment’s. Microcontrollers from the basic building blocks for many embedded
systems. The project deals with the development of infrared remote controller of home
appliances using AT89S51 micro controller, which is used to regulate the power flowing in
the a.c. load using a remote controller sending signals to the micro controller AT89S52 as
interrupts. The device is manufactured using Atmel’s high -density non-volatile memory
technology and is compatible with the industry standards MCS-51 instruction set. By
combining a versatile 8-bit CPU with flash on a monolithic chip, the AT89S52 is a powerful
micro controller which provides a highly flexible and cost effective solution to many
embedded control applications.

An embedded system is not always a separate block, very often it is physically built in to
device it is controlling. The software written for embedded systems is often called firmware,
and is stored in read only memory or flash converter chips rather than a disk drive. It often
runs with limited computer hardware resources: small or no keyboard, screen, and little
memory.

The revolution of home networking is an emerging technology in this digital era. Like many
other A.C. drives gets to be automated with the embedded controllers for most of the
devices for safety at residential areas or in industries. The project is an attempt to
implementation of few consumer electronic products mostly at homes.

1.2 OBJECTIVE OF THE PROJECT

4|Page
The objective of this project is to provide a combination of manual supervision and partial
automation and is similar to manual set-up in most respects but it reduces the labour
involved in terms of Irrigation design is simple, easy to install, microcontroller-based circuit
to monitor and record the values of temperature, soil moisture (Transistor circuit) that are
continuously modified and controlled in order optimize them to achieve maximum plant
growth and yield.

Also, the use of easily available components reduces the manufacturing and. The design is
quite flexible as the software can be changed any time. It can thus be made to the specific
requirements of the user. This makes the proposed system to be an economical, portable
and a low maintenance solution for greenhouse applications, especially in rural areas and for
small scale agriculturists.

1.3 ORGANIZATION OF THESIS


In view of the proposed thesis work explanation of theoretical aspects and algorithms used
in this work are presented as per the sequence described below.

 Describes a brief review of the objectives and goals of the work.


 Discusses the existing technologies and the study of various technologies in detail.
 Describes the Block diagram, Circuit diagram of the project and its description. The
construction and description of various modules used for the application are
described in detail.
 Description of AT89S51
 Description of soil moisture, temperature
 Description of Relays, Motor, LCD, ADC.
 Explains the Software tools required for the project, the Code developed for the
design.

1.4 BLOCK DIAGRAM

5|Page
Fig: Block Diagram of Circuit

CHAPTER 2
HARDWARE AND SOFTWARE
DESCRIPTION

6|Page
2
HARDWARE AND SOFTWARE REQUIREMENTS
In this project, various types of hardware and software parts and program
are required as given below:

2.1 Hardware Requirements

1. ATMEGA32 (Microcontroller)

2. Soil Moisture Sensor

3. Battery

4. Capacitor

5. 16x2 LCD

6. LED

7. Relay

8. DC Motor

9. Sensor Input Driver

10. PCB Board

11. Switch

12. Voltage Regulator

7|Page
13. Crystal

14. Soldering Equipment

15. Pipe

For PCB Designing

1. Coppercleated board
2. Butterworth Paper
3. Printer
4. Electric Iron

2.2 Software Requirements

1. Arduino

3
HARDWARE DESCRIPTION
3.1 Microcontroller (8051)

3.1.1 Introduction to 8051[2]

In 1981, Intel Corporation, Intel Corporation introduced an 8 bit Microprocessor called 8051.
This microcontroller has 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial
port, and four ports all on one single chip. At the time it was also referred as “A SYSTEM ON
A CHIP”.

When it became widely popular, Intel allowed other manufacturers to make and market
different flavors of 8051 with its code compatible with 8051. It means that if you write your
program for one flavor of 8051, it will run on other flavors too, regardless of the
manufacturer. This has led to several versions with different speeds and amounts of on-chip
RAM.

8051 Members

89S52 microcontroller – 89S52 has all the standard features of the 8051 microcontroller as
well as an extra 128 bytes of RAM and an extra timer. It also has 8K bytes of on-chip program
ROM instead of 4K bytes.

8|Page
8031 microcontroller − It is another member of the 8051 family. This chip is often referred to
as a ROM-less 8051, since it has 0K byte of on-chip ROM. You must add external ROM to it in
order to use it, which contains the program to be fetched and executed. This program can be
as large as 64K bytes. But in the process of adding external ROM to the 8031, it lost 2 ports
out of 4 ports. To solve this problem, we can add an external I/O to the 8031. [2]

3.1.2 Description of ATMEGA32 Microcontroller [3]

The ATmega32 provides the following features: 32Kbytes of In-System Programmable Flash
Program memory with Read-While-Write capabilities, 1024bytes EEPROM, 2Kbyte SRAM, 32
general purpose I/O lines, 32 general purpose working registers, a JTAG interface for
Boundaryscan, On-chip Debugging support and programming, three flexible Timer/Counters
with compare modes, Internal and External Interrupts, a serial programmable USART, a byte
oriented Two-wire Serial Interface, an 8-channel, 10-bit ADC with optional differential input
stage with programmable gain (TQFP package only), a programmable Watchdog Timer with
Internal Oscillator, an SPI serial port, and six software selectable power saving modes. The
Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter,
SRAM, Timer/Counters, 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 External 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. Features of 8051 Microcontroller

An ATMEGA microcontroller comes bundled with the following features −

 32K bytes on-chip program memory (ROM)


 128 bytes on-chip data memory (RAM)
 Four register banks
 128 user defined software flags
 8-bit bidirectional data bus
 16-bit unidirectional address bus
 32 general purpose registers each of 8-bit
 16 bit Timers (usually 2, but may have more or less)
 Three internal and two external Interrupts
 Four 8-bit ports,(short model have two 8-bit ports)
 16-bit program counter and data pointer
 ATMEGA32 may also have a number of special features such as UARTs, ADC, Op-amp, etc.

9|Page
3.1.3 Block Diagram of Microcontroller

Fig 3.1- Block Diagram of ATMEGA32 Microcontroller

10 | P a g e
3.1.4 Pin Configuration

Fig 3.2 – Pin Diagram of ATMEGA32

11 | P a g e
3.1.5 Pin Description
VCC
Digital supply voltage.

GND
Ground.

Port A (PA7..PA0)
Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-
directional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up
resistors (selected for each bit). The Port A output buffers have symmetrical drive
characteristics with both high sink and source capability. When pins PA0 to PA7 are used as
inputs and are externally pulled low, they will source current if the internal pull-up resistors
are activated. The Port A pins are tri-stated when a reset condition becomes active, even if
the clock is not running.

Port B (PB7..PB0)

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. Port B also serves the functions of various
special features of the ATmega32.

Port C (PC7..PC0)

Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port C 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. If the JTAG interface is enabled, the pull-up
resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset occurs.
The TD0 pin is tri-stated unless TAP states that shift out data are entered. Port C also serves
the functions of the JTAG interface and other special features of the ATmega32.

Port D (PD7..PD0)

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. Port D also serves the functions of various
special features of the ATmega32.

12 | P a g e
RESET

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 15 on page
37. Shorter pulses are not guaranteed to generate a reset.

XTAL1
Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.

XTAL2
Output from the inverting Oscillator amplifier.

AVCC
AVCC is the supply voltage pin for Port A and the A/D Converter. 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.

AREF
AREF is the analog reference pin for the A/D Converter.

ALU – Arithmetic Logic Unit


The high-performance Atmel ALU operates in direct connection with all the 32 general
purpose working registers. Within a single clock cycle, arithmetic operations between
general purpose registers or between a register and an immediate are executed. The ALU
operations are divided into three main categories – arithmetic, logical, and bit-functions.
Some implementations of the architecture also provide a powerful multiplier supporting
both signed/unsigned multiplication and fractional format.

Status Register
The Status Register contains information about the result of the most recently executed
arithmetic instruction. This information can be used for altering program flow in order to
perform conditional operations. Note that the Status Register is updated after all ALU
operations, as specified in the Instruction Set Reference. This will in many cases remove the
need for using the dedicated compare instructions, resulting in faster and more compact
code.
The Status Register is not automatically stored when entering an interrupt routine and
restored when returning from an interrupt. This must be handled by software.

13 | P a g e
Bit 7 – I: Global Interrupt Enable

The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual
interrupt enable control is then performed in separate control registers. If the Global
Interrupt Enable Register is cleared, none of the interrupts are enabled independent of the
individual interrupt enable settings. The I-bit is cleared by hardware after an interrupt has
occurred, and is set by the RETI instruction to enable subsequent interrupts. The I-bit can
also be set and cleared by the application with the SEI and CLI instructions, as described in
the instruction set reference.

• Bit 6 – T: Bit Copy Storage

The Bit Copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T-bit as source or desti-
nation for the operated bit. A bit from a register in the Register File can be copied into T by
the BST instruction, and a bit in T can be copied into a bit in a register in the Register File by
the BLD instruction.

• Bit 5 – H: Half Carry Flag

The Half Carry Flag H indicates a half carry in some arithmetic operations. Half Carry is useful
in BCD arithmetic.

• Bit 4 – S: Sign Bit, S = N ⊕ V

The S-bit is always an exclusive or between the Negative Flag N and the Two’s Complement
Overflow Flag V.

• Bit 3 – V: Two’s Complement Overflow Flag

The Two’s Complement Overflow Flag V supports two’s complement arithmetics.

• Bit 2 – N: Negative Flag

The Negative Flag N indicates a negative result in an arithmetic or logic operation

• Bit 1 – Z: Zero Flag

The Zero Flag Z indicates a zero result in an arithmetic or logic operation.

• Bit 0 – C: Carry Flag

The Carry Flag C indicates a carry in an arithmetic or logic operation.

General Purpose Register File

14 | P a g e
The Register File is optimized for the Atmel ® AVR ® Enhanced RISC instruction set. In order
to achieve the required performance and flexibility, the following input/output schemes are
supported by the Register File:
• One 8-bit output operand and one 8-bit result input
• Two 8-bit output operands and one 8-bit result input
• Two 8-bit output operands and one 16-bit result input
• One 16-bit output operand and one 16-bit result input
Most of the instructions operating on the Register File have direct access to all registers, and
most of them are single cycle instructions.

As shown in Figure 4, each register is also assigned a data memory address, mapping them
directly into the first 32 locations of the user Data Space. Although not being physically
implemented as SRAM locations, this memory organization provides great flexibility in
access of the registers, as the X-, Y-, and Z-pointer Registers can be set to index any register
in the file.

The X-register, Y-register and Z-register

The registers R26..R31 have some added functions to their general purpose usage. These
registers are 16-bit address pointers for indirect addressing of the Data Space. The three
indirect address registers X, Y, and Z are defined as described in Figure 5.

15 | P a g e
Stack Pointer
The Stack is mainly used for storing temporary data, for storing local variables and for storing
return addresses after interrupts and subroutine calls. The Stack Pointer Register always
points
to the top of the Stack. Note that the Stack is implemented as growing from higher memory
locations to lower memory locations. This implies that a Stack PUSH command decreases the
Stack Pointer.
The Stack Pointer points to the data SRAM Stack area where the Subroutine and Interrupt
Stacks are located. This Stack space in the data SRAM must be defined by the program
before
any subroutine calls are executed or interrupts are enabled. The Stack Pointer must be set to
point above $60. The Stack Pointer is decremented by one when data is pushed onto the
Stack
with the PUSH instruction, and it is decremented by two when the return address is pushed
onto the Stack with subroutine call or interrupt. The Stack Pointer is incremented by one
when data is popped from the Stack with the POP instruction, and it is incremented by two
when data is popped from the Stack with return from subroutine RET or return from
interrupt RETI.
The AVR Stack Pointer is implemented as two 8-bit registers in the I/O space. The number of
bits actually used is implementation dependent. Note that the data space in some
implementations of the AVR architecture is so small that only SPL is needed. In this case, the
SPH Register will not be present.

Reset and Interrupt Handling

16 | P a g e
The Atmel provides several different interrupt sources. These interrupts and the separate
reset vector each have a separate program vector in the program memory space. All interrupts
are assigned individual enable bits which must be written logic one together with the Global
Interrupt Enable bit in the Status Register in order to enable the interrupt. Depending on the Pro-
gram Counter value, interrupts may be automatically disabled when Boot Lock bits BLB02 or
BLB12 are programmed. This feature improves software security.
The lowest addresses in the program memory space are by default defined as the Reset and
Interrupt Vectors. The complete list of vectors is shown in “Interrupts” on page 44. The list also
determines the priority levels of the different interrupts. The lower the address the higher is the
priority level. RESET has the highest priority, and next is INT0 – the External Interrupt Request 0. The
Interrupt Vectors can be moved to the start of the Boot Flash section by setting the IVSEL
bit in the General Interrupt Control Register (GICR). Refer to “Interrupts” on page 44 for more
information. The Reset Vector can also be moved to the start of the boot Flash section by pro-
gramming the BOOTRST fuse.
When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are dis-
abled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled
interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a
Return from Interrupt instruction – RETI – is executed.
I/O Memory
The I/O space definition of the ATmega32 is shown in “Register Summary” on page 327.
All ATmega32 I/Os and peripherals are placed in the I/O space. The I/O locations are accessed
by the IN and OUT instructions, transferring data between the 32 general purpose working regis-
ters and the I/O space. I/O Registers within the address range $00 - $1F are directly bit-
accessible using the SBI and CBI instructions. In these registers, the value of single bits can be
checked by using the SBIS and SBIC instructions. Refer to the Instruction Set section for more
details. When using the I/O specific commands IN and OUT, the I/O addresses $00 - $3F must
be used. When addressing I/O Registers as data space using LD and ST instructions, $20 must
be added to these addresses.
For compatibility with future devices, reserved bits should be written to zero if accessed.
Reserved I/O memory addresses should never be written.
Some of the Status Flags are cleared by writing a logical one to them. Note that the CBI and SBI
instructions will operate on all bits in the I/O Register, writing a one back into any flag read as
set, thus clearing the flag. The CBI and SBI instructions work with registers $00 to $1F only.

Crystal Oscillator

17 | P a g e
XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be con-
figured for use as an On-chip Oscillator, as shown in Figure 12. Either a quartz crystal or a
ceramic resonator may be used. The CKOPT Fuse selects between two different Oscillator
amplifier modes. When CKOPT is programmed, the Oscillator output will oscillate will a full rail-
to-rail swing on the output. This mode is suitable when operating in a very noisy environment or
when the output from XTAL2 drives a second clock buffer. This mode has a wide frequency
range. When CKOPT is unprogrammed, the Oscillator has a smaller output swing. This reduces
power consumption considerably. This mode has a limited frequency range and it cannot be
used to drive other clock buffers.
For resonators, the maximum frequency is 8MHz with CKOPT unprogrammed and 16 MHz with
CKOPT programmed. C1 and C2 should always be equal for both crystals and resonators. The
optimal value of the capacitors depends on the crystal or resonator in use, the amount of stray
capacitance, and the electromagnetic noise of the environment. Some initial guidelines for
choosing capacitors for use with crystals are given in Table 4. For ceramic resonators, the
capacitor values given by the manufacturer should be used.

Power Management and Sleep Modes


Sleep modes enable the application to shut down unused modules in the MCU, thereby saving
power. The AVR provides various sleep modes allowing the user to tailor the power consumption to
the application’s requirements.
To enter any of the six sleep modes, the SE bit in MCUCR must be written to logic one and a
SLEEP instruction must be executed. The SM2, SM1, and SM0 bits in the MCUCR Register
select which sleep mode (Idle, ADC Noise Reduction, Power-down, Power-save, Standby, or
Extended Standby) will be activated by the SLEEP instruction. See Table 13 for a summary. If
an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU is
then halted for four cycles in addition to the start-up time, it executes the interrupt routine, and

18 | P a g e
resumes execution from the instruction following SLEEP. The contents of the Register File and
SRAM are unaltered when the device wakes up from sleep. If a Reset occurs during sleep
mode, the MCU wakes up and executes from the Reset Vector.

Idle Mode
When the SM2..0 bits are written to 000, the SLEEP instruction makes the MCU enter Idle
mode, stopping the CPU but allowing SPI, USART, Analog Comparator, ADC, Two-wire Serial
Interface, Timer/Counters, Watchdog, and the interrupt system to continue operating. This sleep
mode basically halts clk CPU and clk FLASH, while allowing the other clocks to run.
Idle mode enables the MCU to wake up from external triggered interrupts as well as internal
ones like the Timer Overflow and USART Transmit Complete interrupts. If wake-up from the
Analog Comparator interrupt is not required, the Analog Comparator can be powered down by
setting the ACD bit in the Analog Comparator Control and Status Register – ACSR. This will
reduce power consumption in Idle mode. If the ADC is enabled, a conversion starts automatically
when this mode is entered.

ADC Noise Reduction Mode


When the SM2..0 bits are written to 001, the SLEEP instruction makes the MCU enter ADC
Noise Reduction mode, stopping the CPU but allowing the ADC, the External Interrupts, the
Two-wire Serial Interface address watch, Timer/Counter2 and the Watchdog to continue operat-
ing (if enabled). This sleep mode basically halts clk I/O, clk CPU, and clk FLASH, while allowing the
other clocks to run.
This improves the noise environment for the ADC, enabling higher resolution measurements. If
the ADC is enabled, a conversion starts automatically when this mode is entered. Apart from the
ADC Conversion Complete interrupt, only an External Reset, a Watchdog Reset, a Brown-out
Reset, a Two-wire Serial Interface Address Match Interrupt, a Timer/Counter2 interrupt, an
SPM/EEPROM ready interrupt, an External level interrupt on INT0 or INT1, or an external interrupt
on INT2 can wake up the MCU from ADC Noise Reduction mode.

Power-down Mode
When the SM2..0 bits are written to 010, the SLEEP instruction makes the MCU enter Power down
mode. In this mode, the External Oscillator is stopped, while the External interrupts, the
Two-wire Serial Interface address watch, and the Watchdog continue operating (if enabled).
Only an External Reset, a Watchdog Reset, a Brown-out Reset, a Two-wire Serial Interface

19 | P a g e
address match interrupt, an External level interrupt on INT0 or INT1, or an External interrupt on
INT2 can wake up the MCU. This sleep mode basically halts all generated clocks, allowing operation
of asynchronous modules only.
Note that if a level triggered interrupt is used for wake-up from Power-down mode, the changed
level must be held for some time to wake up the MCU. Refer to “External Interrupts” on page 66
for details.
When waking up from Power-down mode, there is a delay from the wake-up condition occurs
until the wake-up becomes effective. This allows the clock to restart and become stable after
having been stopped. The wake-up period is defined by the same CKSEL fuses that define the
reset time-out period, as described in “Clock Sources” on page 25.

Power-save Mode
When the SM2..0 bits are written to 011, the SLEEP instruction makes the MCU enter Power save
mode. This mode is identical to Power-down, with one exception:
If Timer/Counter2 is clocked asynchronously, that is, the AS2 bit in ASSR is set, Timer/Counter2
will run during sleep. The device can wake up from either Timer Overflow or Output Compare
event from Timer/Counter2 if the corresponding Timer/Counter2 interrupt enable bits are set in
TIMSK, and the Global Interrupt Enable bit in SREG is set.
If the Asynchronous Timer is NOT clocked asynchronously, Power-down mode is recommended
instead of Power-save mode because the contents of the registers in the Asynchronous Timer
should be considered undefined after wake-up in Power-save mode if AS2 is 0.
This sleep mode basically halts all clocks except clk ASY, allowing operation only of asynchronous
modules, including Timer/Counter2 if clocked asynchronously.

Standby Mode
When the SM2..0 bits are 110 and an external crystal/resonator clock option is selected, the
SLEEP instruction makes the MCU enter Standby mode. This mode is identical to Power-down
with the exception that the Oscillator is kept running. From Standby mode, the device wakes up
in six clock cycles.

System Control and Reset


Resetting the AVR
During Reset, all I/O Registers are set to their initial values, and the program starts execution from
the Reset Vector. The instruction placed at the Reset Vector must be a JMP – absolute

20 | P a g e
jump – instruction to the reset handling routine. If the program never enables an interrupt
source, the Interrupt Vectors are not used, and regular program code can be placed at these
locations. This is also the case if the Reset Vector is in the Application section while the Interrupt
Vectors are in the Boot section or vice versa.

The I/O ports of the AVR are immediately reset to their initial state when a reset source goes
active. This does not require any clock source to be running.
After all reset sources have gone inactive, a delay counter is invoked, stretching the Internal
Reset. This allows the power to reach a stable level before normal operation starts. The time-out
period of the delay counter is defined by the user through the CKSEL Fuses.

21 | P a g e
Reset Sources
The ATmega32 has five sources of reset:
• Power-on Reset. The MCU is reset when the supply voltage is below the Power-on Reset
threshold (V POT).
• External Reset. The MCU is reset when a low level is present on the RESET pin for longer
than the minimum pulse length.
• Watchdog Reset. The MCU is reset when the Watchdog Timer period expires and the
Watchdog is enabled.
• Brown-out Reset. The MCU is reset when the supply voltage V CC is below the Brown-out
Reset threshold (V BOT) and the Brown-out Detector is enabled.
• JTAG AVR Reset. The MCU is reset as long as there is a logic one in the Reset Register,
one of the scan chains of the JTAG system.

Watchdog Timer
The Watchdog Timer is clocked from a separate On-chip Oscillator which runs at 1MHz. This is the
typical value at V CC = 5V. See characterization data for typical values at other V CC levels. By
controlling the Watchdog Timer prescaler, the Watchdog Reset interval can be adjusted as
shown in Table 17 on page 42. The WDR – Watchdog Reset – instruction resets the Watchdog
Timer. The Watchdog Timer is also reset when it is disabled and when a Chip Reset occurs.
Eight different clock cycle periods can be selected to determine the reset period. If the reset
period expires without another Watchdog Reset, the ATmega32 resets and executes from the
Reset Vector. For timing details on the Watchdog Reset, refer to page 40.

22 | P a g e
To prevent unintentional disabling of the Watchdog, a special turn-off sequence must be followed
when the Watchdog is disabled.

Interrupts
This section describes the specifics of the interrupt handling as performed in ATmega32.

Timer/Counter Clock Sources


The Timer/Counter can be clocked by an internal or an external clock source. The clock
source

23 | P a g e
is selected by the clock select logic which is controlled by the clock select (CS02:0) bits
located
in the Timer/Counter Control Register (TCCR0).

Counter Unit
The main part of the 8-bit Timer/Counter is the programmable bi-directional counter unit.
Figure shows a block diagram of the counter and its surroundings.

Signal description (internal signals):


count Increment or decrement TCNT0 by 1.
direction Select between increment and decrement.
clear Clear TCNT0 (set all bits to zero).
clk Tn Timer/Counter clock, referred to as clk T0 in the following.
TOP Signalize that TCNT0 has reached maximum value.
BOTTOM Signalize that TCNT0 has reached minimum value (zero).

3.2 DC Motor:
A DC Motor[4] is any of a class of rotary electrical machines that converts direct current electrical energy
into mechanical energy. The most common types rely on the forces produced by magnetic fields. Nearly
all types of DC motors have some internal mechanism, either electromechanical or electronic, to
periodically change the direction of current flow in part of the motor. DC motors were the first form of
motor widely used, as they could be powered from existing direct-current lighting power distribution
systems. A DC motor's speed can be controlled over a wide range, using either a variable supply voltage or

24 | P a g e
by changing the strength of current in its field windings. Small DC motors are used in tools, toys, and
appliances. The universal motor can operate on direct current but is a lightweight brushed motor used for
portable power tools and appliances. Larger DC motors are currently used in propulsion of electric
vehicles, elevator and hoists, and in drives for steel rolling mills. The advent of power electronics has
made replacement of DC motors with AC motors possible in many applications.

3.2.1 DC Motor Components:


Stator :The stator consists of either a permanent magnet or electromagnetic windings, and generates

a stationary magnetic field around the rotor which occupies the central part of the motor.

Rotor ( Armature ) :The rotor is made up of one or more electric windings around armature arms.

These electric windings generate a magnetic field when energized by the external current. The

magnetic poles thus generated by this rotor field are attracted to the opposite poles generated by the

stator field and repelled by the similar poles, which causes the rotor to rotate.

Commutator :The DC motor doesn’t use an external current switching device, instead it uses a

mechanical connector called the commutator which is a segmented sleeve usually made of copper,

mounted on the rotating shaft. The current +/- is supplied to this commutator segments with the help

of brushes.

Brushes :As the motor turns the brushes slide over the commutator segments hence creating the

variable magnetic field in different arms through the commutator segments attached to the windings.

Hence a dynamic magnetic field is generated in motor when a voltage is applied across the brushes.

3.2.2 How DC motor works?

A magnetic field is produced as the current passes through the wire, or coil of wires. This magnetic

field opposes against the permanent magnet set the right beside the coil Thus resulting in a force going up

or down depends on the right hand rule. When the motor rotates, the direction of the current will change

25 | P a g e
to the other direction. Consequently, keeping the polarity of electromagnetic force always opposing the

permanent magnet. Therefore, the motor keep rotating as long as electrical power is constantly supplied.

3.3 RELAY:

A RELAY[5] is classified into many types, a standard and generally used relay is made up of electromagnets

which in general used as a switch. Dictionary says that relay means the act of passing something from

one thing to another, the same meaning can be applied to this device because the signal received

from one side of the device controls the switching operation on the other side. So relay is a switch

which controls (open and close) circuits electromechanically. The main operation of this device is to

make or break contact with the help of a signal without any human involvement in order to switch it ON or OFF.

It is mainly used to control high powered circuit using a low power signal.

3.3.1 Construction of RELAY and its operation:

On a casing, a core with copper windings (forms a coil) winded on it is placed. A movable a
consists of a spring support or stand like structure connected to one end, and a metal cont
connected to
another side, all these arrangements are placed over the core such that, when the coil is e
attracts the armature. The movable armature is generally considered as a common termin
to
be connected to the external circuitry. The relay also has two pins namely normally close
normally
opened (NC and NO), the normally closed pin is connected to the armature or the comm

26 | P a g e
terminal
whereas the normally opened pin is left free (when the coil is not energized). When the coi
energized
the armature moves and is get connected to the normally opened contact till there exists fl
current
through the coil. When it is de-energized it goes to its initial position.

3.3.2 How RELAY Works:

Relay in NORMALLY CLOSED condition:


When no voltage is applied to the core, it cannot generate any magnetic field and it doesn
magnet. Therefore, it cannot attract the movable armature. Thus, the initial position itself i
connected in normally closed position (NC).
Relay in NORMALLY OPENED condition:
When sufficient voltage is applied to the core it starts to create a magnetic field around it a
magnet. Since the movable armature is placed within its range, it gets attracted to that ma
created by the core, thus the position of the armature is being altered. It is now connected
normally opened pin of the relay and external circuit connected to it function in a different
So finally, we can say that when a coil is energized the armature is attracted and the switc
can be seen, if the coil is de-energized it loses its magnetic property and the armature goe
initial position.

Fig: Relay

27 | P a g e
3.4 LCD(Liquid Crystal Display):

LCD[6] (liquid crystal display) is the technology used for displays in notebook and other sm
Like light-emitting diode (LED) and gas-plasma technologies, LCDs allow displays to be mu
cathode ray tube (CRT) technology. LCDs consume much less power than LED and gas-disp
because they work on the principle of blocking light rather than emitting it.
An LCD is made with either a passive matrix or an active matrix display display grid. The a
is also known as a thin film transistor (TFT) display. The passive matrix LCD has a grid of co
pixels located at each intersection in the grid. A current is sent across two conductors on th
the light for any pixel.

Fig: LCD Screen

3.4.1 How LCD’s Work:


The principle behind the LCD’s is that when an electrical current is applied to the liquid crystal molecule, the
molecule tends to untwist. This causes the angle of light which is passing through the molecule of the polarized
glass and also cause a change in the angle of the top polarizing filter. As a result a little light is allowed to pass the
polarized glass through a particular area of the LCD. Thus that particular area will become dark compared to other.
The LCD works on the principle of blocking light. While constructing the LCD’s, a reflected mirror is arranged at
the back. An electrode plane is made of indium-tin oxide which is kept on top and a polarized glass with a
polarizing film is also added on the bottom of the device. The complete region of the LCD has to be enclosed by
a common electrode and above it should be the liquid crystal matter.
Next comes to the second piece of glass with an electrode in the form of the rectangle on the bottom and, on top,
another polarizing film. It must be considered that both the pieces are kept at right angles. When there is no
current, the light passes through the front of the LCD it will be reflected by the mirror and bounced back. As the
electrode is connected to a battery the current from it will cause the liquid crystals between the common-plane
electrode and the electrode shaped like a rectangle to untwist. Thus the light is blocked from passing through.
That particular rectangular area appears blank.

28 | P a g e
3.4.2 Advantages of LCD:

 LCD’s consumes less amount of power compared to CRT and LED


 LCD’s are consist of some microwatts for display in comparison to some mill watts fo
 LCDs are of low cost
 Provides excellent contrast
 LCD’s are thinner and lighter when compared to cathode ray tube and LED

3.4.3 Disadvantages of LCD:

 Require additional light sources


 Range of temperature is limited for operation
 Low reliability
 Speed is very low
 LCD’s need an AC drive

3.5 SOIL MOISTURE SENSOR:

Soil moisture sensors measure the volumetric water content in soil. Since the direct gra
measurement of free soil moisture requires removing, drying, and weighting of a sample, s
sensors measure the volumetric water content indirectly by using some other property of t
electrical resistance, dielectric constant, or interaction with neutrons, as a proxy for the mo
The relation between the measured property and soil moisture must be calibrated and may
on environmental factors such as soil type, temperature, or electric conductivity. Reflected
radiation is affected by the soil moisture and is used for remote sensing in hydrology and a
Portable probe instruments can be used by farmers or gardeners.
Soil moisture sensors typically refer to sensors that estimate volumetric water content. An
of sensors measure another property of moisture in soils called water potential; these sens
usually referred to as soil water potential sensors and include tensiometers and gypsum bl

3.5.1 Working Of Sensor:


The soil moisture sensor consists of two probes which are used to measure the volumetric content of water.

The two probes allow the current to pass through the soil and then it gets the resistance value to measure the

moisture value.

When there is more water, the soil will conduct more electricity which means that there will be less resistance.

Therefore, the moisture level will be higher. Dry soil conducts electricity poorly, so when there will be less water,

29 | P a g e
then the soil will conduct less electricity which means that there will be more resistance. Therefore, the moisture

level will be lower. This sensor can be connected in two modes; Analog mode and digital mode. First, we will

connect it in Analog mode and then we will use it in Digital mode.[7]

3.5.2 Specifications:

The specifications of the soil moisture sensor FC-28 are as follows

Input Voltage 3.3 – 5V

Output Voltage 0 – 4.2V

Input Current 35mA

Output Signal Both Analog and Digital

3.5.3 A Pin Out-Soil Moisture Sensor:

The soil Moisture sensor FC-28 has four pins:

VCC: For power


A0: Analog output
D0: Digital output
GND: Ground
The Module also contains a potentiometer which will set the threshold value and then this threshold value

will be compared by the LM393 comparator. The output LED will light up and down according to this

threshold value.

30 | P a g e
Fig: Soil Moisture Sensor

3.5.4 Advantages:

 Automation eliminates the manual operation of opening or closing valves.


 Possibility to change frequency of irrigation and fertilization processes and to optimiz
processes.
 Adoption of advanced crop systems and new technologies, especially new crop syste
complex and difficult to operate manually.
 Use of water from different sources and increased efficiency in water and fertilizer us
 System can be operated at night, water loss from evaporation is thus minimized.
 Irrigation process starts and stops exactly when required, thus optimizing energy req
• This system consists of less hardware hence it is compact.
• More cost efficient.
• Consumes 40-50% less water when compared with traditional methods.[8]

3.6 VOLTAGE REGULATOR


A voltage regulator[9] is used to regulate voltage level. When a steady, reliable voltage is needed, then
voltage regulator is the preferred device. It generates a fixed output voltage that remains constant for any
changes in an input voltage or load conditions. It acts as a buffer for protecting components from
damages. A voltage regulator is a device with a simple feed- forward design and it uses negative feedback
control loops.

There are mainly two types of voltage regulators: Linear voltage regulators and switching voltage

31 | P a g e
regulators; these are used in wider applications.

Linear voltage regulator is the easiest type of voltage regulators. It is available in two types, which are
compact and used in low power, low voltage systems.

FIG: Voltage Regulator

3.7 POTENTIOMETER

A potentiometer[10] is a 3-terminal variable resistor and is one of the most used in this category. It has
two terminals and a wiper and works exactly like a variable resistor.

A potentiometer can be linear or logarithmic. For a linear potentiometer, its resistive track has the same
cross-section from start to end whereas for a logarithmic one it is tapered to cause a logarithmic change in
resistance.

32 | P a g e
3.8 CRYSTAL:-
An electronic circuit that is used to generate an electrical signal of precise frequency by utilizing the
vibrating crystal’s mechanical resonance made of piezoelectric material. There are different types of
piezoelectric
resonators, but typically, quartz crystal is used in these types of oscillators. Hence, these
oscillator electronic circuits are named as crystal oscillators.

Figure:- Crystal

3.9 BATTERY :-
An electric battery is a device consisting of one or more electrochemical cells with external connections
provided to power electrical devices such as flashlights, and electric cars. When a battery is supplying
electric power, its positive terminal is the cathode and its negative terminal is the anode. The terminal
marked negative is the source of electrons that will flow through an external electric circuit to the positive
terminal. When a battery is connected to an external electric load,

33 | P a g e
Figure :- Battery

3.10 PRINTED CIRCUIT BOARD (PCB)


A printed circuit board or PCB[11], is a plate or board where different elements are placed to form an
electrical circuit and it contains the electrical interconnections between them. In its simplest form, a PCB is
a plastic board reinforced with glass. It uses conductive tracks, pads and other similar features etched from
copper sheets and laminated onto a non-conductive substrate.

These copper lines (known as traces) allow electrical charge to flow through the PCB, providing power to
the different components that are situated systematically on the board.

Capacitors, resistors and other components are soldered onto the PCB where needed.

FIG: A 2 layer PCB

34 | P a g e
3.10.1 Layers of a PCB
The simplest PCBs are single sided boards i.e., it contains copper tracks and interconnects only on one of
its surfaces. These types of boards are known as 1 layer printed circuit board or 1 layer PCB.

The most common type of PCB’s contain 2 layers, that means, it has interconnects on both surfaces of the
board.

However, depending on the physical complexity of the design (PCB layout), the boards can be
manufactured of 8 or more layers. These new layers have their own copper trace formations.

3.10.3 Different Types of Printed Circuit Boards

FIG: Types of PCBs

PCBs have copper tracks to connect the holes where the various components are located They are specially
designed for each and every circuit and build construction very easy. Though, making the PCB necessitates
special tools. The different types of printed circuit boards mainly include the following.

 Single Sided PCBs


 Double Sided PCBs
 Multilayer PCBs
 Rigid PCBs
 Flex PCBs
 Rigid-Flex PCBs

35 | P a g e
4.0 SOFTWARE DESCRIPTION
The Arduino integrated development
environment (IDE) is a cross-platform application
(for Windows, macOS, Linux) that is written in the
programming language Java. It is used to write
and upload programs to Arduino compatible
boards, but also, with the help of 3rd party cores,
other vendor development boards.

The source code for the IDE is released under the


GNU General Public License, version 2. The
Arduino IDE supports the languages C and C++
using special rules of code structuring. The
Arduino IDE supplies a software library from the
Wiring project, which provides many common
input and output procedures. User-written code
only requires two basic functions, for starting the
sketch and the main program loop, that are
compiled and linked with a program stub main()
into an executable cyclic executive program with
the GNU toolchain, also included with the IDE
distribution. The Arduino IDE employs the
36 | P a g e
program avrdude to convert the executable code
into a text file in hexadecimal encoding that is
loaded into the Arduino board by a loader
program in the board's firmware.

Workspace for writing program

Fig 1: Arduino’s Opening screen

37 | P a g e
Workspace after writing the program

Fig 2- Workspace after writing the program

Click on File and then on Save As to save


the program.

Fig 3: Saving the workspace

38 | P a g e
Name the File with which we want to
save and click on save

Fig 4: Naming the workspace

Checking for any Error by Compiling the


program

Fig 5: Compiling the program for Errors

39 | P a g e
After all the error has been resolved, the
program is fed into the Arduino by
Uploading it

Fig 6: Uploading the program to the Arduino


4.1 Program Compiled:
#include<LiquidCrystal.h>
LiquidCrystal lcd(14,15,16,17,18,19);
#define soil 9

void setup() {
pinMode(soil, INPUT);
pinMode(10,OUTPUT);
lcd.begin(16, 2);
lcd.print(" AUTOMATIC ");
lcd.setCursor(0,1);
lcd.print("IRRIGATION SYSTEM");

delay(2000);

40 | P a g e
void loop() {
if(digitalRead(soil)==HIGH)
{
digitalWrite(10,HIGH);
lcd.clear();
lcd.print(" MOTOR ");
lcd.setCursor(0,1);
lcd.print(" ON ");
delay(300);

}
else
{
digitalWrite(10,LOW);
lcd.clear();
lcd.print(" MOTOR ");
lcd.setCursor(0,1);
lcd.print(" OFF ");
delay(300);
}
}

41 | P a g e
CHAPTER 3
CONCLUSION AND FUTURE SCOPE

42 | P a g e
5.0 CONCLUSION:

• Combination of hardware and software provides irrigation controller that can be


implemented at relatively low cost and which is extremely user friendly.

• This system can work constantly for indefinite time period, even in certain
abnormal circumstances.

• Can be used to irrigate very large areas as it only needs to divide the whole land
into number of sectors and single microcontroller can control the whole process.

• Saves human energy, time, cost, etc.

6.0 FUTURE SCOPE


1. The System can be embedded with GSM to receive messages as to
when the motor was turned On and OFF.

2. It is considered to be used at Cricket stadiums or Golf stadiums and also in public


garden area for proper irrigation.

43 | P a g e
3. The System can be connected to IOT sensors to tell various details about the field,
sensors, irrigation timings and this data can be stored and be used for future purpose.

REFERENCES
1] Kim MK, Park JH, Cho YW. Current Trends and Industrial Strategies of IT
Convergence. 1 Vol. 25. ETRI Electronic Communications Trend Report; Electronics
and Telecommunications Research Institute; Daejeon, Korea: Feb, 2010.
[2] . Yoo S, Kim J, Kim T, Ahn S, Sung J, Kim D. A2S: Automated Agriculture System
Based on WSN. Proceedings of ISCE 2007. IEEE International Symposium on
Consumer Electronics; Irving, TX, USA. 20–23 June 2007
[3] http://ww1.microchip.com/downloads/en/devicedoc/doc2503.pdf
[4]https://www.google.co.in/search?
q=5v+dc+motor+for+projects&espv=2&biw=1366&bih=623&source=lnms&tbm=isch
&sa=X&ved=0ahUKEwjV87vftIjKAhUVU44KHYJtCr0Q_AUIBigB
[5]https://www.facstaff.bucknell.edu/mastascu/elessonshtml/sensors/templm35.ht
ml
[6]https://www.engineersgarage.com/electronic-components/16x2-lcd-module-
datasheet
[7]. https://en.wikipedia.org/wiki/Soil_moisture_sensor
[8].https://www.edgefxkits.com/automatic-irrigation-system-on-sensing-soil-
moisture-content.
[9]. https://www.elprocus.com/types-of-voltage-regulators-and-working-principle/
[10].https://www.facstaff.bucknell.edu/mastascu/elessonshtml/sensors/templm35.h
tml
[11] https://www.techopedia.com/definition/2267/printed-circuit-board-pcb

44 | P a g e
45 | P a g e
Fig: Final View of the Project

46 | P a g e

Vous aimerez peut-être aussi