96
i A MAJOR PROJECT REPORT On AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM Submitted in partial fulfillment of the requirement for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING By B.SANDEEP (12C81A0410) Under the esteemed guidance of Ms. K.GAYATHRI M.Tech., Assistant Professor, Dept of ECE. DEPTARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING Spurthi Educational Society’s SREEKAVITHA ENGINEERING COLLEGE (Approved by AICTE, New Delhi & Affiliated to JNTUH), (Accredited by NBA) Karepally-507 122, Khammam (Dist), T.S, INDIA. E-mail: [email protected] 2015-16

Automatic irrigation and flood controlling system by using GSM

Embed Size (px)

Citation preview

Page 1: Automatic irrigation and flood controlling system by using GSM

i

A MAJOR PROJECT REPORT

On

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING

SYSTEM BY USING GSM

Submitted

in partial fulfillment of the requirement

for the award of the degree of

BACHELOR OF TECHNOLOGY

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

By

B.SANDEEP

(12C81A0410)

Under the esteemed guidance of

Ms. K.GAYATHRI M.Tech.,

Assistant Professor, Dept of ECE.

DEPTARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Spurthi Educational Society’s

SREEKAVITHA ENGINEERING COLLEGE

(Approved by AICTE, New Delhi & Affiliated to JNTUH),

(Accredited by NBA)

Karepally-507 122, Khammam (Dist), T.S, INDIA.

E-mail: [email protected]

2015-16

Page 2: Automatic irrigation and flood controlling system by using GSM

ii

Ph: 08745 – 246008, 09 08745 – 246017. ESTD 2001

SPURTHI EDUCATIONAL SOCIETY’S

SREEKAVITHA ENGINEERING COLLEGE

(APPROVED BY AICTE, NEW DELHI AND AFFILIATED TO JNTU, HYDERABAD)

(Accredited by NBA)

KAREPALLY, KHAMMAM – 507 122.

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

BONAFIDE CERTIFICATE

This is to certify that the dissertation entitled “AUTOMATIC

IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM” is being

submitted by B.SANDEEP (12C81A0410) in partial fulfillment of the requirement

for the award of the degree of Bachelor of Technology in ELECTRONICS AND

COMMUNICATION ENGINEERING, from Jawaharlal Nehru Technological

University, Hyderabad for the academic year 2015- 16.

Ms. K.Gayathri M.Tech., Mrs.D.Sailaja M.Tech,(Ph.D)., Asst.Professor, Internal guide, Assoc. Professor Dept.of ECE. Head of the Department,

Dept.of ECE.

Submitted for Viva Voce Examination held on.

External Examiner

Page 3: Automatic irrigation and flood controlling system by using GSM

iii

ACKNOWLEDGEMENT

I take this opportunity to thank all who have rendered their full support to my

project work.

I offer my sincere thanks to the internal guide Ms.K.Gayathri M.Tech,

Assist.Professor for her valuable suggestions and support

I thank and express my gratitude to Mrs. D.Sailaja M.Tech, (Ph.D.),and

Head of the department for providing with both time and amenities to make this

project a success with in schedule.

I express my special thanks to Sri Prof.P. Bala Gangadhar Rao, Dean of the

college for his valuable advice in this work.

I express my sincere gratitude to Principal, Vice-Principal of Sreekavitha

Engineering College, for providing excellent academic environment in the college.

I render my thanks to Mr. P.UshaKiran Kumar M.Tech, Chairman

SreeKavitha Engineering College, for his encouragement.

I am grateful to Mr. S.Chalama Reddy M.Sc, M.Ed Correspondent

SreeKavitha Engineering College, for facilitating all the required amenities.

I offer my sincere thanks to our Faculty members and Lab in-charges that have

helped me a lot.

I extend my thanks to all the people, who have helped me a lot directly or

indirectly in the completion of this project.

B.SANDEEP

(12C81A0410)

Page 4: Automatic irrigation and flood controlling system by using GSM

iv

Ph: 08745 – 246008,09 08745 – 246017. ESTD 2001

SPURTHI EDUCATIONAL SOCIETY’S

SREEKAVITHAENGINEERINGCOLLEGE

(APPROVED BY AICTE, NEW DELHI AND AFFILIATED TO JNTU, HYDERABAD)

(Accredited by NBA)

KAREPALLY, KHAMMAM – 507 122.

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

DECLARATION

I am here by declare that the results embodied in this dissertation entitled

“AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING

GSM” is record of work done by us in the department of Electronics and

Communication Engineering from Jawaharlal Nehru Technological University,

Hyderabad.

The reported are based on the project work done entirely by me and not copied

from any other source. The results embodied in this dissertation have not been

submitted to any other University for the award of any degree or diploma.

DATE:

PLACE:

B.SANDEEP

(12C81A0410)

Page 5: Automatic irrigation and flood controlling system by using GSM

v

ABSTRACT

Irrigation has been the backbone of human civilization since man has started

agriculture. As the generation evolved, man developed many methods of irrigation to supply

water to the land. In the present scenario on conservation of water is of high importance. The

motivation for this project came from the countries where economy is based on agriculture

and the climatic conditions lead to lack of rains & scarcity of water. The farmers working in

the farm lands are solely dependent on the rains and bore wells for irrigation of the land.

Even if the farm land has a water-pump, manual intervention by farmers is required to turn

the pump on/off whenever needed. Present work is attempts to save the natural resources

available for human kind. By continuously monitoring the status of the soil, we can control

the flow of water and thereby reduce the wastage. By knowing the status of moisture and

temperature through GSM with the use of moisture and temperature sensors, water flow can

be controlled by just sending a message from our mobile.And automatically control the flood

in the field when sudden raining.

The aim of our project is to minimize this manual intervention by the farmer, which is

why we are using a micro-controller (AT89S52). The micro-controller based Automated

Irrigation system will serve the

following purposes:

1) As there is no un-planned usage of water, a lot of water is saved from being wasted.

2) The irrigation is d only when there is not enough moisture in the soil and the

microcontroller decides

when should the pump be turned on/off based on SMS from the farmers, saves a lot time for

the farmers. This also gives much needed rest to the farmers, as they don’t have to go and

turn the pump on/off manually.

Page 6: Automatic irrigation and flood controlling system by using GSM

vi

INDEX

ACKNOWLEDGEMENT iii

DECLARATION iv

ABSTRACT v

INDEX vi-vii

LIST OF TABLES viii

LIST OF FIGURES ix

LIST OF ABRIVATIONS x

CHAPTER 1: INTRODUCTION (01-03)

1.1 EMBEDDED SYSTEMS 01

1.2 OBJECTIVE OF THE PROJECT 03

CHAPTER 2: BLOCK DIAGRAM DESCRIPTION (04-05)

CHAPTER 3: DESCRIPTION OF HARDWARE COMPONENTS (06-56)

3.1 MICRO CONTROLLER 06

3.2 LM324 21

3.3 GSM MODEM 23

3.4 MAX-232 AND RS-232 29

3.5 GEAR MOTOR 39

3.6 RELAY 42

3.7 LIQUID CRYSTAL DISPLAY (LCD) 46

3.8 POWER SUPPLY 48

CHAPTER 4: CIRCUIT DIAGRAM AND OPERATION (57-58)

4.1 CIRCUIT DIAGRAM 57

4.2 CIRCUIT OPERATION 58

CHAPTER 5: SOFTWARE DEVOLOPEMENT (59-74)

5.1 INTRODUCTION 59

5.2 C51 COMPILER & A51 MACRO ASSEMBLER 60

5.3 µVISION 60

5.4 FLASH MAGIC 69

5.5 CODING 71

Page 7: Automatic irrigation and flood controlling system by using GSM

vii

CHAPTER 6: RESULTS (77-83)

CHAPTER 7: CONCLUSION 84

CHAPTER 8: FUTURE SCOPE 85

CHAPTER 9: REFERENCES 86

Page 8: Automatic irrigation and flood controlling system by using GSM

viii

LIST OF TABLES

S.NO TABLE NAME OF TABLE PAGE NO

1 TABLE 3.1 TECHNICAL SPECIFICATIONS OF GSM 25

2 TABLE 3.2 PIN DESCRIPTION OF SIM900A 29

3 TABLE 3.3 PIN DESCRIPTION OF MAX232 33

4 TABLE 3.4 MAX 232 PIN DETAILS 36

5 TABLE 3.5 LCD PIN DETAILS 47

6 TABLE 3.6 COMMANDS OF LCD 48

7 TABLE 3.6 SPECIFICATIONS OF IC7805 48

Page 9: Automatic irrigation and flood controlling system by using GSM

ix

LIST OF FIGURES

S.NO FIGURE NAME OF FIGURE PAGE NO

1 FIG 2.1 BLOCK DIAGRAM 4

2 FIG 3.1 FUNCTIONAL BLOCK DIAGRAM OF MICRO CONTROLLER 6

3 FIG 3.2 PIN DIAGRAM OF 89S52 MICRO CONTROLLER 4

4 FIG 3.3 OSCILLATOR AND TIMING CIRCUIT 15

5 FIG.3.4 PIN DIAGRAM OF LM-324 21

6 FIG.3.5 GSM MODEM 23

7 FIG.3.6 TRANSMITTER FOR THE VOICE SIGNAL 26

8 FIG.3.7 RECEIVER FOR THE VOICE SIGNAL 26

9 FIG.3.8 GSM SIM 900A 28

10 FIG.3.9 BLOCK DIAGRAM OF RS232 32

11 FIG.3.10 MAX 232 IC 33

12 FIG.3.11 MAX-232 CONNECTER DIAGRAM 35

13 FIG.3.12 RS-232 INTERFACE DIAGRAM 37

14 FIG.3.13 12V HIGH TORQUE DC GEAR MOTOR 39

15 FIG.3.14 LCD DISPLAY AND DATA R/W WAVEFORM 46

16 FIG 3.15 INTERFACING OF LED 48

17 FIG 3.16 BASIC BLOCK DIAGRAM OF A FIXED REGULATED

POWER SUPPLY 49

18 FIG3.17 CIRCUIT DIAGRAM OF POWER SUPPLY 56

19 FIG.4.1 CIRCUIT DIAGRAM 57

20 FIG.5.1 KEIL SOFTWARE- INTERNAL STAGES 59

Page 10: Automatic irrigation and flood controlling system by using GSM

x

LIST OF ABBREVIATIONS

TITLE EXPANSION

PDA PERSONAL DIGITAL ASSISTANTS

SMS SHORT MESSAGE SERVICE

RAM RANDOM ACCESS MEMORY

ROM READ ONLY MEMORY

GSM GLOBAL SYSTEM FOR MOBILES

CPU CENTRAL PROCESSING UNIT

