Anda di halaman 1dari 56

A PROJECT REPORT

on

AUTOMATIC GARDENING SYSTEM


Submitted by

Patel Jaydeep (120443111019)


Sanghani Kishor (120443111001)
Prikh Rutvik (120443111034)
In fulfillment for the award of the degree
Of

BACHELOR OF ENGINEERING
In
Electronics and Communications

C. U. Shah College of Engineering & Technology, Wadhwan city

Gujarat Technological University, Ahmedabad


OCT 2014

C.U. Shah College of Engineering & Technology


C. U. Shah College of Engineering & Technology
Electronics and Communications
2014

CERTIFICATE
Date:
This is to certify that the dissertation entitled Automatic Gardening
System has been carried out by Patel Jaydeep, Sanghani Kishor & Prikh
Rutvik under my guidance in fulfillment of the degree of Bachelor of Engineering
in Electronics and Communications (7th Semester) of Gujarat Technological
University, Ahmedabad during the academic year 2013-14.

Guide: Prof. K.R.Ranipa

Head of the Department


Prof. D. N. Khandhar

C. U. Shah College of Engg. & Tech.

Page 2

ACKNOWLEDGEMENT
Initially, we would like to express our sincere gratitude and gratefulness to our professor
Mr. K.R.Ranipa for providing us with all sorts of basic ideas and techniques essential for
carrying out this project work from the very beginning to the end and enabled us to present this
dissertation in this form. The teaching staffs also deserve our sincere thanks for sharing their
discussion and exchange of ideas.
We are very much grateful to the C.U. Shah College of Engineering & Technology,
Wadhwan city Campus for providing us an enthusiastic support and opportunity. Also to the
Head of Department of Electronics and Communications Prof. D. N. Khandhar also must come
in special mention for their unstinting cooperation in completion of this project. We would like
to give heartily thanks to our friends who have provided a great help and cooperation for the
existence of this output. Our obligation goes to our family and all our friends who assisted us
directly and indirectly in completing this study.
Lastly, we would like to extend our sincere gratitude to the known and unknown writers
of the books and references that has been taken during the preparation of this project work.

C. U. Shah College of Engg. & Tech.

Page 3

LIST OF FIGURES
Sr.

Chapter Name

Pg. No.

No.
2.1

Block Diagram

10

3.1

Circuit Diagram

12

4.1

Power Supply Circuit

14

4.2

Transformer

15

4.3

Rectifier Operation 1

16

4.4

Rectifier Operation 2

17

4.5

Rectifier Operation 3

17

4.6

LM 7805

18

4.7

Pin Diagram of 8051

20

4.8

Block Diagram of 8051

21

4.9

Crystal Circuit of 8051

26

4.10 DS 1307

27

4.11 DS 1307 Block Diagram

28

4.12 DS1307 Pin Diagram

29

4.13 DS 1307 Interfacing

30

4.14 I2C Protocol

31

4.15 I2C Protocol Communication

33

C. U. Shah College of Engg. & Tech.

Page 4

4.16 2x16 LCD Display

35

4.17 2x16 LCD Pin Diagram

37

4.18 LCD Interfacing

40

4.19 Buzzer Interfacing Circuit

41

4.20 L293D Pin Diagram

43

4.21 L293D Interfacing

44

4.22 Relay Pin Diagram

47

4.23 Relay Interfacing

47

4.24 Relay ON

48

4.25 Relay OFF

48

4.26 Relay

50

4.27 Different Types of Relay

51

C. U. Shah College of Engg. & Tech.

Page 5

TABLE OF CONTENTS
Sr. No.

Page No

Acknowledgement

Abstract

1. Introduction

2. Block Diagram

10

3. Circuit Diagram

12

4. Circuit Working

13

4.1 Power Supply

14

4.2 Sensor Signaling Conditioning

19

4.3 Microcontroller

19

4.4 RTC DS 1307

27

4.5 LCD

35

4.6 Buzzer

41

4.7 Motor Driver IC (L293D)

42

4.8 Relay

46

5. Result & Conclusion

53

6. Application

54

7. Advantages

55

8. Reference

56

C. U. Shah College of Engg. & Tech.

Page 6

ABSTRACT

The most important problems faced in Garden automation are the misusage of electricity
and its wastage. Sometimes due to carelessness of the authorities and the workers lamps are left
ON which results in wastage of electricity. Water wastage is another problem which needs to be
dealt with. Our project helps to overcome all these problems.
Firstly the Microcontroller around 4.00pm switches on the water supply once to water the
entire garden few hours before opening of the garden for public. Next the gate is opened by
running the motor which is driven by a motor driver operated by the Microcontroller. At around
6.00pm the two lights are switched on depending upon the output of the LDR and the lights
remain functional till the garden remains open for visitors.
The garden remains open for about three hours and so around 8.50 pm a buzzer is
sounded to indicate closure of the garden and alert the visitors. The gate is then closed at 9.00pm
and one of the two lamps is switched off. One lamp is kept on throughout the night. In the
morning the remaining lamp is switched off as the depending upon the signal sent by the light
dependent resistor to the Microcontroller. These are the step involved in the operation of the
circuit and the public garden automation. Microcontroller is used to supervise the actions of all
other devices and to control the entire set of operations.

C. U. Shah College of Engg. & Tech.

