Project Banao Smart Irrigation Project Model Kit | Arduino UNO Automatic Plant Watering System with Soil Moisture Sensor, Water Pump & Relay | DIY STEM Science Project for School Students

–

by

in

const int SENSOR_PIN = A0;
const int RELAY_PIN  = 7;
const int DRY_LIMIT  = 650;   // Calibrate for your soil

const int PUMP_ON  = LOW;     // Typical active-LOW relay
const int PUMP_OFF = HIGH;

void setup() {
  Serial.begin(9600);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, PUMP_OFF);
}

void loop() {
  int moistureValue = analogRead(SENSOR_PIN);
  Serial.println(moistureValue);

  if (moistureValue > DRY_LIMIT) {
    digitalWrite(RELAY_PIN, PUMP_ON);
    delay(3000);                 // Water for 3 seconds
    digitalWrite(RELAY_PIN, PUMP_OFF);
    delay(10000);                // Allow water to soak in
  } else {
    digitalWrite(RELAY_PIN, PUMP_OFF);
    delay(1000);
  }
}

Leave a Reply

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