Page 1
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 1/14
Chapter 3
Methodology
3.1 System Overview
Solar
Battery
Moisture
Sensor
Microcontroller
Transmitter
Solar
Battery
Moisture
Sensor
Microcontroller
Transmitter
Solar
Battery
Moisture
Sensor
Microcontroller
Transmitter
AREA 1 AREA 3AREA 2
MICROCONTROLLER
RECEIVER
GATE VALVE for AREA 1
GATE VALVE for AREA 2
GATE VALVE for AREA 3
Figure 3-1 Block diagram of microcontroller based automatic watering sprinkler with moisture sensor.
Page 2
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 2/14
The project Microntroller based automatic watering system is divided into two
main parts: (1) Sensor Module, (2) Channel (3) Controller Module node as shown in
Figure 3-1.
The sensor module is composed of the following: (1) Solar Panel, (2) Battery, (3)
Moisture Sensor, (4) the PIC16F689, and the (5) RF Transmitter. The battery will supply
the power for the microcontroller, transmitter and the moisture sensor and the solar panel
will do the charging of these batteries for an uninterruptible working system. The solar
panel is also equipped with control switch to avoid overcharging of the batteries. The
moisture sensor measure the water change through the changes in its resistance and these
values will be fed to the microcontroller. The PIC16F688 is the main controller of the
Sensor Module with the following functions: (1) accept the input of the moisture sensor
and analyze the data if the moisture content has reached its critical point (2) send a data
to open a valve and a data to close the valve to the RF transmitter. The RF transmitter
processes the data from the microcontroller and modulates the data suitable for
transmission. The transmitter acts as a link between the sensor and the controller modules
which will have a range of more than 100m distance separation. This allows ease
transmission of serial data between two locations wirelessly.
The channel is a medium that uses Radio Frequency allowing transmittal of
frequencies within the radio wave propagation in the electromagnetic spectrum.
The third block is the Controller Module which comprises the following: (1) the
RF Receiver, (2) the PIC16F688, and (3) Gate Valves. The RF Receiver accepts the
received data from the transmitter module. It is in this block that the received data is
checked for its consistency and if it is error free before it will be fed to the
microcontroller. The PIC16F688 is the main controller of the Receiver module that
performs the following: (1) check data’s reliability and accept input from the RF
Receiver (2) analyze the data and identify from what area it came from, (3) trigger the
opening of the gate valve if the critical level is reached and closing it if the received data
shows soil stability on the specified area.
3.2 Description of the Design Process and Implementation
Page 3
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 3/14
The main objective of this project is to automatically open the valve when the
moisture content is at its critical level and close it when the moisture content is reached.
Thus, the input of this overall system is the moisture content and the output is the
opening and closing of the valve on the receiving side.
In the preceding section, the overview of the system is discussed. It is composed
of three major blocks, the Sensor Module, the Channel and the Controller Module. The
Sensor Module sends a controlling data for gate valves via Radio Frequency Channel and
the Controller Module accepts what has been sent. The discussion that follow highlights
the design process and implementation of the Sensor module and Controller module. It is
discussed in separate sections. Since each module comprises of different parts, these
sections are subdivided into subsections tackling each of the subcomponents.
3.2.1 Sensor Module
The sensor module functions as a sensing mechanism if the soil moisture has
reached its critical level and send command data to the controller side through radio
frequency. It powered by battery charged by the solar panel. Below is the thorough
discussion of the components of sensor module.
3.2.1.1 Moisture Sensor
The moisture sensor can read the amount of moisture present in the soil
surrounding it. A manufactured soil moisture sensor is used for this project shown in
VCC
GND
DO
AO
PROBE
CONNECTING
WIRE
Figure 3-2 Soil Moisture Sensor [20]
Page 4
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 4/14
Figure 3-2. This sensor has a working voltage of 3.3 V - 5 V and uses the two probes to
pass current through the soil, and then it reads that resistance to get the moisture level.
More water makes the soil conduct electricity more easily (less resistance), while dry soil
conducts electricity poorly (more resistance).
The control board consists of four pins: (1) A0 for analog output, (2) D0 for
digital output, (3) VCC for voltage of 3.3V- 5V and (4) GND for ground. The board also
includes comparator LM393 chip, adjustable sensitivity, and has an analog and digital
output which enable to read the specific soil moisture information for analog signal
output or the over-wet or over-dry soil information according to the threshold for digital
signal output. The adjustable potentiometer is used to set the moisture threshold. This
control board can get the moisture value or threshold in the soil via analog or digital pins.
Threshold voltage is a voltage for comparison. When the soil moisture value read
by the sensor is above the threshold value, a low level (0V) will be digitally output; when
the soil moisture value read by the sensor is below the threshold value, a high level (3.3V
or 5V) will be digitally output. In this way, the digital pin can be used directly to read the
current soil moisture value to see if it is above the threshold or not. The threshold voltage
can be regulated by simply twisting the potentiometer which is shown in Figure 3-3, and
it increases by rotating to left side and decreases by rotating to right side. In this system
there will be using two moisture sensors that is separated by some distance for an
efficient moisture measurement detection.
Figure 3-3 Adjustable Sensitivity on the Control Board of Soil Moisture Sensor [19]
Page 5
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 5/14
3.2.1.2 PIC Microcontroller
The PIC16F688 serves as the main controller for the Sensor Module, this same
transmitter module will be used in all designated AREAS. As already stated, this
controller performs two functions: (1) check the digital output of the moisture sensor if it
is “1” or “0” and (2) send data that would open or close the valve in the receiver module
side. It has a total of 14 ports, 12 ports of which are configurable as input/output pins.
More than enough for the system design. Below is the figure of a PIC16F688.
The PIC microcontroller is set to run through its internal 20 Mhz oscillator. As
stated above, we will be using two sensors in each area so two ports will be used. Pins 9
and 10 are used as an input port for the digital output of the soil moisture sensor. The
transmitter is connected to its pin 6 where it is supported of UART Com suitable for
transmission. If this pin has a transmit enable bit then the sensor module will send data to
the receiver side.
Figure 3-4 Pin diagram of PIC16F88
Page 6
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 6/14
Yes
No
The schematic diagram shows the algorithm of the microcontroller shown in Figure 3-6.
Initialize I/O Ports
Send Open Gate
Valve Data Frame
Receive Data from
Sensor
Is data = ‘1’?
START
Initialize UART Com
Figure 3-5 PIC16F688 connection (Sensor Module)
Page 7
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 7/14
No
Yes
At start-up, the MCU initializes the I/O and UART ports including the pin
assignment of the line circuit. After initializing all the ports, the MCU accepts the
feedback from the sensor about the soil moisture measurement. It then examine if the
data from the sensor signifies that the soil already reached its critical level. If the input is
“0”, the sensor will just continue to measure the moisture content until such time that the
digital output of the sensor is “1”. When an input “1” is given, the microcontroller will
give an output data that would trigger the transmitter to send data to open the gate valve
data frame to the receiver module. After sending, the microcontroller will again receive
data coming from the sensor, it will analyze if the data is “0”. If the reading is “0” the
MCU will again trigger the transmitter to send data but this time, it will be a close gate
valve data frame. After transmitting the close data gate valve, it will start again from
where it accepts data after initializing all the MCU ports.
3.2.1.3 RF Transmitter
The output from the MCU is used as an input to the RF Transmitter Module. This
modules functions as follows: (1) accepts the input from the microcontroller and (2) send
this data serially to the RF Channel. HopeRF’s RFM22B is the transmitter that will be
used for the system for its wireless transmission. Shown in Fig. 3-7 below is the
transmitter used for the system.
Is data = ‘0’?
Receive Data from
Sensor
Figure 3-6 Algorithm for Sensor Module
Send Close Gate Valve
Data Frame
Page 8
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 8/14
It is highly integrated and low cost wireless ISM transceiver module. The low
receive sensitivity coupled with industry leading +20dBm output power ensures extended
range and improved link performance. Built-in antenna diversity and support for
frequency hopping can be used to further extend range and improved link performance.
The direct digital transmit modulation and automatic power ramping ensure precise
transmit modulation and reduced spectral spreading ensuring compliance with global
regulations. An easy-to-use calculator is provided to quickly configure the radio settings.
The RFM22B has a wide operating voltage range of 1.8-3.6 V and low current
consumption makes an ideal solution for battery powered applications. The project will
use FSK as a modulation technique. A standard 4-pin serial peripheral interface (SPI) bus
is used to communicate with an external microcontroller. Three configurable general
purpose I/Os are available. Figure 3-8 below shows the pin diagram of the transmitter
that will be used.
Figure 3-7 HopeRF RFM22B Transceiver [18]
Page 9
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 9/14
3.2.1.4 Solar Panel
A solar panel is used to charge the battery in each area. A single cell can produce
½ volt by converting the sun’s energy into an electrical signal. A 4.5AH, 6V lead acid
battery will using for this system. To charge the batteries with this rating, building
multiple cells into a single substrate in order to yield the convenience of higher output
voltage from a single package will be necessary. 24 cells will be connected in series to
provide the necessary voltage. Figure 3-9 below shows a configuration of the battery
charging from the solar panel.
Charging
circuit
Figure 3-9 Power supply diagram for the transmitter module
Figure 3-8 Pin diagram of RFM22B [18]
Page 10
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 10/14
The circuit shown in Figure 3-10 is a solar battery charger circuit which uses a 12
volt solar panel and IC LM 317 as its variable voltage regulator. LM317 is an adjustable
three terminal positive-voltage regulator capable of supplying more than 1.5A over an
output-voltage range of 1.25V to 37V. It has also a better standard than other regulators.
The charging current passes through diode D1 to the LM 317 and to regulate the output
voltage and current you need to tune the Adjust pin. A variable resistor (VR) is placed
between the adjust pin and ground to provide an output voltage of 9V to the battery. The
resistor (R3) controls the charging current and diode D2 prevents current discharge from
the battery. To stop the charging of battery when it is full, the transistor T1 and Zener
diode ZD act as cut off switch. Normally, T1 is off and battery is charging. When the
terminal voltage of the battery rises above 6.8 volts, Zener conducts and provides base
current to the transistor. It then turns on grounding the output of LM317 to stop charging.
3.2.2 Controller Module
In the controller module side, this part act as a receiver of the data command sent
by the sensor module. It will analyze those data and perform necessary actions with
respect to the sensor data. Below is the discussion of the elements present in thecontroller module.
3.2.2.1 RF Receiver
Figure 3-10 Schematic of solar battery charger
Page 11
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 11/14
In building an RF system, the transmitter selection is accompanied by the
selection of the receiver. Hence, the Receiver Module design similar to that of the
transmitter side. The input is the serial data from the RF channel sent by the transmitter
module. This receiver is capable of accepting all the data sent by the transmitters in each
area. With this, the same type of module will be used as with the transmitters.
3.2.2.2 PIC Microcontroller
The design for the controller of the Receiver module is far more complicated to
that of the Transmitter Module. While the controller in the latter only checks the input
given by the sensor and analyzes it to trigger the transmitter to send an open or close gate
valve data to the receiver side. The receiver MCU performs the following functions: (1)checks if the data received is valid, (2) verify if the data received is area A, B or C, (3)
trigger the gate valve if an open valve data is received and (4) close the gate if the
transmitter send a close valve data. Figure 3-11 is the pin connection of the PIC16F688 in
the controller module.
Fig. 3-11. PIC16F688 connection (Controller Module)
Page 12
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 12/14
The schematic diagram shows the algorithm of the microcontroller is shown in
figure 3-12. After initializing the ports, the MCU will check the validity of the data
received. It then verify if the data is from the transmitter of area A, B, or C. If for
example, the data is from area A, the MCU will trigger the pin to open the valve A. After
opening the valve, it will continue to accept data coming from designated or specific area
while ignoring others. If a command data is received to close the valve that is the time the
MCU will acknowledge and process data from other transmitters. Since the MCU will
only process the data received one at a time, each gate valve will have an open and close
transition.
3.2.2.3 Solenoid Valve
Solenoid Valve is an electromechanically operated valve. The valve is controlled
by an electric current through a solenoid. A solenoid is operated by opening and closing
an orifice in a valve body that permits and prevents flow through the valve. The orifice is
opened or closed through the use of a plunger that is raised or lowered within a sleeve
tube by energizing the coil.
Figure 3-13 shows a solenoid valve that will be used for this project. The valve is
made up of plastic having a port size of 12mm, both for inlet and outlet. It is a 2- way
Figure 3-13 Solenoid Valve [20]
Page 13
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 13/14
solenoid valve having one inlet and one outlet. The valve is a normally closed type which
operates at 12V DC with a pressure range of 0.02- 0.8 MPa. A normally closed valve
prevents the water to flow through unless a current is applied.
In this project, three solenoid valves will be used since there are three plots or
irrigation fields needed for the prototype. This solenoid valve is triggered during the
critical level where soil moisture content is below the threshold value or the desired
moisture level. When the soil moisture content is below the threshold value, the solenoid
valve will automatically open to allow the flow of water, and closes when soil moisture
content is reached.
Each area or irrigation field has a circuit shown in Fig.3-3 to control a solenoid.
The circuit is connected to the output pins of the PIC16F688. The output pins used for the
circuit for area 1, area 2, and area 3 are RC0 (pin 10), RC1 (pin 9), and RC2 (pin 8)
respectively.
Many output devices such as relays and solenoid will require a transistor
switching circuit. In most cases a darlington pair formed from two transistors is ideal. In
the circuit in Fig.3-3, a transistor called BCX38B is used which looks like a single
transistor but is in fact two transistors set up as a Darlington Pair in a single package
which gives a high gain and high current capability. This discrete device has a collector-
current rating of 800mA that will easily drive the output devices. In addition to the
Figure 3-14 Schematic for the triggering circuit of the solenoid valve
Page 14
8/12/2019 automatic watering system
http://slidepdf.com/reader/full/automatic-watering-system 14/14
circuit, the use of a back emf suppression diode across the relay contacts is to prevent
damage to the transistor when the relay switches off.