CMOS COMPLEMENTARY METAL-OXIDE SEMI CONDUCTOR

ISP IN-SYSTEM PROGRAMMING

IAP IN-APPLICATION PROGRAMMABLE

TTL TRANSISTOR-TRANSISTOR LOGIC

ETSI EUROPEAN TELECOMMUNICATIONS STANDARDS INSTITUTE

CEPT CONFERENCE OF EUROPEAN POSTS AND TELEGRAPHS

GPRS GENERAL PACKET RADIO SERVICE

RS-232 RECOMMENDED STANDARD-232

UART UNIVERSAL ASYNCHRONOUS RECEIVER-TRANSMITTER

USART UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER

TRANSMITTER

PCB PRINTED CIRCUIT BOARD

LCD LIQUID CRYSTAL DISPLAY

Page 11: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 1

CHAPTER-1

INTRODUCTION

1.1 EMBEDDED SYSTEMS :

An embedded system is a special-purpose system in which the computer is completely

encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose

computer, such as a personal computer, an embedded system performs one or a few pre-defined

tasks, usually with very specific requirements. Since the system is dedicated to specific tasks,

design engineers can optimize it, reducing the size and cost of the product. Embedded systems

are often mass-produced, benefiting from economies of scale

Personal digital assistants (PDAs) or handheld computers are generally considered

embedded devices because of the nature of their hardware design, even though they are more

expandable in software terms. This line of definition continues to blur as devices expand.

Physically, embedded systems range from portable devices such as digital watches, MP3

players, large stationary installations like traffic lights, factory controllers, or the systems

controlling nuclear power plants.

In terms of complexity embedded systems can range from very simple with a single

microcontroller chip, to very complex with multiple units, peripherals and networks mounted

inside a large chassis or enclosure.

Fig 1.1 real-time system interacts with environment

EMBEDDED

SYSTEM

INPUTS

(Sensors)

OUTPUTS

(Actuators)

Page 12: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 2

1.1.1EXAMPLES OF EMBEDDED SYSTEM

Automatic teller machines (ATMs)

Avionics, such as inertial guidance systems, flight control hardware/software and other

integrated systems in aircraft and missiles

Cellular telephones and telephone switches

engine controllers and antilock brake controllers for automobiles

Home automation products, such as thermostats, air conditioners, sprinklers, and security

monitoring systems

Handheld calculators

Handheld computers

Household appliances, including microwave ovens, washing machines, television sets, DVD

players and recorders

Medical equipment

Personal digital assistant

Videogame consoles

Computer peripherals such as routers and printers

Industrial controllers for remote machine operation.

1.1.2 CHARACTERISTICS

Embedded systems are designed to do some specific task, rather than be a general-

purpose computer for multiple tasks. Some also have real-time performance constraints that must

be met, for reason such as safety and usability; others may have low or no performance

requirements, allowing the system hardware to be simplified to reduce costs.

An embedded system is not always a separate block - very often it is physically built- in to

the device it is controlling. The software written for embedded systems is often called firmware,

and is stored in read-only memory or Flash memory chips rather than a disk drive. It often runs

with limited computer hardware resources: small or no keyboard, screen, and little memory.

Page 13: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 3

1.2 OBJECTIVE OF THE PROJECT

Actually this project is for our farmers. They work hard and hard not only everyday but

also every night in the field. Because in the day they do their field work and in the night our

farmers have to irrigate the field land at some intervals. So to wake up in the night from a sleep

and then go to field and irrigate the land is to typical for a farmer. There are many disadvantage

of this irrigation system that if a farmer started the irrigation system in the night and he forgot to

switch off the irrigation system again. In this condition the a lot of water goes to wastage and the

crops may get harm or sometimes he forget to switch on the irrigation system then again the

crops get dried due to lack of water. This depends on the type of crops. Lighter weight fruits

always follow slight water deficiency. Sometimes it is harmful to farmers by snakes and insects.

And due to sudden rainfalls the crops get damaged

So to rectify this problem I have brought this is electronic project (GSM Based

Automatic Irrigation System Using 8052 Micro-controller). The system works on SMS feature of

the mobile phone. No hard work need to be done by the farmer. He has to send a SMS to the

irrigation system to switched on as well as off the irrigation system. The irr igation system

switching status will be received to the farmer in his mobile as a SMS. The return sms will be

automatically sent by the irrigation system. This project works on two mode. It depends on the

farmer that what he choose to control the irrigation system. This project is developed based on

EMBEDDED and GSM Technology. When a field is in the dry condition, the sensing logic

senses the state of the field and intimates it to the microcontroller. It in response makes the motor

on. We can know the status of the field by sending a message to the GSM modem which is

placed at the field. Through our mobile we can switch on-off the motor by sending the respective

commands to the kit through the GSM modem. Thus the irrigation motor can be controlled

through our mobiles using GSM technology.

The project deals with When get sudden rainfalls level control of water in field for the

safety purpose the control of water level in field With help of microcontroller. the

microcontroller automatically on the motor when the field is full or reaches the MAX level and

the gate will be open automatically.

Page 14: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 4

CHAPTER-2

BLOCK DIAGRAM DESCRIPTION

BLOCK DIAGRAM:

Fig 2.1 Block diagram

The block diagram and its brief description of the project work a re explained in

block wise and this block diagram consists the following blocks.

1. Microcontroller(AT89S52)

2. GSM

3. LCD 16*2

POWER

SUPPLY

LM324

RELAY

WATER PUMP

MOTOR

MOISTURE SENSOR

AT PLANT ROOTS

LCD DISPLAY

AT

89S52

MOTOR

AS GATE

GSM

Page 15: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 5

4. Power supply

5. LM324

6. Moisture sensor

7. Water pump motor

8. Gear Motor

9. Relay

2.2.1 MICROCONTROLLER SECTION

This section forms the control unit of the whole project. This section basically consists of

a Microcontroller with its associated circuitry like Crystal with capacitors, Reset circuitry, Pull

up resistors (if needed) and so on. The Microcontroller forms the heart of the project because it

controls the devices being interfaced and communicates with the devices according to the

program being written.

2.2.2 POWER SUPPLY SECTION

This section is meant for supplying Power to all the sections mentioned above.It basically

consists of a Transformer to step down the 230V ac to 24 V ac followed by diodes. Here diodes are used

to rectify the ac to dc. After rectification the obtained rippled dc is filtered using a capacitor Filter. A

positive voltage regulator is used to regulate the obtained dc voltage.

Page 16: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 6

CHAPTER 3

DESCRIPTION OF HARDWARE COMPONENTS

3.1 MICRO CONTROLLER:

3.1.1 A BRIEF HISTORY OF 8051:

In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. This

microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial port, and

four ports all on a single chip. At the time it was also referred as ―A SYSTEM ON A CHIP‖.

Fig 3.1 Functional block diagram of micro controller

Page 17: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 7

8031 has 128 bytes of RAM, two timers and 6 interrupts.

8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts.

8052 has 8K ROM, 256 bytes of RAM, three timers and 8 interrupts.

Of the three microcontrollers, 8051 is the most preferable. Microcontroller supports both

serial and parallel communication.

In the concerned project 8052 microcontroller is used. Here microcontroller used is

AT89S52, which is manufactured by ATMEL laboratories.

The 8051 is the name of a big family of microcontrollers. The device which we are going

to use along this tutorial is the 'AT89S52' which is a typical 8051 microcontroller manufactured

by Atmel™. Note that this part doesn't aim to explain the functioning of the different

components of a 89S52 microcontroller, but rather to give you a general idea of the organization

of the chip and the available features, which shall be explained in detail along this tutorial.

This figures shows the main features and components that the designer can interact with.

You can notice that the 89S52 has 4 different ports, each one having 8 Input/output lines

providing a total of 32 I/O lines. Those ports can be used to output DATA and orders do other

devices, or to read the state of a sensor, or a switch. Most of the ports of the 89S52 have 'dual

function' meaning that they can be used for two different functions: the fist one is to perform

input/output operations and the second one is used to implement special features of the

microcontroller like counting external pulses, interrupting the execution of the program

according to external events, performing serial data transfer or connecting the chip to a computer

to update the software.

NECESSITY OF MICROCONTROLLERS:

Microprocessors brought the concept of programmable devices and made many

applications of intelligent equipment. Most applications, which do not need large amount of data

and program memory, tended to be costly.

The microprocessor system had to satisfy the data and program requirements so,

sufficient RAM and ROM are used to satisfy most applications .The peripheral control

equipment also had to be satisfied. Therefore, almost all-peripheral chips were used in the

design. Because of these additional peripherals cost will be comparatively high.

Page 18: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 8

An example:

8085 chip needs:

An Address latch for separating address from multiplex address and data.32-KB RAM and

32-KB ROM to be able to satisfy most applications. As also Timer / Counter, Parallel

programmable port, Serial port, and Interrupt controller are needed for its efficient applications.

In comparison a typical Micro controller 8051 chip has all that the 8051 board has except a

reduced memory as follows.

4K bytes of ROM as compared to 32-KB, 128 Bytes of RAM as compared to 32-KB.

Bulky:

On comparing a board full of chips (Microprocessors) with one chip with all components

in it (Microcontroller).

Debugging:

Lots of Microprocessor circuitry and program to debug. In Micro controller there is no

Microprocessor circuitry to debug.

Slower Development time: As we have observed Microprocessors need a lot of debugging at

board level and at program level, where as, Micro controller do not have the excessive circuitry

and the built- in peripheral chips are easier to program for operation.

So peripheral devices like Timer/Counter, Parallel programmable port, Serial

Communication Port, Interrupt controller and so on, which were most often used were integrated

with the Microprocessor to present the Micro controller .RAM and ROM also were integrated in

the same chip. The ROM size was anything from 256 bytes to 32Kb or more. RAM was

optimized to minimum of 64 bytes to 256 bytes or more.

Microprocessor has following instructions to perform:

1. Reading instructions or data from program memory ROM.

2. Interpreting the instruction and executing it.

Page 19: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 9

3. Microprocessor Program is a collection of instructions stored in a Nonvolatile memory.

4. Read Data from I/O device

5. Process the input read, as per the instructions read in program memory.

6. Read or write data to Data memory.

7. Write data to I/O device and output the result of processing to O/P device.

3.1.2 Introduction to AT89S52:

AT89S52:

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K

bytes of in-system programmable Flash memory. The device is manufactured using Atmel’s

high-density nonvolatile memory technology and is compatible with the industry-standard 80C51

instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed

in-system or by a conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit

CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a

powerful microcontroller, which provides a highly flexible and cost-effective solution to many,

embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of

RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector

two- level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry.

In addition, the AT89S52 is designed with static logic for operation down to zero frequency and

supports two software selectable power saving modes. The Idle Mode stops the CPU while

allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The

Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip

functions until the next interrupt or hardware reset.

The system requirements and control specifications clearly rule out the use of 16, 32 or 64

bit micro controllers or microprocessors. Systems using these may be earlier to implement due to

large number of internal features. They are also faster and more reliable but, the above

Page 20: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 10

application is satisfactorily served by 8-bit micro controller. Using an inexpensive 8-bit

Microcontroller will doom the 32-bit product failure in any competitive market place. Coming to

the question of why to use 89S52 of all the 8-bit Microcontroller available in the market the main

answer would be because it has 8kB Flash and 256 bytes of data RAM32 I/O lines, three 16-bit

timer/counters, a Eight-vector two-level interrupt architecture, a full duplex serial port, on-chip

oscillator, and clock circuitry.

In addition, the AT89S52 is designed with static logic for operation down to zero

frequency and supports two software selectable power saving modes. The Idle Mode stops the

CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue

functioning. The Power Down Mode saves the RAM contents but freezes the oscillator, disabling

all other chip functions until the next hardware reset. The Flash program memory supports both

parallel programming and in Serial In-System Programming (ISP). The 89S52 is also In-

Application Programmable (IAP), allowing the Flash program memory to be reconfigured even

while the application is running.

By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is

a powerful microcomputer which provides a highly flexible and cost effective solution to many

embedded control applications.

FEATURES:

Compatible with MCS-51 Products

8K Bytes of In-System Reprogrammable Flash Memory

Fully Static Operation: 0 Hz to 33 MHz

Three- level Program Memory Lock

256 x 8-bit Internal RAM

32 Programmable I/O Lines

Three 16-bit Timer/Counters

Eight Interrupt Sources

Programmable Serial Channel

Low-power Idle and Power-down Modes

4.0V to 5.5V Operating Range

Page 21: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 11

Full Duplex UART Serial Channel

Interrupt Recovery from Power-down Mode

Watchdog Timer

Dual Data Pointer

Power-off Flag

Fast Programming Time

Flexible ISP Programming (Byte and Page Mode)

3.1.3 PIN DIAGRAM:

Fig 3.2 Pin diagram of 89S52 micro controller

Page 22: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 12

3.1.4 PIN DESCRIPTION:

The AT89S52 has 40 pins. In these 32 are I/O pins and 8 are special purpose pins. I/O

pins are classified into 4 ports and each port has 8 pins

Port 0:

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink

eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance

inputs.Port 0 can also be configured to be the multiplexed loworder address/data bus during

accesses to external program and data memory. In this mode, P0 has internal pullups. Port 0 also

receives the code bytes during Flash programming and outputs the code bytes during program

verification.

External pullups are required during program verification.

Port 1:

Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output buffers

can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the

internal pullups and can be used as inputs. As inputs,Port 1 pins that are externally being pulled

low will source current (IIL) because of the internal pullups. In addition, P1.0 and P1.1 can be

configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2

trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the

low-order address bytes during Flash programming and verification.

Port 2:

Port 2 is an 8-bit bidirectional I/O port with internal pullups.The Port 2 output buffers can

sink/source four TTL inputs.When 1s are written to Port 2 pins, they are pulled high by

Page 23: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 13

the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being

pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order

address byte during fetches from external program memory and during accesses to external data

memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong

internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit

addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2

also receives the high-order address bits and some control signals during Flash programming and

verification.

Port 3:

Port 3 is an 8-bit bidirectional I/O port with internal pullups.The Port 3 output buffers can

sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the

internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled

low will source current (IIL) because of the pullups. Port 3 also serves the functions of vario us

special features of the AT89S52, as shown in the following table. Port 3 also receives some

control signals for Flash programming and verification.

VCC: Supply voltage.

GND: Ground.

RST:

Reset input. A high on this pin for two machine cycles while the oscillator is running

resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out.

The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default

state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG Address Latch Enable

(ALE) is an output pulse for latching the low byte of the address during accesses to external

Page 24: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 14

memory. This pin is also the program pulse input (PROG) during Flash programming. In normal

operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for

external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each

access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of

SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.

Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the

microcontroller is in external execution mode.

PSEN:

Program Store Enable (PSEN) is the read strobe to external program memory. When the

AT89S52 is executing code from external program memory, PSEN is activated twice each

machine cycle, except that two PSEN activations are skipped during each access to external data

memory.

EA/VPP:

External Access Enable. EA must be strapped to GND in order to enable the device to

fetch code from external program memory locations starting at 0000H up to FFFFH. Note,

however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be

strapped to VCC for internal program executions. This pin also receives the 12-volt

programming enable voltage

(VPP) during Flash programming.

XTAL1:

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

XTAL2:

Output from the inverting oscillator amplifier.

The 8052 Oscillator and Clock:

The heart of the 8051 circuitry that generates the clock pulses by which all the internal all

internal operations are synchronized. Pins XTAL1 And XTAL2 is provided for connecting a resonant

network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal

frequency is the basic internal clock frequency of the microcontroller. The manufacturers make 8051

designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz.

Page 25: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 15

Fig3.3 Oscillator and timing circuit

MEMORIES:

Types of memory:

The 8052 have three general types of memory. They are on-chip memory, external Code

memory and external Ram. On-Chip memory refers to physically existing memory on the micro

controller itself. External code memory is the code memory that resides off chip. This is often in

the form of an external EPROM. External RAM is the Ram that resides off chip. This often is in

the form of standard static RAM or flash RAM.

Page 26: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 16

a) Code memory:

Code memory is the memory that holds the actual 8052 programs that is to be run. This

memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have

8K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory

is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

b) Internal RAM:

The 8052 have a bank of 256 bytes of internal RAM. The internal RAM is found on-chip.

So it is the fastest Ram available. And also it is most flexible in terms of reading and writing.

Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 256 bytes of internal

memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains

8 registers. Internal RAM also contains 256 bits, which are addressed from 20h to 2Fh. These

bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are

numbered 00h to FFh. The user may make use of these variables with commands such as SETB

and CLR.

Special Function registered memory:

Special function registers are the areas of memory that control specific functionality of

the 8052 micro controller.

a) Accumulator (0E0h):

As its name suggests, it is used to accumulate the results of large no of instructions. It can

hold 8 bit values.

b) B registers (0F0h):

The B register is very similar to accumulator. It may hold 8-bit value. The b register is

only used by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets

stored in B register. In div AB the quotient gets stored in B with the remainder in A.

Page 27: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 17

c) Stack pointer (81h):

The stack pointer holds 8-bit value. This is used to indicate where the

next value to be removed from the stack should be taken from. When a value is to be pushed

onto the stack, the 8052 first store the value of SP and then store the value at the resulting

memory location. When a value is to be popped from the stack, the 8052 returns the value from

the memory location indicated by SP and then decrements the value of SP.

d) Data pointer :

The SFRs DPL and DPH work together work together to represent a 16-bit value called

the data pointer. The data pointer is used in operations regarding external RAM and some

instructions code memory. It is a 16-bit SFR and also an addressable SFR.

e) Program counter:

The program counter is a 16 bit register, which contains the 2 byte address, which tells

the 8052 where the next instruction to execute to be found in memory. When the 8052 is

initialized PC starts at 0000h. And is incremented each time an instruction is executes. It is not

addressable SFR.

f) PCON (Power control, 87h):

The power control SFR is used to control the 8051’s power control modes. Certain

operation modes of the 8051 allow the 8051 to go into a type of ―sleep mode‖ which consumes

much lee power.

g) TCON (timer control, 88h):

Page 28: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 18

The timer control SFR is used to configure and modify the way in which the 8051’s two

timers operate. This SFR controls whether each of the two timers is running or stopped and

contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related

bits are located in TCON SFR. These bits are used to configure the way in which the e xternal

interrupt flags are activated, which are set when an external interrupt occurs.

h) TMOD (Timer Mode, 89h):

The timer mode SFR is used to configure the mode of operation of each of the two

timers. Using this SFR your program may configure each timer to be a 16-bit timer, or 13 bit

timer, 8-bit auto reload timer, or two separate timers. Additionally you may configure the timers

to only count when an external pin is activated or to count ―events‖ that are indicated on an

external pin.

i) TO (Timer 0 low/high, address 8A/8C h):

These two SFRs taken together represent timer 0. Their exact behavior depends on how

the timer is configured in the TMOD SFR; however, these timers always count up. What is

configurable is how and when they increment in value.

j) T1 (Timer 1 Low/High, address 8B/ 8D h):

Page 29: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 19

These two SFRs, taken together, represent timer 1. Their exact behavior depends on how

the timer is configured in the TMOD SFR; however, these timers always count up..

k) P0 (Port 0, address 90h, bit addressable):

This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a high level on

the corresponding I/O pin whereas a value of 0 will bring it to low level.

l) P1 (port 1, address 90h, bit addressable):

This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a high level on

the corresponding I/O pin whereas a value of 0 will bring it to low level

m) P2 (port 2, address 0A0h, bit addressable):

This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

0 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on

the corresponding I/O pin whereas a value of 0 will bring it to low level.

n) P3 (port 3, address B0h, bit addressable) :

This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro

controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port

0 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a high level on

the corresponding I/O pin whereas a value of 0 will bring it to low level.

o) IE (interrupt enable, 0A8h):

The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits

of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable

or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of

whether an individual interrupt is enabled by setting a lower bit.

Page 30: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 20

p) IP (Interrupt Priority, 0B8h):

The interrupt priority SFR is used to specify the relative priority of each interrupt. On

8051, an interrupt maybe either low or high priority. An interrupt may interrupt interrupts. For

e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt

always interrupts the system, even if another interrupt is currently executing. However, if a serial

interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since

the serial interrupt routine has the highest priority.

q) PSW (Program Status Word, 0D0h):

The program Status Word is used to store a number of important bits that are set and

cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the

parity flag and the overflow flag. Additionally, it also contains the register bank select flags,

which are used to select, which of the ―R‖ register banks currently in use.

r) SBUF (Serial Buffer, 99h):

SBUF is used to hold data in serial communication. It is physically two registers. One is

writing only and is used to hold data to be transmitted out of 8052 via TXD. The other is read

only and holds received data from external sources via RXD. Both mutually exclusive registers

use address 99h.

SERIAL DATA INPUT/OUTPUT

Onecost –effective way to communicate with other computers is to send and receive data bits

serially. The 89C51 has a serial data communication circuit but uses register SBUF to hold data. Register

SCON controls data communication and register PCON controls data rates and pins RXD (P3.0) and TXD

Page 31: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 21

(P3.1) connect to the serial data network. SBUF is physically two registers. One is write only and used to

hold data to be transmitted out of the micro controller using TXD. The other is read only and hold-

