How to Use Arduino Uno to Build an Automatic Plant Watering System

In this tutorial, we will guide you through the process of creating an automatic plant watering system using Arduino Uno, a versatile microcontroller board.

This project is designed to simplify the task of watering your plants, ensuring they receive the right amount of water at the right time, even when you’re not around. By the end of this tutorial, you’ll have a fully functional system capable of keeping your plants healthy and hydrated with minimal effort.

Let’s get started!

Materials Required:

  • Arduino Uno board
  • Soil moisture sensor
  • Submersible water pump
  • Transistor (NPN)
  • Diode (1N4007)
  • Relay module
  • 12V power adapter
  • Peristaltic tubing
  • Water reservoir
  • Jumper wires
  • Breadboard
  • Enclosure (optional)
  • Screwdriver
  • Soldering iron and solder (optional)

Once you have all of the necessary materials, it’s time to start building. Here’s how:

Step 1: Set up the Hardware

Start by assembling the hardware components on a breadboard. Connect the soil moisture sensor to the Arduino Uno board using jumper wires. Then, connect the water pump to the relay module, ensuring proper polarity.

Use a separate power source for the water pump to avoid overloading the Arduino. Finally, connect the relay module to the Arduino Uno using jumper wires.

Step 2: Wire the Components

Wire the soil moisture sensor to the analog input pin of the Arduino Uno. Connect the signal pin of the sensor to analog pin A0, the VCC pin to 5V, and the GND pin to GND on the Arduino board.

Next, wire the relay module to the Arduino Uno. Connect the control pin of the relay module to digital pin 7 on the Arduino board.

Step 3: Program the Arduino Uno

Upload the Arduino sketch provided below to your Arduino Uno board using the Arduino IDE:

// Define sensor and pump pins

const int soilMoisturePin = A0;

const int pumpPin = 7;

// Define threshold for watering

const int moistureThreshold = 500;

void setup() {

// Initialize serial communication


// Set pump pin as output

pinMode(pumpPin, OUTPUT);


void loop() {

// Read soil moisture value

int moistureValue = analogRead(soilMoisturePin);

 // Print moisture value to serial monitor

Serial.print(“Moisture: “);


 // Check if soil is dry

if (moistureValue < moistureThreshold) {

 // Turn on pump

digitalWrite(pumpPin, HIGH);

delay(5000); // Run pump for 5 seconds

digitalWrite(pumpPin, LOW); // Turn off pump

Serial.println(“Watering plant…”);


 // Delay before next reading



This code continuously reads the soil moisture value from the sensor. If the moisture level falls below the defined threshold, it activates the water pump for a specified duration to water the plant.

Step 4: Assemble the System

Once you’ve uploaded the code and tested the individual components, it’s time to assemble the system.

Place the soil moisture sensor in the plant’s soil, ensuring it’s inserted deep enough to accurately measure moisture levels. Position the water pump near the plant, ensuring it’s submerged in the water reservoir.

Step 5: Power the System

Connect the Arduino Uno board to a power source using a USB cable or a suitable power adapter. Connect the power adapter to a power outlet.

Ensure that the water pump is connected to its own power source.

Step 6: Test the System

After powering up the system, monitor the serial output in the Arduino IDE to observe the soil moisture readings. Verify that the pump activates when the moisture level falls below the threshold and deactivates once the plant is watered.

Step 7: Calibration and Adjustment

Fine-tune the moisture threshold value in the Arduino code based on your plant’s watering needs.

You may need to adjust this value depending on factors such as the type of plant and environmental conditions.


Congratulations! You have successfully built an automatic plant watering system using Arduino Uno. This project demonstrates how technology can be used to automate tasks and simplify everyday life.

Feel free to customize and expand upon this project by adding features such as scheduling, remote monitoring, or integrating with a smartphone app. Happy gardening!

Leave a Reply

Your email address will not be published. Required fields are marked *