Sie sind auf Seite 1von 51

Debre Markos University

College of Technology
Department of Electrical and Computer Engineering
Design and Simulation of Automatic Plant Watering System
Using Microcontroller

Fourth Year Control Stream

Group members

Name ID Number

1. Likie Tesfa TER/3935/05


2. Mellash Dessalegn TER/3811/05
3. Merete Hirbaye TER/3812/05
4. Yalew Mersha TER/3895/05
5. Yeshanbel Shbabaw TER/4152/05

Advisor: Mr.Lakishmi June 2016


Debre Markos, Ethiopia

ii
CERTIFICATE/ DECLARETION

This is to certify that the project report entitled Automatic plant Watering system using
microcontroller design and simulation being submitted.

Group Members

Name ID Number

1. Likie Tesfa TER/3935/05


2. Mellash Dessalegn TER/3811/05
3. Merete Hirbaye TER/3812/05
4. Yalew Mersha TER/3895/05
5. Yeshanbel Shbabaw TER/4152/05

Guide Name Head of the Department

Signature
Acknowledgement
First of all, we would like to acknowledge the Almighty God help us for giving physical
and spiritual strength during our studies. Then we would like to express our deep
appreciation to electrical and computer engineering department instructors and our
adviser Mr. Lakishmi who gave us comment advice and any technical support to
complete this project.

i
Abstract
In crop production a healthy water balance is essential for high quality yields. New
irrigation electrical control technologies improve irrigation efficiency, promoting water
conservation and reducing the environmental impacts. The objectives of this project is
to avoid wastage of water and increase irrigation efficiency by using microcontroller
based plant watering system with the help of soil moisture sensor, and water level
sensor. The purpose of our project is to implement manual planting system by automatic
planting system. Soil moisture sensor inserted in the soil to sense whether the soil is
moisture or dry.

This automatic plant watering system has the following uses: As there is no unplanned
usage of water, a lot of water is saved from being wasted. The irrigation is the only
when there is not enough moisture in the soil and the sensor detects when the pump be
turned on/off save a lot of time for the farmers. This also gives much needed rest to the
farmers, as they do not have to go and turn the pump on/off manually .The level of the
water in a field is controlled by this equipment using microcontroller. Main components
are arduino, motor, sensors etc. The sensors sense the intensity of water and give
indication to the arduino. The arduino produces the control signals to drive the motor. If
there is no water then arduino gives control signal to start the motor and if there is
sufficient water in the field then the arduino give control signal to stop the motor.

ii
Table of Contents
Acknowledgement ..........................................................................................................................i
Abstract .......................................................................................................................................... ii
List of figures .................................................................................................................................. v
List of tables .................................................................................................................................. vi
List of abbreviations ..................................................................................................................... vii
Chapter one .................................................................................................................................. 1
Introduction .................................................................................................................................. 1
1.1 Background of the Study ..................................................................................................... 1
1.2 Statement of the Problem .................................................................................................. 3
1.3 Motivation........................................................................................................................... 3
1.4 Objectives of the Study ....................................................................................................... 4
1.4.1 General objective ......................................................................................................... 4
1.4.2 Specific Objective ......................................................................................................... 4
1.5 Scope ................................................................................................................................... 4
1.6 The limitation ...................................................................................................................... 4
1.7 Significance of the Study ..................................................................................................... 5
1.8 Theoretical frame work....................................................................................................... 5
Chapter two .................................................................................................................................. 6
Literature review........................................................................................................................... 6
2.1 Automatic plant watering system review ........................................................................... 6
2.2 Materials requirement ........................................................................................................ 6
2.2.1 Microcontroller ............................................................................................................ 6
2.2.2 Types of micro controller ............................................................................................. 6
2.2.3 Types of arduino boards .............................................................................................. 8
2.2.4 Liquid crystal display .................................................................................................... 9
2.2.5 Sensor........................................................................................................................... 9
2.2.6 Level sensor................................................................................................................ 10
2.2.7 Types of level sensor .................................................................................................. 10
2.2.8 Moisture sensor ......................................................................................................... 11
2.2.9 Types of soil moisture sensors ................................................................................... 11
2.2.10 pumping Motor ........................................................................................................ 16
2.2.11 DC motor .................................................................................................................. 16

iii
2.2.12 Relay ......................................................................................................................... 17
2.2.13 Diode ........................................................................................................................ 18
2.2.14 Motor drive .............................................................................................................. 18
2.2.15 Sprinkler ................................................................................................................... 19
2.2.16 Components of Sprinkler Irrigation System ............................................................. 19
2.2.17 Resistor .................................................................................................................... 21
Chapter three .............................................................................................................................. 22
Materials and Methodology ....................................................................................................... 22
3.1 materials ........................................................................................................................... 22
3.2 Placement of Sensors ........................................................................................................ 27
3.3 Block diagram.................................................................................................................... 27
3.4 Flow chart........................................................................................................................ 28
3.5 Arduino interfacing with moisture sensor ........................................................................ 30
3.6 Arduino interfacing with level sensor ............................................................................... 30
3.7 Arduino interfacing with moisture sensor and level sensor ............................................. 31
Chapter four ................................................................................................................................ 31
Simulation results and Discussion............................................................................................... 32
Chapter five ................................................................................................................................. 35
Conclusion and Recommendation .............................................................................................. 35
5.1 Conclusion ......................................................................................................................... 35
5.2 Recommendation.............................................................................................................. 35
5.3 Future work ....................................................................................................................... 35
Reference .................................................................................................................................... 36
Appendix ..................................................................................................................................... 37

iv
List of figures
Fig 2.1 arduino uno ....................................................................................................................... 9
Fig 2.2 LCD ..................................................................................................................................... 9
Fig 2.3 Level Detection Using a Float Sensor .............................................................................. 10
Fig 2.4 homemade soil moisture sensor ..................................................................................... 12
Fig 2.5 heat dissipation sensor.................................................................................................... 15
Fig 2.6 YL-69 moisture sensor ..................................................................................................... 16
Fig 2.7 pump Motor .................................................................................................................... 16
Fig 2.8 DC motor ......................................................................................................................... 17
Fig 2.9 Relay ................................................................................................................................ 18
Fig 2.10 diodes ............................................................................................................................ 18
Fig 2.11 sprinkler irrigation system ............................................................................................. 21
Fig 2.12 resistors ......................................................................................................................... 21
Fig 3.1 arduino uno ..................................................................................................................... 23
Fig 3.2 transistor ......................................................................................................................... 23
Fig 3.3 single pole double through relay ..................................................................................... 24
Fig 3.1block diagram of automatic plant watering system ......................................................... 28
Fig 3.2 flow chart......................................................................................................................... 29
Fig 3.4 simulation circuit diagram for soil moisture sensor ........................................................ 30
Fig 3.5 simulation circuit diagram for water level sensor ........................................................... 30
Fig 3.6 the overall simulation circuit diagram............................................................................. 31
Fig 4.1 circuit shows tank full and moisture ok .......................................................................... 32
Fig 4.2 circuit shows water to tank and moisture is ok .............................................................. 33
Fig 4.3 circuit shows water to tank and soil dray ........................................................................ 33
Fig 4.4 circuit shows weather bad and user take another option .............................................. 34
Fig 4.5 circuit shows water to tank and soil very dray ................................................................ 34