receive data from external sources using RXD.

INTERRUPTS

Interrupts may be generated by the internal chip operations or provided by external

sources. Five interrupts are provided in the 89C51.Internal operations timer flag0, timer flag1

and the serial port generate three of these automatically interrupt (R1 or T1). Two interrupts are

triggered by external signals provided by circuitry which are connected to pins INT0 and INT1.

3.2 LM324:

LM324 is a 14pin IC consisting of four independent operational amplifiers (op-amps)

compensated in a single package. Op-amps are high gain electronic voltage amplifier with

differential input and, usually, a single-ended output. The output voltage is many times higher

than the voltage difference between input terminals of an op-amp.

These op-amps are operated by a single power supply LM324 and need for a dual supply

is eliminated. They can be used as amplifiers, comparators, oscillators, rectifiers etc. The

conventional op-amp applications can be more easily implemented with LM324.

Fig 3.4: Pin diagram of LM-324

Page 32: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 22

Application areas include transducer amplifiers, DC gain blocks and all the conventional op amp

circuits which now can be more easily implemented in single power supply systems. For example, the

LM124 series can be directly operated off of the standard +5V power supply voltage which is used in

digital systems and will easily provide the required interface electronics without requiring the additional

±15V power supplies.

Unique Characteristics:

In the linear mode the input common-mode voltage range includes ground and the output voltage

can also swing to ground, even though operated from only a single power supply voltage the unity gain

cross frequency is temperature compensated. The input bias current is also temperature compensated

Advantages

Eliminates need for dual supplies four internally compensated op amps in a single package

Allows directly sensing near GND and VOUT also goes to GND Compatible with all forms of

logic Power drain suitable for battery operation.

Features:

Internally frequency compensated for unity gain Large DC voltage gain 100 Db Wide and width

(unity gain) 1 MHz (temperature compensated) Wide power supply range:

Single supply 3V to 32V or dual supplies ±1.5V to ±16V Very low supply current drain (700 μA)—

essentially. Independent of supply voltage Low input biasing current 45 nA (temperature compensated)

Low input offset voltage 2 mV and offset current: 5 nA Input common-mode voltage range includes

ground Differential input voltage range equal to the power supply voltage

Large output voltage swing 0V to V+ − 1.5V.

SENSING LOGIC :

In this section we will discuss how the sensing action takes place in the project. In this we use

the simple principle of conduction between two wires through a medium. The logic consists of two

wires one with the 5V supply and the other one was the ground. When there is water in the field, a

medium is being established between the wires and the conduction will take place between the wires

and the voltage at the microcontroller will go low indicating the wet condition of the field. In this wet

condition the mpotor will be in off position.

Page 33: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 23

If there is no water in the field, the re is no conduction between the wires and the voltage at

the microcontroller will go high indicating the dry condition of the field and the motor will be made on

position.

We can not only know the status of the field but also control the motor action from our home

itself by using the GSM technology. The following are the commands or messages to be passed to the

GSM modem from our user moblie for the above mentioned operations.

To know the status of the field, GIFMOD

To make the motor off postion, we use MTR OF

To make the motor on.. MTR ON

3.3 GSM MODEM:

Definitions

The words, ―Mobile Station‖ (MS) or ―Mobile Equipment‖ (ME) are used for mobile

terminals Supporting GSM services.

A call from a GSM mobile station to the PSTN is called a ―mobile originated call‖

(MOC) or ―Outgoing call‖, and a call from a fixed network to a GSM mobile station is called a

―Mobile Terminated call‖ (MTC) or ―incoming call‖.

Fig 3.5: GSM modem

Page 34: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 24

What is GSM?

GSM (Global System for Mobile communications) is an open, digital cellular technology

used for transmitting mobile voice and data services.

What does GSM offer?

GSM supports voice calls and data transfer speeds of up to 9.6 kbit/s, together with the

transmission of SMS (Short Message Service).

GSM operates in the 900MHz and 1.8GHz bands in Europe and the 1.9GHz and 850MHz

bands in the US. The 850MHz band is also used for GSM and 3G in Australia, Canada and many

South American countries. By having harmonised spectrum across most of the globe, GSM’s

international roaming capability allows users to access the same services when travelling abroad

as at home. This gives consumers seamless and same number connectivity in more than 218

countries.

Terrestrial GSM networks now cover more than 80% of the world’s populat ion. GSM

satellite roaming has also extended service access to areas where terrestrial coverage is not

available

HISTORY

In 1980’s the analog cellular telephone systems were growing rapidly all throughout

Europe, France and Germany. Each country defined its own protocols and frequencies to work

on. For example UK used the Total Access Communication System (TACS), USA used the

AMPS technology and Germany used the C-netz technology. None of these systems were

interoperable and also they were analog in nature.

In 1982 the Conference of European Posts and Telegraphs (CEPT) formed a study group

called the GROUPE SPECIAL MOBILE (GSM) The main area this focused on was to get the

cellular system working throughout the world, and ISDN compatibility with the ability to

incorporate any future enhancements. In 1989 the GSM transferred the work to the European

Telecommunications Standards Institute (ETSI.) the ETS defined all the standards used in GSM.

Page 35: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 25

Some of the technical specifications of GSM are listed below –

Multiple Access Method TDMA / FDMA

Uplink frequencies (MHz) 933-960 (basic GSM)

Downlink frequencies (MHz) 890-915 (basic GSM)

Duplexing FDD

Channel spacing, kHz 200

Modulation GMSK

Portable TX power, maximum / average (mW) 1000 / 125

Power control, handset and BSS Yes

Speech coding and rate (kbps) RPE-LTP / 13

Speech Channels per RF channel: 8

Channel rate (kbps) 270.833

Channel coding Rate 1/2 convolutional

Frame duration (ms) 4.615

Table 3.1: Technical specifications of GSM

GSM was originally defined for the 900 Mhz range but after some time even the 1800

Mhz range was used for cellular technology. The 1800 MHz range has its architecture and

specifications almost same to that of the 900 Mhz GSM technology but building the Mobile

exchanges is easier and the high frequency Synergy effects add to the advantages of the 1800

Mhz range.

3.3.2 ARCITECTURE AND BUILDIGN BLOCKS :

GSM is mainly built on 3 building blocks. (Ref Fig. 2)

GSM Radio Network – This is concerned with the signaling of the system. Hand-overs

occur in the radio network. Each BTS is allocated a set of frequency channels.

GSM Mobile switching Network – This network is concerned with the storage of data

required for routing and service provision.

Page 36: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 26

GSM Operation and Maintenance – The task carried out by it include Administration and

commercial operation , Security management, Network configuration, operation,

performance management and maintenance tasks.

3.3.3 SIGNALLING SCHEMES AND CIPHERING CODES USED :

GSM is digital but voice is inherently analog. So the analog signal has to be converted

and then transmitted. The coding scheme used by GSM is RPE-LTP (Rectangular pulse

Excitation – Long Term Prediction)

Fig.3.6 Transmitter for the voice signal

Fig.3.7 Receiver for the Voice signal

The voice signal is sampled at 8000 bits/sec and is quantized to get a 13 bit resolution

corresponding to a bit rate of 104 kbits/sec. This signal is given to a speech coder (codec) that

compresses this speech into a source-coded speech signal of 260 bit blocks at a bit rate of 13

Page 37: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 27

kbit/sec. The codec achieves a compression ratio of 1:8. The coder also has a Voice activity

detector (VAD) and comfort noise synthesizer. The VAD decides whether the current speech

frame contains speech or pause, this is turn is used to decide whether to turn on or off the

transmitter under the control of the Discontinuous Transmission (DTX). This transmission takes

advantage of the fact that during a phone conversation both the parties rarely speak at the same

time. Thus the DTX helps in reducing the power consumption and prolonging battery life. The

missing speech frames are replaced by synthetic background noise generated by the comfort

noise synthesize in a Silence Descriptor (SID) frame. Suppose a loss off speech frame oc curs due

to noisy transmission and it cannot be corrected by the channel coding protection mechanism

then the decoder flags such frames with a bad frame indicator (BFI) In such a case the speech

frame is discarded and using a technique called error concealment which calculates the next

frame based on the previous frame.

3.3.4 GSM Sim 900A:

GSM/GPRS Modem-RS232 is built with Dual Band GSM/GPRS engine- SIM900A,

works on frequencies 900/ 1800 MHz. The Modem is coming with RS232 interface, which

allows you connect PC as well as microcontroller with RS232 Chip(MAX232). The baud rate is

configurable from 9600-115200 through AT command. The GSM/GPRS Modem is having

internal TCP/IP stack to enable you to connect with internet via GPRS. It is suitable for SMS,

Voice as well as DATA transfer application in M2M interface. The onboard Regulated Power

supply allows you to connect wide range unregulated power supply . Using this modem, you can

make audio calls, SMS, Read SMS, attend the incoming calls and internet ect through simple AT

commands.

Page 38: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 28

Fig 3.8: Diagram of SIM 900A

Features:

Dual band GSM/GPRS 900/1800MHz.

Configurable baud rate.

SIM card holder.

Built in network status LED.

Inbuilt powerful TCP/IP protocol stack for internet data transfer over GPRS.

Applications:

Access control devices.

Supply chain management

Page 39: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 29

Specifications:

Parameter Value

Operating voltage +12v DC

weight <140g

Pin Specification:

Pin Name Details

1 GND Power supply ground

2 tx transmitter

3 rx receiver

4 Line_r & Line_l Line input

5 Spk_p & spk_n Speaker positive & negative

6 Mic_p & mic_n Mic positive & negative

7 DTR Data terminal ready

8 CTS Clear to send

9 RTS Request to send

Table 3.2: Pin Description of SIM900A

Working:

Unlike mobile phones, a GSM modem doesn’t have a keypa interact with. It just accepts

certain commands through a serial interface and acknowledges for those. These commands are called as AT commands. There are a list of AT commands to instruct the modem to perform its functions. Every command starts with "AT". That’s why stands for attention.

In our simple project, the program waits for the mobile number to be entered through

the keyboard. When a ten digit mobile number is provided, the program instructs the modem to send the text message using a sequence of AT commands

3.4 MAX 232 AND RS-232:

3.4.1 RS232 STANDARD:

RS denotes ―Recommended Standard‖ and refers to official standards of Electronics

Industries Association. RS-232 is the most known serial port used in transmitting the data in

Page 40: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 30

communication and interface. Even though serial port is harder to program than the parallel port, this is

the most effective method in which the data transmission requires less that yields to the less cost. Serial

RS-232 communication works with voltages (-15V ... -3V for high [sic]) and +3V ... +15V for low [sic])

which are not compatible with normal computer logic voltages.

The maximum RS-232 signal levels are far too high for computer logic electronics, and the

