How to make an automatic irrigation and plant watering system using Arduino and soil moisture sensor | Step by step instruction

 Automatic irrigation and plant watering system using Arduino and soil moisture sensor

                Hello, welcome back. In this tutorial, I will show you how to make automatic irrigation and plant watering system using Arduino and soil moisture sensor. Also, we can control the water supply automatically through this system. This can be done in such a way that when the soil is dry, the motor automatically activates and when the soil gets wet, it becomes inactive again. Also, we can use this project for mainly Small gardens, flower gardens, or greenhouses. The soil moisture sensor is mainly used for this design. An LCD display is also used to monitor the soil moisture level. Also, you can also connect a motor pump or a buzzer to the relay here.

The process of this irrigation system

When this is activated, the system starts to work. After, the soil moisture sensor probe should be inserted into the soil. Then, the moisture content of the soil is displayed on the LCD as Low, Medium, and High. Also, the relay module is activated automatically in the LOW situation and deactivated in MEDIUM and HIGH situations. If a water pump is connected to the relay module, it will automatically turn on and off.
 
So, let’s do this project step by step. The required components are given below. 
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Arduino UNO board

Soil moisture sensor

 

Relay module

LCD display 

I2C module

Li-ion battery and Battery holder

Jumper wires 

Foamboard

You can use foam board or cardboard.

Step 2

Second, cut the foam board pieces as follows.
 
 

Step 3

Thirdly, adjust the 1.5 x 3-inch piece to fit the Arduino board and glue it to the 3 x 4.5-inch piece. 
 

Step 4

Now, glue the 1.5 x 4.5-inch piece to the base piece.
 
 

Step 5

Then, connect the relay module and soil moisture sensor to the Arduino board. For that, use the circuit diagram below.
 
Automatic irrigation and plant watering system using Arduino and soil moisture sensor
 
 

Step 6

OK, now glue the Soil moisture sensor to the base piece. Then, take a 3 x 4.5-inch piece and attach the LCD display to its center.
 

Step 7

Now, glue the 1.5 x 3-inch piece to the base foam board piece. Then, connect the LCD display to the Arduino board.
 

Step 8

Next, attach the relay module as follows. Then, glue the 1.5 x 4.5-inch piece to the base foam board to fit the relay module.
 

Step 9

Now, glue the top lid on this project and connect this project to the computer.
 

Step 10

OK, let’s creates the program for this project. It is as follows.
 
I2C library — Download
The complete program of this project – Download
/*How to make an Irrigation system.
 * This code creates by the SriTu Hobby team.
 * https://srituhobby.com
 */
 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C dis(0x27, 16, 2);
 
void setup() {
  Serial.begin(9600);
  dis.init();
  dis.backlight();
  dis.clear();
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  delay(1000);
  dis.setCursor(0, 0);
  dis.print("IRRIGATION");
  dis.setCursor(0, 1);
  dis.print("SYSTEM IS ON ");
  for (int a = 12; a <= 15; a++) {
    dis.setCursor(a, 1);
    dis.print(".");
    delay(1500);
  }
  dis.clear();
}
 
void loop() {
  int value = analogRead(A0);
  Serial.println(value);
  if (value > 950) {
    digitalWrite(2, LOW);
    dis.setCursor(0, 0);
    dis.print("MOTOR IS ON ");
  } else {
    digitalWrite(2, HIGH);
    dis.setCursor(0, 0);
    dis.print("MOTOR IS OFF");
  }
 
  if (value < 300) {
    dis.setCursor(0, 1);
    dis.print("MOISTURE : HIGH");
  } else if (value > 300 && value < 950) {
    dis.setCursor(0, 1);
    dis.print("MOISTURE : MID ");
  } else if (value > 950) {
    dis.setCursor(0, 1);
    dis.print("MOISTURE : LOW ");
  }
}

Code explanation

First, the I2C library is included and creates the object for this library. It includes the I2C address and the LCD height and width.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C dis(0x27, 16, 2);
 
In the setup function, the LCD display is started and the relay module connected pin set as output. Also printed on the LCD as “IRRIGATION SYSTEM IS ON”.
void setup() {
  Serial.begin(9600);
  dis.init();
  dis.backlight();
  dis.clear();
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  delay(1000);
  dis.setCursor(0, 0);
  dis.print(“IRRIGATION”);
  dis.setCursor(0, 1);
  dis.print(“SYSTEM IS ON “);
  for (int a = 12; a <= 15; a++) {
    dis.setCursor(a, 1);
    dis.print(“.”);
    delay(1500);
  }
  dis.clear();
}
 
In the loop function, the sensor values are taken and inserted into the variable named “value”. Afterward, if these values are less than 300, they are printed as “HIGH” on the LCD, “MID” between 300 and 950, and “LOW” above 950. Also. If the value is greater than 950, the relay module is activated.
void loop() {
  int value = analogRead(A0);
  Serial.println(value);
  if (value > 950) {
    digitalWrite(2, LOW);
    dis.setCursor(0, 0);
    dis.print(“MOTOR IS ON “);
  } else {
    digitalWrite(2, HIGH);
    dis.setCursor(0, 0);
    dis.print(“MOTOR IS OFF”);
  }
 
  if (value < 300) {
    dis.setCursor(0, 1);
    dis.print(“MOISTURE : HIGH”);
  } else if (value > 300 && value < 950) {
    dis.setCursor(0, 1);
    dis.print(“MOISTURE : MID “);
  } else if (value > 950) {
    dis.setCursor(0, 1);
    dis.print(“MOISTURE : LOW “);
  }
}
 

Step 11

OK, now select board and port. After, upload this code to the Arduino board.
 
Automatic irrigation and plant watering system using Arduino and soil moisture sensor code upload

Step 12

Lastly, connect the battery holder to this project and connect it Arduino board. OK, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.
 
 

 How to make automatic irrigation and plant watering system using Arduino and soil moisture sensor | Step by step instruction

Similar Posts

10 Comments

  1. Is a nice project.
    Can you a integratet DHT11 and a FAN please. This make it than compleet. Thanks friend

  2. Thank you…
    It’s working fine, can you please use esp8266 together with arduino and integrate DHT11 and Fan, rain sensor…..

  3. This sounds great and I’m looking forward to making it for my plants. How would you add multiple sensors to the project so you can water more than a single plant? Thanks for the tutorial.

  4. it showing this type pf error what should i do
    C:\Users\aadi\Downloads\irrigation_system\irrigation_system.ino:1:9: fatal error: LiquidCrystal_I2C.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~~~~~
    compilation terminated.

    exit status 1

    Compilation error: LiquidCrystal_I2C.h: No such file or directory

Leave a Reply

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