v
List of tables
Table 1.1 theoretical frame work ................................................................................................. 5
Table3.1 Contact characteristics ................................................................................................. 24
Table 3.2 Coil characteristics ...................................................................................................... 25
Table 3.4 LCD pins description .................................................................................................... 25
Table 3.5 YL-69 soil moisture sensor specifications.................................................................... 26
Table 3.6 YL-69 soil moisture sensor reading ............................................................................. 26

vi
List of abbreviations
AC Alternative Current

A/D Analog to Digital

ADC Analog to Digital Convertor

AVR Advanced Virtual Risc

DC Direct Current

EEPROM Electrical Erasable Programmable Read Only Memory

FDR Frequency Domain Reflectometry

HDPE High Density Poly Ethylene

I/O input out put

IDE Integrated Development Environment

LCD Liquid Crystal Display

LED Light Emitting Diode

NC Normal Close

NO Normal Open

PCB Printed Circuit Board

PIC Programmable Interfacing Controller

PVC Polyvinyl Chloride

PWM Pulse Width Modulation

RAM Read Accesses Memory

TDM Time Domain Reflectometry

USAR Universal Synchronous/Asynchronous Receiver/Transmitter

vii
USB Universal Serial

SPDT Single pole double through

EEPROM Electrical erasable program read only memory

viii
Chapter one
Introduction
1.1 Background of the Study
The Ethiopian government has recognized Ethiopia’s irrigation potential and has
identified the important role of irrigation development for reducing vulnerability to
inconsistent rain fall distribution and at the same time addressing poverty reduction of
the people. Traditional irrigation is very old in Ethiopia. The traditional small-scale
schemes are, in general, simple river diversions. The diversion structures are elementary
and subject to frequent damage by flood. ‘Modern' irrigation was started at the
beginning of the 1960s by private investors in the middle awash valley where big sugar
estates, fruit and cotton farms are found. With the1975 rural land proclamation, the
large irrigated farms were placed under the responsibility of the Ministry of State
Farms. Almost all small-scale irrigation schemes built after 1975 were made into
Producers' Cooperatives.

In Ethiopia, Agriculture plays an important role in the development of the country’s


economy. Since scorching summers threatens our planet every year, our farmers are
unable to cultivate our traditional crops at their suitable seasons. On other hand farmers
are wasting water abundantly without proper management. This leads to the scarcity of
water at the time of requirement. Irrigation is the key to a successful agricultural
investment.

Improving irrigation efficiency can contribute greatly to reduce production costs of


vegetables, making the country more competitive and sustainable. Through proper
irrigation, average vegetable yields can be maintained (or increased) while minimizing
environmental impacts caused by excess applied water and subsequent agrichemical
leaching. Recent technological advances have made soil water sensors available for
efficient and automatic operation of irrigation systems. Automatic soil water sensor-
based irrigation seeks to maintain a desired soil water range in the root zone that is
optimal for plant growth. Another benefit of automatic irrigation techniques is
convenience. This type of system adapts the amount of water applied according to plant
needs and actual weather conditions throughout the season. This translates not only into

1
convenience for the manager but into substantial water savings compared to irrigation
management based on average historical weather conditions.

Irrigation is the most important cultural practice and most labour intensive task in daily
agriculture sector. Knowing when and how much to water is two important aspects of
irrigation. To do this automatically, sensors and methods are available to determine
when plants may need water. In Ethiopia, the agriculture plays the important role in the
economy and development of the country. Since irrigation system in Ethiopia has given
high priority in economic development, many new technologies should be developed to
allow agriculture automation to flourish and deliver its full potential. At the present
time, the farmers have been using irrigation technique in Ethiopia through the manual
control in which the farmers irrigate the land at the regular intervals. This process
sometimes consumes more water or sometimes the water reaches late due to which the
crops will get dried. So this research project is an excellent solution for such kind of
problems. Here is a simple project more useful in watering plants automatically without
any human interference. We may call it as automatic plant irrigation system. The system
will be electronic device, It will allow irrigation to take place in zones where watering is
required, while by passing zones where adequate soil moisture is indicated. The main
aim of this research project is to provide automatic irrigation to the plants which helps
in saving money, labour-power, and water.

The aforementioned arguments presented play a very important role in the pursuit to
improve the irrigation system of Ethiopian farmlands. The relevant facts about the
irrigation status of the country and the impact of its efficiency to the economy and the
environment may have tremendous effect to the country’s stability. Thus, the
compelling evidence of the challenges posed by this current phenomenon motivated the
conduct of the study on design and simulation of a low-cost electronic-based automatic
irrigation system. The project concept provides an excellent design to local farmers to
venture into irrigated farming by using an irrigation system that is anchored on compact
electronic circuit that controls a simple and affordable control concept.

Since proper use of water resources and environmental preservation has become key
factors to optimize farm productivity, the need to examine key factors on resource
optimization are required. The key factors relative to soil moisture, rainfall, wind, and

2
sunlight intensity availability compels the conduct of this study where water availability
to irrigate the farmlands have to be discretely operated with most efficiency without
compromising cost. Hence, the conduct of this study provides better way to address cost
effectiveness and environmental balance.

1.2 Statement of the Problem


The human traditionally accustomed to direct water for supplementing its plant
irrigation. These irrigation systems have many drawback like wastage of water ,high
labour cost, timing problem ,uniformity of water supply ,so that each plant will not get
the amount of water it needs either too much or too little . Since the system is
uncontrolled the soil is soaked too much. Therefore, the moisture of the soil that
determines the amount of water in soil must be checked regularly to prevent the plant
from wilting or in the worst case it might die. Besides, each species of the plant and the
soil have their own characteristic. So, the consumption of water is different following
their type.

These systems have low requirement for infrastructure and technical equipment but
need high labour input, so our project comes up with a remedy to solve the above
problem with high efficiency and low water wastage.