negative RS-232 voltage for high cant be applicable at all by computer logic. Therefore, to receive serial

data from an RS-232 interface the voltage has to be reduced, and the low and high voltage level

inverted. In the other direction (sending data from some logic over RS-232) the low logic voltage has to

be bumped up‖, and a negative voltage has to be generated, too.

Independent channels are established for two-way (full-duplex) communications. The RS232

signals are represented by voltage levels with respect to a system common (power I logic ground). The

―idle‖ state (MARK) has the signal level negative with respect to common, and the ―active‖ state

(SPACE) has the signal level positive with respect to common. RS232 has numerous handshaking lines

(primarily used with modems), and also specifies a communications protocol.

The RS-232 interface presupposes a common ground between the DTE and DCE. This is a

reasonable assumption when a short cable connects the DTE to the DCE, but with longer lines and

connections between devices that may be on different electrical busses with different grounds, this may

not be true.

RS232 data is bi-polar.... +3 to +12 volts indicate an ―ON or 0-state (SPACE) condition’s while

A -3 to -12 volts indicates an ―OFF‖ 1-state (MARK) condition.... Modern computer equipment ignores

the negative level and accepts a zero voltage level as the ―OFF‖ state. In fact, the ―ON‖ state may be

achieved with lesser positive potential.

The output signal level usually swings between +12V and -12V. The ―dead area‖ between +3v

and -3v is designed to absorb line noise. In the various RS-232-like definitions this dead area may vary.

This can cause problems when using pin powered widgets - line drivers, converters, modems etc.

These types of units need enough voltage & current to power them self’s up. Typical URART (the RS-

232 I/O chip) allows up to 50ma per output pin - so if the device needs 70ma to run we would need to

Page 41: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 31

use at least 2 pins for power. The number of output lines, the type of interface driver IC, and the state of

the output lines are important considerations.

The types of driver ICs used in serial ports can be divided into three general categories:

Drivers which require plus (+) and minus (-) voltage power supplies such as the 1488 series of interface

integrated circuits. (Most desktop and tower PCs use this type of driver.)

Low power drivers which require one +5 volt power supply. This type of driver has an internal charge

pump for voltage conversion. (Many industrial microprocessor controls use this type of driver.)

Low voltage (3.3 v) and low power drivers which meet the EIA-562 Standard. (Used on notebooks and

laptops.)

Data is transmitted and received on pins 2 and 3 respectively. Data Set Ready (DSR) is an

indication from the Data Set (i.e., the modem or DSU/CSU) that it is on. Similarly, DTR indicates to the

Data Set that the DTE is on. Data Carrier Detect (DCD) indicates that a good carrier is being received

from the remote modem.

Pins 4 RTS (Request to Send - from the transmitting computer) and 5 CTS (Clear to Send - from

the Data set) are used to control. In most Asynchronous situations, RTS and CTS are constantly on

throughout the communication session. However where the DTE is connected to a multipoint line. RTS

is used to turn carrier on the modem on and off. On a multipoint line, it’s imperative that only one

station is transmitting at a time (because they share the return phone pair). When a station wants to

transmit, it raises RTS. The modem turns on carrier, typically waits a few milliseconds for carrier to

stabilize, and then raises CTS. The DTE transmits when it sees CTS up. When the station has finished

its transmission, it drops RTS and the modem drops CTS and carrier together.

Clock signals (pins 15, 17, & 24) are only used for synchro/.

nous communications. The modem or DSU extracts the clock from the data stream and provides a

steady clock signal to the DTE. The transmit and receive clock signals do not have to be the same, or

even at the same baud rate.

Page 42: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 32

To allow compatibility among data communication equipment made by various Manufacturers,

an interfacing standard called RS232 was set by the Electronics and Industries Association in

1960.Today, RS232 is the most widely used serial I/O interfacing standard. RS232 standard is not TTL

compatible; therefore it requires a line driver such as MAX232chip to convert RS232 voltage levels to

TTL levels and vice versa. One advantage of the MAX 232 chip is that it uses +5V power source that

has same source voltage as that of 8052.

RS232 Logic Level Converter TTL Logic

Figure 3.9: Block Diagram of RS232

3.4.2 MAX 232:

The RS 232 is not compatible with micro controllers, so a line driver converts the RS 232's

signals to TTL voltage levels. It is a 16 pin DIP package.

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply

TIA/EIA-232-F voltage levels from a single 5-V supply. Each receiver converts TIA/EIA-232-F inputs

to 5-V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V, a typical hysteresis of 0.5

V, and can accept ±30-V inputs. Each driver converts TTL/CMOS input levels into TIA/EIA-232-F

levels.

System

Max

232

89C

5

1

Page 43: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 33

Figure 3.10: MAX 232 IC

Table 3.3: Pin Description of MAX232

Page 44: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 34

Registers Used For Communication

SBUF Register

SBUF is an 8-bit register used solely for serial communication in the 8051. For byte of data to be

transferred via TxD line, it must be placed in SBUF register. SBUF also holds the byte of data when it is

received by the 8051’s RxD line.

The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred

serially via TxD line. Similarly when bits r received serially via RxD, the 8051 defames it by

eliminating a byte out of the received, and then placing it in the SBUF.

RS-232 WAVEFORM

TTL/CMOS Serial Logic Waveform

The diagram above shows the expected waveform from the UART when using the

common 8N1 format. 8N1 signifies 8 Data bits, No Parity and 1 Stop Bit. The RS-232 line, when

idle is in the Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then

each bit is sent down the line, one at a time. The LSB (Least Significant Bit) is sent first. A Stop

Bit (Logic 1) is then appended to the signal to make up the transmission.

The data sent using this method, is said to be framed. That is the data is framed

between a Start and Stop Bit.

RS-232 Voltage levels

+3 to +25 volts to signify a "Space" (Logic 0)

-3 to -25 volts for a "Mark" (logic 1).

Any voltage in between these regions (i.e. between +3 and -3 Volts) is undefined.

The data byte is always transmitted least-significant-bit first.

Page 45: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 35

The bits are transmitted at specific time intervals determined by the baud rate of the

serial signal. This is the signal present on the RS-232 Port of your computer, shown below.

RS-232 Logic Waveform

3.4.3 PC INTERFACE SECTION:

Fig 3.11 MAX-232 Connecter diagram

Page 46: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 36

The above shown connector known as 9-pin, D-type male connector is used for RS232

connections. The pin description is given in the following table.

Pin number Common

Name

RS232

name

Description Signal

direction

1 /CD CF Received line signal detector IN

2 RXD BB Received data IN

3 TXD BA Transmitted data OUT

4 /DTR CD Data terminal ready OUT

5 GND AB Signal ground --

6 /DSR CC Data set ready IN

7 /RTS CA Request to send OUT

8 /CTS CB Clear to send IN

9 -- CE Ring indicator IN

Table 3.4: MAX 232 pin details

We cannot simply connect our system to this terminal without providing proper hand

shaking signal. For communicating with RS-232 type equipment, the /RTS of the connector is

simply looped into the /CTS, so /CTS will automatically be asserted when /RTS is asserted

internally. Similarly the /DTR is looped into /DSR and /CD, so when PC asserts its /DTR output

the /DSR and /CD inputs are automatically be asserted. These connections do not provide for any

hardware hand shaking. They are necessary to get the PC and our system talk each other. The

connection diagram is shown below.

Page 47: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 37

Fig 3.12 RS-232 Interface diagram

Serial communication:

When a processor communicates with the outside world, it provides data in byte sized

chunks. Computers transfer data in two ways: parallel and serial. In parallel data transfers, often

more lines are used to transfer data to a device and 8 bit data path is expensive. The serial

communication transfer uses only a single data line instead of the 8 bit data line of parallel

communication which makes the data transfer not only cheaper but also makes it possible for

two computers located in two different cities to communicate over telephone.

Serial data communication uses two methods, asynchronous and synchronous. The

synchronous method transfers data at a time while the asynchronous transfers a single byte at a

time. There are some special IC chips made by many manufacturers for data communications.

These chips are commonly referred to as UART (universal asynchronous receiver-transmitter)

and USART (universal synchronous asynchronous receiver transmitter). The AT89C51 chip has

a built in UART.

In asynchronous method, each character is placed between start and stop bits. This

is called framing. In data framing of asynchronous communications, the data, such as ASCII

characters, are packed in between a start and stop bit. We have a total of 10 bits for a character: 8

bits for the ASCII code and 1 bit each for the start and stop bits. The rate of serial data transfer

communication is stated in bps or it can be called as baud rate.

Page 48: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 38

To allow the compatibility among data communication equipment made by various

manufacturers, and interfacing standard called RS232 was set by the Electronics industries

Association in 1960. Today RS232 is the most widely used I/O interfacing standard. This

standard is used in PCs and numerous types of equipment. However, since the standard was set

long before the advent of the TTL logic family, its input and output voltage levels are not TTL

compatible. In RS232, a 1 bit is represented by -3 to -25V, while a 0 bit is represented +3 to +25

V, making -3 to +3 undefined. For this reason, to connect any RS232 to a microcontroller system

we must use voltage converters such as MAX232 to connect the TTL logic levels to RS232

voltage levels and vice versa. MAX232 ICs are commonly referred to as line drivers.

The RS232 cables are generally referred to as DB-9 connector. In labeling, DB-9P

refers to the plug connector (male) and DB-9S is for the socket connector (female). The simplest

connection between a PC and microcontroller requires a minimum of three pin, TXD, RXD, and

ground. Many of the pins of the RS232 connector are used for handshaking signals. They are

bypassed since they are not supported by the UART chip.

IBM PC/ compatible computers based on x86(8086, 80286, 386, 486 and Pentium)

microprocessors normally have two COM ports. Both COM ports have RS232 type connectors.

Many PCs use one each of the DB-25 and DB-9 RS232 connectors. The COM ports are

designated as COM1 and COM2. We can connect the serial port to the COM 2 port of a PC for

serial communication experiments. We use a DB9 connector in our arrangement.

Page 49: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 39

3.5 GEAR MOTOR:

What Is a Gear Motor?

Gear motors are complete motive force systems consisting of an electric motor

and a reduction gear train integrated into one easy-to-mount and -configure package. This greatly

reduces the complexity and cost of designing and constructing power tools, machines and

appliances calling for high torque at relatively low shaft speed or RPM. Gear motors allow the

use of economical low-horsepower motors to provide great motive force at low speed such as in

lifts, winches, medical tables, jacks and robotics. They can be large enough to lift a building or

small enough to drive a tiny clock.

.

Fig 3.13: 12V High Torque DC GEAR MOTOR

Page 50: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 40

Operation Principle:

Most synchronous AC electric motors have output ranges of from 1,200 to 3,600 revolutions per

