Automated Irrigation System Based on Rainfall

Automated Irrigation System Based on Rainfall Using Arduino

This smart irrigation system automates watering based on rainfall detection, using an Arduino Uno, a rain sensor module, a relay module, and a water pump.

Key Components & Their Roles

  1. Arduino Uno – Microcontroller that processes signals from the rain sensor.
  2. Rain Sensor Module – Detects rainfall and sends an analog signal to the Arduino.
  3. Relay Module – Controls the pump based on Arduino’s instructions.
  4. Water Pump – Delivers water when no rainfall is detected.
  5. 9V Battery – Powers the pump when activated.

Working Principle

  • The rain sensor module continuously detects rainfall levels.
  • If rain is detected, the sensor sends a signal to the Arduino Uno.
  • The Arduino Uno processes the signal and deactivates the relay module, preventing the pump from running.
  • If no rain is detected, the Arduino activates the relay module, turning on the water pump to irrigate the plants.
  • This prevents overwatering and conserves water resources.

Wiring Connections

ComponentArduino Uno Pin
Rain Sensor (AO)A0
Rain Sensor (VCC)5V
Rain Sensor (GND)GND
Relay Module (Signal)D7
Relay Module (VCC)5V
Relay Module (GND)GND
Pump (Positive)Relay NO (Normally Open)
Pump (Negative)Relay Common
Battery (Positive)Relay NC (Normally Closed)

CODE

#define RAIN_SENSOR_PIN A0  // Analog pin connected to the rain sensor
#define RELAY_PIN 7         // Digital pin connected to the relay module

void setup() {
  // Start serial communication for debugging
  Serial.begin(9600);

  // Set relay pin as output
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);  // Start with the pump off

  // Display a setup message
  Serial.println("Automated Irrigation System Initialized.");
}

void loop() {
  // Read the analog value from the rain sensor
  int sensorValue = analogRead(RAIN_SENSOR_PIN);

  // Convert the sensor value to a percentage (0-1023 range to 100-0%)
  float rainfallIntensity = map(sensorValue, 0, 1023, 100, 0);

  // Print the sensor value to the Serial Monitor
  Serial.print("Rainfall Intensity: ");
  Serial.print(rainfallIntensity);
  Serial.println(" %");

  // Check if the rainfall intensity indicates rain (adjust threshold as needed)
  if (rainfallIntensity > 20) {  // Adjust 20% as the threshold for "wet" condition
    // If it is raining, keep the pump off
    digitalWrite(RELAY_PIN, LOW);
    Serial.println("Rain detected. Pump is OFF.");
  } else {
    // If it is not raining, turn the pump on
    digitalWrite(RELAY_PIN, HIGH);
    Serial.println("No rain detected. Pump is ON.");
  }

  // Delay for a brief moment before the next reading
  delay(1000);
}

Advantages of This System

Automated Watering – Saves manual effort and ensures proper irrigation.
Water Conservation – Only irrigates when necessary, avoiding waste.
Protection Against Overwatering – Prevents excess moisture that can harm plants.
Easy to Build – Uses simple components for effective automation.

Leave a Reply

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

More Articles & Posts