In order to maintain the condition and overcome the problem, Automatic Plant watering
System is used. This system is created to reduce the time by using automatic system
rather than manual way of watering. An automatic farm irrigation system will provide
proper and moderate irrigation system for the country low cost and almost no man
power for farm irrigation and it will increase also productivity in the country.

1.3 Motivation
The motivation of this project comes from our country economic policy. Since our
country economy is based on agriculture and the climate condition lead to lack of rain
and scarcity of water. This lack of rain and scarcity of water leads to decrease product
and productivies. The main aim of our project to proved automatic irrigation based on
microcontroller to the plant in order to increase productivity, saving time, money and
water.

3
1.4 Objectives of the Study

1.4.1 General objective


The general objective of the study is to study, design and develop an automated
irrigation system and determine the level of water present in tank through
microcontroller system.

1.4.2 Specific Objective

The specific object:

 To design an automated farm irrigation system that utilizes electronic,


electromechanical equipments and sensors.

 To develop the pre-established design parameters and integrate circuit


components according to its technical purposes.

 To solve the problems on manual irrigation technique.

1.5 Scope
The scope of this project entails the design and implementation of a micro controller
based irrigation system, depending on the soil moisture content. Moisture sensor and
level sensor will be the inputs of the system and irrigation pump and water pump will be
the output of the microcontroller.

The automatic plant irrigation control system has been used in farmlands. The sensors
that is soil moisture sensor and water level sensor used to detect the value of soil
moisture and water level respectively.

1.6 The limitation


 The irrigation pump may irrigate at high temperature. This leads to the crop dry.
 After the irrigation pump irrigate crop, there may be rain. In this cause the
amount of soil moisture content very high. This may to damage the crop.
 Different crops require different amount of water. But in this project it is not
considered.

4
1.7 Significance of the Study
The proposed study will offer automatic irrigation solution to the country providing
improvement to conventional irrigation using microcontroller based control intervention
The application of automation technology to farm irrigation paves the way for an
efficient and productive farming across the country thereby provides significant
economic impact. Moreover, the technology adopted also provides potent technology
transfer to various academic and technical institutions in the country through which
training and livelihood of country may be enhance.

1.8 Theoretical frame work


The theoretical frame work of the study is as shown in the table below. It is fix firmly
the input, process and output model that outline the relationship of the input base line
information and device, the process relevant base line information synthesis and the
control frame work, and final the expected output of the project.

Table 1.1 theoretical frame work

Input Process Output


 Water Level sensor  Arduino uno  LCD
 Soil Moisture  c-code  Irrigation pump
sensor  Pumping motor

5
Chapter two
Literature review
2.1 Automatic plant watering system review
An automatic plant watering system refers to the operation of the system with no or just
a minimum manual intervention apart from field surveillance which requires human
critical thinking. Almost every system (drip, sprinkler, surface) can be automated with
the help of microcontroller, sensors and some electro-mechanical devices. It makes the
irrigation process more efficient and workers can concentrate on other important
farming tasks. On the other hand, such a system can be expensive and very complex in
its design and may needs experts to plan and implement it.

2.2 Materials requirement

2.2.1 Microcontroller
A microcontroller is a single on chip computer which includes number of peripherals
like RAM, EEPROM, Timers etc., required to perform some predefined task. There are
different microcontroller families including: 8051, PIC (Programmable Interface
Controller), arduino and AVR. Microcontrollers are used in digital applications as
control units. Some microcontrollers come with their in-build circuits like Analog to
digital convertors or digital to analog convertors. Microcontrollers are mostly
programmed using assembly language but in recent years high level languages like C,
C++ PASCAL and java have been used. High level programming of microcontrollers
brings the advantage of not having a different program for each microcontroller
manufacturer. High level programming is also neat, easy to document and maintain and
user friendly. In our project we use arduino.

2.2.2 Types of micro controller

a) 8051 micro controller

These are among the earlier microcontrollers to be fabricated. Due to superiority in


technology in the newer versions, very few companies still fabricate 8051. Earlier types
of 8051 have 12 clocks per instruction whereas the newer versions have 6 clocks per

6
instruction. 8051 microcontroller does not have an in built memory bus and ADC. First
8051 microcontroller to be fabricated with Harvard architecture was done in 1980 by
Intel [11].

b) Programmable Interface Controller (PIC)


Programmable Interface Controllers are commonly referred to as PIC. PICs are slightly
older than 8051 microcontrollers. PICs are preferred to 8051 because of their small low pin
count devices. PICs perform better and are affordable than 8051. The Microchip technology
fabricated the single chip microcontroller PIC with Harvard architecture. The only major
downside of PIC is its programming part is very tedious. PICs are hence not recommended
for beginners [12].
b) AVR microcontroller

This is single chip microcontroller which is loaded with C- compiler and a free IDE.
Like PIC, AVR microcontrollers are difficult for the beginners to work with. AVR
microcontroller has on-chip boot-loader thus AVR can be programmed easily without
any external programmer. AVR controllers has number of I/O ports, timers/counters,
interrupts, A/D converters, USART, I2C interfaces, PWM channels, on-chip analog
comparators[11].

c) Arduino

An Arduino is a single-board microcontroller and a software suite for programming it.


The hardware consists of a simple open hardware design for the controller with an
Atmel AVR processor and on-board I/O support. The software consists of a standard
programming language and the boot loader that runs on the board.

To put that in layman’s terms, an Arduino is a tiny computer that you can program to
process inputs and outputs between the device and external components you connect to
it. The Arduino is what is known as a Physical or Embedded Computing platform,
which means that it is an interactive system that can interact with its environment
through the use of hardware and software.
To program the Arduino (make it do what you want it to) you use the Arduino IDE
(Integrated Development Environment), which is a piece of free software in which you
write code in the language that the Arduino understands (a language called C). The IDE

7
lets you to write a computer program, which is a set of step-by-step instructions that you
then upload to the Arduino. Your Arduino will then carry out these instructions and
interact with whatever you have connected to it [1].
The Arduino hardware and software are both open source, which means that the code,
schematics, design, etc. can be taken freely by anyone to do what they like with them.
2.2.3 Types of arduino boards

