Telechargé par rurangwa bosco

Irrigation automatic

publicité
INTERNATIONAL UNIVERSITY OF EAST AFRICA
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND CONTROL ENGINEERING
AUTOMATIC IRRIGATION SYSTEM
BY
USANASE BARAKA
17/625/BSEE-S
SUPERVISOR: MR. APOLLO OCHIENG
A PROJECT REPORT SUBMITTED TO THE FACULTY OF ENGINEERING IN PARTIAL
FULFILMENT OF THE REQUIREMENTS FOR THE AWARD OF A DEGREE OF
BACHELOR OF SCIENCE IN ELECTRICAL AND CONTROL ENGINEERING OF
INTERNATIONAL UNIVERSITY OF EAST AFRICA- (IUEA)
AUGUST, 2018
Declaration
I hereby declare that the work that is being reported hereof was done by me and I have never
presented it anywhere else for any award whatsoever. Whatever is presented here is out if my
research and efforts and any journal, textbook, website referred to has been clearly sited. I
therefore declare this report authentic and ready for examination as one of the requirements for
the award of Bachelor of Electrical and Control Engineering of International University of East
Africa.
Signature: ………………………..
Date: …………………………
USANASE BARAKA
ii
Approval
Prior to submission, this document has been presented to and reviewed by my project supervisor.
By signing here, the the following certify that the project under the title Automatic Irrigation System
has been done by Usanase Baraka under their supervision and is now ready for examination
Signature: ………………………..
Date …………………………
Mr. Apollo Ocheng
Supervisor
Signature: ……………………………
Date……………………………
Professor Dawoud Shenouda Dawoud
Dean, faculty of Engineering
iii
Acknowledgement
I thank GOD who continues to give me strength to live and to meet achievements like this. I would like
to express great gratitude to my supervisor Mr. Apollo Ocheng for his continued advice through
the course of this project. His pieces of advice have been a stepping stone to the success of the
project. I also appreciate the advice offered by my lecturer Mr. Awali Musitwa regarding
electronics.
The dean of the faculty of engineering, Professor Dawoud Shenouda Dawoud, deserves much
appreciation for he has kept the faculty in order and this has helped me in acquiring the
knowledge and skills that I used in working on the project.
I also acknowledge the support and advise of my friends and classmates, especially Nshuti
Tevin, Mahad M. Ashafa, among others. May God reward them all abundantly.
Finally but very importantly, I would also like to thank a lot my parents who helped me
financially and encourage me through the course. Their support has been the backbone of my
course and may God pay them countlessly.
iv
Abstract
The entitled Automatic irrigation system which involved the design and making of a small cheap
system that automatically controls an irrigation pump depending on the moisture content and the
real time. An automatic irrigation system was developed to optimize water use for agricultural
crops while ensuring availability of the necessary water in the soil, depending on the crop in the
garden. A soil moisture sensor has been used to detect the water content in the soil and a Real
Time Clock has been used to keep track of the real time even when power leaves. The system
use a microcontroller as the processor and this is what cordinates the rest of the components.
This report presents and discusses the details of the system as well as the tasks that were
undertaken to come up with the system, including a brief introduction to the project, review of
literature, system design among others.
v
Acronyms
ADC
Analog Digital Converter
AVR
Automatic Virtual RISC
I2C
Inter Integrated Circuit
IUEA
International University of East Africa
LCD
Liquid crystal display
NC
Normally Closed
NO
Normally Open
PC
personal Computer
RISC
Reduced Instruction Set Computer
RTC
Real Time Clock
SCL
Serial clock
SDA
Serial Data
vi
Contents
Declaration ................................................................................................................................................ ii
Approval ................................................................................................................................................... iii
Acknowledgement ................................................................................................................................... iv
Abstract ..................................................................................................................................................... v
Acronyms ................................................................................................................................................. vi
Contents .................................................................................................................................................. vii
Figures ...................................................................................................................................................... ix
Tables ....................................................................................................................................................... ix
CHAPTER 1: INTRODUCTION ......................................................................................................................... 1
1.1 Background ......................................................................................................................................... 1
1.3 Objectives .......................................................................................................................................... 2
1.4 Significance And Justification .............................................................................................................. 2
1.5 Scope ................................................................................................................................................... 2
CHAPTER 2: LITERATURE REVIEW ................................................................................................................. 4
2.1 The YL-69 Moisture Sensor ................................................................................................................. 4
2.2 Microcontroller Unit ........................................................................................................................... 5
2.3 The ATMEGA328 Microcontroller ....................................................................................................... 7
2.4 Real Time Clock and I2C ...................................................................................................................... 7
2.5 Liquid Crystal Display (LCD) ................................................................................................................. 9
2.6 Light Emitting Diode (LED) ................................................................................................................ 10
2.7 DC Motor........................................................................................................................................... 11
2.8 Relay switching circuit....................................................................................................................... 12
2.9 VOLTAGE REGULATOR IC (7805) ....................................................................................................... 13
2.10 Tools Used ....................................................................................................................................... 14
CHAPTER 3: METHODOLOGY ...................................................................................................................... 16
3.1 System Design ................................................................................................................................... 16
3.2 Block Diagram ................................................................................................................................... 17
3.3 Circuit Diagram ................................................................................................................................. 18
3.4 Power supply..................................................................................................................................... 18
3.5 The LCD ............................................................................................................................................. 19
3.6 The Microcontroller .......................................................................................................................... 19
vii
3.7 Motor and Relay Circuit .................................................................................................................... 19
CHAPTER 4: RESULTS................................................................................................................................... 21
4.1 Results ............................................................................................................................................... 21
4.2 Advantages of System ....................................................................................................................... 22
4.3 Disadvantages ................................................................................................................................... 23
CHAPTER 5: CONCLUSION AND RECOMMENDATION................................................................................. 24
5.1 Conclusion ......................................................................................................................................... 24
5.2 Recommendation.............................................................................................................................. 24
REFERENCES ................................................................................................................................................ 25
APPENDICES ................................................................................................................................................ 26
Project Code ............................................................................................................................................ 26
viii
Figures
Figure 3. 1 ATMEGA328 ............................................................................................................................. 7
Figure 3. 2 LED .......................................................................................................................................... 11
Figure 3. 3 DC electric motor ..................................................................................................................... 11
Figure 3. 4 soldering iron ............................................................................................................................ 14
Figure 3. 5 Hardware setup during dry season............................................................................................ 21
Figure 3. 6 Hardware setup during wet season ........................................................................................... 22
Tables
Table 1 JHD162A LCD .................................................................... Ошибка! Закладка не определена.
Table 2 LCD Pin Configuration .................................................................................................................. 10
Table 3 Block Diagram ............................................................................................................................... 17
ix
CHAPTER 1: INTRODUCTION
1.1 Background
In scarcity of water, besides human lives, the most threatened industry is agriculture. Animals
and crops need water for proper growth. Plants also make their food from air (specifically
carbon-dioxide) and water and so, without water, crops can hardly survive for long. However, as
seasons pass, time comes when rain can’t be a reliable source of water into soil from when plants
absorb it. There is an urgent need to create strategies based on science and technology for
sustainable use of water, including technical, agronomic, managerial, and institutional
improvements.
Irrigation is the process of manually or automatically availing water to the soil/plants by artificial
mechanisms. This process is often constrained by a number of factors including but not limited
to; the long distance from the source of water, hardship in determination of the right quantities of
water required for the different crops, and inconvenience caused by having to irrigate at the exact
time that the water is most important and least dangerous to the crops.
This project aimed at developing an automatic irrigation system that irrigates at the times when
the sprinkled water is not evaporated by high temperatures and thus can be absorbed by the roots
of the crops. The system also first checks the amount of soil moisture (water level in soil) before
irrigating. The system uses a microcontroller as the processor that connects to a real time clock,
LCD, water pump and soil moisture sensor.
The very best time to water plants is in the early morning and evening, when it is still cool. This
allows the water to run down into the soil and reach the roots of the plant without too much loss
to evaporation.There is a myth that watering in the morning will make the plants susceptible to
scorch. This is not true. First of all, almost all areas in the world do not get intense enough sun
for water droplets to scorch the plants.
1.3 Objectives
1.3.1 General Objective
To design and make a small cheap system that can be used to automatically irrigate a small
garden of a certain crop depending on the real time and soil moisture content.
1.3.2 Specific Objectives
i) To design an automatic irrigation system
ii) Build the system following the design
iii) To test the built system and present it
1.4 Significance And Justification
The system helps to make sure that water is always available in the soil for the crops. It can
further be used to avail just the required range of water level instead of availing more than
enough that may even spoil the crop.
As there is no un-planned usage of water, a lot of water is saved from being wasted. The
automatic irrigation system is the only when earn detect is no enough moisture in the soil and
sensor automatically decide when should the pump turn on/off. Save a lot of time.
The system has been designed is such a way that it can easily be modified to control either an
AC pump or a DC pump and thus making it quite flexible and easily usable even in remote areas
where the main source of power is solar.
Furthermore, this system can also be used to control a valve instead of a pump. This is very
important in cases where the water comes from a higher altitude than the garden and thus the
flow of water is by natural gravitation which does not require extra energy but just closing and
opening of a valve.
1.5 Scope
Circuit design was made using proteus software . the circuit was then assembled and tested on a
breadboard and the final circuit was assembled on a stripboard. The system works as an
automatic switch that is controlled by the developed circuit. This circuit is powered using a 12V
adapter and it consists of several components including a relay switch that can be used to control
2
either a DC pump or an AC pump. In summary, the system has involved use of resistors,
capacitors, microcontroller, relay switch, transistor, among other components.
3
CHAPTER 2: LITERATURE REVIEW
2.1 The YL-69 Moisture Sensor
Sensors are basically components used to detect and measure physical quantities and convert
them into electronic signals. These electric signals can be currents or, most often, voltages.
There are several moisture sensors but one needs to consider a lot of factors before choosing any.
These include the cost price, power consumption, shape (and size), durability, accuracy,
linearity, range,responsivity (response
time), among others.
Figure 1 Soil Moisture Sensor
The YL-69is an electrical resistance Sensor. The sensor is made up of two electrodes which read
the moisture content of their surrounding environment which for this project is the soil. A current
is passed across the electrodes through the soil and the resistance to the current through the soil
determines the soil moisture.
If the soil has more water, the 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.
The YL-69 soil moisture sensor has the following specifications:
Property
Value
Vcc power supply
3.3V or 5V
4
Current
35mA
Signal output voltage
0 – 4.2V
Digital outputs
0 or 1
Analogue
Resistance (Ω)
Panel Dimension
3.0cm by 1.6cm
Probe Dimension
6.0cm by 3.0cm
GND
Connected to ground
The YL-69 sensor comes with a small PCB board fitted with LM393 comparator (op-amp) chip
and a digital potentiometer. This helps convert the soil resistance to a an analogue voltage a
digital one.
Figure 2 Op-Amp Circuit
2.2 Microcontroller Unit
A microcontroller is as a single chip computer with several peripherals like Random Access
Memory (RAM), EEPROM, and Timers etc. Microcontroller units are able to perform
predefined functions when programmed. There are several microcontroller families like the
8051, PIC (Programmable Interface Controller) and AVR. Microcontrollers are usually used as
control units in digital systems. Some come with an in-built analog to digital convertor (ADC)
and a digital to analog convertor (DAC) circuits.Microcontroller units in most cases are
programmed using assembly language but of recent high level languages like C and C are also
used.
Microcontrollers Vs Microprocessors
Microcontroller differs from a microprocessor in many ways. First and the most important is its
functionality. In order for a microprocessor to be used, other components such as memory, or
5
components for receiving and sending data must be added to it. In short that means that
microprocessor is the heart of the computer. On the hand, microcontroller is designed to be all of
that in one.
8051
The first 8051 microcontroller was fabricated in 1980 by Intel and it used Harvard architecture.
The 8051 microcontrollers were among the first microcontroller units to be fabricated. As
technology has gone on advancing fewer companies are fabricating them. The first ones which
were used had 12 clocks per instruction. The later technologies now use 6 clocks per instruction.
The 8051 microcontroller architecture does not have an in built memory bus and an analogue to
digital converter (ADC) circuit. [2]
Advanced Virtual RISC (AVR)
This microcontroller chip was fabricated by Atmel in 1996 with a modified architecture from
Harvard of Reduced Instruction Set Computer (RISC). AVR microcontroller units are usually a
bit difficult for first time users to work with. The microcontroller chip has input/output ports,
timers, counters, interrupts, Analog to Digital converters (ADC), Digital to Analog converters
(DAC), USART, Pulse Width modulation(PWM) channels, on chip analogue comparators, and
(inter IC) 12C interfaces. [4]
Arduino
Arduino is an open-source electronics design platform. The Arduino board is specially designed
for programming and prototyping with Atmel’s AVR microcontrollers. An Arduino interacts
with physical world via sensors. There are several types of Arduino boards. The open-source
Arduino environment allows one to write code and load it onto the memory of the
microcontroller on the Arduino board. The development environment is written in Java and
based on Processing, AVR-GCC, and other open source software. [3]
The Arduino Uno
The Arduino Uno is currently the most popular of all the Arduino programming boards. It
utilizes the ATmega328P AVR microcontroller with connectors linking to the microcontrollers
IO pimso.
6
Figure 3 Arduino Uno board
2.3 The ATMEGA328 Microcontroller
Although we have many controllers ATMEGA328P is most popular of all because of its
features and cost. It’s further characterized with program memory of 32kB of flash memory for
program storage,
various power saving modes, a watchdog timer to reset under, 1kB of
EEPROM, RAM, support for up to 20MHz processor speed.
Fig 3. 1 ATMEGA328
2.4 Real Time Clock and I2C
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
re-program your microcontroller or disconnect it from power. ATMEGA328 has a built-in
timekeeper called through the millis() function and there are also timers (0 and 1) built into the
7
chip that can keep track of longer time periods like minutes or days but these are restarted every
when the system is restarted.
There are many types of RTC like DS 1307, DS 3031, 3232, 3231, etc. The DS3231 is a lowcost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated
crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains
accurate timekeeping when main power to the device is interrupted.
Figure 4 DS 3231 above
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at
the end of the month 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 an
active-low AM/PM indicator. Two programmable time-of-day alarms and a programmable
square-wave output are provided.
Address and data are transferred serially through an I²C (I2C) bidirectional wire. I2C combines
the best features of SPI and UARTs. With I2C, you can connect multiple slaves to a single
master (like SPI) and you can have multiple masters controlling single, or multiple slaves. This
is really useful when you want to have more than one microcontroller logging data to a single
memory card or displaying text to a single LCD. Like UART communication, I2C only uses two
wires (SDA and SCL) to transmit data between devices.
Where master is microcontroller and slave is real time clock (DS 3231)
SDA (Serial Data) – The line for the master and slave to send and receive data.
SCL (Serial Clock) – The line that carries the clock signal.
8
Figure 5.1 i2c bidirectional wire
2.5 Liquid Crystal Display (LCD)
LCD screen is an electronic display module and finds a wide range of applications. These
modules are preferred to seven segments and other multi-segment LED displays because LCDs
are economical, easily programmable, not limited to displaying special characters among other
pros. 16x2 LCD [11] means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, command and
Data chosen between using its register selection (RS) pin.
Fig 6.1 Liquid Crystal Display
The command register stores the command instructions given to the LCD. A command is an
instruction to do a predefined tasks like initializing the LCD, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on LCD.
Pin Name
Description
1
Vss/Gnd
Ground pin connected to system ground
2
Vdd/Vcc
(+5 volt)
3
VEE/Vo
To Microcontroller to shit between command/data register
4
Register Select To Microcontroller. Tell whether data is for character or instruction
Pin
No:
(RS)
5
Read/Write
Used to read or write data. Normally grounded to write data to LCD
9
(R/W)
6
Enable (E)
Triggers LCD to pick data on data pins on falling edge of E
7
Data Pin 0 (D0) Carry data from Microcontroller to LCD (in writ mode)
8
Data Pin 1 (D1) They may be used in 4-bit write mode where only the last 4 are used
9
Data Pin 2 (D2)
10
Data Pin 3 (D3)
11
Data Pin 4 (D4)
12
Data Pin 5 (D5)
13
Data Pin 6 (D6)
14
Data Pin 7 (D7)
15
LED Positive Backlight LED pin positive terminal
(A)
16
LED Negative Backlight LED pin negative terminal
(K)
Table 1 LCD Pin Configuration
Specifications of JHD162A LCD module

