How to make a plant watering system with ESP32 board and Blynk app
Hello and welcome back. In this project, we will learn how to make a plant watering system with an ESP32 board. For that, I mainly used a soil moisture sensor to help determine when to water the plants. And you can make this project easily and cheaply. I think it is a good option for your school or university assignments.
Also, I used the Blynk cloud for controlling this system. This means we can easily manage and control the watering system using either our computer or smartphone. Additionally, I have used a mini water pump. But you can connect any other water pump. Just ensure that you select a water pump that is compatible with the relay module. (Please refer to the relay module’s specifications)
It’s important to note that this is just a basic structure, and you have the freedom to modify the project according to your preferences. I believe this project will be particularly beneficial for transforming a regular home garden into a smart home garden.
- If you want to do this project with the ESP8266 board, please use this link.
OK, let’s do this project step by step. The required components are given below.
- ESP32 board x 1 — Our Store / Amazon
- ESP32 adapter x 1 — Our Store / Amazon
- Soil moisture sensor x 1 — Our Store / Amazon
- LCD screen x 1 — Our Store / Amazon
- I2C module x 1 — Our Store / Amazon
- Relay module x 1 — Our Store / Amazon
- Breadboard x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
- Mini Water pump and pipe — Amazon
- Li-ion battery x 2 — Amazon
- Battery holder x 1 — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.
Step 2
Secondly, install the ESP32 board on the adapter. If you haven’t an adapter, you can use two breadboards.
Step 3
Thirdly, connect the power lines to the breadboard.
Step 4
Next, place the soil moisture sensor on the breadboard and connect it to the ESP32 board. For that, use the circuit diagram below.
Step 5
And then, connect the LCD screen and relay module to the ESP32 board.
Step 6
Now, let’s prepare the Blynk web dashboard. For that, follow the instructions below.
- First, go to the Blynk website and create a new account using your Email. And then, log in to your account and create a new template. I have created it as a “Plant watering system”. You can name it as you like.
- Next, click the Detastrem tab and create two virtual pins. For that, use the instructions below.
- Name — Soil moisture value / PIN — V0 / MIN — 0 / MAX — 100
- Name — Water pump / PIN — V1 / MIN — 0 / MAX — 1
- And then, create a dashboard. I have used one button and one gauge for that. Next, click the gear wheel icons on the widgets and select the Data stream. After, click the save button.
- Now, click the search icon and create a new device. For that, select the template you created earlier.
Ok, the Blynk web dashboard is ready for the project.
Step 7
Now, let’s prepare the Blynk mobile dashboard. For that, follow the instructions below.
- First, download and install the Blynk app on your smartphone. Then, log in to your account using your email and password.
- Next, select the template you created on the web dashboard. After, add one button and one gauge to the dashboard. You can customize these widgets as you like.
- Finally, click the widgets one by one and select the appropriate data stream as in the web dashboard. Also, you can change the color, text size, and other settings as you like.
Step 8
Now, connect the ESP32 board to the computer. Then, copy and paste the following program into your Arduino IDE.
//Include the library files
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define sensor 33
#define relay 4
//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);
BlynkTimer timer;
// Enter your Auth token
char auth[] = "*******************";
//Enter your WIFI SSID and password
char ssid[] = "******************";
char pass[] = "**************";
void setup() {
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
lcd.init();
lcd.backlight();
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
lcd.setCursor(1, 0);
lcd.print("System Loading");
for (int a = 0; a <= 15; a++) {
lcd.setCursor(a, 1);
lcd.print(".");
delay(200);
}
lcd.clear();
}
//Get the ultrasonic sensor values
void soilMoisture() {
int value = analogRead(sensor);
value = map(value, 0, 4095, 0, 100);
value = (value - 100) * -1;
Blynk.virtualWrite(V0, value);
Serial.println(value);
lcd.setCursor(0, 0);
lcd.print("Moisture :");
lcd.print(value);
lcd.print(" ");
}
//Get the button value
BLYNK_WRITE(V1) {
bool Relay = param.asInt();
if (Relay == 1) {
digitalWrite(relay, LOW);
lcd.setCursor(0, 1);
lcd.print("Motor is ON ");
} else {
digitalWrite(relay, HIGH);
lcd.setCursor(0, 1);
lcd.print("Motor is OFF");
}
}
void loop() {
soilMoisture();
Blynk.run();//Run the Blynk library
delay(200);
}
- Next, copy and paste the Blynk auth token. (For that, check the Blynk website) And then, enter your WIFI name and password.
- After, select the board and port. Finally, click the upload button.
- Now, remove the USB cable.
Step 9
Next, connect the water pump to the relay module. I have used the small water pump for that. You can change it to your liking, but you must remember to use the appropriate relay module. Also, I used the two Li-ion batteries to power up this motor.
Step 10
Next, install the components as you like. For that, you can use the pictures below. Finally, provide an external 5VDC power supply to the ESP32 board.
Now, you can test this project. The full video guide is below. We hope to see you in the next project or tutorial.
Troubleshoot
- Check all connections.
- Check the Blynk Auth token.
- Check the sensor.
How to make a plant watering system with ESP32 board and Blynk app
Where is
1)LiquidCrystal_I2C.h
2)Wire.h
3)WifiClient.h
4)BlynkSimpleESP32.h??
These are library files. Download these files and include to the Arduino IDE.
how to include them
Even if you are far away from your house or working, is it still possible to control the watering of plants?
Do we need ultrasonic sensor in this project (HC-SR04)?