Smart Irrigation System using Arduino

Project Overview

This project automatically waters plants based on soil moisture level. It also measures temperature and humidity using the DHT11 sensor and displays the temperature on an I2C LCD display.

Features

  • Automatic irrigation based on soil moisture
  • Temperature and humidity monitoring
  • LCD display output
  • Water pump control using relay
  • Low-cost and beginner-friendly IoT/agriculture project

Components Required

ComponentQuantity
Arduino UNO1
Soil Moisture Sensor1
DHT11 Temperature & Humidity Sensor1
16×2 I2C LCD Display1
Relay Module (5V)1
Mini Water Pump1
Jumper WiresAs needed
Breadboard1
Power Supply1

Working Principle

The soil moisture sensor measures the moisture level in the soil.

  • If soil becomes dry:
    • Arduino turns ON the relay
    • Relay activates the water pump
    • Plants get watered
  • If soil is wet:
    • Pump remains OFF

The DHT11 sensor continuously measures:

  • Temperature
  • Humidity

The temperature is displayed on the I2C LCD module.


Circuit Connections

1. Soil Moisture Sensor Connections

Sensor PinArduino Pin
VCC5V
GNDGND
AOA0

2. DHT11 Sensor Connections

DHT11 PinArduino Pin
VCC5V
GNDGND
DATAD2

3. I2C LCD Connections

LCD PinArduino Pin
VCC5V
GNDGND
SDAA4
SCLA5

4. Relay Module Connections

Relay PinArduino Pin
VCC5V
GNDGND
IND7

5. Water Pump Connections

  • Pump Positive → Relay NO terminal
  • Pump Negative → Battery Negative
  • Relay COM → Battery Positive

Arduino Libraries Required

Install these libraries from Arduino IDE Library Manager:

  1. DHT sensor library
  2. Adafruit Unified Sensor
  3. LiquidCrystal_I2C

Complete Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// DHT Sensor Setup
#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

// LCD Setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Soil Moisture Sensor
int soilPin = A0;
int soilValue = 0;

// Relay Setup
int relayPin = 7;

// Threshold value
int threshold = 500;

void setup() {

  Serial.begin(9600);

  // Initialize DHT sensor
  dht.begin();

  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Relay Pin
  pinMode(relayPin, OUTPUT);

  // Initially turn OFF pump
  digitalWrite(relayPin, HIGH);

  lcd.setCursor(0,0);
  lcd.print("Smart Irrigation");
  delay(2000);
  lcd.clear();
}

void loop() {

  // Read Soil Moisture
  soilValue = analogRead(soilPin);

  // Read Temperature and Humidity
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  // Display on Serial Monitor
  Serial.print("Soil Moisture: ");
  Serial.println(soilValue);

  Serial.print("Temperature: ");
  Serial.println(temperature);

  Serial.print("Humidity: ");
  Serial.println(humidity);

  // Display on LCD
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print((char)223);
  lcd.print("C ");

  lcd.setCursor(0,1);

  // Soil Condition Logic
  if (soilValue > threshold) {

    lcd.print("Soil Dry  PumpON");

    // Turn ON Pump
    digitalWrite(relayPin, LOW);

  } else {

    lcd.print("Soil Wet PumpOFF");

    // Turn OFF Pump
    digitalWrite(relayPin, HIGH);
  }

  delay(2000);
}

How to Upload the Code

  1. Open Arduino IDE
  2. Connect Arduino UNO
  3. Select:
    • Board → Arduino UNO
    • Port → Correct COM Port
  4. Paste the code
  5. Click Upload

Testing the Project

Dry Soil Test

  • Remove sensor from wet soil
  • Pump should turn ON

Wet Soil Test

  • Insert sensor into wet soil
  • Pump should turn OFF

Applications

  • Smart agriculture
  • Home gardening
  • Greenhouse monitoring
  • Water-saving systems
  • Automatic plant watering

Advantages

  • Saves water
  • Reduces human effort
  • Low cost
  • Easy to build
  • Energy efficient

Future Improvements

You can upgrade this project by adding:

  • WiFi monitoring using ESP8266
  • Mobile app control
  • IoT dashboard
  • Rain sensor
  • Solar power supply
  • Automatic fertilizer system

Troubleshooting

LCD Not Displaying

  • Check I2C address
  • Try:
0x27 or 0x3F

Pump Not Working

  • Check external power supply
  • Verify relay connections

Incorrect Sensor Readings

  • Ensure proper wiring
  • Avoid loose jumper wires

Conclusion

This Smart Irrigation System is an excellent beginner Arduino project that demonstrates automation in agriculture. It helps conserve water by watering plants only when needed and provides real-time environmental monitoring using the DHT11 sensor and LCD display.

It is a practical project for students, hobbyists, and IoT beginners.