minute. They also have both normal speed and stall-speed torque specifications. The reduction

gear trains used in gear

motors are designed to reduce the output speed while increasing the torque. The increase in

torque is inversely proportional to the reduction in speed. Reduction gearing allows small electric

motors to move large driven loads, although more slowly than larger electric motors. Reduction

gears consist of a small gear driving a larger gear. There may be several sets of these reduction

gear sets in a reduction gear box.

Toothed wheel that transmits the turning movement of one shaft to another shaft.

Gear wheels may be used in pairs or in threes if both shafts are to turn in the same direction. The

gear ratio – the ratio of the number of teeth on the two wheels – determines the torque ratio, the

turning force on the output shaft compared with the turning force on the input shaft. The ratio of

the angular velocities of the shafts is the inverse of the gear ratio.

The common type of gear for parallel shafts is the spur gear, with straight teeth parallel to the

shaft axis. The helical gear has teeth cut along sections of a helix or corkscrew shape; the double

form of the helix gear is the most efficient for energy transfer. Bevel gears, with tapering teeth

set on the base of a cone, are used to connect intersecting shafts.

Page 51: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 41

The toothed and interlocking wheels which make up a typical gear movement.

Gear ratio is calculated by dividing the number of teeth on the driver gear by the number of teeth

on the driven gear (gear ratio = driver/driven); the idler gears are ignored. Idler gears change the

direction of rotation but do not affect speed. A high driven to driver ratio (middle) is a speed-

reducing ratio.

Different gears are used to perform different engineering functions depending on the change in

direction of motion that is needed. Rack and pinion gears are the commonest gears and are used

in car steering mechanics.

Speed Reduction

Sometimes the goal of using a gear motor is to reduce the rotating shaft speed of a motor

in the device being driven, such as in a small electric clock where the tiny synchronous

motor may be spinning at 1,200 rpm but is reduced to one rpm to drive the second hand,

and further reduced in the clock mechanism to drive the minute and hour hands. Here the

amount of driving force is irrelevant as long as it is sufficient to overcome the frictional

effects of the clock mechanism.

Torque Multiplication

Another goal achievable with a gear motor is to use a small motor to generate a very

large force albeit at a low speed. These applications include the lifting mechanisms on

hospital beds, power recliners, and heavy machine lifts where the great force at low speed

is the goal.

Motor Varieties

Most industrial gear motors are AC-powered, fixed-speed devices, although there are

fixed-gear-ratio, variable-speed motors that provide a greater degree of control. DC gear

Page 52: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 42

motors are used primarily in automotive applications such as power winches on trucks,

windshield wiper motors and power seat or power window motors.

Many Applications

What power can openers, garage door openers, stair lifts, rotisserie motors, timer cycle

knobs on washing machines, power drills, cake mixers and electromechanical clocks

have in common is that they all use various integrations of gear motors to derive a large

force from a relatively small electric motor at a manageable speed. In industry, gear

motor applications in jacks, cranes, lifts, clamping, robotics, conveyance and mixing are

too numerous to count.

3.6 RELAY:

3.6.1 Overview:

A relay is an electrically operated switch. Current flowing through the coil of the relay

creates a magnetic field which attracts a lever and changes the switch contacts. The coil current

can be ON or OFF so relays have two switch position and they are double throw (changeover)

switches.

Relays allow one circuit to switch a second circuit which can be completely separate

from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC

mains circuit. There is no electrical connection inside the relay between the two circuits; the link

is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it

can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips)

can not provide this current and a transistor is usually used to amplify the small IC current to the

larger value required for the relay coil. The maximum output current for the popular 555 timer

IC is 200mA so these devices can supply relay coils directly without amplifica tion.

Relays are usually SPDT or DPDT but they can have many more sets of switch contacts,

for example relay with 4 sets of changeover contacts are readily available. Most relays are

Page 53: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 43

designed for PCB mounting but you can solder wires directly to the pins providing you take care

to avoid melting the plastic case of the relay.

The supplier's catalogue should show you the relay's connection. The coil will be obvious

and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when

they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage

you must connect a protection diode across the relay coil.

The relay’s switch connections are usually contains COM, NC and NO.

COM = Common, always connect to this; it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

Connect to COM and NO if you want the switched circuit to be on when the relay coil is on.

Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

Most relays are SPDT or DPDT which are often described as "single pole changeover" (SPCO)

Or "double pole changeover"(DPCO).

This is a Single Pole Double Throw relay. Current will flow between the movable contact

and one fixed contact when the coil is energized and between the movable contact and the

alternate fixed contact when the relay coil is energized. The most commonly used rela y in car

audio, the Bosch relay, is a SPDT relay..

Page 54: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 44

This relay is a Double Pole Double Throw relay. It operates like the SPDT relay but has

twice as many contacts. There are two completely isolated sets of contacts.

3.6.2 Relay Construction:

Relays are amazingly simple devices. There are four parts in every relay:

Electromagnet

Armature that can be attracted by the electromagnet

Spring

Set of electrical contacts

A relay consists of two separate and completely independent circuits. The first is at

the bottom and drives the electromagnet. In this circuit, a switch is controlling power to the

electromagnet. When the switch is on, the electromagnet is on, and it attracts the armature. The

armature is acting as a switch in the second circuit. When the electromagnet is energized, the

armature completes the second circuit and the light is on. When the electromagnet is not

energized, the spring pulls the armature away and the circuit is not complete. In that case, the

light is dark.

When you purchase relays, you generally have control over several variables:

The voltage and current that is needed to activate the armature

The maximum voltage and current that can run through the armature and the armature

contacts

The number of armatures (generally one or two)

Page 55: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 45

The number of contacts for the armature (generally one or two -- the relay shown here

has two, one of which is unused)

Whether the contact (if only one contact is provided) is normally open (NO) or normally

closed (NC)

3.6.3 Relay Applications:

In general, the point of a relay is to use a small amount of power in the electromagnet

coming, say, from a small dashboard switch or a low-power electronic circuit -- to move an

armature that is able to switch a much larger amount of power. For example, you might want the

electromagnet to energize using 5 volts and 50 milliamps (250 mill watts), while the armature

can support 120V AC at 2 amps (240 watts).

Relays are quite common in home appliances where there is an electronic control turning

on something like a motor or a light. They are also common in cars, where the 12V supply

voltage means that just about everything needs a large amount of current. In later model cars,

manufacturers have started combining relay panels into the fuse box to make maintenance easier.

In places where a large amount of power needs to be switched, relays are often cascaded.

In this case, a small relay switches the power needed to drive a much larger relay, and that

second relay switches the power to drive the load.

Relays can also be used to implement Boolean logic.

3.6.4 Advantages of Relay:

Relays can switch AC and DC, transistors can only switch DC.

Relays can switch high voltages, transistors cannot.

Relays are a better choice for switching large currents (> 5A).

Relays can switch many contacts at once.

Page 56: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 46

3.7 LIQUID CRYSTAL DISPLAY (LCD):

To display interactive messages we are using LCD Module. We examine an intelligent

LCD display of two lines,16 characters per line that is interfaced to the controllers. The protocol

(handshaking) for the display is as shown. Whereas D0 to D7th bit is the Data lines, RS, RW and

EN pins are the control pins and remaining pins are +5V, -5V and GND to provide supply.

Where RS is the Register Select, RW is the Read Write and EN is the Enable pin.

The display contains two internal byte-wide registers, one for commands (RS=0) and the

second for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the

character RAM) that can be programmed to generate any desired character that can be formed

using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will

be used to signify that the display RAM address 00h will be chosen.Port1 is used to furnish the

command or data type, and ports 3.2 to3.4 furnish register select and read/write levels.

The display takes varying amounts of time to accomplish the functions as listed. LCD bit 7 is

monitored for logic high (busy) to ensure the display is overwritten.

Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as

for debugging purpose. The most common type of LCD controller is HITACHI 44780 which

provides a simple interface between the controller & an LCD. These LCD's are very simple to

interface with the controller as well as are cost effective.

2x16 Line Alphanumeric LCD Display

Fig 3.14 (a)LCD Display (b) LCD Data R/W waveform

Page 57: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 47

The most commonly used ALPHANUMERIC displays are 1x16 (Single Line & 16

characters), 2x16 (Double Line & 16 character per line) & 4x20 (four lines & Twenty characters

per line).

The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on data

lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines + 3 control

lines i.e. total 11 lines are required. And if operated in 4-bit mode then 4 data lines + 3 control

lines i.e. 7 lines are required. How do we decide which mode to use? It’s simple if you have

sufficient data lines you can go for 8 bit mode & if there is a time constrain i.e. display should be

faster then we have to use 8-bit mode because basically 4-bit mode takes twice as more time as

compared to 8-bit mode.

Pin Symbol Function

1 Vss Ground

2 Vdd Supply Voltage

3 Vo Contrast Setting

4 RS Register Select 5 R/W Read/Write Select

6 En Chip Enable Signal

7-14 DB0-DB7 Data Lines

15 A/Vee Gnd for the backlight

16 K Vcc for backlight

Table 3.5 LCD pin details

When RS is low (0), the data is to be treated as a command. When RS is high (1), the

data being sent is considered as text data which should be displayed on the screen.

When R/W is low (0), the information on the data bus is being written to the LCD. When

RW is high (1), the program is effectively reading from the LCD. Most of the times there is no

need to read from the LCD so this line can directly be connected to Gnd thus saving one

controller line.

The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is

required to latch the data. The LCD interprets and executes our command at the instant the EN

line is brought low. If you never bring EN low, your instruction will never be executed.

Page 58: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 48

Fig 3.15: Interfacing of LED

COMMANDS USED IN LCD:

Table 3.6: Commands of LCD

3.8 POWER SUPPLY:

All digital circuits require regulated power supply. In this article we are going to learn

how to get a regulated positive supply from the mains supply.

Page 59: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 49

Figure 3.16 Basic block diagram of a fixed regulated power supply

Figure 3.16 shows the basic block diagram of a fixed regulated power supply. Let us go through

each block.

Transformer:

A transformer consists of two coils also called as ―WINDINGS‖ namely Primary &

Secondary.

They are linked together through inductively coupled electrical conductors also called as

CORE. A changing current in the primary causes a change in the Magnetic Field in the core &

this in turn induces an alternating voltage in the secondary coil. If load is applied to the

secondary then an alternating current will flow through the load. If we consider an ideal

Page 60: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 50

condition then all the energy from the primary circuit will be transferred to the secondary circuit

through the magnetic field.

So

The secondary voltage of the transformer depends on the number of turns in the Primary as well as in

the secondary.

Rectifier:

A rectifier is a device that converts an AC signal into DC signal. For rectification purpose

we use a diode, a diode is a device that allows current to pass only in one direction i.e. when the

