Plant Monitoring System using ESP32

IoT Based Plant Monitoring System using ESP32 & Soil Moisture Sensor

Build an IoT-based Plant Monitoring System using ESP32 and a Capacitive Soil Moisture Sensor. Explained the Circuit and Source codes.

With the rise of IoT (Internet of Things), it has become easier to automate everyday tasks and monitor essential parameters remotely. One such application is smart plant monitoring. In this article, we will learn how to build an IoT-based Plant Monitoring System using ESP32 and a Soil Moisture Sensor.

This system allows you to:

  • Monitor soil moisture levels in percentage on a mobile app dashboard.
  • Control a water pump remotely using IoT or voice commands.
  • Automate plant watering based on real-time soil conditions.
Plant Monitoring System using ESP32 P18

This is a beginner-friendly project that combines ESP32 microcontroller, Sinric Pro IoT cloud, and Alexa voice assistant to create a powerful and practical smart gardening solution.

Required Components for the ESP32 Project

  • ESP32 Development Board
  • Capacitive Soil Moisture Sensor
  • Relay Module (for water pump control)
  • Submersible DC Water Pump
  • Jumper Wires and Breadboard
  • Power Supply (5V/USB)

Circuit of ESP32 Plant Monitoring System

Circuit of ESP32 Plant Monitoring System

The circuit connections are simple and beginner-friendly:

  • Soil Moisture Sensor → Analog output connected to ESP32 GPIO34 (ADC)
  • Relay IN Pin → Connected to ESP32 GPIO25
  • Relay VCC and GND → Connected to ESP32 5V and GND
  • Water Pump → Connected to relay output as a controlled load
  • ESP32 → Powered via USB cable or external 5V adapter

Note: Always use a relay or MOSFET driver to safely operate pumps or motors.

Tutorial video on the Plant Monitoring System

Working Principle of IoT Plant Monitoring System

The working of this IoT-based plant monitoring system can be explained in four simple steps:

This ensures plants always receive the right amount of water without human intervention.

Soil Moisture Measurement

  • The capacitive soil moisture sensor detects the water content in soil.
  • The sensor’s analog signal is read by ESP32 through an ADC pin.
  • ESP32 converts this value into a percentage (%) for easy monitoring.

IoT Dashboard Monitoring

  • ESP32 sends the moisture percentage to the Sinric Pro IoT platform via Wi-Fi.
  • The real-time soil moisture data is displayed in the Sinric Pro mobile app.
  • You can check plant health remotely from anywhere in the world.

Pump Control via Relay

  • A relay module is connected to ESP32 to control the water pump.
  • The relay can be switched ON/OFF manually from the IoT dashboard or Alexa.
  • Example commands:
    • “Alexa, turn on the Garden pump”
    • “Alexa, turn off the Garden pump”
Plant Monitoring System using ESP32 P9

You will also get a notification on your mobile from the Sinric Pro app if the soil is very dry.

Plant Monitoring System using ESP32 P8

Sinric Pro Setup for Plant Monitoring System

To connect your ESP32 Soil Moisture Monitoring System with IoT, we will use the Sinric Pro platform. Sinric Pro provides free and premium cloud services to connect your devices, monitor sensors, and control appliances with Alexa or Google Assistant.

Create a Sinric Pro Account

  • Verify your account and log in to the Sinric Pro Dashboard.
  • Visit Sinric Pro Website.
  • Sign up using your email ID.

Create a Custom Device Type for Capacitive Soil Moisture Sensor

Since Sinric Pro does not provide a built-in device type for a Capacitive Soil Moisture Sensor, we need to create one manually using the Device Template feature. This custom template will allow us to monitor two important parameters:

  • 🌱 Soil Condition – whether the soil is Wet or Dry.
  • 💧 Moisture Level – real-time moisture percentage.

Steps to Create the Device Template

  1. Log in to your Sinric Pro account.
  2. Go to Device Templates.
  3. Click Add Device Template.
    • Enter Name: Moisture Sensor
    • Enter Description: Moisture Sensor
    • Select Device Type: Capacitive Soil Moisture Sensor
Plant Monitoring System using ESP32 P13

Add Capabilities

Now, we need to add features to our sensor. Click Capabilities and add the following:

Plant Monitoring System using ESP32 P11
  • Range Capability – Represents numerical values, e.g., soil moisture percentage.
  • Mode Capability – Represents predefined values, e.g., Wet or Dry.
  • Push Notification Capability – Allows sending real-time alerts from ESP32 to the mobile app.

Configure Capabilities

Click on Configure and set them up as follows:

Configure Capabilities
  • Range Capability
    • Instance: rangeInstance1
    • Range Name: Soil Moisture
    • Minimum Value: 0
    • Maximum Value: 100
    • Precision: 1
  • Mode Capability
    • Instance: modeInstance1
    • Mode Name: Soil Type
    • Mode Values: Wet, Dry

Finally, click Save to store your new template.

Create the Device from Template

  1. Go to Devices in the left menu.
  2. Click Add Device.
  3. Enter the details:
    • Device Name: Garden Soil Moisture
    • Description: Garden Soil Moisture
    • Device Type: Moisture Sensor (the template you just created).
  4. Go to the Others tab → Click Save.