Page 7

Chapter 1
Introduction
The most important problems faced are the misusage of electricity and its wastage.
Sometimes due to carelessness of the authorities and the workers lamps are left ON which results
in wastage of electricity. Water wastage is another problem which needs to be dealt with. Our
project helps to overcome all these problems.
Firstly the Microcontroller around 4.00pm switches on the water supply once to water the
entire garden few hours before opening of the garden for public. Next the gate is opened by
running the motor which is driven by a motor driver operated by the Microcontroller. At around
6.00pm the lights are switched on depending upon the output of the LDR and the lights remain
functional till the garden remains open for visitors.
The garden remains open for about three hours and so around 8.50 pm a buzzer is
sounded to indicate closure of the garden and alert the visitors. The gate is then closed at 9.00pm
and three of the four lamps are switched off. One lamp is kept on throughout the night. In the
morning the remaining lamp is switched off as the depending upon the signal sent by the light
dependent resistor to the Microcontroller. These are the step involved in the operation of the
circuit and the public garden automation. Microcontroller is used to supervise the actions of all
other devices and to control the entire set of operations.
Appropriate environmental conditions are necessary for optimum plant growth, improved
crop yields, and efficient use of water and other resources. Automating the data acquisition
process of the soil conditions and various climatic parameters that govern plant growth allows
information to be collected at high frequency with less labor requirements. The existing systems
employ PC or SMS-based systems for keeping the user continuously informed of the conditions
inside the greenhouse; but are unaffordable, bulky, difficult to maintain and less accepted by the
technologically unskilled workers.
The objective of this project is to design a simple, easy to install, microcontroller-based
circuit to monitor and record the values of temperature, humidity, soil moisture and sunlight of
the natural environment that are continuously modified and controlled in order optimize them to

C. U. Shah College of Engg. & Tech.

Page 8

achieve maximum plant growth and yield. The controller used is a low power, cost efficient chip
manufactured by ATMEL having 8K bytes of on-chip flash memory. It communicates with the
various sensor modules in real-time in order to control the light, aeration and drainage process
efficiently inside a greenhouse by actuating a cooler, fogger, dripper and lights respectively
according to the necessary condition of the crops. An integrated Liquid crystal display (LCD) is
also used for real time display of data acquired from the various sensors and the status of the
various devices. Also, the use of easily available components reduces the manufacturing and
maintenance costs. The design is quite flexible as the software can be changed any time. It can
thus be tailor-made to the specific requirements of the user.
This makes the proposed system to be an economical, portable and a low maintenance
solution for greenhouse applications, especially in rural areas and for small scale agriculturists.

C. U. Shah College of Engg. & Tech.

Page 9

Chapter 2
Block Diagram
Block Diagram of Automatic Gardening System

RTC
DS1307
LDR
Keypad

Micro
Controller
Unit
8051
Family

Buzzer

Relay 1

Lamp 1

Relay 2

Lamp 2

Motor
Driver

DC Motor
(For Water
Supply)

Motor
Driver

DC
Motor
(For Gate)

Figure 2.1 Block Diagram

C. U. Shah College of Engg. & Tech.

Page 10

Description of Block Diagram


LDR:
The output of LDR is given as input to the signal conditioning circuit the output of which is
given to 89C51 on input side to control the state of lamps.
RTC:
A real time clock is basically just like a watch - it runs on a battery and keeps time for you even
when there is a power outage! Using an RTC, you can keep track of long timelines, even if you
reprogram your microcontroller or disconnect it from USB or a power plug.
MICRO CONTROLLER AT 89C51:
It processes the calculated digital values by converting it to ASCII & sends it to the LCD display
in order to display the data. Also depending upon the setting at the input, it controls the output
LIQUID CRYSTAL DISPLAY:
As the name suggests, it is used for displaying purpose. It displays the current date, time.
RELAY:
It is used to control the flow of water in the garden just like any simple valve and is driven by a
relay driver.
KEYPAD:
The keypad is used for entering the time and date and also can be used for manual over ride.
POWER SUPPLY UNIT:
Power supply unit provides a 5V regulated supply to the micro controller AT 89C51, ADC 0804,
LCD, MUX 4051, serial memory. It provides a 12V unregulated supply to the relays.

C. U. Shah College of Engg. & Tech.

Page 11

Chapter 3
Circuit Diagram

Figure 3.1 Circuit Diagram


C. U. Shah College of Engg. & Tech.

Page 12

Chapter 4
Circuit Working
OUR complete project is to be divided into 6 sections.
1. Power supply.
2. Sensor signal conditioning
3. Analogue to digital converter.
4. Microcontroller
5. RTC (Real Time Clock)
6. LCD connectivity.
7. Output interface.

C. U. Shah College of Engg. & Tech.

Page 13

4.1 POWER SUPPLY


In this project firstly we use one step down transformer. Step down transformer step
down the voltage from 220 volt Ac to 12 volt Ac. This Ac voltage is further converted into DC
with the help of rectifier circuit. In rectifier circuit we use four diode. All the diodes are arranges
as a bridge rectifier circuit. Output of this rectifier is pulsating Dc. To convert this pulsating DC
into smooth dc we use one capacitor as a filter components. Capacitor converts the pulsating Dc
into smooth DC with the help of its charging and discharging effect.
Output of the rectifier is now regulated with the help of IC regulator circuit. In this
project we use positive voltage regulator circuit. Here we use three pin regulator. Output of this
regulator is regulated voltage. If we use 7805 regulator then its means its is 5 volt regulator and
if we use 7808 regulator then its means that it is 8 volt regulator circuit. In this project we use 5
volt dc regulated power supply for the complete circuit.
5 VOLT REGULATED POWER SUPPLY CIRCUIT

