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
- Components Required
- Circuit Diagram & Connections
- Arduino Code
- Working Explanation
- Calibration Tips
- Applications
- FAQs
- Conclusion
- Similar Projects
Components Required
| Component | Quantity | Description |
| Arduino Uno / Nano | 1 | Controls the entire system |
| Soil Moisture Sensor (with Module) | 1 | Detects soil wetness level |
| Relay Module (5V) | 1 | Controls the water pump ON/OFF |
| Mini Water Pump | 1 | Waters the plant automatically |
| Connecting Wires | — | For circuit connections |
| Breadboard / PCB | 1 | For prototyping |
| 12V Power Supply / Adapter | 1 | Powers the pump |
| 5V Power (USB or adapter) | 1 | Powers Arduino |
⚙️ Circuit Connections
| Component | Arduino Pin | Description |
| Soil Moisture Sensor (AO) | A0 | Reads analog moisture data |
| Relay IN Pin | D7 | Controls pump switching |
| VCC & GND (Sensor + Relay) | 5V & GND | Common power lines |
| Pump | Connected to relay’s NO terminal | Switched by relay |
| Relay COM | 12V Power Supply | Common 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
1// ------------------------------------------------------------2// Project: Automatic Plant Watering System3// Author: Electronixity4// Blog: https://www.electronixity.com/blog/arduino-plant-watering-system5// ------------------------------------------------------------6 7const int sensorPin = A0; // Soil moisture sensor analog pin8const int relayPin = 7; // Relay module control pin9int sensorValue = 0; // To store sensor reading10int threshold = 500; // Adjust based on calibration11 12void setup() {13 Serial.begin(9600);14 pinMode(relayPin, OUTPUT);15 digitalWrite(relayPin, HIGH); // Relay off initially16 Serial.println("Automatic Plant Watering System Initialized");17}18 19void loop() {20 sensorValue = analogRead(sensorPin);21 Serial.print("Soil Moisture Value: ");22 Serial.println(sensorValue);23 24 if (sensorValue > threshold) {25 // Soil is dry → Turn ON the pump26 digitalWrite(relayPin, LOW); // Active LOW relay27 Serial.println("Soil Dry - Pump ON 💧");28 } else {29 // Soil is wet → Turn OFF the pump30 digitalWrite(relayPin, HIGH);31 Serial.println("Soil Moist - Pump OFF 🌿");32 }33 34 delay(2000); // Delay before next reading35}🔍 How It Works
- Sensor Input:
The Soil Moisture Sensor measures the soil’s resistance — dry soil gives higher resistance, hence a higher analog value. - 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. - 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. - 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
