Back to Blog
Arduino Projects

Arduino Automatic Plant Watering System using Soil Moisture Sensor and Relay

aquibansari12377@gmail.comaquibansari12377@gmail.com··

Introduction

Keeping your plants healthy often requires regular watering — but what if you could automate it?
In this project, we’ll create a smart plant watering system using Arduino, a soil moisture sensor, a relay module, and a mini water pump.

The system monitors the soil’s moisture level in real-time. When the soil becomes dry, Arduino automatically turns ON the pump to water the plant. Once the soil reaches an adequate moisture level, it automatically switches OFF the pump.

It’s one of the most practical and beginner-friendly Arduino automation projects, combining sensor reading, relay control, and environmental awareness.


Table of Contents

  1. Components Required
  2. Circuit Diagram & Connections
  3. Arduino Code
  4. Working Explanation
  5. Calibration Tips
  6. Applications
  7. FAQs
  8. Conclusion
  9. Similar Projects

Components Required

ComponentQuantityDescription
Arduino Uno / Nano1Controls the entire system
Soil Moisture Sensor (with Module)1Detects soil wetness level
Relay Module (5V)1Controls the water pump ON/OFF
Mini Water Pump1Waters the plant automatically
Connecting WiresFor circuit connections
Breadboard / PCB1For prototyping
12V Power Supply / Adapter1Powers the pump
5V Power (USB or adapter)1Powers Arduino

⚙️ Circuit Connections

ComponentArduino PinDescription
Soil Moisture Sensor (AO)A0Reads analog moisture data
Relay IN PinD7Controls pump switching
VCC & GND (Sensor + Relay)5V & GNDCommon power lines
PumpConnected to relay’s NO terminalSwitched by relay
Relay COM12V Power SupplyCommon input for relay

Working Flow:

  • When the soil is dry, sensor output gives LOW moisture value, and Arduino activates the relay (pump ON).
  • When the soil becomes wet, the sensor value increases, and Arduino turns OFF the relay (pump OFF).

💻 Arduino Code for Automatic Plant Watering System

Arduino
// ------------------------------------------------------------
// Project: Automatic Plant Watering System
// Author: Abdulla | Alpha DigitAll
// ------------------------------------------------------------

const int sensorPin = A0;   // Soil moisture sensor analog pin
const int relayPin = 7;     // Relay module control pin
int sensorValue = 0;        // To store sensor reading
int threshold = 500;        // Adjust based on calibration

void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH); // Relay off initially
  Serial.println("Automatic Plant Watering System Initialized");
}

void loop() {
  sensorValue = analogRead(sensorPin);
  Serial.print("Soil Moisture Value: ");
  Serial.println(sensorValue);

  if (sensorValue > threshold) {
    // Soil is dry → Turn ON the pump
    digitalWrite(relayPin, LOW);   // Active LOW relay
    Serial.println("Soil Dry - Pump ON 💧");
  } else {
    // Soil is wet → Turn OFF the pump
    digitalWrite(relayPin, HIGH);
    Serial.println("Soil Moist - Pump OFF 🌿");
  }

  delay(2000); // Delay before next reading
}

🔍 How It Works

  1. Sensor Input:
    The Soil Moisture Sensor measures the soil’s resistance — dry soil gives higher resistance, hence a higher analog value.
  2. Arduino Logic:
    The Arduino continuously reads the sensor’s analog value. If it crosses the threshold (indicating dryness), it sends a signal to the relay module.
  3. Relay Activation:
    The relay module acts as a switch — it turns the pump ON when the soil is dry and OFF when it becomes moist again.
  4. Pump Operation:
    The pump irrigates the soil until the required moisture is reached, after which the relay deactivates the pump.

🔧 Calibration Tips

  • You can determine the threshold value by printing raw sensor readings:
    • Insert the sensor in dry soil → note value.
    • Insert in wet soil → note value.
    • Set threshold roughly halfway between these two.
  • Example: Dry soil = 750, Wet soil = 350 → Threshold ≈ 550.
  • Adjust threshold in code accordingly.

🧠 Applications

  • Home garden or indoor plant care
  • Greenhouse irrigation systems
  • Smart agriculture setups
  • IoT-based soil monitoring
  • Educational electronics projects

#Arduino Projects#DIY Arduino Tutorial#Embedded Systems#Plant Watering Automation#Relay Module#Smart Garden Project#Smart Irrigation#Soil Moisture Sensor