i) Legacy Versions
Arduino legacy versions include Arduino NG, Diecimila, and the Duemilanove. These
arduinos use ATMEGA168 chips. They require manual selection of either USB or
battery power. For Arduino NG one is required to hold the rest button on the board for a
few seconds before uploading a program on to it.
ii) Arduino Mega 2560
This is regarded as an advancement of arduino uno. It has more memory than arduino
uno. It has a total of 54 input pins of which 16 are analog inputs. It has a larger PCB
board than arduino. Overall it is more powerful than arduino uno. This arduino board is
based on ATmega2560.
iii) Arduino LilyPad
This arduino board is designed for wearable applications. It is usually sewn on fabric.
This board requires the use of a special FTDI-USB TTL serial programming cable.
Arduino LilyPad is used to design "smart" wearable.
iv) Arduino Mega ADK
This arduino board is specifically designed to interact with android devices.
v) Arduino Uno
This is the most common arduino type. This arduino type uses ATmega328 AVR
microcontroller.

8
Fig 2.1 arduino uno

2.2.4 Liquid crystal display


There are many display devices used by the hobbyists. LCD displays are one of the
most sophisticated display devices used by them. It is the easiest and very reliable
output device used by users. More, for micro controller based project, not every time
any debugger can be used. So LCD displays can be used to test the outputs. It is
displaying text, image and symbols, LCDs are the displays typically used in calculators
and clocks. LCD accepts two types of signals, one is data, and another is control. These
signals are recognized by the LCD module from status of the RS pin. Now data can be
read also from the LCD display, by pulling the R/W pin high. As soon as the E pin is
pulsed, LCD display reads data at the falling edge of the pulse and executes it, same for
the case of transmission [1].

LCD1
LM016L
VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14

Fig 2.2 LCD

2.2.5 Sensor
A sensor is advice that detects and responds to some type of input from the physical
environment. The specific input could be light, heat, motion, moisture, level or any one
of other environmental phenomena. The output is generally a signal that is converted
to human readable display at the sensor location or transmitted electronically over a
network for reading further processing. Examples of sensors include: oxygen sensors,
temperature sensors, infra red sensors, humidly sensors, soil moisture sensors and

9
motion detection sensors. The output of the sensors is usually charge, current or voltage.
We are use two important sensor in our project such as level sensory and moisture
sensor [13].

2.2.6 Level sensor


Level sensor is one of very important sensors. It play very important role in variant
form. Level sensors are used to measure the level of the free flowing substance. Such as
substance include liquid like water, oil ….etc

2.2.7 Types of level sensor


The different types of level sensors are: Float Sensor, Capacitance Sensor, Conductivity
Probes, Ultrasonic Sensor, Radar level sensor, Optical Sensor [14].

a) Level Detection and Measurement by Using a Float Sensor

Level detection of liquids is often done with a float-type liquid level switch. The float
transfers on a mechanical arm or sliding pole and activates a switch when the level
moves towards upward direction. Sometimes the float itself contains a small magnet that
varies the state of a switch when the liquid level gets moving up and moves into the
original position. This type of level sensor comes with many advantages like it is very
simple, highly accurate, and best suitable for various products [14].

Fig 2.3 Level Detection Using a Float Sensor

a) Level Detection by Using Conductivity Probes

Principle of operation: The principle used in this system states that “the presence of a
product will make a change in the resistance between the two conductors.” This system
is applicable for level measurement in conductive liquids. The conductivity of the

10
insulated material can be varied if the probe is covered or not covered within the
conductive product. There are two electrodes: one is used as a metal wall of the tank,
and the other electrode is inserted into the tank. This principle can be explained with a
practical application. A Conductive probe is used as a liquid level indicator for
measuring the level of electrically conductive products in a metal water tank, or other
container, which can be obtained by means of a probe isolated from the container and a
conductivity amplifier. When the product is not in connection with the probe, the
electrical resistance is relatively high or infinite between the probe and the metal tank
wall. If the level of the liquid rises completely between the probe and the tank wall, then
the resistance gradually decreases [14].

2.2.8 Moisture sensor


This sensor can be used to detect moisture of soil or judge If there is water around it.
The operating logic of it is through the soil resistivity to which it connected or water to
which it is immersed. Thus the lower level of the soil moisture, the lower the out put of
the sensor, and therefor its peak is when immersed in water [13].

The Soil Moisture Sensor is used to measure the volumetric water content of soil. This
makes it ideal for performing experiments in courses such as soil science, agricultural
science, environmental science, horticulture, botany, and biology. Use the Soil Moisture
Sensor to:

• Measure the loss of moisture over time due to evaporation and plant uptake.

• Evaluate optimum soil moisture contents for various species of plants.

• Monitor soil moisture content to control irrigation in greenhouses.

• Enhance your Bottle Biology experiments.

2.2.9 Types of soil moisture sensors

a) Electrical resistance blocks Sensors


These sensors are made up of two electrodes made from a porous substance like sand
ceramic mixture or gypsum. The two electrodes are imbedded in the soil during
installation. [4] Moisture is allowed to move freely in and out of the sensors electrodes

11
as the soil becomes moist or dries up. The resistance of the electrodes to the flow
current is correlated with moisture content. To measure this resistance the electrodes are
biased (energized) with a dc voltage and the current flowing through them measured.
Applying Ohm’s law;

R=V/I
Where: R is resistance (Unknown) (Ω)
V is biasing voltage (3.3V to 5.0V)
I is the current flowing through the electrodes (Amps)

Fig 2.4 homemade soil moisture sensor

When the moisture content in the soil is high more current will be allowed to flow thus
indicating low resistance. On the other hand for dry soils the sensor will indicate higher
resistance portrayed by the low current reading. This type of sensor is cheap and readily
available. Electrical resistance blocks Sensors can also be readily assembled from home
using two metal plates or steel nails.

Electrical resistance blocks Sensors are mostly used in small projects and gardens due to
the following disadvantages;

 They are badly affected by soil PH and salinity thus requiring regular
maintenance
 They have low sensitivity
 .The electrodes; especially which provides a constant source of ions; do not dry at
the same rate as the soil surrounding it.

12
b) Electrical conductivity probe sensors

Electrical conductivity probes employ the same principle as the Electrical resistance
blocks Sensors. The one major difference between the two types of sensors is that
Electrical conductivity probes sensors have their electrodes/probes in direct contact with
the soil. By definition electricity is the flow of charges and water in its pure form cannot
conduct electricity. The amount of impurities in water and mineral salts make it polar
thus able to conduct electricity. A large volume of water will mean more ions and thus
better electric conduction. Electrical conductivity probes sensors takes advantage of this
phenomenon. The amount of current passing between the probes is directly proportional
to the soil moisture content.

Moist soil allow more current to flow between the probes while drier soils only allow a
little current to flow between the probes. Better conductivity indicates a lower electrical
resistance.

Most of the soil moisture sensors currently in the market especially for small projects
are Electrical conductivity probes sensors. They have the following advantages.

 They are cheap


 They are readily available
 Easy to calibrate and install
