DIY Projects Lab
Published © CC BY-NC-SA

Automatic irrigation and plant watering system

The watering system using Arduino and soil moisture sensor. Also, we can control the water supply automatically through this system.

BeginnerFull instructions provided1 hour16,466
Automatic irrigation and plant watering system

Things used in this project

Story

Read more

Schematics

flomr33ljcvevd7_5MfpOlFFqb.jpg

Soil Moisture Wiring..

Circuit

Code

Arduino code

Arduino
#include <LiquidCrystal.h>


LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const int AirValue = 600;
const int WaterValue = 310;
const int ThresholdValue = 484;
int soilMoistureValue = 0;
const int RelayPin = 2;


void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(RelayPin, OUTPUT);
  digitalWrite(RelayPin, HIGH);
}


void loop()
{
  soilMoistureValue = analogRead(A0);
  Serial.println(soilMoistureValue);


  lcd.setCursor(0, 0);
  lcd.print("Moisture: ");
  float moisturePercentage = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  lcd.print(moisturePercentage, 0);
  lcd.print("%");


  int upperLimit = ThresholdValue + 0.1 * (AirValue - WaterValue);
  int lowerLimit = ThresholdValue - 0.1 * (AirValue - WaterValue);


  if (moisturePercentage < 30.0)
  {
    digitalWrite(RelayPin, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Pump: ON ");
  }
  else if (moisturePercentage > 70.0)
  {
    digitalWrite(RelayPin, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Pump: OFF");
  }
  else
  {
    lcd.setCursor(0, 1);
    lcd.print("Pump: ");
    if (digitalRead(RelayPin) == LOW)
    {
      lcd.print("ON");
    }
    else
    {
      lcd.print("OFF");
    }
  }


  delay(250);
  lcd.clear();
}

Credits

DIY Projects Lab

DIY Projects Lab

41 projects • 156 followers
I am a DIY hobbyist by passion and an Electronics Engineer by profession. Sponsor (PCB Manufacturer) - www.nextpcb.com

Comments