ControlDigital ElectronicsElectronicsElectronics Engineering ProjectHow ToSensors

Smart Irrigation System – Circuit Diagram and Code

Arduino Based Smart Irrigation System

India is a country where 70% of the population depends on agriculture for their livelihood. Nowadays, every work can be done in the easiest way by the use of machines. No doubt, automation increases the productivity and saves a lot of time and effort. Irrigation is the most important part of agriculture to yield maximum profit from your investment in the field. However, there are several machines which can be used in agriculture field by farmers to ease their work. Unfortunately, such machines are not affordable by farmers due to high cost. All they need is a simple and low-cost machine that can be used easily for agricultural purposes.

In this post, we will be discussing a smart and simple irrigation system that is designed using low-cost materials. The aim of this irrigation system is to detect the moisture content in soil and run the motor pump automatically.

Apart from the agriculture field, we also need an automated plant irrigation system at our home to take care of our plants in our absence. Through this article, we will be discussing the design process of smart irrigation system project than can be used to water the plants automatically while you are sitting at the comfort of your home. You can tailor the water schedules and run time using this smart irrigation system device.

About 50% of water losses are caused due to inefficiencies of traditional irrigation systems that cause overwatering. To overcome this problem, we are going to design a smart irrigation system that checks the moisture level in soil and provide water to the plants automatically. When the circuit finds enough moisture in the soil, the motor pump gets off.

Also, we have used GSM module to update your regularly about the condition of moisture in soil and water pump. This project is highly reliable and useful to eliminate the need of manpower from irrigation process in fields.

As discussed above, we have used soil moisture sensor to sense the moisture in the soil. Before starting the project, let us take a look at the major components used in the circuit to help you clearly understand the circuit working.

Soil Moisture Sensor

There are two probes in the soil moisture sensor which is used to measure the volumetric content of water in soil. These two probes allow the current to pass through the soil and then it gets the moisture value present in the soil.

When there is water present in the soil, there will be less resistance and therefore soil will conduct electricity. As a result, the moisture level sensed by the sensor will be higher. Dry soil is a poor conductor of electricity. When there is less water in the soil, it will conduct less electricity and therefore resistance will be more. This is the reason moisture level will be lower.

Humidity, rain and Soil Moisture Sensor

Technical Specifications:

  • Input voltage – 3.3-5V
  • Output voltage- 0- 4.2 V
  • Input current- 35mA
  • Output voltage- Analog/Digital

Pinouts of Soil Moisture Sensor:

  • Vcc- Power supply
  • A0- Analog output
  • D0- Digital output
  • GND- Ground

Related Project: Rain Alarm Circuit – Snow, Water and Rain Detector Project

As discussed above, soil moisture sensor consists of two conducting plates which function as probe. As Soil moisture sensor simply acts as two conducting plates. First plate is connected to the +5v power supply. Second plate is connected directly to the ground. The output is taken directly from the first terminal of soil moisture sensor pin.

Soil moisture sensor works on the principle of open and closed circuit. When the soil is dried, no current will flow through it and it works like an open circuit. When soil is moist, the current will start flowing from one terminal to another, working as a closed circuit. We have interfaced the moisture sensor with Arduino UNO board. We will be discussing the interfacing and simulation code of the circuit in later part of this article.

Applications of Soil Moisture Sensor:

This device can be used in home gardens and lawns to eradicate the need of manual plant watering process. It can be used for interior plant to supply water regularly for irrigation.

The second most important part of this project is GSM module that is used along with the Arduino microcontroller for communication.

TTL SIM800 GSM Module:

We have used SIM800 GSM module in our irrigation system project and interfaced with the Arduino to send and receive messages. A GSM module is basically a GSM modem. This device is connected with PCB to take different types of outputs from the board. In our project, we have interface the GSM module with Arduino and TTL output is taken. This quad-band GSM module works on frequencies ranging from GSM 850MHz, EGSM 900MHz, DCS 1800MHz and PCS 1900MHz. GSM modules are highly compatible with Arduino and microcontrollers. TTL SIM800 GSM Module is assembled in 24*24*3mm size to fit almost every device be it smartphone PDA etc.TTL SIM800 GSM Module

