Professional Documents
Culture Documents
Kyambogo University: Faculty of Engineering Department of Electrical Engineering
Kyambogo University: Faculty of Engineering Department of Electrical Engineering
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL ENGINEERING
JUNE 2019
DECLARATION
I declare that all the content in this report is true and original work.
It is as a result of our research and has never been submitted to any university for the award of
any academic qualification.
ii
APPROVAL
This is to certify that this research report entitled design and construction of an automatic solar
irrigation system with GSM monitoring technology was under my supervision and submitted for
examination with my approval to the department of Electrical engineering of Kyambogo
University.
MR. SERUYANGE WILLIAM
KYAMBOGO UNIVERSITY
iii
DEDICATION
With great pleasure and appreciation, we dedicate this report to our friends, bosses , lecturers and
all the family members for the crucial role they played in terms of constant guidance,
encouragement, financial support, to mention but a few.
May the almighty GOD bless them abundantly.
iv
ACKNOWLEDGMENT
We highly appreciate all the efforts of our parents and all the family members .We also wish to
convey our sincere gratitude to the management of Kyambogo University for the knowledge and
guidance accorded to us more especially during studying. Special thanks go to our project
supervisor Mr. Seruyange William.
TABLE OF CONTENTS
v
DECLARATION.............................................................................................................................ii
Approval.........................................................................................................................................iii
DEDICATION................................................................................................................................iv
ACKNOWLEDGMENT:................................................................................................................v
LIST OF FIGURES:.....................................................................................................................viii
LIST OF TABLES:......................................................................................................................viii
ACRONYMS..................................................................................................................................ix
ABSTRACT:...................................................................................................................................x
CHAPTERONE...............................................................................................................................1
1.0............................................................................................................................................ Introduction
.........................................................................................................................................................1
1.1 Background................................................................................................................................1
1.2 Problem Statement.....................................................................................................................2
1.3 General objective...................................................................................................................2
1.3.1 Specific Objectives.............................................................................................................2
1.4 Significance of the System....................................................................................................2
1.6 Project Scope.........................................................................................................................3
CHAPTERTWO..............................................................................................................................4
2.0 Literature review....................................................................................................................4
2.1 Related work:.........................................................................................................................5
2.1.1 Automatic Irrigation Based on Soil Moisture for Vegetable Crops:..............................5
2.1.2 GSM based Automatic Irrigation Control System for Efficient Use of Resources and
Crop Planning by Using an Android Mobile...........................................................................5
2.1.3 Tensiometers to automatically irrigate apple trees:........................................................6
2.1.4 GSM-SMS remote measurement and control system for greenhouse based on PC-
based database:........................................................................................................................6
CHAPTERTHREE..........................................................................................................................7
3.0 Methodology:.........................................................................................................................7
3.1 Research design:....................................................................................................................7
3.2 Study area and population:....................................................................................................7
3.3 Sample size:...........................................................................................................................7
3.4 Data collection methods:.......................................................................................................7
3.4.1 Documentation:...............................................................................................................7
3.4.2 Interviews.......................................................................................................................7
3.5 Data analysis:.........................................................................................................................8
vi
REFERENCES................................................................................................................................9
APPENDICES:..............................................................................................................................10
Appendix A: Project budget......................................................................................................10
Appendix B: Project time frame....................................................................................................10
LIST OF FIGURES
LIST OF TABLES
vii
ACRONYMS
viii
ABSTRACT
The main aim of this project is to provide automatic irrigation to the plants using reliable solar
power, which helps in saving money and water. The entire system is using microcontroller, Soil
moisture sensor and float switch (for water level control from the reservoir). Whenever there is a
change in the soil moisture, the sensor detects the change in moisture content, and gives an
interrupt signal to the micro-controller and thus the valve (or pump for larger gardens) is
activated. In addition the system provides water top up mechanism via the float switch that give
an interrupt flag to the controller to turn on the reservoir pump, so as to cover up the irrigation
water tank level. In otherwise the GSM tracks and monitors the system with texts to the farmer’s
phone.
ix
CHAPTER ONE
1.0 Introduction
This chapter looks at the background of the study, statement of the problem, general objective and specific
objectives of the study, scope of the study and the significance of the study, justification and the definition of
terms.
1.1Background [9]
Agriculture is a stressful carrier choice and often with very many challenges, One of the most common
challenges being less food production as a result of lack of enough water for food crops during dry seasons.
Considering areas in Uganda such as Mpigi and Nakasongola where rain-fed agriculture is less productive
than the irrigation based agriculture, basing on the rapidly increasing irrigation scheme farms over years
search as doho and mubuku that have satisfied rice demands for the Ugandan population. The highest yields
obtained from irrigation are more than double the highest yields from rain fed agriculture.
Automatic irrigation system incorporates the theory of digital control and feedback system with irrigation.
This is where critical information provided by the moisture sensor is sent to a microcontroller. This
information indicates the soil moisture content and the requirement for irrigation. In absence of this system,
farmers have been unable to determine specific time for irrigation due to little knowledge of the moisture
content levels. This leads to low crop production due to insufficient water for crop growth in the soils.
Farmers working on farmland depend on manual intervention to switch on and off the irrigation pumps
whenever they need to irrigate. Even if the farmland has a water-pump, this makes it very hard to determine
when to switch on and off the irrigation pumps as there is no critical method to determine the soil moisture
content. The process is time consuming to the farmers and puts crops at risk hence losses to the farmers again.
Farmers with this particular have got the ability to monitor their system status via texts received and if without
a reliable water reservoir the farmers knows when to refill his irrigation tank. This system efficiently utilizes
solar power as source of energy.
1.3. Justification
The project is aimed at improving crop production since it helps crops to get enough water needed for their
growth. It also helps in conservation of water, reducing costs and time spent during irrigation. The system
automatically enables irrigation process by monitoring the soil moisture content level (for which threshold is
set in the IDE program depending on the crop and soil type), and switches ON or OFF the pump.
1
1.4. Objectives
1.4.1. General objective
To design and construct an automatic solar irrigation system with GSM monitoring Technology
1.4.2. Specific Objectives
i. To study and analyze the current irrigation systems and their mode of control.
ii. To design and construct an automatic irrigation control system from study requirements.
iii. To test the efficacy of the designed system.
1.5. Significance of the System
The system will minimize the manual intervention by the farmer to switch on and off the water irrigation
pumps, which is why we are using microcontroller. The micro-controller based Automated Irrigation system
will serve the following purposes:
i. As there is no un-planned usage of water, a lot of water is saved from being wasted.
ii. The irrigation is done only when there is not enough moisture in the soil and the microcontroller decides
when should the pump be turned on/off, saves a lot time for the farmers. This also gives much needed rest
to the farmers, as they don’t have to go and turn the pump on/off.
iii. This automatic irrigation system helps the farmer by supplying water as needed by the plants. This leads
to plant growth optimization and helps in conserving water and energy. It also reduces labor costs during
irrigation.
iv. The farmer also gets information from the controller for every action the system takes.
2
CHAPTER TWO: LITERATURE REVIEW
Uganda’s agricultural sector is largely dependent on the rain-fed agriculture. Even if the farm land has a
water-pump, manual intervention by farmers is required to turn the pump on/off whenever needed. Overall,
96 % of the parcels (piece of land) in Uganda depend on rain as their main source of water while 3 % parcels
were reported using swamps as their main water source (2.9 %) and only 1 % using irrigation as their
main source of water shown in [8] .
Despite this, prolonged drought is a key climate variability disaster which has already occurred in Uganda and
has affected community livelihoods and the economy.
According to the UN report of August 2010, the areas hit by drought in Nakapiripirit district are Kamaturu
and Narisae. The droughts which used to last for a period of 3 months currently have been extended to
about 4-6 months. This presents much stress to both food (banana, maize, beans, cassava, vegetables)
and cash (coffee) crops and results in low productivity and at extreme there is complete death of the
crops [8] .
Drought has occurred in various parts of Uganda many times seriously affecting crop production, food market
prices and ultimately, the cost of living. This uncertainty regarding agricultural production as well as
investments in agricultural improvements has caused concerns in both local authorities and world bodies
alike, which have been collaborating to combat drought.
The unplanned use of water inadvertently results in wastage of water. In recent times, the farmers have been
using irrigation technique through the manual control in which the farmers irrigate the land at regular intervals
by turning the water-pump on/off when required. This process sometimes consumes more water and
sometimes the water supply to the land is delayed thus the crops dry out. Water deficiency deteriorates plant
growth before visible wilting occurs. In addition to this slowed growth rate, lighter weight fruit follows water
deficiency. This problem can be perfectly rectified if we use the Moisture Based Automated Irrigation Control
System in which the irrigation will take place only when there will be intense requirement of water, as
determined by the moisture sensor in the soil.
2.2. Related work
In [9], An Automatic Irrigation Based on Soil Moisture for Vegetable Crops is proposed. 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 convenience for the manager but into substantial water savings compared
to irrigation management based on average historical weather conditions.
In [10], the concept of drip irrigation to manage the watering of crops remotely from an android cellphone
was used. Drip irrigation is artificial method of supplying water to the roots of the plant. It is also called micro
irrigation. In past few years there is a rapid growth in this system. The user communicates with the centralized
unit through SMS. The centralized unit communicates with the system through SMS which will be received
by the GSM with the help of the SIM card. The GSM sends this data to ARM7 which also continuously
receives the data from sensors in some form of codes. After processing, this data is displayed on the LCD.
In [12], Shen introduced a GSM-SMS remote measurement and control system for greenhouse based on PC-
based database system connected with base station. The Base station is developed by using a microcontroller,
GSM module, sensors and actuators. In practical operation, the central station receives and sends messages
through GSM module. Criterion value of parameters to be measured in every base station is set by central
station, and then in base stations parameters including the air temperature, the air humidity. However, his
work did not provide any activity after getting the weather parameters.
3
CHAPTER THREE: METHODOLOGY
This chapter covers steps and procedures that was used in the specification of requirements, design,
construction, testing and implementation of the proposed system.
3.1. Research design
The study utilised qualitative and descriptive research design by analyzing the study data and comparing it
with the project objectives. It is out of these that conclusions and recommendations will be made. Interview
method was used through which both analytical and descriptive studies were adopted. With descriptive
studies, we undertook the relationship between variables. The emphasis here was to study the problem in
order to have a solution that comprehensively solved the farmers’ problems. The study provided system
specifications and suggested appropriate tools from which we developed a framework for the design and
construction.
3.2. Sample size
A sample of 10 farmers was selected randomly from different villages of Jinja district. The study considered
nursery bed farmers who commonly use watering cans to irrigate the young plants.
3.3. Data collection methods
In order to collect the required information two instruments of data collection were used, which include
interview and documentation.
3.3.1. Documentation;-Documents included journals, online published documents, reports, device
manuals/datasheets, and text books among others. These provided support literature for both the technical
design and understanding of the study requirements.
3.3.2 Interviews;-To gain better knowledge of how people currently irrigate crops, I will make consultations
with the local farmers on ground and some staff from the Fiduga flower farm in Jinja district.
3.4 Data analysis
Data about the response of respondents were collected, summarized and then entered in a computer using
Microsoft office word and excel, analyzed using descriptive tables in which respondents had recorded from
which conclusions and recommendations were made basing on objectives and questions of the study. The
response data was used in system design to a direction that meets the farmers’ requirements.
4
CHAPTER FOUR: MAIN WORK
4.1 Design of solar power supply system
The solar system consists of the solar panel array, charge controller, battery and an inverter (for AC loads).
The size of each of this largely depends on the load demand from the system.
5
The standard charge controller required for the design is hence rated 12 V, 5 A max charge current, 5
A max load current.
4.2. Construction
4.2.1 Circuit diagram
Fig: indicationLEDcircuit
R
pumpinterfacecircuit
100
D1
LED
RL
12V
D4 C3 R Q1 R
9 D13
DIODE BC547 10k
10k
22pF
XL R
Q CRYSTAL
C4
BC547 10 470k
R Q2
22pF BC547
Fig: central microcontroller circuit 10k D2
LED
R U1
10k 1 VCC 2 14
PD0/RXD/PCINT16 PB0/ICP1/CLKO/PCINT0
3 15
A0 PD1/TXD/PCINT17 PB1/OC1A/PCINT1
4 16
PD2/INT0/PCINT18 PB2/SS/OC1B/PCINT2 Vin9V
5 17
27.0 PD3/INT1/OC2B/PCINT19 PB3/MOSI/OC2A/PCINT3 Vout 5V
6 18
11
PD4/T0/XCK/PCINT20 PB4/MISO/PCINT4
19 LM7805
PD5/T1/OC0B/PCINT21 PB5/SCK/PCINT5 7805
2 12 9
D6 VOUT PD6/AIN0/OC0A/PCINT22 PB6/TOSC1/XTAL1/PCINT6
13 10
PD7/AIN1/PCINT23 PB7/TOSC2/XTAL2/PCINT7
1 3
VI VO
21 23
AREF PC0/ADC0/PCINT8
GND
3 LM34 20
AVCC PC1/ADC1/PCINT9
24 R1 C1
PC2/ADC2/PCINT10
25 10K 10uF C2
26 1uF
VCC PC3/ADC3/PCINT11
2
1 27
PC4/ADC4/SDA/PCINT12
28
PC5/ADC5/SCL/PCINT13
1
PC6/RESET/PCINT14
27.0 Fig: Tempratureinterfacecircuit
ATMEGA328P LCD
JHD204A
A1
2
VOUT
CTS D10
3 YL-69
RTS D9
TXD RX
RXD TX
VDD
VSS
VEE
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
RV?
D12
D11
D5D4D3D2
100
6
4.2.2. System flow chat for the program
START
Initialize system
interface
Establish
network service LCD
display
NO
NO
Is soil moisture GSM
m≤800?
text
YES
YES YES
Is float
Switch on switch
reservoir pump HIGH?
NO
NO
Is soil moisture still
m≤800?
YES
STOP
7
Figure 3: flow chart
The flow chart above describes the operation of the controller program so as to drive the attached components
into system operation. On starting the system, it initializes, establishes GSM network between the GSM shield
and cellular phone. This is displayed on the LCD display and a phone sms received to show system is ready
for operation.
The soil moisture threshold set for the controller gives a monitoring range of values so that below it, the
solenoid value is open if the float switch is low. The system irrigates the farm soil till threshold is reached as
detected by the soil moisture sensor. On threshold, the solenoid is switch off and the system continuously
monitors the soil moisture.
The Arduino Uno is a microcontroller board based on the ATmega328. It has 20 digital input/output pins (of
which 6 can be used as PWM outputs and 6 can be used as analog inputs), a 16 MHz resonator, a USB
connection, a power jack, an in-circuit system programming (ICSP) header, and a reset button. It contains
everything needed to support the microcontroller; simply connect it to a computer (or appropriate wall power
adapter) with a USB cable or power it with an AC-to-DC adapter or battery to get started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead,
it features an ATmega16U2 programmed as a USB-to-serial converter. This auxiliary microcontroller has its
own USB boot loader, which allows advanced users to reprogram it [3].
When ATmega328 chip is used in place of Arduino Uno, or vice versa, the image below shows the pin
mapping between the two.
8
Figure 5: at mega 328 pin configuration with related arduino UNO board match
The figure shows the at mega pin label versus the arduino board pin label (in red). Generally the actual pin
labeling differs from the arduino labeling hence care was taken when programing the controller using the
board. At mega328 consists of It has 20 digital input/output pins (of which 6 can be used as PWM outputs and
6 can be used as analog inputs, 2 oscillator inputs, RXD and TXD pins). Also consists READ and WRITE
pins, VCC (input DC voltage), 2 ground pins, analogue reference pin and analogue VCC.
4.2.3.3. Software
Arduino IDE (Integrated Development Environment) is required to program the Arduino Uno board. Once
arduino IDE is installed on the computer, connect the board with computer using USB cable. Now open the
arduino IDE and choose the correct board by selecting Tools>Boards>Arduino/Genuino Uno, and choose the
correct Port by selecting Tools>Port. Arduino Uno is programmed using Arduino programming language
based on Wiring. To get it started with Arduino Uno board. Shown below is a pc open window of the software
where the file, edit, sketch, tool, and help dialogue boxes enable the program to manipulate the software for
the program to correctly compile and upload to the controller.
9
4.2.3.4. 12 to 5 V regulator (LM7805)
While external capacitors are typically required, 78xx series ICs do not require additional components to set
their output voltage. 78xx series ICs have built-in protection against a circuit drawing too much current. They
have protection against overheating and short-circuits, making them robust in most applications [6]. 12 V as
the input voltage produces an out of 5 V DC
10
4.2.3.6. FC- 28 soil moisture sensor
The soil moisture sensor consists of two probes that are used to measure the volumetric content of water. The
two probes allow the current to pass through the soil, which gives the resistance value to measure the moisture
value.
The specifications of the FC-28 soil moisture sensor are: - Input Voltage: 3.3–5 V, Output Voltage: 0–4.2 V,
Input Current: 35 mA, Output Signal: both analog and digital Pin-out
The FC-28 soil moisture sensor has four pins: Power, Analog Output, Digital Output, and Ground [3].
11
A float sensor is a device used to detect the level of liquid within a tank. The switch may be used in a pump,
an indicator, an alarm, or other devices. Magnetic float sensor is an electromagnetic ON/OFF switch. It helps
to sense the level of water present in the overhead tank or sump [1]
4.2.3.11. Charge controller
Its Equipped with the MCU, artificially controlled, a device to avoid the over charge, over release, electronic
short circuit, over loading battery inversely connected, solar battery inversely connecting. The series
connection PWM circuit is implemented to form the major charging circuit, make the voltage loss 50 % lower
than the diode charging circuit, and the charging efficiency 3 % -6 % higher than the non-PWM. The LED
display shows the batteries current situation to make the customer get the information .The controller can
automatically identify the 12/24 V and rated 5 A system current, 5 A charging current[5].
4.2.3.12. Solar panel
Small, compact, all weather and built to high standards. 12 V, 20 W Solar Panel Mono-crystalline an ideal
panel for regular battery charging and maintenance on vehicles with alarms or a source of power drain comes
with crocodile clips for easy connection. 12 V, 20 W Solar Panel Mono-crystalline Specification:- Panel Size
426 mm(w) x 356 mm(h) x 25 mm(d),Weight: 2.2 kg, Peak Power: 20 W, Open Circuit Voltage: 21.4 V,
Short Circuit Current: 1.32 A, Power Allowance Range: 5 %, Max Power Voltage: 16.94 V, Max System
Current: 1.18 A, Max System Voltage: 300 VDC, Number of Cells: 36 [5].
4.2.3.13. Battery
This is composed of Pure Lead With 99.9% above-average high purity level and corrosion resistant micro
crystal structure plates insulated by Promotion Performance Fleece Glass-mat separator with maximum
absorption on level. It has Balanced Electrolyte Specialized pH-value for optimised ion mobility and has
symmetrical lattice structure Special geometry of lead components for high capacity and efficiency [5].
4.3. Implementation
4.3.1. Modeling
The size solar power supply is installed as in conceptual block diagram so that it supplies the entire system
with DC on its output. For this prototype an inverter is not necessary since the components are DC rated (12
V). The other components i.e. controller, regulators, diodes, relays capacitors, oscillators and the LCD display
as arranged with reference to the circuit diagram and soldered onto the circuit board.
4.3.2. Uploading of working program to controller
After writing the project code using C++ language using arduino IDE, it is uploaded using arduino Uno board.
The hub port on the pc, onto with the board drivers are installed must be known and then commanded by the
pc software to receive program into the controller. The project code is described in appendix C.
4.3.3. Peripherals
Additional equipment such as buckets (to represent reservoir and system tanks), water horse pipes (attached to
the valve and pumps) and a stand (to support the entire system) are used to implement the functionality to the
farmer as shown in figure10.
12
Figure 10: addition peripherals
4.3.4. Experimentation
Before final installation, the system is tested for; - correct project code, proper power input to the system,
right power output to the components and sequential operation of the overall system set up. On
experimentation we faced a number of challenges in the code, and circuit modeling that needed time and more
research to ensure the right implementation is achieved
13
CHAPTER SIX: RECOMMENDATIONS AND CONCLUSIONS
6.1. Conclusions
Automatic irrigation control system has been designed and constructed. The prototype of the system
worked according to specification and quite satisfactorily. The system components are readily
available, relatively affordable and they operate quite reliably.
The system helps to eliminate the stress of manual irrigation and irrigation control while at the same
time conserving the available water supply. Improving Irrigation efficiency can contribute greatly to
reducing production costs of agricultural products, thereby making the industry to be more competitive
and sustainable.
6.2. Recommendations
14
The system can be equipped with actual larger equipment for irrigation of large farm land where the
supply power can also be varied either from solar to thermal or hydro (commonest power supplies in
Uganda), according to size of the farms.
Sprinklers and peripherals haven't been used in this due to the cost ventures. However can be
substituted for the solenoid valve.
Water from the irrigation tank depends on gravity flow due to the height but for large farm booster
water pumps can be added to the tank.
A wireless sensor and GPRS (General Packet Radio Service) based automated irrigation system can
also be employed, which will help monitor the soil moisture and to control the application of water to
the agricultural products thereby saving water.
REFERENCES
[1] “Automatic Irrigation Based on Soil Moisture for Vegetable Crops”- Rafael Muñoz- Carpena and Michael
D. Dukes, 2003.
[2] Practical Use of Soil Moisture Sensors for Irrigation Scheduling, R. Troy Peters, 2013.
[3] http:// www.arduino.cc/en/Guide/introduction.
[4] K. K. Tse, M. T. Ho, H. S. H. Chung, S. Y. Hui , “A novel maxi-mum power point tracker for PV panels
using switching frequency modulation”, IEEE Trans. Power Electron., Vol. 17, Issue 6, (2006), pp: 980–989.
15
[5] Prakash Persada, Nadine Sangsterb, Edward Cumberbatch, Aneil Ramkhalaw and Aatma Maharajh,
“Investigating the Feasibility of Solar Powered Irrigation for Food Crop Production” A Caroni Case, The
Journal of the Association of Professional Engineers of Trinidad and Tobago, Vol.40, No.2, (2011), pp: 61-65.
[6] Practical Electronics for Inventors, Paul Schertz, 2009
[7] International Journal of Science and Research (IJSR) Lewis Ndaro, Wang Liqiang, 2013.
[8] UN Inter-Agency Task Force on Disaster Reduction: Tenth Session Geneva, 7-8 October, 2010
[9] . Automatic Irrigation Based on Soil Moisture for Vegetable Crops:
With a previous experience working with a soil-moisture-based automatic irrigation system, Dukes et al.
(2003) found that once such a system is set up and verified, only weekly observation was required
[10] GSM based Automatic Irrigation Control System for Efficient Use of Resources and Crop Planning by
Using an Android Mobile
[11] Pavithra D.M. S .Srinath (2014), used the concept of drip irrigation to manage the watering of crops
remotely from an android cellphone was used
[12] GSM-SMS remote measurement and control system for greenhouse based on PC-based database: Shen al
(2007) introduced a GSM-SMS remote measurement and control system for greenhouse based on PC-based
database system connected with base station
APPENDICES:
Appendix A: Project budget
16
ITEMS COST(Ug shs) DESCRIPTION
Table 1: budget
Project proposal
presentation
Project research
Data accumulation
and data analysis
System design,
prototype
construction and
testing
Final presentation
and final report
preparation
Table 2: Project timeline
17
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
String str="";
#define moisture_sensorPin A0
#define float_switchPin A1
#define valvePin 4
#define soil_statusPin 6
#define tank_statusPin 7
#define pumpPin 5
const int avg_moisture = 800;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" AUTOMATIC SOLAR ");
delay(1000);
lcd.setCursor(0,1);
lcd.print(" IRRIGATION S/M ");
Serial.begin(19200); // the GPRS baud rate
delay(1000);
Serial.println("Searching network.....");
delay(1000);
Serial.println("AT");
delay(1000);
Serial.println("AT+CSMP=17,167,0,0");
delay(1000);
pinMode(moisture_sensorPin,INPUT);
pinMode(float_switchPin,INPUT);
pinMode(valvePin,OUTPUT);
pinMode(soil_statusPin,OUTPUT);
pinMode(tank_statusPin,OUTPUT);
pinMode(pumpPin,OUTPUT);
}
void loop()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" MOISTURE - ");
if(analogRead(moisture_sensorPin) > avg_moisture ){
lcd.print("LOW");
sendSMS("Moisture is LOW. Valve is OPEN");
digitalWrite(soil_statusPin,LOW);
digitalWrite(valvePin,HIGH);
delay(500);}
if(analogRead(moisture_sensorPin) < avg_moisture){
lcd.print("HIGH");
digitalWrite(soil_statusPin,LOW);
digitalWrite(valvePin,LOW);
delay(500);}
lcd.setCursor(0,1);
lcd.print("TANK LEVEL- ");
if( digitalRead(float_switchPin) == HIGH ){
lcd.print("HIGH");
18
digitalWrite(tank_statusPin,LOW);
digitalWrite(pumpPin,LOW);
delay(500);}
if( digitalRead(float_switchPin) == LOW ){
lcd.print(" LOW");
sendSMS("Tank is Low.Pump ON");
digitalWrite(tank_statusPin,HIGH);
digitalWrite(pumpPin,HIGH);
delay(500);}
}
void sendSMS(String msg)
{
lcd.clear();
lcd.print("Sending SMS");
Serial1.println("AT+CMGF=1"); // set the SMS mode to text
delay(500);
Serial1.print("AT+CMGS=");
Serial1.print('"');
Serial1.print("+256704066764"); // number
Serial1.print('"');
Serial1.println();
delay(500);
Serial1.println(msg);
delay(500);
Serial1.write(26);
delay(500);
lcd.clear();
lcd.print("SMS Sent");
delay(500);
lcd.begin(16,2);
}
19