Indoor Plant Watering System project using ESP32 Blynk

Indoor Plant Watering System project using ESP32

Make IoT-based indoor plant watering system using ESP32 Blynk & Capacitive soil moisture sensor. Having AUTO & MANUAL mode. Circuit + Code

In this IoT internet of things project, I have shown how to make the IoT-based indoor plant watering system using ESP32 Blynk and a soil moisture sensor.

plant watering system indoor using ESP32

The ESP32 will control the water pump automatically as per the soil moisture level. You can control and monitor the moisture level, and temperature from anywhere in the world on Blynk IoT.

So if you follow all the steps, you can easily make this IoT-based plant monitoring system using ESP32 and Blynk app.

Required Components for Plant Watering System

Required Components for Plant Watering System
  • ESP32 DEV KIT V1
  • Capacitive soil moisture sensor V2.0
  • DHT11 Sensor
  • 0.96″ OLED Display
  • 1k 0.25watt Resistors (R1-R6) – 6 no
  • 1N4007 diode
  • BC547 NPN Transistor
  • TIP122 NPN Transistor with heat sink
  • LEDs 5mm – 4no
  • 7805 voltage regulator with heat sink
  • 2-pin Push Button – 2no
  • 2-pin Terminal connectors (2 no)
  • 3-pin Terminal connectors (1 no)
  • 5V DC Buzzer
  • 100uF 25V capacitor (C1)
  • 100nF 330nF AC capacitors (C1, C2)
  • 12V DC pump or solenoid valve
  • 12VDC Supply

Circuit of IoT Based Indoor Plant Watering System

Circuit of Indoor Plant Watering System

In the circuit, you have to give a stable 12V DC supply. The amps rating of the power supply will depend on the pump or solenoid valve current rating.

A 7805 voltage regulator is used to provide the 5V supply to ESP32, and the 3.3V supply is given to OLED and capacitive moisture sensor from ESP32 3.3V pin.

To control the pump we have used a TIP122 NPN transistor which is connected with the GPIO D25.

Please refer to the following table for ESP32 GPIO used in this circuit.

ESP32 GPIOsConnected Sensors/Components
D34Capacitive moisture sensor AOUT pin
D32Push-Button to turn ON/OFF pump
D33Push-Button for changing MODE.
D25TIP122 base pin (controlling pump)
D26BC547 base pin (controlling Buzzer)
D14DHT11 sensor O/P pin
D15LED indicator for MODE
D2LED indicator for WiFi
D21SDA of OLED
D22SCL of OLED

If you want to use a 12V solenoid valve to control the water, then refer to the following circuit.

Plant Watering System with Solenoid valve
Plant Watering System with Solenoid valve.

Please use heat sinks with TIP122 and 7805 voltage regulator.

PCB Layout for ESP32 Plant Monitoring System

Please download the PCB layout, then print it on the A4 page.

Please check the PCB size while printing, it should be the same as mentioned in Layout.

Homemade PCB for DIY Plant Watering system

Homemade PCB for DIY Plant Watering system

In the tutorial video, I have explained, how you can easily make the complete circuit on zero PCB using the PCB Layout.

Tutorial video on Automatic Plant Watering System

During the ESP32 IoT project video, I covered the following topics:

  • Quick demo on the automatic watering system for plants.
  • Explained the Circuit diagram of the ESP32 plant watering system.
  • Make plant watering system project on Zero PCB.
  • Set up Blynk IoT Cloud for ESP32.
  • How to get the MIN MAX values of the capacitive moisture sensor.
  • Explained source code for the IoT-based plant monitoring system.
  • Set up the new Blynk IoT app to monitor soil moisture level.

Set up Blynk IoT Cloud for the ESP32 Project

You can refer to the following article to set up the new Blynk cloud account

Getting started with New Blynk 2.0 IoT platform

  • Create Blynk Template

    During creating the template, I selected ESP32 as the hardware and the connection type as WiFi.

  • Create Datastreams in Blynk Cloud

    plant watering system v1 p10

    In the template, I have created the first Datastreams (Pin: V1, Datatype: Integer, Min Value: 0, Max Value: 100) to show the moisture level in percentage.

    The next two Datastreams (Pin: V2 & V3, Datatype: Integer) will show the Temperature and Humidity reading from the DHT11 sensor.

    Forth Datastream (Pin: V4, Datatype: Integer, Min Value: 0, Max Value: 1, Default Value: 1) is for changing the MODE.

    Fifth Datastream (Pin: V5, Datatype: Integer, Min Value: 0, Max Value: 1, Default Value: 0) is for manually controlling the pump.

    (Please refer to the above picture)

  • Create Web Dashboard in Blynk Cloud

    plant watering system v1 p11

    After that, click and drag 1 Gauge widget, 2 Level widgets, and 2 Switch widgets and select the related Datastreams for each widget.

    Then click on “Save” to save the template.

  • Add Device in Blynk Cloud using Template

    You can refer to the following article to add a device to the Blynk cloud.

    Add Device in Blynk Cloud from Template

  • Set up Mobile Dashboard in Blynk IoT App

    plant watering system v1 p2 scaled

    Now open the Blynk IoT App and tap on the device name.

    Then add 1 Gauge widget, 2 Leveled Value widgets, and 2 Button widgets from Widget Box.

    1. Tap on the Gauge widget and select Datastream “Moisture” with V1.

    2. Tap on the first Leveled Value widget and select Datastream “Temperature” with V2.

    3. Tap on the second Leveled Value widget and select Datastream “Humidity” with V3.

    4. Tap on the first Button widget and select Datastream “Mode” (V4) and MODE “Switch“.

    5. Tap on the second Button widget and select Datastream “Water” (V5) and MODE “Switch“.

    (Please refer to the above picture)

PCB for the Plant watering system project

You can also download the PCB Gerber file and order the PCB from PCBWay.

PCB for the Plant watering system project

About PCBWay and their services

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

This image has an empty alt attribute; its file name is PCBWay-750x161-Banner.jpg

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/.

For more details please visit the following articles.
Why PCBway

Source Codes for Blynk 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.5) from the Board manager or Click Here to download the ESP32 board.
  • Download the required libraries from the following links:

Get Sensor reading for the DRY & WET soil

To get the MIN & MAX 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.

Get Sensor reading for the DRY & WET soil

Note the MAX value when the sensor is dry, then dip the sensor into water and note the MIN value.

Save these two values.

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

Blynk AUTH code and template details

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""

WiFi Name and Password.

// Set password to "" for open networks.
char ssid[] = ""; //WiFi Name
char pass[] = ""; //WiFi Password

Update the MAX value when the sensor is dry, and the MIN value for the wet soil.


int wetSoilVal = 930 ;  //min value when soil is wet
int drySoilVal = 3000 ;  //max value when soil is dry

With these two readings, we will calculate the moisture percentage.

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

Connect the Pump & Sensors with PCB

Connect the Pump & Sensors with PCB

Now connect the sensors, OLED, Pump, and 5V Buzzeras per the above diagram.

Here I have a 12V 2A DC supply, you have to use the power supply as per the pump amps rating.

Testing the DIY Plant Watering circuit

Testing the DIY Plant Watering circuit

Before connecting the solenoid valve with the pipeline, I will recommend you to test the circuit for Dry and Wet soil scenarios.

If everything works fine, connect the solenoid valve with the main water pipeline of the drip irrigation system.

Now your plants will get water automatically whenever needed.

I hope you like this IoT-based plant monitoring system using ESP32 and Blynk IoT app.

Click Here for more such ESP32 projects.

Please do share your feedback on this IoT project. Thank you for your time.