Figure 4.1 Power Supply Circuit

C. U. Shah College of Engg. & Tech.

Page 14

Transformer:
A transformer is an electrical device which is used to convert electrical power from one
electrical circuit to another without change in frequency. Transformers convert AC electricity
from one voltage to another with little loss of power. Transformers work only with AC and this
is one of the reasons why mains electricity is AC. Most power supplies use a step-down
transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coil is
called the primary and the output coil is called the secondary. There is no electrical connection
between the two coils; instead they are linked by an alternating magnetic field created in the softiron core of the transformer. The two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in. Note
that as voltage is stepped down current is stepped up. The ratio of the number of turns on each
coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a
large number of turns on its primary (input) coil which is connected to the high voltage mains
supply, and a small number of turns on its secondary (output) coil to give a low output voltage.

Figure 4.2 Transformer

Rectifier:
A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of
conversion a.c to d.c is called rectification
Types of Rectifiers:
Half wave Rectifier
Full wave rectifier

C. U. Shah College of Engg. & Tech.

Page 15

1. Centre tap full wave rectifier.


2. Bridge type full bridge rectifier.
Full-wave Rectifier:
In our project we are using full wave bridge rectifier circuit. Bridge Rectifier: A bridge
rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This
is a widely used configuration, both with individual diodes wired as shown and with single
component bridges where the diode bridge is wired internally.
A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig(a) to
achieve full-wave rectification. This is a widely used configuration, both with individual diodes
wired as shown and with single component bridges where the diode bridge is wired internally.

Figure 4.3 Transformer Operation1

C. U. Shah College of Engg. & Tech.

Page 16

Figure 4.4 Transformer Operation

Figure 4.5 Transformer Operation


Filter:
A Filter is a device which removes the a.c component of rectifier output but allows the
d.c component to reach the load.

C. U. Shah College of Engg. & Tech.

Page 17

Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output
voltages. The maximum current they can pass also rates them. Negative voltage regulators are
available, mainly for use in dual supplies. Most regulators include some automatic protection
from excessive current ('overload protection') and overheating ('thermal protection'). Many of the
fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V
1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive
lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin,
connect the negative lead to the Common pin and then when you turn on the power, you get a 5
volt supply from the output pin.

Figure 4.6 LM 7805 IC

C. U. Shah College of Engg. & Tech.

Page 18

4.2 SENSOR SIGNAL CONDITIONING


Light Sensor:
In the light sensor we use one LDR. LDR is a light dependent resistor. Resistance of the
ldr is depend on the intensisty of the light. As the light on the ldr is change , resistance of ldr is
also change. Resistance of the ldr is varies from 1k ohm to 500 k ohm. In full llight resistance of
the ldr is very low below then 1 k ohm and in no light resistance of the ldr is become very high
above then 500k ohm.
In this project we use ldr with only one 10k ohm variable resistor. This 10 k ohm resistor
is connected to the positive voltage 5volt.

4.3 MICROCONTROLLER

C. U. Shah College of Engg. & Tech.

Page 19

Figure 4.7 Pin Diagram


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 Atmels
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 programmer. 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 contents but freezes the
oscillator, disabling all other chip functions until the next interrupt or hardware reset.

C. U. Shah College of Engg. & Tech.

Page 20

Figure 4.8 Block Diagram


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.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 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 pullC. U. Shah College of Engg. & Tech.

Page 21

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
highorder 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 various
special features of the AT89S52. Port 3 also receives some control signals for Flash
programming and verification.
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 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

C. U. Shah College of Engg. & Tech.

Page 22

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.
Memory Organization
MCS-51 devices have a separate address space for Program and Data Memory. Up to
64K bytes each of external Program and Data Memory can be addressed.
Program Memory
If the EA pin is connected to GND, all program fetches are directed to external memory.
On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through
1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to
external memory.
Data Memory
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a
parallel address space to the Special Function Registers. This means that the upper 128 bytes
have the same addresses as the SFR space but are physically separate from SFR space. When an
instruction accesses an internal location above address 7FH, the address mode used in the
instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space.
Instructions which use direct addressing access of the SFR space. For example, the following

C. U. Shah College of Engg. & Tech.

Page 23

