Automatic Irrigation System Using Soil Moisture and Temperature Sensor
Automatic Irrigation System Using Soil Moisture and Temperature Sensor
Abstract: Automatic irrigation system is a system which has been used in the land of crop’s to give the
water on that time of the year rainfall is not occurred. This Automatic Irrigation System has done the
work in the absence of human. We will explain about circuit design, equipment, Coding, working
procedure of Automatic Irrigation System.
Keyword: Irrigation System, Arduino Uno R3,DC power adaptor,Relay,DS18B20 temperature
sensor,Shading.
Introduction
Automatic Irrigation System is invented or made for the development of the agriculture. The moisture and
temperature of the soil is significant aspect for the growth of the crops. This Automatic Irrigation System
consist of Moisture and Temperature sensor.Basic operation of the Automatic Irrigation System is given
below:
1. The moisture and temperature sensor take the data from soil and give these data to the Arduino.
2. Arduino take the next steps according to the data of moisture and temperature sensor. These steps
are like :
When the value of water is not enough for the soil then Arduino starts the water
pumping motor which irrigate the soil.
When temperature is so high for crops to survive then Arduino helps in shading.
On the basis of farming Automatic Irrigation System has many advantages.This System can be used in
irrigation and shading without the help of human. This System preserves time and water. This system also
saves the crops from the high temperature. This System maintain Soil structure and Nutrients. In this
paper, we are explaining the system architecture, design,coding, algorithm and flowchart and other
objects.
Equipment of Automatic Irrigation System
1. Arduino Uno R3 and Arduino IDE
2. Moisture sensor(FC-28)
3. Temperature sensor(DS18B20)
4. 16×2 LCD display
5. Breadboard
6. 4.7kΩ resister
7. IC(L293D)
8. 4V DC motor
9. 6V-12V DC pumping motor
10. 5V one channel relay (jqc-3ff-s-z)
11. Power adaptor(9V,350mA)
12. Power adaptor(5V,2A)
We used Power adaptor (9V, 350mA) for supplying the power in Arduino and Power adaptor (5V, 2A)
for supplying the power in 4V DC motor and 6V-12V DC pumping motor.
We used 4.7kΩ resister to determine the exact value of value of temperature sensor. And we also used IC
(L293D) to operate the 4V DC motor.
Arduino Uno R3and Arduino ide
Arduino Uno R3 is a microcontroller board based on the ATmega328p (datasheet). It has 14 digital I/O
pins(of which 6 can be used as PWM outputs) 6 analog inputs, a 16MHz quartz crystal, a USB
connection, a power jack, an ICSP header and a reset button. Arduino has everything needed to support
the microcontroller .Any one can program it by connecting it with the computer by a USB cable. It
accepts or supports 9V to 20V DC. It controls the whole System actions.
VCC
GND
D0
A0
It has also a potentiometer. Moisture Sensor measures the soil moisture and sends it to the Arduino in the
form of data. According to data Arduino performs the next operations.
VCC
GND
SIG
SIG is known as a data wire. This sensor connected with the Arduino and it provides the data to the
Arduino from the soil.
Fig: Temperature Sensor (DS18B20)
DC motors
Motor is the main part of the automatic irrigation system. We used in this system 2 types of motor. One is
6V-12V DC pumping motor and the other is 4V DC motor. Here 6V-12V DC pumping motor is used for
irrigation. Moisture sensor measures the moisture of the soil .If the moisture value of the soil is low then
soil needs water. To give the water we used this DC pumping motor. In this System we also use 4V DC
motor for the shading. If the temperature is so high for crops to survive, the temperature sensor sends the
data to the Arduino and Arduino turn on the 4V DC motor and also arrange the shading.
Pin 1 Ground
Pin 2 5V
Pin 3 D3
Pin 4 D12
Pin 5 Ground
LCD Display Pin 6 D11
Pin 11 D10
Pin 12 D9
Pin 13 D8
Pin 14 D7
Pin 15 5V
Pin 16 Ground
Pin 1 A4
L293D(IC) Pin 2 A3
Pin 7 A2
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int flag=0;
void setup()
{
Serial.begin(9600);
pinMode(A5,INPUT); //moisture
pinMode(A1,INPUT); // Temp
pinMode(3,OUTPUT);
pinMode(6,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A4,OUTPUT);
analogWrite(3,110);
//analogWrite(6,200);
LCD.begin(16,2);
}
void loop()
{
int SensorValue=analogRead(A5);
sensors.requestTemperatures();
clrtemp();
LCD.setCursor(0,1);
LCD.print("Temp: ");
LCD.print(sensors.getTempCByIndex(0));
float sv=sensors.getTempCByIndex(0);
Serial.println(sv);
if(sv>50.0 && flag==0)
{
shadeon();
}
else if(sv<50.0 && flag==1)
{
shadeoff();
}
//Serial.println(SensorValue);
if(SensorValue>=1000)
{
clrscr();
LCD.setCursor(0,0);
LCD.print("NOT IN Soil??");
}
else if(SensorValue<1000 && SensorValue>=700)
{
clrscr();
LCD.setCursor(0,0);
LCD.print("DRY!!!");
delay(7000);
giveWater();
}
else if(SensorValue<700 && SensorValue>=500)
{
clrscr();
LCD.setCursor(0,0);
LCD.print("Humid..");
}
else if(SensorValue<500)
{
clrscr();
LCD.setCursor(0,0);
LCD.print("Enough Water..");
}
delay(1000);
}
void giveWater()
{
int k=analogRead(A5);
clrscr();
LCD.setCursor(0,0);
LCD.print("Watering...");
clrtemp();
Serial.println(k);
while(analogRead(A5)>700 )
{
Serial.println(analogRead(A5));
digitalWrite(6,HIGH);
delay(10);
}
digitalWrite(6,LOW);
clrscr();
LCD.setCursor(0,0);
LCD.print("Done...");
delay(1000);
}
void clrscr()
{
LCD.setCursor (0, 0);
for (int i = 0; i < 16; ++i)
{
LCD.print(' ');
}
}
void clrtemp()
{
LCD.setCursor (0, 1);
for (int i = 0; i < 16; ++i)
{
LCD.print(' ');
}
}
void shadeon()
{
flag=1;
analogWrite(A4,200);
analogWrite(A3,255);
analogWrite(A2,0);
delay(1000);
off();
}
void shadeoff()
{
flag=0;
analogWrite(A4,200);
analogWrite(A2,255);
analogWrite(A3,0);
delay(1000);
off();
}
void off()
{
analogWrite(A4,0);
analogWrite(A3,0);
analogWrite(A2,0);
}
Algorithm
1. Declaring library
a. Dallas Temperature
b. OneWire
c. LiquidCrystal
2. Defining pins
a. LCD
b. ONE_WIRE
3. Void setup()
a. Defining pins
i. A1-INPUT
ii. A2-OUTPUT
iii. A3-OUTPUT
iv. A4-OUTPUT
v. 3-OUTPUT
vi. 6-OUTPUT
b. Defining values:
i. 3-110
ii. 6-200
iii. LCD-begin()
4. void loop()
a. Take input: A5
i. Do
1. requestTemperature
2. clrtemp();
3. setCursor(0,1)
4. Print(“Temp: “)
5. Print(getTempCByIndex(0))
ii. SET: sv= sensors.getTempCByIndex(0)
b. IF(sv>50.0 AND flag==1)
i. DO: shadeon()
ELSE IF(sv<50.0 AND flag==0)
i. DO:shadeoff()
c. IF(Sensorvalue>=1000)
i. DO
1. Clrscr()
2. Print(“NOT IN SOIL??”)
d. ELSE IF(Sensorvalue<1000 && Sensorvalue>=700)
i. DO
1. Clrscr()
2. Print(“DRY!!!”)
3. Wait-7 sec
4. giveWater()
e. ELSE IF(Sensorvalue <700 && Sensorvalue>=500)
i. DO
1. Clrscr()
2. Print(“Humid”)
f. ELSE IF(Sensorvalue<500)
i. DO
1. Clrscr()
2. Print(“Enough Water”)
g. Wait-1 sec
5. Define Function
a. void giveWater()
i. SET:k=input(A5)
ii. Clrscr()
iii. Print(“Watering…”)
iv. Clrtemp()
v. While
1.DO
a. Read: A5
b. Write:6 –HIGH
c. Wait-10 ms
vi. Write:6-HIGH
vii. Clrscr()
viii. Print(“Done..”)
ix. Wait-1 Sec.
b. Void Clrscr()
i. For i=0 to 16
ii. Print(“ “)
c. Void shadeon()
i. SET:flag=1
ii. Write:
1. A4:200
2. A3:255
3. A2:0
iii.Wait-1 sec
iv. Off()
d. Void shadeoff()
i.SET:flag=0
ii.Write:
1.A4:200
2.A2:255
3.A3:0
iii. Wait-1 sec
iv. Off()
e. Void Off()
i.Write:
1.A4:0
2.A3:0
3.A2:0
FLOWCHART
START
True
True
Give water
3) https://www.google.com/search?client=firefox-b&biw=1536&bih=728&tbm=isch&sa=1&ei=P9DIW-
nAI8mdzwLPu6r4CQ&q=arduino+uno+r3+&oq=arduino+uno+r3+&gs_l=img.3..35i39k1j0l2j0i67k1j0j0i67
k1j0l4.27741.28413.0.29461.3.3.0.0.0.0.390.773.3-2.2.0....0...1c.1.64.img..1.2.771....0.FIE3PAUlZWI
4)https://www.google.com/search?client=firefox-
b&biw=1536&bih=728&tbm=isch&sa=1&ei=5NDIW9KPEtDYzwLFjKrICQ&q=Arduino+uno&oq=Arduino+
uno&gs_l=img.3..35i39k1l2j0l8.178629.186996.0.187407.34.18.0.0.0.0.412.2760.3-
3j4.7.0....0...1c.1.64.img..27.6.2384.0..0i67k1.0.sFhAOLrHsCI
5) https://www.google.com/search?q=5v+one+channel+relay+(jqc-3ff-s-
z)&source=lnms&tbm=isch&sa=X&ved=0ahUKEwigjoWm0ZDeAhXErFMKHfChApQQ_AUIDigB&biw=1536
&bih=754&dpr=1.25
6)https://www.google.com/search?biw=1536&bih=754&tbm=isch&sa=1&ei=99LIW7GVMsTozgKjsIuICg
&q=16%C3%972+LCD+display&oq=16%C3%972+LCD+display&gs_l=img.3..0l2j0i24k1l2.63691.66035.0.6
6866.35.9.0.0.0.0.490.883.3-1j1.2.0....0...1c.1.64.img..33.1.393.0...0.P_mVXj5SS8Q
7)https://www.google.com/search?biw=1536&bih=754&tbm=isch&sa=1&ei=RtPIW-abAo72zgLo-
bCoCg&q=Temperature+Sensor+%28DS18B20%29&oq=Temperature+Sensor+%28DS18B20%29&gs_l=i
mg.3..0i30k1l2j0i5i30k1l2j0i8i30k1l6.51615.88435.0.89514.20.10.0.0.0.0.451.828.3-
1j1.2.0....0...1c.1.64.img..18.2.826.0..0j0i24k1.0.mR-LwWSo658
8)https://www.google.com/search?biw=1536&bih=754&tbm=isch&sa=1&ei=pNPIW8zQIYyjzwKemqmQ
Cw&q=Soil+Moisture+Sensor&oq=Soil+Moisture+Sensor&gs_l=img.3..0i67k1j0l9.25643.48833.0.50522.
31.11.0.0.0.0.393.753.3-2.2.0....0...1c.1.64.img..29.2.752.0..0i30k1j0i5i30k1j0i8i30k1.0.MgePCVKCELc
9)https://www.google.com/search?biw=1536&bih=754&tbm=isch&sa=1&ei=29PIW5XTA8jVzwKg4pnICg
&q=Arduino+IDE&oq=Arduino+IDE&gs_l=img.3..35i39k1j0l9.50693.57400.0.57913.31.18.0.0.0.0.420.27
20.3-4j3.7.0....0...1c.1.64.img..24.7.2716.0..0i67k1.0.ANOgm6Bjbkg
10)https://store.arduino.cc/usa/arduino-uno-rev3