Sie sind auf Seite 1von 12

Moisture sensing automatic plant watering system

using 8051.
This project is about a moisture-sensing automatic plant watering system
using 8051 microcontroller. The system simply senses the moisture level and
switches on the irrigation pump when the moisture is below the set limit. The
system switches off the pump when the moisture rises above the set point. The
moisture level threshold can be set using a trim pot on the system. The status of
the pump (whether ON or OFF) is displayed on a 162 LCD display. The system
can be divided into three section as follows.

Sensing prob.
YL 69 moisture sensing probe is used to sense the moisture here. It is simply a
fork-shaped PCB with tracks running on both sides of the legs. Just plug this
probe into the soil where you want to sense the moisture. Image of the YL 69
sensing probe is given below.
Comparator circuit.
YL 38 comparator module is used in this project. It is a single channel opamp
comparator based on L393 IC. This module just compares the output voltage of
the sensing probe with a reference voltage and switches its voltage appropriately
for the microcontroller to read. Circuit diagram of the YL 38 comparator module
is shown below.

The output voltage of the sensing probe is connected to the inverting input of the
opamp. When the moisture level is high more current passes through the sensing
probe and so the voltage at the inverting pin will be higher than the reference.
The reference can be set using the trim pot R2. At this condition output of the
opamp goes low and sinks the LED D1 to make it glow. When the moisture is
lower than the set point, the opposite happens. So in simple words, a LOW output
of the opamp indicates a high moisture and a HIGH output of the opamp indicates
a low moisture. The output of the opamp is marked as pin D0 on the sensor YL
38 module. This pin is connected to the microcontroller for further processing.
LED D2 is just a power ON indicator. Capacitors C1 and C2 are noise filters.
Microcontroller section.
Microcontroller section senses the status of the comparator module and switches
the irrigation motor appropriately. It also displays the status of the pump on the
LCD screen. The power supply unit and the motor driver unit are incorporated in
this section. Full circuit diagram of the project is given below.

Output pin of the comparator module (D0) is connected to P3.5 pin of the 8051
microcontroller. The microcontroller monitors the moisture level by polling the
status of the P3.5 pin which is the output of the comparator.
Program auto watering

RS EQU P2.7

RW EQU P2.6

E EQU P2.5

ORG 00H

SETB P3.5

MOV TMOD,#00000001B

MAIN:ACALL DINT

ACALL TEXT1

JB P3.5, NEXT

ACALL LINE2

ACALL TEXT2

CLR P2.0

SJMP EXIT

NEXT:ACALL LINE2

ACALL TEXT3

SETB P2.0
EXIT:ACALL DELAY1

SJMP MAIN

DELAY1:MOV R0,#15D

BACK1: MOV TH0,#00000000B

MOV TL0,#00000000B

SETB TR0

HERE2: JNB TF0,HERE2

CLR TR0

CLR TF0

DJNZ R0,BACK1

RET

TEXT1: MOV A,#"M"

ACALL DISPLAY

MOV A,#"o"
ACALL DISPLAY

MOV A,#"i"

ACALL DISPLAY

MOV A,#"s"

ACALL DISPLAY

MOV A,#"t"

ACALL DISPLAY

MOV A,#"u"

ACALL DISPLAY

MOV A,#"r"

ACALL DISPLAY

MOV A,#"e"

ACALL DISPLAY

MOV A,#" "

ACALL DISPLAY

MOV A,#"C"

ACALL DISPLAY

MOV A,#"o"

ACALL DISPLAY

MOV A,#"n"
ACALL DISPLAY

MOV A,#"t"

ACALL DISPLAY

MOV A,#"r"

ACALL DISPLAY

MOV A,#"o"

ACALL DISPLAY

MOV A,#"l"

ACALL DISPLAY

RET

TEXT2: MOV A,#"["

ACALL DISPLAY

MOV A,#"O"

ACALL DISPLAY

MOV A,#"K"

ACALL DISPLAY

MOV A,#"]"

ACALL DISPLAY

MOV A,#" "


ACALL DISPLAY

MOV A,#"P"

ACALL DISPLAY

MOV A,#"u"

ACALL DISPLAY

MOV A,#"m"

ACALL DISPLAY

MOV A,#"p"

ACALL DISPLAY

MOV A,#" "

ACALL DISPLAY

MOV A,#"O"

ACALL DISPLAY

MOV A,#"F"

ACALL DISPLAY

MOV A,#"F"

ACALL DISPLAY

RET

TEXT3: MOV A,#"["


ACALL DISPLAY

MOV A,#"L"

ACALL DISPLAY

MOV A,#"o"

ACALL DISPLAY

MOV A,#"w"

ACALL DISPLAY

MOV A,#"]"

ACALL DISPLAY

MOV A,#" "

ACALL DISPLAY

MOV A,#"P"

ACALL DISPLAY

MOV A,#"u"

ACALL DISPLAY

MOV A,#"m"

ACALL DISPLAY

MOV A,#"p"

ACALL DISPLAY

MOV A,#" "


ACALL DISPLAY

MOV A,#"O"

ACALL DISPLAY

MOV A,#"N"

ACALL DISPLAY

RET

DINT:MOV A,#0CH

ACALL CMD

MOV A,#01H

ACALL CMD

MOV A,#06H

ACALL CMD

MOV A,#80H

ACALL CMD

MOV A,#3CH

ACALL CMD

RET
LINE2:MOV A,#0C0H

ACALL CMD

RET

CMD: MOV P0,A

CLR RS

CLR RW

SETB E

CLR E

ACALL DELAY

RET

DISPLAY:MOV P0,A

SETB RS

CLR RW

SETB E

CLR E

ACALL DELAY

RET
DELAY: CLR E

CLR RS

SETB RW

MOV P0,#0FFH

SETB E

MOV A,P0

JB ACC.7,DELAY

CLR E

CLR RW

RET

END

Das könnte Ihnen auch gefallen