How to make a smart irrigation system with ESP32 DEVKIT V1 board and Blynk

How to make a smart irrigation system with ESP32 DEVKIT V1 board and Blynk

Hello and welcome back. In this project, we will learn how to make a smart irrigation system with ESP32 DEVKIT V1 board. For this project, I have primarily used a soil moisture sensor. Additionally, I used the Blynk cloud platform, which allows us to monitor and control the system remotely via a smartphone or computer, from anywhere in the world. I have also used a water pump in this project, which is controlled using a 10A relay module. You can connect a suitable water pump to the relay, but you can also test the system without the water pump. Also, we can monitor the motor pump’s status and the soil moisture level both on an LCD screen and through the Blynk mobile or web dashboards. I have designed a PCB for this project especially. Therefore, we can assemble this project more easily and cleanly. This project is ideal for school or university assignments, and you can order the PCBs using free coupons from JLCPCB.

  • How to use the ESP32 DEVKIT V1 board and Blynk cloud – Click on me

Ok, let’s do it step by step. The required components are given below.

Step 1

Firstly, identify these components.

Step 2

Secondly, let’s order PCBs for this system.

  • First, go to the JLCPCB official website and log in to your account.
  • If you’re a new member of JLCPCB, please sign up using this link to receive an $80 new user coupon.
  • Please register to get $80 Coupons — Click on me
  • Now, click the instant quote button and upload the Gerber file. You can download it using the link below.
  • Gerber file — Download
  • I have ordered five purple PCBs. Next, select the build time and shipping options, then click the ‘Save to Cart’ button.

Step 3

Thirdly, unbox your PCB package.

Step 4

Next, solder the SMD components using a hot air gun.

Step 5

Then, solder the other components one by one.

Step 6

Afterward, install the LCD screen, ESP32 board, and sensor onto the PCB. Then connect the ESP32 board to the computer.

Step 7

Now, let’s set up the Blynk web dashboard. To do this, follow the instructions below.

  • First, go to the Blynk website and log in to your account. If you’re a new user, please sign up using your email address.
  • Next, click the ‘Template’ button and create a new template for this project. You can name it as you like. Then, select ‘ESP32’ as the hardware.
  • Next, click the ‘Datastreams’ tab and create two virtual pins.
  • Name — Moisture Level / PIN — V0 / MIN — 0 / MAX — 100
  • Name — Water pump / PIN — V1 / MIN — 0 / MAX — 1
  • Next, click the ‘Dashboard’ tab and add one Button widget and one Gauge widget. Then, arrange these widgets as you like.
  • Afterward, click the settings icon on the widgets and select the datastreams that we created earlier. Finally, click the save button.
  • Now, click the ‘Device’ tab and create a new device. To do this, select the template we created earlier. Then, you will see the project Blynk Auth token.

Step 8

Afterward, copy and paste the following code into the Arduino IDE.

//Include the library files
#include <LiquidCrystal.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define sensor 34
#define relay 22

//Initialize the LCD display
LiquidCrystal lcd(2, 4, 5, 18, 19, 21);

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.begin(16, 2);
  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);

}
  • Now, copy and paste the Blynk auth token from the Blynk web dashboard. Then, enter your WIFI SSID and password.
  • Afterward, select the board and port. Next, click the upload button.

Step 9

Now let’s set up the Blynk mobile dashboard. For that, follow the instructions below.

  • First, download and install the Blynk app from the Play Store or App Store. Then, log in to the app. You will now see your project template.
  • Next, click on this template, then select one button widget and one gauge widget from the widget list. You can customize these widgets as you like.
  • Finally, click on each widget individually and select the datastream we created on the web dashboard. You can also customize these widgets.

Step 10

Now, remove the USB cable. Then, set up the watering system by connecting the water pipes to the water pump and inserting the soil moisture sensor into the soil basket.

Step 11

Afterward, connect the water pump to the relay module. I have used two Li-ion batteries to power the pump, but you can use a 9V battery instead. Finally, power the main system using a 5V power supply.

Now, you can test the system using your smartphone or computer. Enjoy the project! The full video guide is below. We hope to see you in the next project.

Troubleshooting Tips

  • Check all connections.
  • Check Blynk Authentication Token,
  • Check the WIFI SSID and password.
  • Check the power sources.
  • Check the status of hardware components.

How to make a smart irrigation system with ESP32 DEVKIT V1 board and Blynk

Similar Posts

Leave a Reply

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