Automatic Water Irrigation System with Soil Moisture Sensor and Arduino

This project outlines how to build an Automatic Water Irrigation System using an Arduino Uno and a Soil Moisture Sensor. This smart system monitors the soil’s moisture level and automatically turns a water pump ON or OFF, ensuring plants are watered only when necessary, which saves water and promotes healthier plant growth.


Components Required: (Affiliated Links)

  1. Arduino Uno Board:https://amzn.to/3opv2lP
  2. Soil Moisture Sensor:https://amzn.to/3yhzEPl
  3. 5V Relay Module:https://amzn.to/3bwCl5W
  4. Water Pump (Submersible DC Motor):https://amzn.to/3fmCrhI
  5. Male and Female Jumper Wires:https://amzn.to/3tUOI1Q

Wiring the Components

The system connects the sensor to the Arduino’s input and the relay to its output:

Component PinArduino Pin
Soil Sensor VCC3.3V Supply Pin
Soil Sensor GNDGND Pin
Soil Sensor A0 (Analog Out)Analog Pin A0
Relay VCC5V Supply Pin
Relay GNDGND Pin
Relay IN1Digital Pin D4

Power and Pump Wiring

The relay is used to switch the power to the water pump based on the Arduino’s command:

  1. Motor Power Connection: The pump’s power supply (or the AC plug if using an AC pump) is interrupted by the relay.
  2. Relay as a Switch: One line of the pump’s power source is connected to the Common (COM) terminal of the relay module.
  3. The other line leading to the pump motor is connected to the Normally Open (NO) terminal of the relay. This ensures that the pump only turns ON when the Arduino tells the relay to switch (i.e., when the soil is dry).

Code


const int soilSensorPin = A0;    // Soil sensor analog output to Arduino A0
const int relayPin = 4;          // Relay IN1 to Digital Pin D4

void setup() {
  pinMode(relayPin, OUTPUT);    // Set relay pin as output
  digitalWrite(relayPin, LOW);  // Keep relay OFF (pump OFF) at start
  Serial.begin(9600);           // Optional for debugging
}

void loop() {
  int soilMoisture = analogRead(soilSensorPin); // Read sensor value
  Serial.println(soilMoisture); // Print moisture value for debugging

  // Set your threshold value (adjust as needed)
  int threshold = 500; // Example: below 500 means soil is dry

  if (soilMoisture < threshold) {
    digitalWrite(relayPin, HIGH); // Turn ON relay (pump ON)
  } else {
    digitalWrite(relayPin, LOW);  // Turn OFF relay (pump OFF)
  }

  delay(1000); // Wait for 1 second before next reading
}


Watch the full video tutorial here: How to make an Automatic water irrigation system using soil moisture sensor and arduino at Home

More Articles & Posts