IoTBeginnerPRJ-018

IoT Smart Plant Watering System (ESP8266)

Waters your plant automatically whenever the soil gets dry.

Built and tested by Vishnu M · Industrial Robotics Institute

Circuit diagram of the IoT Smart Plant Watering System (ESP8266) using ESP8266 NodeMCU
Circuit diagram · ESP8266 NodeMCU
LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts7 components

What is the IoT Smart Plant Watering System (ESP8266)?

An automatic irrigation system for a potted plant or small garden. A soil moisture sensor tells the ESP8266 how dry the soil is; when it gets too dry, a relay switches on a small water pump, and when the soil is wet again the pump turns off.

How it works

  1. The soil moisture sensor gives an analog reading; higher means drier.
  2. The ESP8266 reads it every 2 seconds and prints it to the Serial Monitor.
  3. Above 700 the soil is dry, so the relay switches the pump on.
  4. Once the reading drops, the relay turns the pump off.

Parts list

ComponentQty
ESP8266 NodeMCU1
Soil Moisture Sensor1
5V Relay Module1
Mini Water Pump1
Breadboard1
Jumper WiresAs needed
Water tank (optional)1

Software

  • Arduino IDE
  • ESP8266 board package

Wiring and connections

FromConnect to
Moisture sensor VCC3.3V
Moisture sensor GNDGND
Moisture sensor AOA0
Relay VCC5V (VIN)
Relay GNDGND
Relay IND1
Pump +Relay NO
Pump −Power supply GND

How to build the IoT Smart Plant Watering System (ESP8266)

  1. Push the soil moisture sensor into the plant’s soil.
  2. Wire the sensor to 3.3V, GND and A0.
  3. Wire the relay module to VIN (5V), GND and D1.
  4. Connect the pump through the relay’s NO terminal to its power supply.
  5. Upload the code from the Arduino IDE.
  6. Open the Serial Monitor at 9600 baud and note the dry and wet readings.
  7. Adjust the 700 threshold in the code if needed.

IoT Smart Plant Watering System (ESP8266) code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.

int moisturePin = A0;
int relayPin = D1;

void setup()
{
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
}

void loop()
{
  int moisture = analogRead(moisturePin);
  Serial.println(moisture);

  if (moisture > 700)          // dry soil
  {
    digitalWrite(relayPin, LOW);   // pump ON (active-low relay)
  }
  else
  {
    digitalWrite(relayPin, HIGH);  // pump OFF
  }

  delay(2000);
}

Real-world uses

  • Home gardens
  • Balcony and indoor plants
  • Greenhouses
  • Learning soil sensing

Frequently asked questions

What is a IoT Smart Plant Watering System (ESP8266)?

An automatic irrigation system for a potted plant or small garden. A soil moisture sensor tells the ESP8266 how dry the soil is; when it gets too dry, a relay switches on a small water pump, and when the soil is wet again the pump turns off.

What components are needed for the IoT Smart Plant Watering System (ESP8266)?

You need: ESP8266 NodeMCU (1), Soil Moisture Sensor (1), 5V Relay Module (1), Mini Water Pump (1), Breadboard (1), Jumper Wires, Water tank (optional) (1). Software: Arduino IDE, ESP8266 board package.

Is the IoT Smart Plant Watering System (ESP8266) project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.

Where can I get the code for the IoT Smart Plant Watering System (ESP8266)?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the IoT Smart Plant Watering System (ESP8266)?

Yes. IRI sells a kit with the parts for this project (PRJ-018). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo