Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA
Delivering to
Select Location ▾
Delivering to Select Location
▾

Smart Irrigation System Using Arduino (Pump + Relay Guide)

Smart Irrigation System Using Arduino (Pump + Relay Guide)
-
Written By - Robocraze -
📅 Updated on 22 Oct 2026
✨ Summarize with AI
✅ Prompt copied

Summary

Efficient water management is an important part of plant care, but fixed watering schedules do not always reflect actual soil conditions. Soil moisture can change throughout the day due to sunlight, temperature, and plant water consumption. This often results in plants receiving either too much or too little water.

In this project, we will build a Smart Irrigation System using Arduino Uno that automatically waters plants based on soil moisture levels. Using a soil moisture sensor, relay module, water pump, and LCD display, the system continuously monitors the soil and activates irrigation only when it is needed. 

Smart Irrigation System Using Arduino Uno: Automatic Plant Watering Project - Cover image

A smart irrigation system using Arduino Uno automatically waters plants when the soil becomes too dry. It uses a soil moisture sensor to measure the soil condition, an Arduino Uno to process the sensor reading, a relay module to switch a water pump, and a 12V DC mini submersible pump to deliver water to the plant.

This project is suitable for home gardens, potted plants, school science exhibitions and beginner electronics projects. With a capacitive soil moisture sensor, a 1-channel relay and a 12V pump, you can build an automatic plant watering system without needing to switch the pump on manually every time the soil dries out.

In this guide, you will learn how the system works, which components you need, how to connect the sensor and pump to an Arduino Uno, and how to calibrate the moisture threshold. You will also learn how to prevent excessive watering and upgrade the project with an ESP32 or rain sensor.

What Is a Smart Irrigation System?

A smart irrigation system monitors soil moisture and waters plants when the moisture level falls below a selected threshold. Unlike a basic timer-based watering system, a soil moisture-based system responds to the condition of the soil.

For this project, the Arduino Uno reads a capacitive soil moisture sensor. When the soil becomes too dry, the Arduino activates a relay that switches on a 12V DC mini submersible water pump. When the soil reaches the desired moisture level, the Arduino switches the pump off.

The main components are:

  • Arduino Uno: Reads the sensor and controls the pump.

  • Capacitive soil moisture sensor: Measures changes associated with soil moisture.

  • 1-channel relay module: Switches the pump's power supply.

  • 12V DC mini submersible pump: Moves water from a reservoir to the plant.

  • 12V power supply: Powers the pump.

  • Jumper wires and a suitable container: Connect the electronics and hold the water.

The goal is to keep the soil within a useful moisture range, not to keep it continuously wet. The correct threshold depends on the sensor, soil type, plant and sensor placement.