c) Dielectric sensors
Dielectric sensors measure the soil water content in the soil by measuring the dielectric
permittivity of the soil. A dielectric material is substance that does not conductor
electricity, but supports electrostatic field s efficiently. At some cases dielectric
substance are referred to as insulators. The volume of water in the soil influences the
dielectric permittivity of soil.

The dielectric of water which is 80.4 is greater than other soil constituents. Therefore
change in the amount of water in the soil will directly lead to change in the soil
dielectric permittivity. Dielectric sensors are classified into two types namely:
Capacitance sensors and Time Domain Reflectometry (TDR) sensors. These sensors do
not measure electrical conductivity while measuring soil moisture.

13
d) Capacitance sensors
Capacitance sensors use frequency domain Reflectometry (FDR).Frequency domain
reflectometry is the measure of signal reflections through a medium across frequency.
Capacitance sensors contain two electrodes which are separated by a dielectric material .
The soil becomes the dielectric component after the electrodes are inserted into the soil;
it could even be inserted into the access tube in the soil to achieve the same results. A
high oscillating frequency is thereafter applied to the electrodes to induce a resonant
frequency. The magnitude of the resonant frequency is dependent on the dielectric
constant of the soil which in turns depends on or can change to the soil’s moisture
content. The change of the frequency as a result of the soil’s moisture content is
converted into the measurement of the soil moisture.
e) Time Domain Reflectometry (TDR) sensors
Time Domain Reflectometry uses the principle of waveguides. The actual content of
water in the soil is measured under this technology and not the water potential.[7] The
TDR device sends signals to the rods inserted in the soil. The time required for an
electromagnetic signal to travel along the wave guide is measured. The rate at which the
send signal returns is used to measure the water content in the soil. The return rate is
dependent on the dielectric properties of the soil. The signal takes longer time in
moisture soils and shorter time in dry soil. This pulse signal is then converted into soil
moisture measurement. [4] TDR sensors give accurate readings faster and require very
little maintenance. The major disadvantage of TDR sensors is that they require they
require different calibrations depending on different soil types.

f) Heat dissipation sensors

Heat dissipation sensors measure the soil moisture content by measuring the amount of
heat dissipated from a medium which is of ceramic kind in most cases. The water
contained in the medium spaces is directly proportional to the heat dissipated from the
medium. The less the water contained in the medium the less the heat dissipated and
more heat is dissipated if the water contained in the medium is high. More heat
dissipated leads to lower reading on the sensor and less heat dissipated leads to higher
reading on the sensor. The sensor uses the principle of capillarity. Capillary forces
influence movement of water between the sensor medium and the surrounding soil.

14
Heat dissipation sensors are independent of soil salinity thus not affected by soil type.
They require minimum or no calibration at all. On the downside this type of sensors are
very expensive.

Fig 2.5 heat dissipation sensor

g) Tensiometer Sensors
Tensiometers sensors measure the soil moisture content in the soil by measuring the
moisture tension/suction in the soil. Tensiometers sensors is made up of two major
parts; a plastic tube which has a ceramic porous medium at its tip and a vacuum gauge
on the opposite end. During installation the ceramic tip is buried in the soil at the
calibrated depth which should be as near as possible to the plants root area. The vacuum
gauge measures the effort the plants roots have to put to extract water from the soil
[4].This is the measure of the soil measure tension which is measured in cent bars.

If the soil moisture content is low the roots work harder to extract water from the soil.
The reading on the sensor is high. When water is more available in the soil the roots
works less and thus lower reading is indicated on the sensor.

h) YL-69 Moisture Sensor


This is an Electrical resistance Sensor. The sensor is made up of two electrodes. This
soil moisture sensor reads the moisture content around it. A current is passed across the
electrodes through the soil and the resistance to the current in the soil determines the
soil moisture. If the soil has more water resistance will be low and thus more current
will pass through. On the other hand when the soil moisture is low the sensor module
outputs a high level of resistance. This sensor has both digital and analogue outputs.
Digital output is simple to use but is not as accurate as the analogue output. In our
project we use YL-69 moisture sensor. Because this sensor does not depend on the soil
type.

15
Fig 2.6 yl-69 moisture sensor

2.2.10 pumping Motor


DC motors are so common electrical machines even where DC power system
themselves are fairly rare. DC machines are highly applicable in a situation where wide
variation in speed is needed. Today induction motor /AC type with solid state drive
package are competitive with DC motors in speed control application. However; many
DC machines are still being purchased and installed for speed control purpose. DC
motors are compared by their speed regulation. They are of course driven from a DC
power supply. The project uses DC motor If water level is less than in the soil for pumping
water from the ground or from the river or from any other water sources, because DC
motors are used for the implementation of simple to medium irrigation systems, which
is the project desire

Fig 2.7 pump Motor

2.2.11 DC motor

16
A DC motor is any of a class of electrical machines that converts direct
current electrical power into mechanical power. The most common types rely on the
forces produced by magnetic fields.
DC(direct current)motor is a fairly simple electric motor that uses electrical and
magnetic filed to produce torque, which is turns the rotor and hence give mechanical
work.

Fig 2.8 DC motor

2.2.12 Relay
A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by an electromagnet to
open or close one or many sets of contacts. A relay is able to control an output circuit of
higher power than the input circuit. There are three basic functions of a relay: On/Off
Control, Limit Control and Logic Operation.
On/Off Control: Example: Air conditioning control, used to limit and control a “high
power” load, such as a compressor
Limit Control: Example: Motor Speed Control, used to disconnect a motor if it runs
slower or faster than the desired speed
Logic Operation: Example: Test Equipment, used to connect the instrument to a
number of
testing points on the device under test.

By default when there is no excitation in the coil the NC (Normally Closed) and C
(Common Terminal) are connected through the contact internally. When the coil is
excited by providing the required coil voltage, the contact switches from the NC to NO
(Normally Open) side. In this case, the C and NC terminals are connected internally.

17
RL1

Fig 2.9 Relay

2.2.13 Diode
An electrical semiconductor device that allows current to flow only one direction. It is a
two terminal device that rectifies signals (passes current in only one direction).Most
commonly a semiconductor consisting of a p-n junction.

Diodes are manufactured by the semiconductor materials germanium, silicon and


selenium. Operation of diode can be classified in two ways, if it allows the current then
it is forward biased otherwise it is reverse biased. For silicon diodes the forward voltage
is 0.7v and for germanium it is 0.3v. In silicon diode the dark band indicates the cathode
terminal and the other terminal is anode. Generally diodes are used as reverse polarity
protector and transient protector. There are many types of diodes and some of these are:

