Automatic Plant Watering System Using Arduino Uno and Soil Moisture Sensor

Auto Irrigation System
🌱
IoT Project

Soil Moisture Sensor
Auto Irrigation System

Build a smart watering system that reads soil moisture and automatically turns a pump on or off — your first step into real-world IoT automation.

⏱ ~45 min 🎯 Intermediate 🔌 Arduino UNO 🌐 Tinkercad

What Are We Building?

This project automatically waters your plants based on how dry the soil is. A soil moisture sensor reads the water content and sends a value to the Arduino UNO. If the soil is too dry, the Arduino switches on a DC motor (water pump) and an LED indicator. Once the soil reaches the right moisture level, everything turns off — saving water and effort.

💧

Efficient Water Use

Water only when the soil actually needs it — no guesswork.

🤖

Real Automation

Experience a complete sense-decide-act loop in a physical system.

🧑‍💻

Analog Sensing

Learn to read real-world analog values using analogRead().

Motor Control

Use digital output pins to switch a DC motor on and off safely.

What You Need

#ComponentQtyRole
1Arduino UNO×1The brain — reads sensor & controls outputs
2Soil Moisture Sensor×1Detects water content in soil (0–1023)
3DC Motor (Water Pump)×1Pumps water when soil is dry
41 kΩ Resistor×1Current limiter for the LED
5LED×1Visual indicator — ON when pump is running
6Breadboard×1Prototyping platform
7Jumper Wires×~10Connections between components

💡 Real hardware tip: When using an actual motor, always add a transistor (e.g. BC547) and a flyback diode (1N4007) to protect the Arduino from voltage spikes.

Wiring It All Together

Circuit diagram

🌿 Soil Moisture Sensor

VCC5V on Arduino
GNDGND on Arduino
A0Analog Pin A0 on Arduino

⚙️ DC Motor (Water Pump)

Terminal +Digital Pin 8 on Arduino
Terminal –GND on Arduino

💡 LED Indicator

Anode (+)Digital Pin 9 → 1 kΩ Resistor → Arduino
Cathode (–)GND on Arduino
Wiring diagram

The Logic Behind It

1

Sensor Reads Soil

Two metal probes are inserted into the soil. A small current passes between them — drier soil means higher resistance and a higher analog reading.

2

Arduino Reads the Value

The analogRead(A0) function reads a value from 0 to 1023. Lower values = wet soil. Higher values = dry soil.

3

Compare Against Threshold

The code checks the reading against a preset threshold (default: 500). Tune this after calibrating your sensor in actual soil.

4

Act on the Result

🏜 SOIL IS DRY (value < threshold)Motor turns ON · LED turns ON · Watering begins
💧 SOIL IS WET (value ≥ threshold)Motor turns OFF · LED turns OFF · Watering stops
5

Repeat Every Second

A delay(1000) at the end of the loop means the sensor is checked once every second — continuously monitoring the soil.

The Program

Copy this into the Arduino IDE or paste directly in Tinkercad's code editor.

irrigation.ino
// ── Pin Definitions ───────────────────────────
int sensorPin = A0;   // Soil moisture sensor output
int motorPin  = 8;    // DC motor / water pump
int ledPin    = 9;    // LED indicator

// ── Variables ─────────────────────────────────
int moistureValue;
int threshold = 500;   // Adjust after calibration

void setup() {
  pinMode(motorPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);   // Open Serial Monitor to see values
}

void loop() {

  moistureValue = analogRead(sensorPin);
  Serial.println(moistureValue);

  if (moistureValue < threshold) {
    // Soil is DRY → turn pump and LED ON
    digitalWrite(motorPin, HIGH);
    digitalWrite(ledPin,   HIGH);
  } else {
    // Soil is WET → turn pump and LED OFF
    digitalWrite(motorPin, LOW);
    digitalWrite(ledPin,   LOW);
  }

  delay(1000);   // Check every 1 second
}
🌊
0–300
Very Wet
Pump stays OFF
💧
300–700
Moist Soil
Ideal range
🏜
700–1023
Dry Soil
Pump turns ON

Values vary by soil type and sensor model. Calibrate by testing bone-dry soil (note value) and fully wet soil (note value), then set threshold in between.

Simulate Before You Build

No components on hand? Use Tinkercad to run the full simulation in your browser — drag the moisture slider and watch the motor and LED respond in real time.

Open in Tinkercad Simulator

The complete circuit is already wired and code is pre-loaded. Hit Start Simulation, open the Serial Monitor, and move the moisture sensor slider to test your logic.

▶ Launch Simulator ↗
🧪 What to try in the simulator:
  1. Start the simulation and open the Serial Monitor to see live moisture values.
  2. Click the sensor and drag to a low value (dry) — watch the motor and LED turn ON.
  3. Drag to a high value (wet) — watch them turn OFF.
  4. Change the threshold from 500 to 300 in the code and observe the difference.
  5. Challenge: Add a second LED on pin 10 that glows when soil is WET — modify the code!

Quick Quiz

Tap an option to check your answer instantly.

Q1. The soil moisture sensor output is connected to which Arduino pin?

Digital Pin 8
Analog Pin A0
Digital Pin 9
5V Power Pin

Q2. What happens when the moisture reading is BELOW the threshold?

Motor turns ON and LED turns ON
Motor turns OFF and LED turns OFF
Only the LED turns ON

Q3. A sensor reading of 850 means the soil is...

Very wet — pump stays OFF
Moist — ideal condition
Dry — pump would turn ON

Q4. Why is a 1 kΩ resistor used with the LED?

To make the LED glow brighter
To limit current and protect the LED
To increase sensor accuracy

Where Can You Use This?

🌾Smart FarmingLarge-scale crop irrigation with automated pumps
🏠Home GardenKeep balcony plants happy while you're away
🌿GreenhouseMaintain precise humidity for delicate plants
📱IoT FarmingAdd Wi-Fi to send moisture data to your phone
🏭School ProjectsDemo automation for science fairs
🌎ConservationReduce water waste in drought-prone regions
🚀 Ready to level up? Try these extensions:
  • Display the moisture value on a 16×2 LCD screen
  • Add a buzzer alert when soil is critically dry
  • Use an L293D motor driver to control a real pump safely
  • Log data over time using the Serial Plotter
  • Connect an ESP8266 Wi-Fi module to monitor remotely

Comments

try for free