Project Overview
This project creates a smart plant watering system that reminds you to water your plants when motion is detected nearby, or automatically waters based on soil moisture. It is perfect for indoor plants that are easily forgotten.
Difficulty: Beginner/Intermediate
Estimated time: 2-3 hours
Estimated cost: $20-30
How It Works
A PIR sensor detects when someone approaches the plant. When motion is detected, a soil moisture sensor checks if watering is needed. If the soil is dry, a water pump is activated for a set duration. An LCD or LED indicates the plant’s status. Optionally, the system can water automatically on a schedule regardless of motion.
Materials Needed
- Arduino Uno or ESP32 (1)
- HC-SR501 PIR sensor (1)
- Capacitive soil moisture sensor (1)
- Submersible water pump (5V)
- MOSFET or relay module
- Water reservoir (container)
- Plastic tubing
- LCD 16×2 with I2C (optional)
- Buzzer (optional)
- LED for status
- 220Ω resistor
- Jumper wires
- Power supply (5V 2A)
Circuit Diagram
Connection Table
| Component |
Pin |
Arduino Pin |
PIR Sensor |
VCC
5V
PIR Sensor |
GND
GND
PIR Sensor |
OUT
Digital Pin 2
Soil Moisture Sensor |
VCC
5V
Soil Moisture Sensor |
GND
GND
Soil Moisture Sensor |
AO
Analog Pin A0
Relay Module |
IN
Digital Pin 3
LCD I2C |
SDA
A4
LCD I2C |
SCL
A5
Buzzer |
Positive
Digital Pin 8
Status LED |
Anode
Digital Pin 13 (via 220Ω)
表
Arduino Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int pirPin = 2;
const int pumpPin = 3;
const int moisturePin = A0;
const int buzzerPin = 8;
const int ledPin = 13;
const int dryThreshold = 500;
const int wetThreshold = 800;
unsigned long lastMotionTime = 0;
const unsigned long cooldownPeriod = 3600000;
bool wateredRecently = false;
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(pumpPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pumpPin, LOW);
digitalWrite(ledPin, LOW);
lcd.init();
lcd.backlight();
lcd.print("Plant Watering");
lcd.setCursor(0, 1);
lcd.print("System Ready");
delay(60000);
}
int readMoisture() {
int value = analogRead(moisturePin);
return value;
}
bool needsWater() {
int moisture = readMoisture();
return moisture < dryThreshold;
}
void waterPlant() {
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
digitalWrite(pumpPin, HIGH);
digitalWrite(ledPin, HIGH);
delay(5000);
digitalWrite(pumpPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
delay(200);
digitalWrite(buzzerPin, HIGH);
delay(200);
digitalWrite(buzzerPin, LOW);
wateredRecently = true;
lastMotionTime = millis();
}
void checkAndWater() {
if (needsWater()) {
if (!wateredRecently || (millis() - lastMotionTime > cooldownPeriod)) {
waterPlant();
} else {
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
delay(100);
}
}
}
void displayStatus() {
int moisture = readMoisture();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Moisture: ");
lcd.print(moisture);
lcd.setCursor(0, 1);
if (moisture < dryThreshold) {
lcd.print("DRY - Water soon");
} else if (moisture < wetThreshold) {
lcd.print("OK");
} else {
lcd.print("WET");
}
}
void loop() {
bool motionDetected = digitalRead(pirPin) == HIGH;
if (motionDetected) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
checkAndWater();
} else {
static unsigned long lastDisplay = 0;
if (millis() - lastDisplay > 10000) {
displayStatus();
lastDisplay = millis();
}
}
delay(100);
}
Installation Steps
- Assemble electronics on breadboard and test
- Calibrate soil sensor in dry and wet soil to set thresholds
- Test pump to verify water movement
- Insert soil moisture sensor into plant pot
- Mount PIR sensor to detect approach
- Place Arduino and power supply in safe location away from water
- Trigger PIR and verify watering occurs when soil is dry
Project Extensions
- Add float switch to detect when reservoir is low
- Add additional soil sensors for multi-plant watering
- Use ESP32 to send soil moisture data to phone
- Add rain sensor for outdoor plants
- Add second pump for liquid fertilizer
Conclusion
This smart plant watering system takes the guesswork out of plant care. It reminds you to water when you are near the plant and only waters when needed, preventing both under-watering and over-watering.