anode of the diode is positive with respect to the cathode also called as forward biased condition

& blocks current in the reversed biased condition.

Rectifier can be classified as follows:

1) Half Wave rectifier:

This is the simplest type of rectifier as you can see in the diagram a half wave rectifier

consists of only one diode. When an AC signal is applied to it during the positive half cycle the

Page 61: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 51

diode is forward biased & current flows through it. But during the negative half cycle diode is

reverse biased & no current flows through it. Since only one half of the input reaches the output,

it is very inefficient to be used in power supplies.

2) Full wave rectifier:

Half wave rectifier is quite simple but it is very inefficient, for greater efficiency we

would like to use both the half cycles of the AC signal. This can be achieved by using a center

tapped transformer i.e. we would have to double the size of secondary winding & provide

connection to the center. So during the positive half cycle diode D1 conducts & D2 is in reverse

biased condition. During the negative half cycle diode D2 conducts & D1 is reverse biased. Thus

we get both the half cycles across the load.

One of the disadvantages of Full Wave Rectifier design is the necess ity of using a center

tapped transformer, thus increasing the size & cost of the circuit. This can be avoided by using

the Full Wave Bridge Rectifier.

Page 62: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 52

3) Bridge Rectifier:

As the name suggests it converts the full wave i.e. both the positive & the negative half

cycle into DC thus it is much more efficient than Half Wave Rectifier & that too without using a

center tapped transformer thus much more cost effective than Full Wave Rectifier.

Full Bridge Wave Rectifier consists of four diodes namely D1, D2, D3 and D4. During

the positive half cycle diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 &

D3 conduct thus the diodes keep switching the transformer connections so we get positive half

cycles in the output.

Page 63: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 53

If we use a center tapped transformer for a bridge rectifier we can get both positive &

negative half cycles which can thus be used for generating fixed positive & fixed negative

voltages.

Filter capacitor:

Even though half wave & full wave rectifier give DC output, none of them provides a

constant output voltage. For this we require to smoothen the waveform received from the

rectifier. This can be done by using a capacitor at the output of the rectifier this capacitor is also

called as ―FILTER CAPACITOR‖ or ―SMOOTHING CAPACITOR‖ or ―RESERVOIR

CAPACITOR‖. Even after using this capacitor a small amount of ripple will remain.

We place the Filter Capacitor at the output of the rectifier the capacitor will charge to the peak voltage

during each half cycle then will discharge its stored energy slowly through the load while the rectified voltage

drops to zero, thus trying to keep the voltage as constant as possible.

Page 64: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 54

If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the

costing will increase. The value of the Filter capacitor depends on the current consumed by the circuit, the

frequency of the waveform & the accepted ripple.

Where,

Vr= accepted ripple voltage.( should not be more than 10% of the voltage)

I= current consumed by the circuit in Amperes.

F= frequency of the waveform. A half wave rectifier has only one peak in one cycle so F=25hz

Where as a full wave rectifier has Two peaks in one cycle so F=100hz.

Voltage regulator :

A Voltage regulator is a device which converts varying input voltage into a constant

regulated output voltage. Voltage regulator can be of two types

1) Linear Voltage Regulator:

Also called as Resistive Voltage regulator because they dissipate the excessive voltage

resistively as heat.

2) Switching Regulators:

They regulate the output voltage by switching the Current ON/OFF very rapidly. Since their

output is either ON or OFF it dissipates very low power thus achieving higher efficiency as

compared to linear voltage regulators. But they are more complex & generate high noise due to

their switching action. For low level of output power switching regulators tend to be costly but

for higher output wattage they are much cheaper than linear regulators.

The most commonly available Linear Positive Voltage Regulators are the 78XX series where the

XX indicates the output voltage. And 79XX series is for Negative Voltage Regulators.

Page 65: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 55

After filtering the rectifier output the signal is given to a voltage regulator. The maximum

input voltage that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the

regulator so the input voltage should be at least 2-3 Volts higher than the output voltage. If the

input voltage gets below the Vmin of the regulator due to the ripple voltage or due to any other

reason the voltage regulator will not be able to produce the correct regulated voltage.

IC 7805:

7805 is an integrated three-terminal positive fixed linear voltage regulator. It supports an

input voltage of 10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp

although lower current models are available. Its output voltage is fixed at 5.0V. The 7805 also

has a built- in current limiter as a safety feature. 7805 is manufactured by many companies,

including National Semiconductors and Fairchild Semiconductors.

The 7805 will automatically reduce output current if it gets too hot.The last two digits

represent the voltage; for instance, the 7812 is a 12-volt regulator. The 78xx series of regulators

is designed to work in complement with the 79xx series of negative voltage regulators in systems

that provide both positive and negative regulated voltages, since the 78xx series can't regulate

negative voltages in such a system.

The 7805 & 78 is one of the most common and well-known of the 78xx series regulators,

as it's small component count and medium-power regulated 5V make it useful for powering TTL

devices.

Page 66: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 56

Specifications of IC 7805:

Table 3.7. Specifications of IC7805

Circuit diagram:

Fig 3.17 Circuit Diagram of power supply

SPECIFICATIONS IC 7805

Vout 5V

Vein - Vout Difference 5V - 20V

Operation Ambient Temp 0 - 125°C

Output Imax 1A

Page 67: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 57

CHAPTER 4

CIRCUIT DIAGRAM AND OPERATION

CIRCUIT DIAGRAM:

Fig 4.1 Circuit Diagram

Page 68: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 58

OPERATION:

This project is developed based on EMBEDDED and GSM Technology. When a field is in the dry

condition, the sensing logic senses the state of the field and intimates it to the microcontroller. It in

response makes the motor on by sending message by GSM. We can know the status of the field by

sending a message by the GSM modem which is placed at the field. Through our mobile we can switch

on-off the motor by sending the respective commands to the kit through the GSM modem. Thus the

irrigation motor can be controlled through our mobiles using GSM technology, and automatically control

the flood in the field when sudden raining by open the gate by on the gate motor.

Algorithm:

Step1: Start the process.

Step2: Initialize Micro controller

Step3: Initialize Motors

Step4: Initialize GSM

Step5: Initialize LCD

Step6: Check the moisture levels

Step7: If Field is dry send sms to the registered number as ―Field is dry‖, If Field is wet send sms

to tothe registered number as ―Field is wet‖

Step8:Wait for response

Step9: Based on replay Motor will be ON/OFF

Step10: Monitor the sensors

Step11:If no water flow send sms as No water flow

Step12: Check the gate sensors

Step13:If water level increases gate motor will be ON and send sms

Step14: After the process completed it getting move to original state.

Step15: Stop the process.

Page 69: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 59

CHAPTER 5

SOFTWARE DEVELOPMENT

5.1 INTRODUCTION:

In this chapter the software used and the language in which the program code is defined

is mentioned and the program code dumping tools are explained. The chapter also documents the

development of the program for the application. This program has been termed as ―Source code‖.

Figure 5.1 Keil Software- internal stages

Page 70: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 60

Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications

5.2 C51 COMPILER & A51 MACRO ASSEMBLER:

Source files are created by the µVision IDE and are passed to the C51 Compiler or A51

Macro Assembler. The compiler and assembler process source files and create replaceable object

files.

The Keil C51 Compiler is a full ANSI implementation of the C programming language

that supports all standard features of the C language. In addition, numerous features for d irect

support of the 8051 architecture have been added.

5.3 µVISION:

What's New in µVision3?

µVision3 adds many new features to the Editor like Text Templates, Quick Function

Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based

startup and debugger setup. µVision3 is fully compatible to µVision2 and can be used in parallel

with µVision2.

What is µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps you write, comp ile,

and debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

Editor.

A powerful debugger.

Page 71: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 61

Starting µVision2 and Creating a Project:

1. Click on the Keil uVision Icon on Desktop

2. The following fig will appear

3. Click on the Project menu from the title bar

4. Then Click on New Project

Page 72: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 62

5. Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

6. Then Click on Save button above.

7. Select the component for u r project. i.e. Atmel……

8. Click on the + Symbol beside of Atmel

Page 73: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 63

9. Select AT89C51 as shown below

10.Then Click on ―OK‖

11.The Following fig will appear

Page 74: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 64

12.Then Click either YES or NO………mostly ―NO‖

13. Now your project is ready to USE

14. Now double click on the Target1, you would get another option ―Source group 1‖ as shown

in next page.

15. Click on the file option from menu bar and select ―new‖

Page 75: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 65

16. The next screen will be as shown in next page, and just maximize it by double clicking on its

blue boarder.

17. Now start writing program in either in ―C‖ or ―ASM‖

18. For a program written in Assembly, then save it with extension ―. asm‖ and for ―C‖ based

program save it with extension ― .C‖

Page 76: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 66

19. Now right click on Source group 1 and click on ―Add files to Group Source‖

20. Now you will get another window, on which by default ―C‖ files will appear.

Page 77: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 67

21. Now select as per your file extension given while saving the file

22. Click only one time on option ―ADD‖

23. Now Press function key F7 to compile. Any error will appear if so happen.

24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

Page 78: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 68

26. Then Click ―OK‖

27. Now Click on the Peripherals from menu bar, and check your required port as shown in fig

below

28. Drag the port a side and click in the program file.

29. Now keep Pressing function key ―F11‖ slowly and observe.

30. You are running your program successfully

Page 79: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 69

5.4 FLASH MAGIC:

Features:

Straightforward and intuitive user interface

Five simple steps to erasing and programming a device and setting any

options desired

Programs Intel Hex Files

Automatic verifying after programming

Fills unused flash to increase firmware security

Ability to automatically program checksums. Using the supplied checksum

calculation routine your firmware can easily verify the integrity of a Flash

block, ensuring no unauthorized or corrupted code can ever be executed

Program security bits

Check which Flash blocks are blank or in use with the ability to easily erase

all blocks in use

Read the device signature

Read any section of Flash and save as an Intel Hex File

Reprogram the Boot Vector and Status Byte with the help of confirmation

features that prevent accidentally programming incorrect values

Displays the contents of Flash in ASCII and Hexadecimal formats

Single-click access to the manual, Flash Magic home page and NXP

Microcontrollers home page

Ability to use high-speed serial communications on devices that support it.

Flash Magic calculates the highest baud rate that both the device and your PC

can use and switches to that baud rate transparently

Command Line interface allowing Flash Magic to be used in IDEs and Batch

Files

Manual in PDF format

supports half-duplex communications

Verify Hex Files previously programmed

Save and open settings

Page 80: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 70

Able to control the DTR and RTS RS232 signals when connected to RST and

/PSEN to place the device into Boot ROM and Execute modes automatically.

An example circuit diagram is included in the Manual. This is essential for

ISP with target hardware that is hard to access.

This enables us to send commands to place the device in Boot ROM mode,