Operating Voltage is 4.7V to 5.3V

Current consumption is 1mA without backlight.

Alphanumeric LCD display module, meaning can display alphabets and numbers

Consists of two rows and each row can print 16 characters.

Each character is built by a 5×8 pixel box

Can work on both 8-bit and 4-bit mode

It can also display any custom generated characters

Available light in Green and Blue Backlight.
2.6 Lighting Emitting Diode (LED)
A light-emitting diode (LED) is a semiconductor device that emits visible light when an electric
current passes through it. The light is not particularly bright, but in most LEDs it is
monochromatic, occurring at a single wavelength. The output from an LED can range from red
(at a wavelength of approximately 700 nanometers) to blue-violet (about 400 nanometers). Some
10
LEDs emit infrared (IR) energy (830 nanometers or longer); such a device is known as an
infrared-emitting diode (IRED).
Fig 3. 2 LED
An LED consists of two elements of processed material called P-type semiconductors and N-type
semiconductors. These two elements are placed in direct contact, forming a region called the P-N
junction. In this respect, the LED resembles most other diode types, but there are important
differences. The LED has a transparent package, allowing light energy to pass through. Also, the
LED has a large PN-junction area whose shape is tailored to the application. Benefits of LEDs,
compared with incandescent and fluorescent illuminating devices, include:

Low power requirement: Most types can be operated with battery power supplies.

High efficiency: Most of the power supplied to an LED or IRED is converted into
radiation in the desired form, with minimal heat production.

Long life: When properly installed, an LED or IRED can function for decades.
Typical applications include Indicator lights, LCD panel backlighting, Fiber optic data
transmission, Remote control and Opto isolator.
2.7DC Motor
A motor is an electrical machine which converts electrical energy into mechanical energy. The principle
of working of a DC motor is that "whenever a current carrying conductor is placed in a magnetic field,
it experiences a mechanical force". The direction of this force is given by Fleming's left hand rule and it's
magnitude is given by F = BIL. Where, B = magnetic flux density, I = current and L = length of the
conductor within the magnetic field.
Fig 3. 3 DC electric motor
11
According to Fleming's left hand rule, If we stretch the first (index) finger, second finger and thumb of
our left hand to be perpendicular to each other and direction of magnetic field is represented by the first
finger, direction of the current is represented by second finger then the thumb represents the direction of
the force experienced by the current carrying conductor. This principle, with motors, is used to design
almost all electro-mechanical systems
2.8 Relay switching circuit
A relay switching circuit is an electromagnetic switch that is used to switch High voltage/Current
using Low power circuits.It basically isolates low power circuits from high power circuits. It is
activated by energizing a coil wounded on a soft iron core when a current is applied to it. Most
relays operate using the electromagnetism principle while others operate as solid state
components. Solid state relays have no moving parts and they use semiconductor devices to
perform switching. Contactors are forms of relays that are used to handle high power required to
directly control loads like electric motors.
Relays are switches and thus terminologies applied to switches are also applied to relays. A relay
switches one or more poles, each of whose contacts can be thrown by energizing the coil in one
of three ways.