Components and Supplies

Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

    Arduino Uno R3 Original

    Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
    Rs 2,750/-
    Rs 2,750/-
    Rs 3,499/-
    Save Rs 749/-
    Soil Moisture Sensor Module - Measures soil moisture for smart gardening. -Soil Moisture Sensor -RobocrazeSoil Moisture Sensor Module - Measures soil moisture for smart gardening. -Soil Moisture Sensor -Robocraze

      Soil Moisture Sensor Module (Analog + Digital Output)

      Soil Moisture Sensor Module (Analog + Digital Output) The Soil Moisture Sensor Module is a simple and affordable solution for detecting moisture levels in soil, ideal for building DIY plant watering systems and smart irrigation projects. Designed for makers, students, and IoT developers, it...
      Rs 40/-
      Rs 40/-
      Rs 69/-
      Save Rs 29/-
      20x4 LCD Display Module (Blue) - 20x4 blue LCD display for Arduino & embedded applications. -LCD Display -Robocraze20x4 LCD Display Module (Blue) - 20x4 blue LCD display for Arduino & embedded applications. -LCD Display -Robocraze

      20x4 LCD Display Module (Blue) 2004A

      20x4 LCD Display Module (Blue) This is the 2004A Parallel LCD Display Module (Blue), A display is required if you want to add visual output to your Arduino projects. If you only need a small amount of data displayed, the LCD 20x4 Parallel LCD...
      Rs 284/-
      Rs 284/-
      Rs 449/-
      Save Rs 165/-
      5V 30A 1-Channel Relay Module – 5V single-channel high-power relay for heavy loads. -Relay Module -Robocraze5V 30A 1-Channel Relay Module – 5V single-channel high-power relay for heavy loads. -Relay Module -Robocraze

        5V 30A 1-Channel Relay Module

        5V 30A 1-Channel Relay Module The 5V 30A 1-Channel Relay Module comes with LED indicators, It can be controlled by microcontrollers such as Arduino, AVR, PIC, ARM any other microcontroller operating at 5V. The relay module uses an authentic quality mechanical relay and the industry's top...
        Rs 145/-
        Rs 145/-
        Rs 199/-
        Save Rs 54/-
        12V Mini Submersible Water Pump – 10 L/min, 8W12V Mini Submersible Water Pump – 10 L/min, 8W

          12V Mini Submersible Water Pump – 10 L/min, 8W

          12V Mini Submersible Water Pump – 10 L/min, 8W The 12V Mini Submersible Water Pump is a compact and practical solution for moving and circulating water in DIY, educational, automation and small-scale water systems. Operating from a 12V DC supply, this fully submersible pump...
          Rs 278/-
          Rs 278/-
          Rs 439/-
          Save Rs 161/-
          9V HW High-Quality Battery – 9V battery for smoke detectors, toys & electronics.-HW Battery -Robocraze9V HW High-Quality Battery – 9V battery for smoke detectors, toys & electronics.-HW Battery -Robocraze

            9V Original HW High-Quality Battery

            High-Quality Original 9V HW Battery Hi-Watt 9V Battery is a high-capacity & low-cost solution for many electronic devices. It is used with its specific battery snap, The HW battery clip can be used to power LEDs or other devices with a 9V battery. It is Used...
            Rs 25/-
            Rs 25/-
            Rs 35/-
            Save Rs 10/-
            Jumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - RobocrazeJumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - Robocraze

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each)

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each) These DuPont jumper wires for electronics are premium quality wire manufactured by using quality assured material and advanced techniques, which make them up to the standard in this highly challenging field. This 120pcs Dupont...
            Rs 164/-
            Rs 164/-
            Rs 169/-
            Save Rs 5/-

            Components Required for the Arduino Irrigation Project

            The following components are enough to build a basic automatic plant watering system.

            Component

            Purpose

            Arduino Uno

            Reads soil moisture and controls watering

            Capacitive soil moisture sensor

            Detects changes in soil moisture

            1-channel 5V relay module

            Switches the pump supply

            12V DC mini submersible water pump

            Pumps water from a reservoir

            12V DC power supply

            Powers the pump

            Jumper wires

            Connects the sensor, Arduino and relay

            Water reservoir and tubing

            Stores and delivers water

            Breadboard or suitable wiring terminals

            Helps connect the low-voltage electronics

            The linked Robocraze pump is listed as a 12V, 8W model with a maximum flow rate of 10 litres per minute. Actual flow depends on the lift height, tubing and outlet restrictions. This is a relatively high flow rate for watering a small pot, so use short pump run times and test the amount of water delivered before leaving the system unattended.

            Robocraze

             

            A capacitive moisture sensor is preferable to many basic resistive probes for projects that stay in soil for extended periods. However, it still needs calibration and should not be left immersed in water unless its manufacturer explicitly permits that use.

            How the Smart Irrigation System Works

            The system follows a simple control cycle:

            1. The soil moisture sensor measures the condition of the soil.

            2. The Arduino reads the sensor's analog output.

            3. The reading is compared with a threshold selected during calibration.

            4. If the soil is dry, the Arduino activates the relay.

            5. The relay switches on the 12V pump, delivering water to the plant.

            6. When the target moisture level is reached, the Arduino switches the pump off.

            The pump should not be powered from an Arduino GPIO pin. The GPIO pin sends a control signal to the relay module, while a separate 12V supply provides power to the pump.

            The code should also limit how long the pump can run in one watering cycle. This reduces the chance of flooding if the sensor becomes disconnected or the moisture reading does not change as expected.

            Wiring the Soil Moisture Sensor, Relay and 12V Pump

            Before wiring, check the pin labels and voltage requirements of your particular sensor and relay board. The connections below assume a capacitive sensor with VCC, GND and AO pins, a 5V relay module, and a 12V DC pump.

            1. Connect the capacitive soil moisture sensor

            Sensor pin

            Arduino Uno connection

            VCC

            5V, if supported by the sensor

            GND

            GND

            AO

            Analog pin A0

            The sensor's analog output changes with soil moisture. The direction and range of the readings depend on the sensor, so do not assume a universal dry or wet value.

            2. Connect the relay module

            Relay pin

            Arduino Uno connection

            VCC

            5V, if supported by the relay board

            GND

            GND

            IN

            Digital pin 7

            Many relay modules are active LOW, meaning the relay switches on when the control input is LOW. Others are active HIGH. Check the module documentation and test its behaviour before connecting the pump.

            3. Connect the 12V pump through the relay contacts

            Use the relay's contact terminals to switch the pump's 12V supply. For a typical arrangement using normally open contacts:

            Connection

            Wiring

            12V supply positive

            Relay COM

            Relay NO

            Pump positive

            Pump negative

            12V supply negative

            With this arrangement, the pump receives power only when the relay energises and closes the COM to NO connection. The pump's 12V supply does not connect to an Arduino digital pin.

            Use a relay whose contact rating is suitable for the pump's DC voltage and starting current. A motor can draw more current when starting than it draws while running. If you use a MOSFET driver instead, choose one designed for the pump's current and provide appropriate protection against motor switching transients.

            Keep water away from the Arduino, relay contacts, connectors and power supply. Secure the reservoir and tubing to prevent leaks from reaching the electronics. Use a suitable enclosure and keep all electrical connections dry.

            Arduino Code for Automatic Plant Watering

            This sketch reads the capacitive soil moisture sensor and switches the relay when the soil is dry. It also limits each pump run to a maximum of five seconds, then pauses to let the water spread through the soil before taking another reading.

            The example assumes the sensor's reading is higher when dry and lower when wet, which is common for many capacitive sensors. Verify this with your own sensor before using the code. It also assumes an active LOW relay module. If your relay is active HIGH, change the relay logic accordingly.

            const int moisturePin = A0;
            const int relayPin = 7;
            
            // Example starting threshold only.
            // Calibrate these values for your sensor and soil.
            const int dryThreshold = 600;
            const int wetThreshold = 450;
            
            const unsigned long maxPumpTime = 5000;
            const unsigned long soakTime = 10000;
            
            bool pumpRunning = false;
            bool waitingForSoak = false;
            
            unsigned long pumpStartTime = 0;
            unsigned long soakStartTime = 0;
            
            int readMoisture() {
              long total = 0;
            
              for (int i = 0; i < 10; i++) {
                total += analogRead(moisturePin);
                delay(10);
              }
            
              return total / 10;
            }
            
            void pumpOn() {
              digitalWrite(relayPin, LOW);  // Active LOW relay
              pumpRunning = true;
              pumpStartTime = millis();
            
              Serial.println("Pump ON");
            }
            
            void pumpOff() {
              digitalWrite(relayPin, HIGH); // Active LOW relay
              pumpRunning = false;
              waitingForSoak = true;
              soakStartTime = millis();
            
              Serial.println("Pump OFF");
            }
            
            void setup() {
              Serial.begin(9600);
            
              digitalWrite(relayPin, HIGH);
              pinMode(relayPin, OUTPUT);
            
              pumpOff();
            
              Serial.println("Smart irrigation system ready");
            }
            
            void loop() {
              int moisture = readMoisture();
            
              Serial.print("Moisture reading: ");
              Serial.println(moisture);
            
              if (pumpRunning) {
                if (millis() - pumpStartTime >= maxPumpTime) {
                  pumpOff();
                }
              } else if (waitingForSoak) {
                if (millis() - soakStartTime >= soakTime) {
                  waitingForSoak = false;
                }
              } else if (moisture >= dryThreshold) {
                pumpOn();
              } else if (moisture <= wetThreshold) {
                Serial.println("Soil moisture is sufficient");
              }
            
              delay(200);
            }

            How the code works

            • moisturePin reads the sensor through A0.

            • readMoisture() averages ten readings to reduce small fluctuations.

            • dryThreshold sets the reading at which watering starts.

            • wetThreshold provides a lower stopping threshold, reducing rapid switching near the threshold.

            • maxPumpTime limits each pump run to five seconds.

            • soakTime pauses watering so water can spread before the next decision.

            • pumpOn() and pumpOff() control the relay.

            The threshold values of 600 and 450 are examples, not universal calibration values. If your sensor produces lower readings when dry, reverse the comparison logic and choose thresholds based on your measurements.

            Code note: The five-second run limit is a safeguard for a beginner prototype, not a guarantee against overwatering. Test the water volume delivered during five seconds and adjust the run time to suit the plant, pot and pump. For a more robust design, add a sensor fault check, a manual override and a longer lockout if the moisture reading fails to change.

            Calibrating the Soil Moisture Sensor

            Calibration is necessary because capacitive soil moisture sensors can produce different readings depending on their design, supply voltage, soil type and placement.

            Step 1: Read the sensor in dry soil

            Upload a simple analog-reading sketch or use the main project code. Place the sensor in the soil you intend to use, keeping the sensing area at a consistent depth. Record the reading when the soil is dry enough to need watering.

            Do not assume that a reading of 600 always means dry soil. It is only an example threshold.

            Step 2: Record the reading in moist soil

            Water the soil and wait for the moisture to distribute. Record the sensor value again. Repeat the measurement at different moisture levels to understand how the readings change.

            Step 3: Set the thresholds

            Choose a dry threshold that starts watering and a separate wet threshold that stops the pump or prevents another watering cycle. The gap between the thresholds helps prevent rapid switching when readings fluctuate slightly.

            For example, if your readings are around 700 in dry soil and 400 in moist soil, you could begin testing with a dry threshold near 650 and a wet threshold near 450. These values are illustrative. Confirm the correct thresholds with your own sensor and soil.

            Step 4: Test the amount of water delivered

            Run the pump for a short, measured interval and observe how much water reaches the plant. If the pot becomes saturated quickly, reduce the run time. If the water does not reach the root zone, check the tubing, pump lift and sensor location.

            Place the sensor away from the immediate water outlet so it measures the broader soil condition rather than a small, freshly watered patch.

            Pump vs Solenoid Valve for Irrigation

            A pump and a solenoid valve perform different jobs. A pump moves water, while a solenoid valve opens or closes a water path.

            Feature

            12V submersible pump

            Solenoid valve

            Main function

            Moves water from a reservoir

            Controls flow through a pipe

            Requires a water source

            Yes

            Yes, plus sufficient pressure or flow

            Best for

            Tank-based watering and small reservoirs

            Systems with an existing pressurised or gravity-fed supply

            Arduino control

            Relay or suitable MOSFET driver

            Relay or suitable driver matched to the valve

            Main consideration

            Flow rate, lift height and pump current

            Valve voltage, pressure rating and whether it is normally open or normally closed

            For a potted plant supplied from a bucket or tank, a submersible pump is often the straightforward choice. If water is already available through a pipe, a suitable solenoid valve may be more appropriate.

            Do not connect a 230V AC solenoid valve directly to an Arduino. Use an appropriately rated switching device, enclosure and safe mains wiring, or choose a compatible low-voltage valve for a beginner project.

            Upgrading the Project with ESP32 and Rain Detection

            Once the basic Arduino system works, you can add features to make watering more convenient.

            ESP32 monitoring: An ESP32 can connect the irrigation system to Wi-Fi, allowing you to view sensor readings or send status updates through a suitable application or web interface. The pump still needs a properly rated driver and a suitable power supply.

            Rain detection: A rain sensor can help prevent unnecessary watering during rainfall. A simple rain sensor detects water on its surface, but it does not measure how much rain has reached the soil. Use it as an additional input rather than the only condition for deciding whether a plant needs water.

            Manual override: Add a button or switch so you can start or stop watering when needed. Include a maximum run time even in manual mode.

            Low-water protection: A float switch in the reservoir can prevent the pump from running when the water level is too low. This is particularly useful when the pump must remain submerged during operation.

            Watering schedule: A time-based restriction can prevent repeated watering during a short period. For example, the system can require a waiting period after a watering cycle before it considers another cycle.

            For a beginner build, start with one sensor and one pump. Add features only after the sensor thresholds, pump run time and relay operation are working reliably.

            Troubleshooting Common Irrigation Problems

            The pump does not turn on. Check the relay's power, input pin and contact wiring. Confirm that the pump has a suitable 12V supply and that the Arduino's dry-soil threshold is being reached. Test the relay without the pump first.

            The pump runs continuously. Your sensor may be disconnected, incorrectly calibrated or producing readings that remain above the dry threshold. Check the serial readings and confirm that the relay's active HIGH or active LOW logic matches the code.

            The pump switches on and off too frequently. Use separate dry and wet thresholds, average sensor readings, and add a pause between watering cycles. Check that water is not reaching the sensor immediately and causing misleading readings.

            The soil becomes too wet. Reduce the pump run time, measure the delivered water volume and reposition the sensor if necessary. A maximum run time and a low-water switch can improve protection, but they do not replace testing.

            The sensor readings are unstable. Check the power and ground connections, keep sensor wiring away from pump wiring, and secure the sensor in the soil. Averaging readings can help with small fluctuations, but it will not correct a damaged sensor or a poor installation.

            Smart Irrigation System Connection Diagram

            Conclusion

            An Arduino Uno smart irrigation system can water plants automatically by combining a capacitive soil moisture sensor, a relay module and a 12V DC mini submersible pump. The Arduino reads the sensor, compares its output with calibrated thresholds and switches the pump when watering is needed.

            For reliable operation, calibrate the sensor in your actual soil, limit pump run time, and allow water to spread before checking the moisture level again. Power the pump from a suitable 12V supply through a correctly rated relay or driver, never directly from an Arduino pin.

            Start with a single potted plant, test the amount of water delivered, and adjust the thresholds before expanding the system. You can later add an ESP32, rain detection, manual control or a reservoir-level switch.

            For your build, consider the 12V mini submersible water pump and a compatible 5V relay module. Check the pump's current requirements, the relay contact ratings and the sensor pinout before connecting the system.

            Excerpt

            Build an automatic plant watering system with Arduino Uno, a soil moisture sensor, relay and 12V pump. Includes wiring, code, calibration and parts list.

            Frequently Asked Questions

            1. Can Arduino power a 12V pump directly?

            No. An Arduino GPIO pin cannot supply the voltage or current required by a 12V pump. Use a separate 12V power supply and a suitably rated relay module or MOSFET driver. The Arduino should provide only the control signal.

            2. Pump or solenoid valve?

            Use a pump when you need to move water from a reservoir to a plant. Use a solenoid valve when you need to open or close an existing water supply. The correct choice depends on the water source, pressure requirements and valve or pump specifications.

            3. Capacitive vs resistive moisture sensor?

            A capacitive soil moisture sensor detects changes in capacitance and is often preferred for longer-term soil monitoring because it avoids the exposed conductive electrodes used by many resistive probes. Both types need calibration, and neither provides a universal moisture percentage without suitable calibration.

            4. How do I prevent the pump from running dry?

            Add a float switch or another suitable water-level sensor to the reservoir. Program the Arduino to disable the pump when the water level is too low. Also use a maximum run time and ensure the pump is operated according to the manufacturer's immersion and operating instructions.

            5. Can I control it from my phone?

            Yes. An ESP32 can connect to Wi-Fi and provide a suitable interface for viewing moisture readings and controlling irrigation. You will need to implement the software interface and secure the control connection. Keep automatic watering limits in place even when remote control is available.

            Prev Post
            Next Post

            Leave a comment

            Please note, comments need to be approved before they are published.

            Thanks for subscribing!

            This email has been registered!

            Shop the look

            Choose Options

            Edit Option
            Back In Stock Notification
            Compare
            Product SKU Description Collection Availability Product Type Other Details

            Choose Options

            this is just a warning
            Login
            Shopping Cart
            0 items
            FREE SHIPPING!
            ₹100 OFF
            ₹200 OFF
            ₹999
            ₹2500
            ₹4900
            WhatsApp Chat Chat