In Asia, most of the mobile phone operators operate in the 900 MHZ band. GSM modules are manufactured by connecting a single GSM modem to PCB. Then provision of RS232 output is provided. Make sure to double check the GSM power requirement in your project before choosing the suitable GSM module for your device. Also, always choose the TTL enabled output pins to interface it directly with Arduino without any inconvenience.

Technical Specifications:

  • Quad band based
  • Required voltage -9VDC-12 VDC
  • Power supply- switching regulator based
  • Power required- 1 MA
  • Operating temperature- -40 TO + 85-degree Celsius

Features of GSM 800 Module:

  • Coding scheme- CS-1, CS-2, CS-3, CS-4 Tx power
  • It consumes low power
  • Equipped with audio channels that include a microphone input and receiver output

Now you have a good knowledge about working of both the devices namely soil moisture sensor and GSM module. Next, you have to interface both the components with Arduino microcontroller.

Arduino UNO Board

Before uncovering the details of Arduino UNO board, let us make you aware that there are various versions of Arduino boards present in the market namely Arduino mega, Arduino Due etc. We have used Arduino UNO in our project as it is the cheapest and easiest to interface microcontroller. This microcontroller consists of 14 digital I/O pins and 6 Analog pins. Arduino UNO microcontroller also supports serial communication using the TX and Rx pins. The biggest advantage of using Arduino is that you can optimize and modify the software and the Arduino board according to your requirement.

Interfacing Soil Moisture Sensor and GSM Module with Arduino

The interfacing of this circuit is simple. You just need to follow the circuit diagram.

Firstly, connect the soil moisture sensor’s analog pin to the analog pin 1 of Arduino. Now, connect the VCC and GND of sensor to the 5V and GND of Arduino.

Next, insert a sim card in the module. Now, you need to connect the GSM module with a power supply. We are using module of 12V if you have a module of 5V then you can directly power it with Arduino’s 5V. Connect a 12V source as shown in circuit diagram. Now, connect the GND pin of module with the GND of Arduino. Connect ST pin of module with digital pin 9 of the Arduino and SR pin of the module with digital pin 10 of Arduino. We’ve also connected an LCD to display the sensed moisture level. Connect the LCD as shown in circuit diagram also connect a pot to manipulate the contrast of LCD.

Connect the relay and transistor using the relay driver diagram.

Now gather the below components mentioned in the list and connect the circuit as shown in the circuit diagram:

  • Arduino UNO board
  • GSM module
  • Connecting Wires
  • Transistors
  • 16×2 LCD display
  • Power Supply
  • Relay
  • Pump
  • Soil Moisture Sensor
  • Resistors
  • Terminal Connector
  • Voltage Regulator

Circuit Diagram of Smart Irrigartion System

Programming Code Explanation

The programming part for this project is very easy. Firstly, we need to define the library for LCD and for the moisture sensor. In the next line we’ve defined the transmitter and receiver pins of sensor which are connected to digital pin 9 and 10 respectively:

#include
#include
SoftwareSerial mySerial(9,10);

Now, we have defined some variables to use them instead of using the pin numbers:

int M_Sensor = A0;
int W_led = 7;

int P_led = 13;

In the next line, we’ve defined the LCD pins connected to Arduino:

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

In the setup function, firstly we’ve initialized the LCD by lcd.begin() function and moisture sensor by using mySerial.begin() function. We’ve passed 16,2 because the LCD is having 16 columns and 2 rows and this indicates that we will be using the whole LCD. Next, we’ve initialized and defined the pin mode of digital pin 13 as output which is connected to the pump status LED and relay and pin 7 as input pin which is connected to water level led.

void setup()
{
lcd.begin(16, 2);
mySerial.begin(9600);
pinMode(7,INPUT);
pinMode(13,OUTPUT);
}

Now, come to the loop function. In the first line, we’ve cleared the LCD so that if there is any previous output that clears out. In the next line we’re fetching the moisture sensor value and storing it in a variable named ‘Moist’:

lcd.clear();
int Moist = analogRead(M_Sensor);

In the next lines we have introduced the conditions for dry, wet and soggy soils:

if (Moist> 700) // for dry soil
{
lcd.setCursor(11,0);
lcd.print(“DRY”);
lcd.setCursor(11,1);
lcd.print(“SOIL”);
if (digitalRead(W_led)==1) //test the availability of water in storage
{
digitalWrite(13, HIGH);
lcd.setCursor(0,1);
lcd.print(“PUMP:ON”);
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.println(“AT+CMGS=\”NUMBER”\r”);
delay(1000);
mySerial.println(“PUMP:ON”);
delay(100);
mySerial.println((char)26);
delay(1000);
}
else
{
digitalWrite(13, LOW);
lcd.setCursor(0,1);
lcd.print(“PUMP:OFF”);
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.println(“AT+CMGS=\”NUMBER”\r”);
delay(1000);
mySerial.println(“PUMP:OFF”);
delay(100);
mySerial.println((char)26);
delay(1000);
}
}

if (Moist>= 300 && Moist<=700) //for Moist Soil
{
lcd.setCursor(11,0);
lcd.print(“MOIST”);
lcd.setCursor(11,1);
lcd.print(“SOIL”);
digitalWrite(13,LOW);
lcd.setCursor(0,1);
lcd.print(“PUMP:OFF”);
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.println(“AT+CMGS=\”NUMBER”\r”);
delay(1000);
mySerial.println(“PUMP:OFF”);
delay(100);
mySerial.println((char)26);
delay(1000);
}

if (Moist < 300) // For Soggy soil
{
lcd.setCursor(11,0);
lcd.print(“SOGGY”);
lcd.setCursor(11,1);
lcd.print(“SOIL”);
digitalWrite(13,LOW);
lcd.setCursor(0,1);
lcd.print(“PUMP:OFF”);
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.println(“AT+CMGS=\”NUMBER”\r”);
delay(1000);
mySerial.println(“PUMP:OFF”);
delay(100);
mySerial.println((char)26);
delay(1000);
}
delay(1000);
}

Working of Automatic Irrigation System

The working of automatic irrigation system is very simple and easy to understand. In this project, Arduino is used for controlling the whole working of the circuit. First of all, when there is no moisture present in the soil, there will be conduction between two probes of the soil sensor. In result, the transistor will remain in ON state. Also, the pin13 of Arduino will remain low. After that, Arduino will send message to the user as Soil moisture is normal. Motor turned OFF”. In this situation, the motor pump will remain in “OFF” state.

When there is no moisture in the soil, transistor Q2 becomes OFF. Also, pin D7 becomes high. Consequently, the Arduino send starts the water pump and send the message to the user as Low moisture detected. Motor is turned ON. Again, the motor pump will automatically be turned OFF when there is enough moisture in the soil detected by the soil moisture sensor.

Features of Smart Irrigation System

This smart irrigation system fulfills all the criteria of an ideal irrigation system. Some of the profitable features are:

  • This smart irrigation system easily adapts with the weather condition and sense the moisture accordingly to operate the water pump
  • The soil moisture sensor easily senses the high-water flow by sensing the moisture present in soil and therefore shuts down and starts automatically
  • Using the smart irrigation system, you can manage the water flow remotely without going to the field
  • The LCD connected with the circuit displays the soil moisture data regularly which can be used to keep record of moisture at different instances

Related Project: Automatic Doorbell with Object Detection By Arduino

Bottom Line

Smart irrigation system is of great use in terms of productivity and reliability as well. Also, this device is easy to design and can be assembled using easily available electronic components. The Arduino microcontroller used in the software is very popular and can be easily interfaced without any inconvenience. We have used the soil moisture sensor to sense the moisture in the soil.

GSM module is used this project to inform the users by sending messages on their cell-phone. We have also described the working and interface method of all the components with Arduino. We hope that you will now be able to design this low-cost smart irrigation system to save water in your day to day life.

Related Projects:

Electrical Technology

All about Electrical and Electronic Engineering & Technology. Join us on WhatsApp at Electrical Technology Official Channel, to receive the latest content, articles, and updates. You can also like and follow our social media networks below, or subscribe with your email to receive premium engineering articles in your mailbox.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button