Zener diodes, light emitting diode, constant current diodes, Shockley diode, varactor
diode e.t.c. in our project we use light emitting diode and ideal diode.

LED
D

DIODE

Fig 2.10 diodes

2.2.14 Motor drive


Electrical drives have become the most essential equipment now a day in the electrical
motors and other rotating machines. We know that electrical drives mainly
accomplishes three kinds of work. These are

18
i) Starting
ii) Speed control and
iii) Braking.

It can be said that the electrical drives enable us to control the motor in every aspect.
But control of electrical drives is also necessary because all the functions accomplished
by the drives are mainly transient operations i.e the change in terminal voltage, current,
etc are huge which may damage the motor temporarily or permanently. In very simple
words, the systems which control the motion of the electrical machines are known as
electrical drives. Atypical drive system is assembled with electric motor (may be
several) and a sophisticated control system that controls the rotation of the motor shaft.
Now a day, this control can be done easily with the help of software. So, the controlling
becomes more and more accurate and this concept of drive also provides the ease of use.

2.2.15 Sprinkler
Sprinkler irrigation is a method of applying irrigation water which is similar to natural
rainfall. Water is distributed through a system of pipes usually by pumping. It is then
sprayed into the air through sprinklers so that it breaks up into small water drops which
fall to the ground. The pump supply system, sprinklers and operating conditions must be
designed to enable a uniform application of water. Sprinkler Irrigation water is applied
through a pressurized system. The pressure causes the water to flow out through the
sprinkler nozzle and fly through the air and falls onto the soil surface.

2.2.16 Components of Sprinkler Irrigation System


i) A pump unit
ii) Tubing- main/sub-mains and laterals
iii) Couplers
iv) Sprinkler head
v) Other accessories such as valves, bends, plugs and risers.
i) Pumping Unit

Sprinkler irrigation systems distribute water by spraying it over the fields. The water is
pumped under pressure to the fields. The pressure forces the water through sprinklers or

19
through perforations or nozzles in pipelines and then forms a spray. A high speed
centrifugal or turbine pump can be used for operating sprinkler irrigation for individual
fields. Centrifugal pump is used when the distance from the pump inlet to the water
surface is less than eight meters. For pumping water from deep wells or more than eight
meters, a turbine pump is suggested.

ii) Tubing

Mains/sub-mains: The Tubing consists of mainline, sub-mains. Main line conveys water
from the source and distributes it to the sub-mains. The sub-mains convey water to the
laterals which in turn supply water to the sprinklers. HDPE (HIGH DESITY POLY
ETHYLENE) pipes are used for sub-mains, PVC e usually used for main lines.

iii) Couplers

Are used for connecting two pipes and uncoupling quickly and easily. Essentially a
coupler should provide: A reuse and flexible connection, not leak at the joint, be simple
and easy to couple and uncouple, be light, non-corrosive, durable.

iv) Sprinkler Head

Sprinkler head distribute water uniformly over the field without runoff or excessive loss
due to deep percolation. Different types of sprinklers are available. They are either
rotating or fixed type. The rotating type can be adapted for a wide range of application
rates and spacing. They are effective with pressure of about 10 to 70 m head at the
sprinkler. Pressures ranging from 16 to 40 m head are considered the most practical for
most farmers. Fixed head sprinklers are commonly used to irrigate small lawns and
gardens. Perforated lateral lines are sometimes used as sprinklers. They require less
pressure than rotating sprinklers. They release more water per unit area than rotating
sprinklers. Hence fixed head sprinklers are adaptable for soils with high intake rat.

20
Fig 2.11 sprinkler irrigation system

2.2.17 Resistor
A resistor is a two terminal electric circuit component that provides opposition to an
electric current. It is available in several common forms: wire wound resistors are
formed from windings of fine wire; film resistor, commonly found in consumer
electronic devices. Resistor absorbs power from a circuit and converts to heat. They are
normally rated for the maximum amount of power that they can simply handle.

Fig 2.12 resistors

21
Chapter three
Materials and Methodology
3.1 Materials
We have used in our project are websites; which we go through different books,
journals, and thesis and ongoing projects in automatic water planting system. From this
we are going to select appropriate rating of arduino uno, transistor, irrigation pump,
pumping motor, resistors, relays, soil moisture sensor, water level sensor, potentiometer
and liquid crystal display based on their application in automatic plant watering system.

1) Arduino uno

It is one type of microcontroller used to upload our system c-code and interface the
input and output of the system. It has analog input and digital output.

Arduino uno specification [7]

 Microcontroller –Atmega328
 Operating voltage-5v
 Input voltage (recommended)-7-12V
 Digital input/output pin-14(of which 6 provides PWM output )
 Analog input pins – 6
 Dc current per I/O pin -40Ma
 Dc current for 3.3V pin- 50Ma
 Flash memory – 32KB (ATmega328) of which 0.5KB used by bootloader
 SRAM-2KB (ATmega328)
 EEPROM-1KB (ATmega328)
 Clock speed -16MHZ

22
Fig 3.1 arduino uno [8]

2) Transistor

In this project we use NPN transistor as a drive. It amplifies output current of arduino
uno and it supply to relay. Transistor has three terminals; emitter, collector and base.
The emitter terminal connected with ground, the base terminal connected with arduino
uno and the collector terminal connected with relay.

We use 2N2222 bipolar junction transistor (BJT).Because it used for general purpose
low power amplifying or switching application. It is designed for low to medium
voltage, and can operate at moderate high speeds [6].

Fig 3.2 transistor [9]

23
3) Relay

A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by an electromagnet to
open or close one or many sets of contacts.

In this project we use single pole double through (SPDT) relay.

Fig 3.3 single pole double through relay [10]

Table3.1 Contact characteristics

0.25 A
Current Rating
Contact Configuration SPDT with Clamping Diode

Contact Materials Rhodium

Switching Voltage (AC) 60 VAC

Switching Voltage (DC) 100 VDC

24
Table 3.2 Coil characteristics

Coil Resistance 200 Ohm

Nominal Input Voltage 5 VDC

Operating Range - % of 80 to 110 %


Nominal (DC)

Average Consumption 0.29 W


(DC)
Drop-out Voltage 10
Threshold (DC)

4) Liquid crystal display (LCD)

We use 16×2 LCD type to display our output parameter. It has14 pins with their
corresponding functions. Its function is described by the following table [1].

Table 3.4 LCD pins description

Pin number Symbol Function