Normally Open (NO) contacts connect the circuit when the relay is activated; the circuit
is disconnected when the relay is inactive.

Normally Closed (NC) contacts disconnect the circuit when the relay is activated; the
circuit is connected when the relay is inactive.
Figure 7.1 SPST Relay Switch
12
A simple example of relay application is where a 12V DC circuit can be used to turn on/off a
230v AC lamp (or any other AC device, say a pump).
Fig 8.1 relay operation
Whenever a relay is driven from a circuit that has delicate components such as integrated circuits
or transistors, a diode is always included across the relay coil to prevent the relay from damaging
the circuit.
2.9 VOLTAGE REGULATOR IC (7805)
Voltage regulators maintain a constant output voltage irrespective of small changes in the input
voltage. The LM7805 monolithic 3-terminal positive voltage regulators use internal currentlimiting, thermal shutdown and safe-area compensation, making them essentially indestructible.
If adequate heat sinking is provided, they can deliver over 1.0A output current. The LM7805
Voltage Regulator outputs +5 volts. A filter capacitor is usually connected in parallel to the
LM7805 to prevent it from being damaged in case of variations from the power supply which for
this project is the 12V dc battery.
13
Fig 9.1 voltage regulator
2.10 Tools Used
2.10.1 Soldering iron
Soldering iron is a hand tool used in soldering. It supplies heat to melt the solder (soldering wire)
so that it can flow into the joint between two work pieces. A soldering iron is composed of
heated metal tip and insulted handle. Heating is often achieved electrically, by passing an electric
current through the resistive material of heating element.
Fig 3. 4 soldering iron
2.10.2 Wire stripper
A wire stripper is used to strip off wire insulator from its conductor before it is used to connect to
another wire or soldered into the printed circuit board. Some wire stripper or wire cutter as a
measurement engraved on it to indicate the length that will be stripped.
14
2.10.3 Side-Cutting Plier
A 4-inch side cutting plier will come in handy as one of the electronic tools when one need to
Trim off excess component leads on the printed circuit board. It can also be used to cut wires
into shorter length before being used.
2.10.4 Proteus
Besides Eagle, Fritzing, Multism and other software is Proteus. These are used to draw circuit
diagrams on computers. Proteus further helps in simulating the operation of the circuit as well as
designing the PCB layout of such a circuit. Version 8.5 was used in this project.
15
CHAPTER 3: METHODOLOGY
3.1 System Design
The implementation design has been divided into two parts:
 Hardware design
 Firmware/software design