with support for command line interfaces. The installation includes an

example project for the Keil and Raisonance 8051 compilers that show how to

build support for this feature into applications.

Able to play any Wave file when finished programming.

built in automated version checker - helps ensure you always have the latest

version.

Powerful, flexible Just In Time Code feature. Write your own JIT Modules to

generate last minute code for programming. Uses include:

Serial number generation

Copy protection and copy authorization

Storing program date and time - manufacture date

Storing program operator and location

Lookup table generation

Language tables or language selection

Centralized record keeping

Obtaining latest firmware from the Corporate Web site or project intranet

Requirements:

Flash Magic works on any versions of Windows, except Windows 95. 10Mb of

disk space is required. As mentioned earlier, we are automating two different routines in

our project and hence we used the method of polling to continuously monitor those tasks

and act accordingly

Page 81: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 71

5.5 CODING:

Source code:

#include<reg52.h> #include<string.h>

#include "Headers.h" #include "Lcd.C"

#include "Serial.C" #include "GSM.C" #include "app.C"

int main() { Buzzzz=0;

Motor=0; Lcd_Init();

Init_UART0(); Init_UART0_Interrupt();

GSM_S900();

Project_Label(); while(1)

{ Check_Sensors();

//Check_Message(); }

}

void Project_Label(void) {

Lcd_Clear; Lcd_Data_Str(1,1,"GSM Based Monitr"); Lcd_Data_Str(2,1,"Flood Control ");

Delay(300); Lcd_Clear;

}

Page 82: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 72

Delay(unsigned int time)

{ unsigned int i,j; for(i=0;i<time;i++)

for(j=0;j<1200;j++); }

/******************************************/ bit LCD_Cmd=0,LCD_Data=1;

Lcd_Init();

Lcd_Data_Chr(bit RS ,unsigned char line,unsigned char position,unsigned char temp1) ; Lcd_Data_Str(unsigned char line,unsigned char position,unsigned char *temp); Lcd_Wr(unsigned char r);

Delay(unsigned int);

/***********************************************************************

Lcd_Data_(0-cmd:1-data,line no,position,char to disp on LCD); ******************************************************************************

***/

sfr LCD_DATA=0X90;//PORT 1

sbit RS=P2^6;

sbit EN=P2^7;

Lcd_Init()

{ unsigned char LCD_2_LINE=0x38;

unsigned char LCD_CLEAR=0X01; unsigned char DISPLAY_ON=0X0E;

unsigned char LCD_CURSOR_OFF=0x0C;

Page 83: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 73

Lcd_Data_Chr(0,0,0, LCD_2_LINE);

Lcd_Data_Chr(0,0,0, DISPLAY_ON); Lcd_Data_Chr(0,0,0, LCD_CURSOR_OFF);

Lcd_Data_Chr(0,0,0, LCD_CLEAR); }

Lcd_Data_Chr(bit RS ,unsigned char line,unsigned char position,unsigned char temp1)

{ if(RS==0)

{ LCD_DATA=temp1;

Lcd_Wr(LCD_Cmd); }

if(RS==1) {

if(line==1) {

LCD_DATA=0x7f+position; Lcd_Wr(LCD_Cmd);

} if(line==2)

{ LCD_DATA=0xbf+position;

Lcd_Wr(LCD_Cmd); }

LCD_DATA=temp1; Lcd_Wr(LCD_Data);

}

}

Lcd_Data_Str(unsigned char line,unsigned char position,unsigned char *temp) {

Page 84: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 74

unsigned char p;

if(line==1) {

p=0x7f+position; Lcd_Data_Chr(0,0,0,p);

}

if(line==2) { p=0xbf+position;

Lcd_Data_Chr(0,0,0,p); }

while(*temp!='\0')

{ LCD_DATA=*temp;

Lcd_Wr(LCD_Data); temp++; }

}

Lcd_Wr(unsigned char r) {

RS=r; EN=1; Delay(1);

EN=0;

} Check_Sensors()

{

if(Level1==0&&Level2==0&&Level3==0) { Lcd_Data_Str(1,1,"Dam Level Full ");

Buzzzzz=1; if(flag1==0)

{ flag1=1;

Page 85: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 75

Sending_Message("GSM Based Dam Level Alert For Floods \r\n Alert...! Dam Water Level Full\r\n",Misscall_Data_Upload());

//Buzzzzz=0; }

}

if(Level1==0&&Level2==0&&Level3==1)

{ Lcd_Data_Str(1,1,"Dam Level Medium"); Buzzzzz=1;

flag1=0; if(flag2==0)

{ flag2=1; //Sending_Message("GSM Based Water Tank System \r\n Aler...! Water Level

Medium\r\n",Misscall_Data_Upload()); //Buzzzzz=0;

} }

if(Level1==0&&Level2==1&&Level3==1) {

Lcd_Data_Str(1,1,"Dam Level Low "); Buzzzzz=1; flag1=0;

if(flag4==0) {

flag4=1; //Sending_Message("GSM Based Water Tank System \r\n Aler...! Water Level Low\r\n",Misscall_Data_Upload());

//Buzzzzz=0; }

}

if(Level1==1&&Level2==1&&Level3==1) {

Lcd_Data_Str(1,1,"Tank Level Empty"); Buzzzzz=1; flag1=0;

if(flag3==0) {

flag1=0; flag3=1;

Page 86: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 76

flag2=0; //Sending_Message("GSM Based Water Tank System \r\n Aler...! Water Level

Empty\r\n",Misscall_Data_Upload()); //Buzzzzz=0;

} }

}

GSM_modem_init()

{

serialtx_str_intr("ATE0\r\n"); Delay(10); serialtx_str_intr("AT\r\n");

Delay(10); serialtx_str_intr("AT\r\n");

Delay(10); serialtx_str_intr("AT+CNMI=1,1,0,0,0\r\n"); serialtx_chr_intr(0x0d);

Delay(10); serialtx_str_intr("AT+CNMI=1,1,0,0,0\r\n");

serialtx_chr_intr(0x0d); serialtx_str_intr("AT+CMGF=1"); serialtx_chr_intr(0x0d);

serialtx_str_intr("AT+CMGF=1"); serialtx_chr_intr(0x0d);

Delay(10); }

Misscal_Messg_Send() {

serialtx_str("AT+CPBS=\"MC\"\r\n");

while(serial_rx()!='O'); while(serial_rx()!='K'); serialtx_str("AT+CPBR=1\r\n");

while(serial_rx()!='1')

}

Page 87: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 77

CHAPTER 6

RESULTS

Our overall system of Automatic irrigation and flood controlling system is shown below

Page 88: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 78

Initially when we switch on the system, the system is initial condition & booting up as

shown below

Initially the LCD display shown as

Page 89: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 79

In the LCD message display as

When we give a missed call to system, call automatically rejected and sends a SMS to

registered mobile number

Page 90: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 80

Page 91: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 81

The motor will be ON/OFF by the SMS from registered mobile number

Page 92: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 82

The results is observesd as

If dam water level reaches maximum level gate motor will on

This project is developed based on EMBEDDED and GSM Technology.

When a field is in the dry condition, the sensing logic senses the state of the field and

intimates it to the microcontroller.

Page 93: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 83

It in response makes the motor on by sending message by GSM. We can know the status

of the field by sending a message by the GSM modem which is placed at the field.

Through our mobile we can switch on-off the motor by sending the respective commands

to the kit through the GSM modem.

Thus the irrigation motor can be controlled through our mobiles using GSM technology,

and automatically control the flood in the field when sudden raining by open the gate by

on the gate motor.

Advantages:

1. Easy to implement

2. Low cost

3. Eco-Friendly

4. Use the man-power more efficiently

Disadvantages:

1. Here the soil sensors can cover only certain distance.

Applications:

1. Agriculture applications

2. Industrial applications

RESULT:

The project ―AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM”

has been successfully designed and tested. Integrating features of all the hardware components

used have developed it.

Page 94: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 84

CHAPTER 7

CONCLUSION

Since earlier days farmer is supposed to visit their agricultural land and check

the moisture content of soil manually. To avoid more human efforts this technology

can be used. It allows the user to monitor and maintain the moisture remotely

irrespective of time. It is really an effective and economic way to reduce human effort

and water wastage in agriculture land. Current techniques in agriculture have reduced

the ground-water level and availability of human resource. This Irrigation control

system using GSM can help farmer in many ways through the use of Humidity,

Automatic and Manual modes of operation.

Page 95: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 85

CHAPTER 8

FUTURE SCOPE

Apart from agricultural fields, this system can be used in Cricket stadiums or Golf

stadiums and also in public gardens. The system has a huge demand and future scope too. It

allows a lot of development within it and leads to the standard and useful system which can be

used vary widely in agricultural field.

Page 96: Automatic irrigation and flood controlling system by using GSM

AUTOMATIC IRRIGATION AND FLOOD CONTROLLING SYSTEM BY USING GSM

DEPT OF ECE, SREEKAVITHA ENGINEERING COLLEGE Page 86

CHAPTER 9

REFERENCES

[1] Veena Divya K member IACSIT ,Ayush Akhouri, Chanda based Automated Irrigation

Control System using Drip Irrigation Methology International Journal of Scientific &

Engineering Research, Volume 4, Issue 5, May 2013 ISSN 2229-5518

[2] In R.Suresh, S.Gopinath, K.Govindaraju, T.Devika,on Control using Raingun Irrigation

System‖ Internat Vol. 3, Issue 2, February 2014

[3] Purnima, S.R.N. Reddy, PhD. Proposed a ―Designtomatic of Irrigation System

using GSM-Bluetooth ―(International Journal–888)Volume of C 47–No.12, June 2012 )

[4] Chandrika Chanda, Surbhi Agarwal Proposed scheme Systems‖ -(ISSN2459,Volume

22502,Issue10, October 2012)

[5] Irrigation, 5th Edition, Muhammad Irfan Khan Yousafzai, Claude H. Pair,

editor, published by the Irrigation Association, 1983

[6] Drip and Micro Irrigation Design and Management for Trees, Vines, and Field

Crops, 3rd Edition, by Charles M. Burt and Stuart W. Styles, published by the

Irrigation Training and Research Center, 2007

[7] http://en.wikipedia.org/wiki/Drip_irrigation

[8] http://en.wikipedia.org/wiki/Android_(operatingsystem)

[9] 8051 programming and applications – by K.J.Ayala

[10] Microprocessors and interfacing - by Douglas V.Hall

[11] https://www.sparkfun.com/datasheets/Components/LM7805.pdf

[12] http://www.atmel.com/images/doc1919.pdf

[13] http://www.ti.com/lit/ds/symlink/lm124-n.pdf

[14] http://forum.researchdesignlab.com/datasheet/SIM900A