1 Vss Ground terminal
2 Vcc( Vee) Positive supply
3 Vdd Contrast adjustment
4 RS register select; 0- instruction register,1- data register
5 R/W Read/ write siginal;1- read, 0- write
6 E Enable; falling flag
7-14 DB0-DB7 Bi-directional data bus, data transfer is performed
once, thru DB0 to DB7, in the case of interface data
length is 8-bits; and twice, through DB4 to DB7 in
the case of interface data length is 4-bits. Upper four
bits first then lower four bits.

25
5) YL-69 soil moisture sensor

Table 3.5 YL-69 soil moisture sensor specifications:

Vcc power supply 3.3V or 5V


Current 35MA
Signal output voltage 0-4.2V
Digital Outputs 0 or 1
Analog Resistance (Ω)
Panel Dimension 3.0cm by 1.6cm
Probe Dimension 6.0cm by 3.0cm
GND Connected to ground

The soil moisture sensor (YL-69) used is a resistance sensor type. Its output is the
resistance in the soil between the two soil moisture sensor probes. The value of the soil
resistance decreases with increase in water content to a certain point. Different soil
types have different moisture content. Example the three soil type (sand soil, loam soil
and red soil) has the following moisture content. The soil was measured in equal
amount of 250gramms. Water was added in the soils in steps and the sensor values
recorded [15].

Table 3.6 YL-69 soil moisture sensor reading

Soil water content Sensor Reading


(cm3)
Loam soil Sand soil Red soil Average
0 1021 1022 1020 1021
50 580 546 781 635.7
75 360 234 568 387.3
100 237 243 295 258.3
125 203 184 274 220.3
150 191 180 235 202
175 180 170 220 190

26
We find the total average of seven experiments for the three soil type shown on the
above table the average value is 416, so we write our code using 416 as desired set
value.

6) Float sensor

Principle of Operation: A liquid level control system by using a float sensor works on
the principle of buoyancy, which states, “A float immersed in a liquid is buoyed
towards upward direction by an applied equal force to the weight of the displaced
liquid”. As a result, the body drives partially and gets submerged upon the liquid
surface and covers the same distance the liquid level moves.

3.2 Placement of Sensors


Sensors should be placed at the right place for efficient data transfer to the controlling
circuit.
 The moisture sensor is placed in the depth of the soil at the 3/4 length of root of
the plant according to the length of the plant root and adequate distribution of
water throughout the irrigated area or farm.
 The float sensor immersed in the reservoir tank.

3.3 Block diagram


A block diagram is a specialized, high-level flowchart used in engineering. It is used to
design new systems or to describe and improve existing ones. Its structure provides a
high-level overview of major system components, key process participants, and
important working relationships.
Our methods of work are organized and accomplished through a sequence of stages.
Then we have made the general block diagram of for our system that enables as to
easily analyze each component of the system as shown in the following figurative
expression.

27
LCD

Motor Pumpi
Level Arduion Relay Reservoir
driver ng
sensor tank
uno motor

Moisture
sensor Motor Irrigati
driver Relay Sprinkler
on
sensor
Pump

Fig 3.1Block diagram of automatic plant watering system

3.4 Flow chart


The following figure is the flow chart that shows the relationship between the level
sensor with the pumping motor, and soil moisture sensor with the irrigation pump.
Arduino is a communication link between level sensor with pumping motor, and soil
moisture sensor with irrigation pump. The Arduino always receives a signal from the
sensor. Arduino receives a signal from the level sensor, and soil moisture sensor and
compares their value with their pre-set threshold value.

If the level that is detected by the sensor is below the threshold value, the Arduino send
a message signal to the motor to fetch water. But when the level detected by the sensor
is above the pre-set value the motor doesn’t rotate. Since water does not inter the
reservoir tank.

In the same manner if the soil moisture value that is detected by the sensor is above the
threshold value, then Arduino send a message signal to the irrigation pump water to
irrigate. But when the soil moisture value detected by the sensor is below the pre-set
value then irrigation pump doesn’t irrigate.

28
Start

Initialize parameters

Level sensor read Moisture sensor


water level value read soil moisture
value

Is tank
not full?
No Is soil moisture
value
>=desired set?

Yes

Pump on Yes No

NO Irrigation
pump on
Is tank
No
full?

Is soil
moisture value
Yes
<desired set?

Pump is off

Yes

Irrigation pump off

Stop

Fig 3.2 flow chart

29
3.5 Arduino interfacing with moisture sensor
Figure shown below describes the interfacing of arduino uno with soil moisture sensor
as input to arduino uno (pin A4) and at the output port of arduino uno pins(2,3,4) with
LCD pins (12,13,14) and arduino uno pin (7) with irrigation pump are interfaced.

Fig 3.4 simulation circuit diagram for soil moisture sensor

3.6 Arduino interfacing with level sensor


Figure shown below describes the interfacing of arduino uno with level sensor as input
to arduino uno (pin A3) and at the output port of arduino uno pins (2, 3, 4) with LCD
pins (12, 13, 14) and arduino uno (pin 6) with pumping motor are interfaced.

Fig 3.5 simulation circuit diagram for water level sensor

30
3.7 Arduino interfacing with moisture sensor and level sensor
Figure shown below describes the interfacing of arduino uno with level sensor and
moisture sensor as input to arduino uno (pin A3,pin A4) respectively and at the output
port of arduino uno pins (2, 3, 4) with LCD pins (12, 13, 14) and arduino uno pins (pin
6, pin 7) with pumping motor and irrigation pump are interfaced.

Working principle: the soil moisture sensor and water level sensor senses the water
content of soil and the amount of water in the reservoir tank respectively and sends
signal to the arduion uno; the arduino uno interprets the received signal and compare it
with their per-set value. Then the relays energize or de energizes based on the arduino
uno output command and the LCD displays the parameters.

Fig 3.6 the overall simulation circuit diagram

Chapter four

31
Simulation results and Discussion
Simulation is the imitation of the operation of a real-world process or system over time.
The act of simulating something first requires that a model be developed; this model
represents the key characteristics or behaviours/functions of the selected physical or
abstract system or process. The simulation results of our project described below.

When the level sensor and moisture sensor detects the value of tank and soil moisture
respectively if the value of tank greater than desired set and soil moisture value less than
the desired set; then the arduino output pins (pin 6 and 7) which is connected to
pumping and irrigation motors are in active(not energize). Then LCD displays ‘tank
full’ and ‘moisture ok’. These parameters are shown as the circuit below.

Fig 4.1 circuit shows tank full and moisture ok