Plant Monitoring System using ESP32 P3

In a similar way, add another device to control the pump.

  1. Go to Devices in the left menu.
  2. Click Add Device.
  3. Enter the details:
    • Device Name: Garden Pump
    • Description: Garden Pump
    • Device Type: Switch.
  4. Go to the Others tab → Click Save.

Get App Key and Secret

Plant Monitoring System using ESP32 P15
  1. In the dashboard, navigate to Credentials.
  2. Copy the APP KEY and APP SECRET.
  3. Note down your Device ID (you’ll need all three in your ESP32 code).

Source Codes for Sinric Pro ESP32 Plant Monitoring System

Click on the following button to download the source codes for this ESP32 project.

Program ESP32 with Arduino IDE

For this IoT-based project, I have used the Arduino IDE to program ESP32.

First update the Preferences –> Aditional boards Manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

  • Then install the ESP32 board (2.0.3) from the Board Manager or Click Here to download the ESP32 board.
  • Download the required libraries from the following links:
    • SinricPro Library (Version 3.5.2)
    • ArduinoJson by Benoit Blanchon (minimum Version 7.0.3)
    • WebSockets by Markus Sattler (minimum Version 2.4.0)

Get Sensor reading for the DRY & WET soil

To get the Calibration values for moisture reading from the sensor, first, upload the following code to ESP32.

#define SensorPin       34  //D34 
int     sensorVal;

void setup() {
  // Set up serial monitor
  Serial.begin(115200);
}

void loop() {
  sensorVal = analogRead(SensorPin);
  Serial.print("Moisture Value: ");
  Serial.println(sensorVal);
  delay(1000);
}

Connect the Moisture Sensor AOUT pin with D34 and supply 3.3V across VCC and GND.

Then open the serial monitor with Baud rate 115200.

Plant Monitoring System using ESP32 P14

Now note down the following values.

  • Soil is very dry.
  • Soil is neither dry nor wet.
  • Soil is very wet.

Now open the main sketch in Arduino IDE and update the following values.

// ---- Credentials ----
#define APP_KEY    "YOUR-APP-KEY"
#define APP_SECRET "YOUR-APP-SECRET"

#define SOIL_DEVICE_ID  "YOUR-SOIL-SENSOR-DEVICE-ID"   // Capacitive Soil Moisture Sensor
#define PUMP_DEVICE_ID  "YOUR-PUMP-SWITCH-DEVICE-ID"   // Switch (for pump)

#define SSID       "YOUR_WIFI"
#define PASS       "YOUR_PASSWORD"

Also enter the Calibration values of the sensor for different soil type

// ---- Calibration values (adjust for your sensor) ----
const int VERY_DRY  = 2910;
const int NEITHER_DRY_OR_WET = 2098;
const int VERY_WET  = 925;
const int DRY_PUSH_NOTIFICATION_THRESHHOLD = 2850;
const int UNPLUGGED = 3000;

After making these changes, please upload the code to the ESP32.

Install Sinric Pro Mobile App

  1. Download the Sinric Pro App from the Play Store or App Store.
  2. Log in using the same account.
  3. Your newly created Plant Monitor device will appear on the dashboard.
  4. Here you can:
    • See real-time soil moisture percentage.
    • Turn ON/OFF the water pump manually.
Plant Monitoring System using ESP32 Sinric Pro

Connect with Alexa

  1. Open the Amazon Alexa app.
  2. Go to Skills & Games → Search for Sinric Pro.
  3. Enable the skill and log in with your Sinric Pro account.
  4. Alexa will now discover your devices.
  5. You can now control your pump with voice commands like:
    • “Alexa, turn on the water pump.”
    • “Alexa, turn off the water pump.”
Plant Monitoring System using ESP32 P17

About PCBWay and their services

You can order any custom-designed PCBs from PCBWay at very reasonable prices.

PCBWay

PCBWay not only produces FR-4 and Aluminum boards but also advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at very affordable prices.
For the online instant quote page please visit – pcbway.com/orderonline

You can also explore different PCB projects from their Open-source community pcbway.com/project/.

Also, during September, there is no extra charge for the purple PCB.

Advantages of IoT-Based Plant Monitoring System

  • 🌍 Remote Monitoring – Check soil moisture percentage anytime, anywhere.
  • 🎙 Alexa Integration – Voice commands for controlling the pump.
  • 🌱 Automated Irrigation – Prevents overwatering or underwatering.
  • 💧 Water Conservation – Water plants only when required.
  • 🔧 Easy to Build – Uses low-cost, readily available components.

Applications

  • Smart Home Gardening Systems
  • Greenhouse Monitoring
  • Agricultural Farms
  • Indoor Plant Automation
  • Lawn Irrigation

Conclusion

This IoT-based plant monitoring system using ESP32 and soil moisture sensor is an innovative way to make gardening smart and hassle-free. By connecting to the Sinric Pro IoT cloud and Alexa, you can monitor soil conditions, control a pump remotely, and even automate watering schedules.

Whether you are a DIY enthusiast, student, or farmer, this project is a great step into the world of IoT and smart agriculture.

👉 Build this project today and take your gardening experience to the next level with ESP32 IoT automation!