In this article we are going to make a NodeMCU and IoT based Smart plant watering system that you can use for your own garden. In our busy schedule, sometimes we need to stay outside for a while. During this abcense, sometimes our plants die due to lack of water. So here is the solution you can use for your own plant.


Smart Plant Watering System

Plants need water to survive. Maintaining the right moisture levels for your plants can be a challenge, especially if you travel often or have a busy schedule. This is where a smart plant watering system can come to your rescue. Using a NodeMCU, soil moisture sensor, and a few other components, you can automate the watering of your plants based on real-time soil moisture levels. Additionally, this system will have remote monitoring and control capabilities, including scheduling features, ensuring your plants are always well-watered.

Components Needed

These are the basic components you may need. If you already have similar things, you can use that.

Hardware settings:

You need to drive a pump through the relay module to turn on watering. Or you can use a valve instead of the pump if you have researve tank overhead. Then simply drive a pin high/low to drive the relay switch. Here is a basic diagram you can follow.

Smart Plant Watering System

Download NodeMCU Proteus library.


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#define RELAY_PIN D2

int moistureLevel = 0;
int threshold = 600;  // Adjust this threshold based on your soil and sensor

BlynkTimer timer;

void setup() {
  Blynk.begin(auth, ssid, pass);
  digitalWrite(RELAY_PIN, HIGH);  // Ensure the relay is off initially

  timer.setInterval(2000L, checkSoilMoisture);

void checkSoilMoisture() {
  moistureLevel = analogRead(SOIL_MOISTURE_PIN);
  Serial.print("Soil Moisture Level: ");
  Blynk.virtualWrite(V1, moistureLevel);
  if (moistureLevel < threshold) {
    digitalWrite(RELAY_PIN, LOW);  // Turn on the water pump
    Serial.println("Watering the plant...");
    Blynk.notify("Watering the plant...");
  } else {
    digitalWrite(RELAY_PIN, HIGH);  // Turn off the water pump
    Serial.println("Soil moisture is adequate.");

  int pinValue = param.asInt();
  if (pinValue == 1) {
    digitalWrite(RELAY_PIN, LOW);  // Manually turn on the pump
  } else {
    digitalWrite(RELAY_PIN, HIGH);  // Manually turn off the pump

  threshold = param.asInt();  // Adjust the threshold remotely

void loop() {;;

Explanation of Code:

  1. Blynk Setup:
    • Replace YourAuthToken, YourNetworkName, and YourPassword with your Blynk authentication token, Wi-Fi SSID, and password.
  2. Moisture Level Check:
    • The checkSoilMoisture function reads the soil moisture level every 2 seconds and decides whether to water the plant based on the threshold.
  3. Remote Control:
    • Virtual pins V1, V2, and V3 are used for remote monitoring, manual control of the pump, and adjusting the moisture threshold via the Blynk app.

Setting Up the Blynk App:

Smart Plant Watering System
  1. Install Blynk App:
    • Download the Blynk app from the App Store or Google Play.
  2. Create a New Project:
    • Create a new project and select NodeMCU as the hardware model.
  3. Add Widgets:
    • Gauge Widget: Set to virtual pin V1 to display soil moisture levels.
    • Button Widget: Set to virtual pin V2 to manually control the water pump.
    • Slider Widget: Set to virtual pin V3 to adjust the soil moisture threshold.
  4. Configure Notifications:
    • Enable notifications to receive alerts when the system waters the plants.

Testing and Calibration:

  1. Upload the Code:
    • Upload the code to your NodeMCU via the Arduino IDE.
  2. Monitor Output:
    • Open the Serial Monitor to observe the soil moisture readings and relay state.
  3. Calibrate the Sensor:
    • Adjust the threshold value in the code or via the Blynk app to suit your plant’s moisture requirements.


With this smart plant watering system, you can ensure your plants receive the right amount of water even when you’re away. The combination of soil moisture sensing and remote control capabilities via the Blynk platform makes this project both practical and educational. Happy gardening!

Feel free to modify and expand this system by adding more sensors, integrating weather data, or even implementing machine learning for more precise watering predictions.

For Professional Designs or Help:


Read more:

Categories: ESP32


Mithun K. Das; B. Sc. in EEE from KUET; Head of R&D @ M's Lab Engineering Solution. "This is my personal blog. I post articles on different subjects related to electronics in the easiest way so that everything becomes easy for all, especially for beginners. If you have any questions, feel free to ask through the contact us page." Thanks.


Leave a Reply

Avatar placeholder

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