Hardware Design
Hardware design involves drawing the schematics on the plane paper according to the
application (Proteus), testing the schematics design on a breadboard, using the various systems to
find if the design meets the objectives, carrying out the PCB layout of the schematics tested on
bread board. Finally preparing the board and testing the designed hardware.
Firmwareimplementation
This part involves programming the microcontroller so that it can control the rest of the system.
In the present works, I have used the proteus software for circuit design, and the Arduino
software tool to write and compile the source code. The project design and principles are
explained in this chapter using the block diagram and circuit diagram.
16
3.2 Block Diagram
A number of blocks have been combined to come up with the system. These have included the
microcontroller unit, the power supply, moisture sensor, LCD, real time clock module, relay based motor
driver circuit and the motor that makes the main part of the water pump. The power supply unit is the
source of regulated power to the microcontroller and to other marts. The microcontroller carries out the
arithmetic and logic calculations required and is thus the brain of the system. The LCD is used to display
the current motor state, time and soil moisture level as read from the sensor and RTC modules. The relay
switch offers isolation between the pump circuit (high AC power) and the control system (low DC
power).
Table 2 Block Diagram
17
3.3 Circuit Diagram
Figure 5 Circuit Diagram
3.4 Power supply
The AC power (240V 50Hz) from the mains supply is stepped down 9V AC by a step-down
transformer. The 9V AC (RMS value) means a peak voltage of 9√2 which gives about 12V.
Passing this through a full wave bridge rectifier converts the negative part to positive ripples that
can be reduced or even removed using a filter capacitor. The resulting voltage is about 12V DC.
To control the relay switch, 12V was required but the other components required a power supply
of 5V and that’s why the LM7805 voltage regulator was used. This inputs 12V DC and output
5V DC with up to 1.5A current.
Figure 6 Power Supply Circuit
18
In order to allow powering the circuit (alternatively) from a solar system, a connecter to an
adapter was used and thus the circuit can be powered from a 12V adapter. The connection of the
adapter to the circuit is achieved with bouncing (off-on effect) and this is filtered off using
capacitor C1. The power diode avoids reverse powering of the circuit in case of a mistake and C2
is added as recommended in the datasheet of the voltage regulator.
3.5 The LCD
The LCD was used in 4-bit mode. Only D4, D5, D6 and D7 are used to transmit data. The RS
and E pins are also connected to the microcontroller. The RW pin was grounded since the
microcontroller was going to only write to the LCD. For best contrast, the VEE pin required
about 0.9V and this was achieved using a 10k ohms potentiometer.
microcontroller was
programmed with the help of the LiquidCrystal Arduino library to control the LCD which uses
functions like lcd.print() to print text on the LCD, lcd.clear() to clear the LCD, and lcd.setCursor
to set the position of the cursor among other functions.
3.6 The Microcontroller
The ATMEGA328P’s speed of operation is can range between 0 and 20MHz. The Supply
voltage can be between 1.8V and 5.5V. The higher the frequency, the more the power
consumption and thus this microcontroller is often powered with 5V and a crystal of 16MHz is
used to determine the speed of operation. Ceramic non-polar capacitors are often added to the
crystal as indicated in the circuit diagram to offer proper pulsing. In order to stop the
microcontroller from automatically restarting, a pullup resistor of 10k ohms (as recommended) is
added to the RST pin (pin 1) and this keeps the voltage on this pin high.
3.7 Motor and Relay Circuit
The relay switch connects its COM contact to NO when a potential difference is connected
across its coil. To achieve this a (TIP31) transistor used as a switch. The resistor R2 is used to
control the amount of current that enter the base of the transistor. An indicator LED is used to
show whether the pump/motor has been turn on or off. The LED requires a resistor to control the
amount of current because currents beyond 30mA can burn the LED.
19
Figure 7 Motor and Relay Circuit
When the voltage from the microcontroller becomes high, a small current flows through the base
to the collector of the transistor. At the same time, current also flows through the LED and it
lights. Small currents at the base of the transistor lead to higher currents at the collector and thus
the collector-emitter connection of the transistor behaves like a short circuit thereby powering
the coil of the relay and thus turning on the pump. The digitalWrite() function was used to give
this pin a low or a high voltage.
20
CHAPTER 4: RESULTS
4.1 Results
After successful hardware implementation of the circuit diagram in PC following outputs will be
obtained:
In dry soil conditions, the moisture sensor detect the low level of moisture in the soil and the
RTC module reports the current time as both required by the microcontroller. The
microcontroller then turns on the pump if the time is in the right range for irrigation. It also
commands the LCD to display that the pump is ON, to display the time and to display the
percentage moisture content in the soil. The system keeps displaying time, pump status and
moisture content values. A similar case occurs when the low soil moisture content increases.
For the pump to start, it must be in the right time range and the soil moisture content must be
low, but for it to stop, it can be when the moisture content has reached the maximum value or
when the time for irrigation has expired.
Fig 3. 5 Hardware setup during dry season
21
This prototype considers thresholds of 30% and 50% moisture content. Besides the time
constraints, for the motor to start, the moisture level should be at most 30% and for it to stop, it
should be at least 50%. This is in consideration of a plant that requires about 30% to 50%
moisture content. However, the time constraint can’t be forgotten. The normal time for irrigation
is from about 7pm to 8am. For presentation purposes, a minute has been used to represent a
day/night and 5 seconds have been used to represent an Hour. Therefore, odd minutes have been
used to represent day time while even minute to represent night time.
Fig 3. 6 Hardware setup during wet season
4.2 Advantages of System
 Automationeliminates the manual operation of opening or closing valves.
 Possibility to change frequency of irrigation and fertigation processes and optimize these
processes.
 Adoption of advanced crop systems and technologies, especially new crop systems that
are complex and difficult to operate manually.
 Use of water from different sources and increased efficiency in water and fertilizer use.
22
 System can be operated at night; water loss evaporation is thus optimizing energy
requirements.
 Irrigation process starts and stops exactly when required, thus optimizing energy
requirements.
 Savetime.
4.3 Disadvantages
 Self-help compatibility is very low with big-scale systems, which are very complex.
 Most automated irrigation systems need electricity .
 For crops like rice we cannot use this same project because of excess need of water.
23
CHAPTER 5: CONCLUSION AND RECOMMENDATION
5.1 Conclusion
The automatic irrigation system implemented was found to be feasible and cost effective for
optimizing water resource for agricultural production. This irrigation system allows cultivation
in places with water scarcity thereby improving sustainability. The automatic irrigation
system developed proves that the wastage of water can be diminished.
The system can also be adjusted to a variety of specific crop needs and requires minimum
maintenance. The use of solar power in this irrigation system is pertinent and significantly
important for
organic crops and other agricultural products that are geographically
isolated, where the investment in electric power supply would be expensive. The modular
configuration of the automatic irrigation system allows it to be scaled up for larger
greenhouses or open fields. The importance of the preservation of this natural resource justify
the use of this kind of irrigation systems.
5.2 Recommendation
Due to the soil’s natural variability, location and number of soil water. Sensors may be crucial
and future work should include specific calibration. Power supply(adapter) can be replaced with
the solar panels. We can add extra sensor like voltage sensor.
Use of GSM: Though this automatic irrigation you need to get the result of the system every day
in any condition. A GSM module can be used to report to the owner of the garden the state of the
garden including whether water is still available in the reservoir or not. This project should be
improved and advanced in any possible way to develop it status.
24
REFERENCES
[1] https://circuitdigest.com/microcontroller-projects/arduino-automatic-plant-watering-system
[2] http://www.edgefxkits.com/automatic-irrigation-system-on-sensing-soil-moisture-content
[3] Distributed wireless sensor network, IEEE Trans. Instrum.
[4] Meas., vol. 57, no. 7, pp. 1379–1387, Jul. 2008.
[5] Y. Kim and R. G. Evans, ―Software design for wireless sensor-basedsite-specific
irrigation, Comput. Electron. Agricult., vol. 66, no. 2,pp. 159–165, May 2009.
[6] O. Mirabella and M. Brischetto, ―A hybrid wired/wireless networking infrastructure
for greenhouse
25
APPENDICES
Project Code
#include <LiquidCrystal.h>
#include <Wire.h>
#define DS3231_I2C_ADDRESS 0x68
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 8, en = 9, d4 = 10, d5 = 11, d6 = 12, d7= 13;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int PUMP = 7;
const int SENSOR = A2;
byte second = 0, minute = 0, hour = 0;
byte decToBcd(int val)
{
return ( ( (byte)val / 10 * 16) + ( (byte)val % 10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(int val)
{
return ( ( (byte)val / 16 * 10) + ( (byte)val % 16) );
}
void readDS3231time()
{
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set DS3231 register pointer to 00h
Wire.endTransmission();
Wire.requestFrom( DS3231_I2C_ADDRESS, 3 );// request seven bytes of data
from DS3231 starting from register 00h
second = bcdToDec( Wire.read() & 0x7f );
minute = bcdToDec( Wire.read() );
hour = bcdToDec( Wire.read() & 0x3f );
}
void setDS3231time(int sekend, int minat, int awa)
{
if(sekend<0){ sekend=0; } if(sekend>59){ sekend=59; }
if(minat<0){ minat=0; } if(minat>59){ minat=59; }
if(awa<0){ awa=0; } if(awa>23){ awa=23; }
26
//sets time and date data to DS3231
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set next input to start at the seconds register
Wire.write(decToBcd(sekend)); // set seconds
Wire.write(decToBcd(minat)); // set minutes
Wire.write(decToBcd(awa)); // set hours
Wire.endTransmission();
}
void showDateTime()
{
readDS3231time();
lcd.clear();
lcd.print("Time: ");
if (hour<10){ lcd.print("0"); }lcd.print(hour);
lcd.print(":"); if (minute<10){ lcd.print("0"); } lcd.print(minute);
lcd.print(":"); if (second<10){ lcd.print("0"); } lcd.print(second);
}
int getLevel()
{
int l1 = analogRead(SENSOR);
int l2 = map(l1, 320, 986, 0,100);
int l3 = constrain(l2, 0, 100);
return 100-l3;
}
void setup() {
Wire.begin();
pinMode(PUMP, OUTPUT);
pinMode(SENSOR, INPUT);
lcd.begin(16, 2);
//setDS3231time(ss, mm, HH); //HH in 24hrs
//setDS3231time(30, 49, 17);
}
void loop() {
delay(1000);
int level = getLevel();
showDateTime();
lcd.setCursor(0, 1); //col, row
lcd.print("Lev:");
27
lcd.print(level);
lcd.print("%");
//using hours of every day
//if( (level<30) && (hour>=19) && (hour<=8)){ /*pump on*/ }
//if( (level>50)||((hour<=18) && (hour>=9)) ){ /*pump off*/ }
//using seconds of every minute
//if( (level<30) && (second<=30) ){ /*pump on*/ }
//if( (level>50)||(second>=40) ){ /*pump off*/ }
//using minutes & seconds every 2 minutes
boolean day_time = (boolean)(minute%2) ;
if(!day_time && (second<=10) ) { day_time = true; }
if( day_time && (second<=20) ) { day_time = false; }
if( (level<=30) && (!day_time) ){ //irrigate at night & morning
digitalWrite(PUMP, HIGH);
lcd.print(" PUMP ON");
}
if( (level>50)||(day_time) ){
digitalWrite(PUMP, LOW);
lcd.print(" PUMP OFF");
}
}
28
Téléchargement