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.
/*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.
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.
Hello guys, welcome back to my blog, This tutorial includes how to use an IR receiver and IR remote with Arduino. This tutorial also covers how to turn an LED bulb…
Hello and welcome back. In this project, we will learn how to control a lot of servo motors using the ESP32 board with a PWM servo motor driver. Also, I…
Hello, welcome back to another tutorial from the SriTu Hobby. This tutorial includes how to make a joystick module control car with Arduino. Also, this project mainly used the Arduino…
Hello, welcome back. In this tutorial, we will learn how to make a DIY Arduino CNC drawing machine at home. This project is mainly based on the L293D motor driver…
IoT based home security system using Nodemcu ESP8266 module and Telegram app Hello, welcome back to another article from SriTu Hobby. Today we are going to talk about how to…
10 Comments
Enak main feel sama lihat history bang… biar menangnya konsisten.
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.
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
Enak main feel sama lihat history bang… biar menangnya konsisten.
Thank you
LCD display does not display anything, kindley help me.
Please check your jumper wires or LCD.
Is a nice project.
Can you a integratet DHT11 and a FAN please. This make it than compleet. Thanks friend
Ok sure
Thank you…
It’s working fine, can you please use esp8266 together with arduino and integrate DHT11 and Fan, rain sensor…..
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.
How would you add blynk app if you want to control it via device?
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