direct addressing instruction accesses the SFR at location 0A0H (which is P2) MOV 0A0H,
#data, Instructions that use indirect addressing access the upper 128 bytes of RAM.
For example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0,
#data, Note that stack operations are examples of indirect addressing, so the upper 128 bytes of
data RAM are available as stack space.
Timers
Watchdog Timer
The WDT is intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 13-bit counter and the Watchdog Timer
Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT,
a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H).
When the WDT is enabled, it will increment every machine cycle while the oscillator is running.
The WDT timeout period is dependent on the external clock frequency. There is no way to
disable the WDT except through reset (either hardware reset or WDT overflow reset). When
WDT overflows, it will drive an output RESET HIGH pulse at the RST pin.
Using the WDT
To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST
register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by writing
01EH and 0E1H to WDTRST to avoid a WDT overflow. The 13-bit counter overflows when it
reaches 8191 (1FFFH), and this will reset the device. When the WDT is enabled, it will
increment every machine cycle while the oscillator is running. This means the user must reset the
WDT at least every 8191 machine cycles. To reset the WDT the user must write 01EH and 0E1H
to WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written.
When WDT overflows, it will generate an output RESET pulse at the RST pin. The RESET
pulse duration is 96xTOSC, where TOSC=1/FOSC. To make the best use of the WDT, it should
be serviced in those sections of code that will periodically be executed within the time required
to prevent a WDT reset. The UART in the AT89S52 operates the same way as the UART in the
AT89C51 and AT89C52.
C. U. Shah College of Engg. & Tech.

Page 24

Timer 0 and 1: Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0
and Timer 1 in the AT89C51 and AT89C52.
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that
can be configured for use as an on-chip oscillator, as shown in Figure Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source, XTAL2
should be left unconnected while XTAL1 is driven, as shown in Figure There are no
requirements on the duty cycle of the external clock signal, since the input to the internal
clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high
and low time specifications must be observed. Idle Mode : In idle mode, the CPU puts itself to
sleep while all the onchip peripherals remain active. The mode is invoked by software. The
content of the on-chip RAM and all the special functions registers remain unchanged during this
mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. Note
that when idle mode is terminated by a hardware reset, the device normally resumes program
execution from where it left off, up to two machine cycles before the internal reset algorithm
takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the
port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when
idle mode is terminated by a reset, the instruction following the one that invokes idle mode
should not write to a port pin or to external memory. Power-down Mode: In the Power-down
mode, the oscillator is stopped, and the instruction that invokes Powerdown is the last instruction
executed. The on-chip RAM and Special Function Registers retain their values until the Powerdown mode is terminated. Exit from Power-down mode can be initiated either by a hardware
reset or by an enabled external interrupt. Reset redefines the SFRs but does not change the onchip RAM. The reset should not be activated before VCC is restored to its normal operating level
and must be held active long enough to allow the oscillator to restart and stabilize.

C. U. Shah College of Engg. & Tech.

Page 25

Figure 4.9 Crystal Circuit

C. U. Shah College of Engg. & Tech.

Page 26

4.4 RTC

- DS 1307 REAL TIME CLOCK:

A real time clock is basically just like a watch - it runs on a battery and keeps time for
you even when there is a power outage! Using an RTC, you can keep track of long timelines,
even if you reprogram your microcontroller or disconnect it from USB or a power plug.
Most microcontrollers, including the Arduino, have a built-in timekeeper called millis ()
and there are also timers built into the chip that can keep track of longer time periods like
minutes or days. So why would you want to have a seperate RTC chip? Well, the biggest reason
is that millis () only keeps track of time since the Arduino was last powered - . That means that
when the power is turned on, the millisecond timer is set back to 0. The Arduino doesn't know
that it's 'Tuesday' or 'March 8th', all it can tell is 'It's been 14,000 milliseconds since I was last
turned on'.

Figure 4.10 DS1307


OK so what if you wanted to set the time on the Arduino? You'd have to program in the
date and time and you could have it count from that point on. But if it lost power, you'd have to
reset the time. Much like very cheap alarm clocks: every time they lose power they blink 12:00
While this sort of basic timekeeping is OK for some projects, some projects such as dataloggers, clocks, etc will need to have consistent timekeeping that doesn't reset when the
Arduino battery dies or is reprogrammed. Thus, we include a seperate RTC! The RTC chip is
a specialized chip that just keeps track of time. It can count leap-years and knows how many

C. U. Shah College of Engg. & Tech.

Page 27