When the level sensor and moisture sensor detects the value of tank and soil moisture
respectively if the value of tank less than desired set and soil moisture value less than
the desired set; then the arduino output pin (pin 6) which is connected to pumping motor
is active (energize) and arduino output pin (pin 7) which is connected to irrigation
motor is in active (not energize). Then LCD displays ‘water to tank’ and ‘moisture ok’.
These parameters are shown as the circuit below.

32
Fig 4.2 circuit shows water to tank and moisture is ok

When the level sensor and moisture sensor detects the value of tank and soil moisture
respectively if the value of tank less than desired set and soil moisture value greater than
the desired set; then the arduino output pins (pin 6 and 7) which is connected to
pumping and irrigation motors are active (energize) . Then LCD displays ‘water to tank’
and ‘soil dray’. These parameters are shown as the circuit below.

Fig 4.3 circuit shows water to tank and soil dray

When the level sensor and moisture sensor detects the value of tank and soil moisture
respectively if the value of tank much greater than desired set and soil moisture value
much less than the desired set; then the arduino output pins (pin 6 and 7) which is
connected to pumping and irrigation motors are in active(not energize). Then LCD
displays ‘weather bad’ and ‘user take another option’. These parameters are shown as
the circuit below.

33
Fig 4.4 circuit shows weather bad and user take another option

When the level sensor and moisture sensor detects the value of tank and soil moisture
respectively if the value of tank less than desired set and soil moisture value much
greater than the desired set; then the arduino output pins (pin 6 and 7) which is
connected to pumping and irrigation motors are active (energize) . Then LCD displays
‘water to tank’ and ‘soil very dray’. These parameters are shown as the circuit below.

Fig 4.5 circuit shows water to tank and soil very dray

34
Chapter five
Conclusion and Recommendation
5.1 Conclusion
The microcontroller based automatic plant watering System is a valuable tool for
accurate soil moisture and water level control in highly specialized crop and vegetable
production and it is a simple, precise method of irrigation. An important of the system
is: Closed loop automatic plant watering system, moisture and water usage monitoring.
Users can observe the current output action of the system on the LCD. The switching
mechanism of the motors can be done automatically with the help of microcontroller
using relays. The proposed controller eliminates the manual switching mechanism used
by the farmers to ON/OFF the irrigation system.

5.2 Recommendation
We know that agriculture is the most important source of income in countries like
Ethiopia, so to improve agricultural products irrigation system is the first method to
achieve this goal. It is recommended to implement this project for a country which
follows agro-industrial economy policy.

The system should be tested to be practical in agricultural sectors to assist the economic
activities of the country and therefore stakeholders such as our university and ministry
of agriculture must cooperate to see the fruit of this project.

5.3 Future work


 We will design the solar source of the system and also modify our system by
using GSM which sends a message to a personal computer that happens during
irrigation for the sake of system reliability.
 We will consider temperature as additional parameter.

35
Reference
[1] Beginning arduino by Michael McRoberts Copyright @ 2010

[2] Beginning Arduino Programming Writing Code for the Most Popular
Microcontroller Board in the World

[3] Electric Machinery Fundamentals Fourth Edition by Stephen J. Chapman Copyright


@2004 McGraw-Hill, Inc.

[4] Schaum’s outline of theory and problems of programming with C++ second edition
by JOHN R. HUBBARD, Ph.D. Copyright 2000 The McGraw-Hill Companies, Inc.

[5] Electric Machinery Fundamentals Fourth Edition by Stephen J. Chapman BAE


SYSTEMS Australia. Copyright @2004 McGraw-Hill, Inc.

[6] Electronic Devices and Circuit Theory by Robert Boylestad Louis Nashelsky

[7] https://www.intorobotics.com/arduino .uno- setup -and- programming- tutorials/

[8] https://www.ntu.edu.sg/home/ehchua/programming/arduino/Arduino.html

[9] http://www.hobbytronics.co.za/p/607/npn-transistorp2n2222a-06a-ic-10vce

[10] www.electronicsbeliever.com/design -considerations-using-relay -and - relay-


datasheet-explanation/

[11] 8051 Microcontroller and Embedded Systems, The by Muhammad Ali


Mazidi, Janice Mazidi, Janice Gillispie Mazidi published 1999 — 2 editions
[12] PIC Microcontroller and Embedded Systems: Using Assembly and C for PIC18
by Muhammad Ali Mazidi, Rolin McKinlay, Danny Causey published 2007 — 2
editions

[13] Clemmens, A.J. Feedback Control for Surface Irrigation Management, ASAE
Publication 04 -90, 1990.

[14] https://www.efxkits.co.uk/liquid-level-sensor-and-types-of-level-sensors/

[15] Soares Book on Grounding and Bonding, 9th addition (ISBN 1890659-36-3)

36
Appendix
The c-code of our project is given below.

#include <LiquidCrystal.h>

int PumpPin = 7;

int MotorPin=6; // initialize the library with the numbers of the interface pins

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

int moistureSensorValue; // stores the moisture sensor values

int levelsensorvalue; // stores the level sensor values

void setup(){

// serial initialization

Serial.begin(9600); // Arduino pins initalization

pinMode(PumpPin,OUTPUT);

pinMode(MotorPin,OUTPUT);

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

void loop()

levelsensorvalue=analogRead(3); // reads the sensor

if(levelsensorvalue >= 900)

digitalWrite(MotorPin,LOW);

37
lcd.clear();

lcd.setCursor(0,0);

lcd.print("tank full");// in case of tank is full:

else if((levelsensorvalue < 900)&&(levelsensorvalue > 0))

digitalWrite(MotorPin,HIGH);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("water to tank");// in case of tank is not full:

moistureSensorValue = analogRead(4); //reads the sensor value:

if((moistureSensorValue >= 400)&&(moistureSensorValue <= 900))

digitalWrite(PumpPin,HIGH);

lcd.setCursor(1,1);

lcd.print("soil dreay pump runing"); // in case of dry soil:

else if(moistureSensorValue < 400)

digitalWrite(PumpPin,LOW);

lcd.setCursor(1,1);

38
lcd.print("mosture ok"); // in case of moist soil:

if((moistureSensorValue > 900)&&(levelsensorvalue ==0))

digitalWrite(MotorPin,LOW);

digitalWrite(PumpPin,LOW);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("weather bad"); //in case of there is no water surrounding:

lcd.setCursor(1,1);

lcd.print("user take anoption"); //in case of dry soil and empty reservoir tank:

else if((moistureSensorValue > 900)&&(levelsensorvalue > 0))

digitalWrite(PumpPin,HIGH); //in case of reservoir tank not full:

lcd.setCursor(1,1);

lcd.print("soil very dry "); //in case of very dry soil:

delay(100);

39

Das könnte Ihnen auch gefallen