days are in a month, but it doesn't take care of Daylight Savings Time (because it changes from
place to place)
The RTC we'll be using is the DS1307. It's low cost, easy to solder, and can run for years
on a very small coin cell.
GENERAL DESCRIPTION
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal
(BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially
through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day,
date, month, and year information. The end of the month date is automatically adjusted for
months with fewer than 31 days, including corrections for leap year. The clock operates in either
the 24-hour or 12- hour format with AM/PM indicator. The DS1307 has a built-in power-sense
circuit that detects power failures and automatically switches to the backup supply. Timekeeping
operation continues while the part operates from the backup supply.
TYPICAL OPERATING CIRCUIT

Figure 4.11 DS1307 Block Diagram

C. U. Shah College of Engg. & Tech.

Page 28

FEATURES

Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of
the week, and Year with Leap-Year Compensation Valid Up to 2100

56-Byte, Battery-Backed, General-Purpose RAM with Unlimited Writes

I2C Serial Interface

Programmable Square-Wave Output Signal

Automatic Power-Fail Detect and Switch Circuitry

Consumes Less than 500nA in Battery-Backup Mode with Oscillator Running

Optional Industrial Temperature Range:

-40C to +85C

Available in 8-Pin Plastic DIP or SO

Underwriters Laboratories (UL) Recognized

PIN CONFIGURATIONS

Figure 4.12 DS1307 Pin Diagram

C. U. Shah College of Engg. & Tech.

Page 29

DS 1307 Interface with Microcontroller

Figure 4.13 DS1307 interface

I2C Protocol
At the low end of the spectrum of communication options for "inside the box"
communication is I2C ("eye-squared-see"). The name I2C is shorthand for a standard Inter-IC
(integrated circuit) bus.
I2C provides good support for communication with various slow, on-board peripheral
devices that are accessed intermittently, while being extremely modest in its hardware resource
needs. It is a simple, low-bandwidth, short-distance protocol. Most available I2C devices operate
at speeds up to 400Kbps, with some venturing up into the low megahertz range. I2C is easy to
use to link multiple devices together since it has a built-in addressing scheme.

C. U. Shah College of Engg. & Tech.

Page 30

Philips originally developed I2C for communication between devices inside of a TV set.
Examples of simple I2C-compatible devices found in embedded systems include EEPROMs,
thermal sensors, and real-time clocks. I2C is also used as a control interface to signal processing
devices that have separate, application-specific data interfaces. For instance, it's commonly used
in multimedia applications, where typical devices include RF tuners, video decoders and
encoders, and audio processors. In all, Philips, National Semiconductor, Xicor, Siemens, and
other manufacturers offer hundreds of I2C-compatible devices.
Inside the box
I2C is appropriate for interfacing to devices on a single board, and can be stretched across
multiple boards inside a closed system, but not much further. An example is a host CPU on a
main embedded board using I2C to communicate with user interface devices located on a
separate front panel board. A second example is SDRAM DIMMs, which can feature an I2C
EEPROM containing parameters needed to correctly configure a memory controller for that
module.
I2C is a two-wire serial bus, as shown in Figure 1. There's no need for chip select or
arbitration logic, making it cheap and simple to implement in hardware.

Figure 4.14 I2C Protocol


The two I2C signals are serial data (SDA) and serial clock (SCL). Together, these signals
make it possible to support serial transmission of 8-bit bytes of data-7-bit device addresses plus
control bits-over the two-wire serial bus. The device that initiates a transaction on the I2C bus is

C. U. Shah College of Engg. & Tech.

Page 31

termed the master. The master normally controls the clock signal. A device being addressed by
the master is called a slave.
In a bind, an I2C slave can hold off the master in the middle of a transaction using what's
called clock stretching (the slave keeps SCL pulled low until it's ready to continue). Most I2C
slave devices don't use this feature, but every master should support it.
The I2C protocol supports multiple masters, but most system designs include only one.
There may be one or more slaves on the bus. Both masters and slaves can receive and transmit
data bytes.
Each I2C-compatible hardware slave device comes with a predefined device address, the
lower bits of which may be configurable at the board level. The master transmits the device
address of the intended slave at the beginning of every transaction. Each slave is responsible for
monitoring the bus and responding only to its own address. This addressing scheme limits the
number of identical slave devices that can exist on an I2C bus without contention, with the limit
set by the number of user-configurable address bits (typically two bits, allowing up to four
identical devices).
Communication
As you can see in Figure 2, the master begins the communication by issuing the start
condition (S). The master continues by sending a unique 7-bit slave device address, with the
most significant bit (MSB) first. The eighth bit after the start, read/not-write (), specifies whether
the slave is now to receive (0) or to transmit (1). This is followed by an ACK bit issued by the
receiver, acknowledging receipt of the previous byte. Then the transmitter (slave or master, as
indicated by the bit) transmits a byte of data starting with the MSB. At the end of the byte, the
receiver (whether master or slave) issues a new ACK bit. This 9-bit pattern is repeated if more
bytes need to be transmitted.

C. U. Shah College of Engg. & Tech.

Page 32

Figure 4.15 I2C Protocol Communication


In a write transaction (slave receiving), when the master is done transmitting all of the
data bytes it wants to send, it monitors the last ACK and then issues the stop condition (P). In a
read transaction (slave transmitting), the master does not acknowledge the final byte it receives.
This tells the slave that its transmission is done. The master then issues the stop condition.
A simple bus
As we've seen, the I2C signaling protocol provides device addressing, a read/write flag,
and a simple acknowledgement mechanism. There are a few more elements to the I2C protocol,
such as general call (broadcast) and 10-bit extended addressing. Beyond that, each device defines
its own command interface or address-indexing scheme.
Standard I2C devices operate up to 100Kbps, while fast-mode devices operate at up to 400Kbps.
A 1998 revision of the I2C specification (v. 2.0) added a high-speed mode running at up
to 3.4Mbps. Most of the I2C devices available today support 400Kbps operation. Higher-speed
operation may allow I2C to keep up with the rising demand for bandwidth in multimedia and
other applications.
Most often, the I2C master is the CPU or microcontroller in the system. Some
microcontrollers even feature hardware to implement the I2C protocol. You can also build an allsoftware implementation using a pair of general-purpose I/O pins (single master implementations
only).
Since the I2C master controls transaction timing, the bus protocol doesn't impose any
real-time constraints on the CPU beyond those of the application. (This is in contrast with other

C. U. Shah College of Engg. & Tech.

Page 33

serial buses that are timeslot-based and, therefore, take their service overhead even when no real
communication is taking place.)

C. U. Shah College of Engg. & Tech.

Page 34

4.5 LIQUID CRYSTAL DISPLAY


Introduction to LCD:
In recent years the LCD is finding widespread use replacing LED s (seven-segment LED
or other multi segment LED s).
This is due to the following reasons:
1. The declining prices of LCD s.
2. The ability to display numbers, characters and graphics. This is in contract to LEDs, which are
limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, there by relieving the CPU of the task of
refreshing the LCD. In the contrast, the LED must be refreshed by the CPU to keep displaying
the data.
4. Ease of programming for characters and graphics.

Figure 4.16 2x16 Display

C. U. Shah College of Engg. & Tech.

Page 35

Specifications
Number of Characters: 16 characters x 2 Lines
Character Table: English-European (RS in Datasheet)
Module dimension: 80.0mm x 36.0mm x 13.2mm(MAX)
View area: 66.0 x 16.0 mm
Active area: 56.2 x 11.5 mm
Dot size: 0.56 x 0.66 mm
Dot pitch: 0.60 x 0.70 mm
Character size: 2.96 x 5.46 mm
Character pitch: 3.55 x 5.94 mm
LCD type: STN, Positive, Transflective, Yellow/Green
Duty: 1/16
View direction: Wide viewing angle
Backlight Type: yellow/green LED
RoHS Compliant: lead free
Operating Temperature: -20C to + 70C

C. U. Shah College of Engg. & Tech.

Page 36

LCD PIN DIAGRAM:

Figure 4.17 2x16 LCD Pin Diagram

Pinout Connections
Pin No Symbol
Level
Description
1
VSS
0V
Ground
2
VCC
5V
Supply Voltage for logic
3
VEE (Variable)
Operating voltage for LCD
4
RS
H/L
H: DATA, L: Instruction code
5
R/W
H/L
H: Read(MPU?Module) L: Write(MPU?Module)
6
E
H,H->L
Chip enable signal
7
DB0
H/L
Data bus line
8
DB1
H/L
Data bus line
9
DB2
H/L
Data bus line
10
DB3
H/L
Data bus line
11
DB4
H/L
Data bus line
12
DB5
H/L
Data bus line
13
DB6
H/L
Data bus line
14
DB7
H/L
Data bus line
15
A
5V
LED +

C. U. Shah College of Engg. & Tech.

Page 37

Description
The HD44780U dot-matrix liquid crystal display controller and driver LSI displays
alphanumeric, Japanese kana characters, and symbols. It can be configured to drive a dot-matrix
liquid crystal display under the control of a 4- or 8-bit microprocessor. Since all the functions
such as display RAM, character generator, and liquid crystal driver, required for driving a dotmatrix liquid crystal display are internally provided on one chip, a minimal system can be
interfaced with this controller/driver.
A single HD44780U can display up to one 8-character line or two 8-character lines. The
HD44780U has pin function compatibility with the HD44780S which allows the user to easily
replace an LCD-II with an HD44780U. The HD44780U character generator ROM is extended to
generate 2085 8 dot character fonts and 32 5 10 dot character fonts for a total of 240 different
character fonts.
The low power supply (2.7V to 5.5V) of the HD44780U is suitable for any portable
battery-driven product requiring low power dissipation.

Features

5 8 and 5 10 dot matrix possible

Low power operation support:

2.7 to 5.5V

3.0 to 11V

Liquid crystal drive waveform

A (One line frequency AC waveform)

Correspond to high speed MPU bus interface

2 MHz (when VCC = 5V)

4-bit or 8-bit MPU interface enabled

80 8-bit display RAM (80 characters max.)

C. U. Shah College of Engg. & Tech.

Page 38

9,920-bit character generator ROM for a total of 240 character fonts

208 character fonts (5 8 dot)

32 character fonts (5 10 dot)

64 8-bit character generator RAM

8 character fonts (5 8 dot)

4 character fonts (5 10 dot)

16-common 40-segment liquid crystal display driver

Programmable duty cycles

1/8 for one line of 5 8 dots with cursor

1/11 for one line of 5 10 dots with cursor

1/16 for two lines of 5 8 dots with cursor

Display clear, cursor home, display on/off, cursor on/off, display character blink,
cursor shift,

display shift

Pin function compatibility with HD44780S

Automatic reset circuit that initializes the controller/driver after power on

Internal oscillator with external resistors

Low power consumption

C. U. Shah College of Engg. & Tech.

Page 39

LCD Interface with Microcontroller

Figure 4.18 16*4 LCD Interface

C. U. Shah College of Engg. & Tech.

Page 40

4.6 BUZZER

Figure 4.19 Buzzer Circuit


To interface a buzzer the standard transistor interfacing circuit is used. Note that if a
different power supply is used for the buzzer, the 0V rails of each power supply must be
connected to provide a common reference.
If a battery is used as the power supply, it is worth remembering that piezo sounders draw
much less current than buzzers. Buzzers also just have one tone, whereas a piezo sounder is
able to create sounds of many different tones.
To switch on buzzer - high
To switch off buzzer - low

C. U. Shah College of Engg. & Tech.

Page 41

4.7 MOTOR DRIVER IC (LM 293D)


L293D is a typical Motor driver or Motor Driver IC which allows DC motor to drive on
either direction. L293D is a 16-pin IC which can control a set of two DC motors simultaneously
in any direction. It means that you can control two DC motor with a single L293D IC. Dual Hbridge Motor Driver integrated circuit (IC).
The l293d can drive small and quiet big motors as well, check the Voltage Specification
at the end of this page for more info.
Concept
It works on the concept of H-bridge. H-bridge is a circuit which allows the voltage to be
flown in either direction. As you know voltage need to change its direction for being able to
rotate the motor in clockwise or anticlockwise direction, Hence H-bridge IC are ideal for driving
a DC motor.
In a single l293d chip there two h-Bridge circuit inside the IC which can rotate two dc
motor independently. Due its size it is very much used in robotic application for controlling DC
motors. Given below is the pin diagram of a L293D motor controller.
There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the motor,
the pin 1 and 9 need to be high. For driving the motor with left H-bridge you need to enable pin 1
to high. And for right H-Bridge you need to make the pin 9 to high. If anyone of the either pin1
or pin9 goes low then the motor in the corresponding section will suspend working. Its like a
switch.

C. U. Shah College of Engg. & Tech.

Page 42

Figure 4.20 Pin Diagram of L293D

Working of L293D
The there 4 input pins for this l293d, pin 2,7 on the left and pin 15 ,10 on the right as
shown on the pin diagram. Left input pins will regulate the rotation of motor connected across
left side and right input for motor on the right hand side. The motors are rotated on the basis of
the inputs provided across the input pins as LOGIC 0 or LOGIC 1.
In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.
L293D Logic Table.
Lets consider a Motor connected on left side output pins (pin 3,6). For rotating the motor
in clockwise direction the input pins has to be provided with Logic 1 and Logic 0.
Pin 2 = Logic 1 and Pin 7 = Logic 0 | Clockwise Direction
Pin 2 = Logic 0 and Pin 7 = Logic 1 | Anticlockwise Direction

C. U. Shah College of Engg. & Tech.

Page 43

Pin 2 = Logic 0 and Pin 7 = Logic 0 | Idle [No rotation] [Hi-Impedance state]
Pin 2 = Logic 1 and Pin 7 = Logic 1 | Idle [No rotation]
In a very similar way the motor can also operated across input pin 15,10 for motor on the right
hand side.
Circuit Diagram For l293d motor driver IC controller.

Figure 4.21 Interfacing Diagram of L293D

Voltage Specification
VCC is the voltage that it needs for its own internal operation 5v; L293D will not use this
voltage for driving the motor. For driving the motors it has a separate provision to provide motor
supply VSS (V supply). L293d will use this to drive the motor. It means if you want to operate a
motor at 9V then you need to provide a Supply of 9V across VSS Motor supply.

C. U. Shah College of Engg. & Tech.

Page 44

The maximum voltage for VSS motor supply is 36V. It can supply a max current of
600mA per channel.Since it can drive motors Up to 36v hence you can drive pretty big motors
with this l293d.
VCC pin 16 is the voltage for its own internal Operation. The maximum voltage ranges
from 5v and upto 36v.

C. U. Shah College of Engg. & Tech.

Page 45

4.8 RELAY
Relay is an electromagnetic device which is used to isolate two circuits electrically and
connect them magnetically. They are very useful devices and allow one circuit to switch another
one while they are completely separate. They are often used to interface an electronic circuit
(working at a low voltage) to an electrical circuit which works at very high voltage. For example,
a relay can make a 5V DC battery circuit to switch a 230V AC mains circuit. Thus a small sensor
circuit can drive, say, a fan or an electric bulb.
A relay switch can be divided into two parts:
1. Input
2. Output
The input section has a coil which generates magnetic field when a small voltage from an
electronic circuit is applied to it. This voltage is called the operating voltage. Commonly used
relays are available in different configuration of operating voltages like 6V, 9V, 12V, 24V etc.
The output section consists of contactors which connect or disconnect mechanically. In a basic
relay there are three contactors: normally open (NO), normally closed (NC) and common
(COM). At no input state, the COM is connected to NC. When the operating voltage is applied
the relay coil gets energized and the COM changes contact to NO. Different relay configurations
are available like SPST, SPDT and DPDT etc, which have different number of changeover
contacts. By using proper combination of contactors, the electrical circuit can be switched on and
off. Get inner details about structure of a relay switch.

C. U. Shah College of Engg. & Tech.

Page 46

PIN DIAGRAM:

Figure 4.22 Relay Basic Pin Diagram

RELAY INTERFACING WITH 89C51

Figure 4.23 Relay Interfacing with 89c51

C. U. Shah College of Engg. & Tech.

Page 47

RELAY ON

Figure 4.24 Relay On

RELAY OFF

Figure 4.25- Relay Off

C. U. Shah College of Engg. & Tech.

Page 48

RELAY APPLICATIONS
Relays are used to and for:

Amplify a digital signal, switching a large amount of power with a small operating
power. Some special cases are:

A telegraph relay, repeating a weak signal received at the end of a long wire

Controlling a high-voltage circuit with a low-voltage signal, as in some types


of modems or audio amplifiers,

Detect and isolate faults on transmission and distribution lines by opening and
closing circuit breakers (protection relays),

Isolate the controlling circuit from the controlled circuit when the two are at different
potentials, for example when controlling a mains-powered device from a low-voltage
switch. The latter is often applied to control office lighting as the low voltage wires are
easily installed in partitions, which may be often moved as needs change. They may also
be controlled by room occupancy detectors to conserve energy,

Logic functions. For example, the Boolean AND function is realized by connecting
normally open relay contacts in series, the OR function by connecting normally open
contacts in parallel. The change-over or Form C contacts perform the XOR (exclusive or)
function. Similar functions for NAND and NOR are accomplished using normally closed
contacts. The Ladder programming language is often used for designing relay
logic networks.

Safety-critical logic. Because relays are much more resistant than semiconductors to
nuclear radiation, they are widely used in safety-critical logic, such as the control panels
of radioactive waste-handling machinery.

Time delay functions. Relays can be modified to delay opening or delay closing a set of
contacts. A very shorts (a fraction of a second) delay would use a copper disk between
the armature and moving blade assembly. Current flowing in the disk maintains magnetic
field for a short time, lengthening release time. For a slightly longer (up to a minute)
delay, a dashpot is used. A dashpot is a piston filled with fluid that is allowed to escape

C. U. Shah College of Engg. & Tech.

Page 49

slowly. The time period can be varied by increasing or decreasing the flow rate. For
longer time periods, a mechanical clockwork timer is installed.

Figure 4.26- Relay

Despite the speed of technological developments, some products prove


so popular that their key parameters and design features remain virtually
unchanged for years. One such product is the sugar cube relay, shown in the
figure above, which has proved useful to many designers who needed to
switch up to 10A, whilst using relatively little PCB area
Since relays are switches, the terminology applied to switches is also
applied to relays. A relay will switch one or more poles, each of whose contacts
can be thrown by energizing the coil in one of three ways:

1. Normally - open (NO) contacts connect the circuit when the relay is activate
d; the circuit is disconnected when the relay is inactive. It is also called a
FORM A contact or make contact.
2. Normally - closed (NC) contacts disconnect the circuit when the relay is
activated ; the circuit is connected when relay is inactive. It is also called
FORM B contact or break contact

C. U. Shah College of Engg. & Tech.

Page 50

3. Change-over or double-throw contacts control two circuits ; one

normally

open contact and one normally closed contact with a common terminal. It is
also called a Form C transfer contact.
The following types of relays are commonly encountered:

Figure 4.27 DIFFERENT TYPES OF RELAYS

SPST - Single Pole Single Throw:


These have two terminals which can be connected or disconnected.
Including two for the coil, such a relay has four terminals in total. It is
ambiguous whether the pole is normally open or normally closed. The
terminology "SPNO" and "SPNC" is sometimes used to resolve the
ambiguity.
C. U. Shah College of Engg. & Tech.

Page 51

SPDT - Single Pole Double Throw:


A common terminal connects to either of two others. Including two for the
coil, such a relay has five terminals in total.
DPST - Double Pole Single Throw:
These have two pairs of terminals. Equivalent to two SPST switches or
relays actuated by a single coil. Including two for the coil, such a relay has
six terminals in total. It is ambiguous whether the poles are normally open,
normally closed, or one of each.
DPDT - Double Pole Double Throw:
These have two rows of hange-over terminals. Equivalent to two SPDT
switches or relays actuated by a single coil. Such a relay has eight terminals,
including the coil.
QPDT - Quadruple Pole Double Throw:
Often referred to as Quad Pole Double Throw, or 4PDT. These have four
rows of change-over terminals. Equivalent to four SPDT switches or
relays actuated by a single coil, or two DPDT relays. In total, fourteen
terminals including the coil.

C. U. Shah College of Engg. & Tech.

Page 52

Chapter 5
Result & Conclusion
The most important problems faced are the misusage of electricity and its wastage.
Sometimes due to carelessness of the authorities and the workers lamps are left ON which results
in wastage of electricity. Water wastage is another problem which needs to be dealt with. Our
project helps to overcome all these problems.

C. U. Shah College of Engg. & Tech.

Page 53

Chapter 6
Applications

1. This small scale project can be implemented with minimum cost and resources in any public
garden which are generally maintained by municipal corporations.
2. This project can also be used at private gardens like company or universities or educational
premises like school / colleges
3. With little modifications, this project can be used in industries. By this the light bulbs can be
controlled with respect to intensity of light in the environment. Also, various industrial
devices can be turned on/off with respect to desired time for the specific interval of time.

C. U. Shah College of Engg. & Tech.

Page 54

Chapter 7
Advantages
1. This project saves electricity because lights are turned on only when there is insufficient light
in the environment. Thus it avoids wastage of electricity.
2. This project also saves water because water supply is turned on only for specific time period.
Thus it avoids wastage of water. Thus it helps in proper utilization of the available resources
3. All process in Garden like Gate opening, water supply, light controlling are fully automated.
Thus it does not require any human attention.

C. U. Shah College of Engg. & Tech.

Page 55

Chapter 8
Reference
1. The 8051 Micro controller and Embedded Systems by Muhammad Ali Mazidi and Janice
Gillispie Mazidi
2. The 8051 Micro controller Architecture, Programming & Applications by Kenneth J. Ayala
3. Fundamentals of Micro processors and Micro computers by B. Ram
4. Electronic Components -D.V. Prasad
5. Wireless Communications - Theodore S. Rappaport

C. U. Shah College of Engg. & Tech.

Page 56