Maker Pro
Blynk

How to Create an IoT Smart Garden Using ESP32 and Blynk

May 19, 2020 by J W
Share
banner

In this tutorial, we are going to create an IoT-based garden you can care for from your phone using Blynk!

Gardening is a very gratifying hobby. However, because of our busy lifestyles, plants in our gardens might not always get the attention they deserve. What if we could remotely monitor their conditions and give them the care they need? There is a way! In this tutorial, we are going to create an IoT-based smart gardening system using the Blynk App.

This smart garden project is a plant environment monitoring system that monitors soil moisture level, air temperature, humidity, and water level. Then, depending on the conditions, the system allows users to deliver what is needed remotely through a mobile app. Moreover, this system can be scaled and expanded to automate the entire gardening process!

Required Hardware

  • ESP32
  • DHT11 Temperature and Humidity Sensor
  • Water Level Sensor
  • Soil Moisture Sensor
  • Relay Module
  • Breadboard and Jumper Wires
  • Smartphone with the Blynk app installed
IOT_Garden_SJ_MP_image9.jpg

Required Hardware

Wiring the Hardware

In this project, we will use a soil moisture sensor to measure the volumetric water content in the soil. The DHT11 sensor will measure temperature and humidity levels in the plant’s surroundings, and the water level sensor will measure the water level in a small tank.

The Fritzing diagram showing the hardware connections is shown below.

IOT_Garden_SJ_MP_image18.jpg

The following diagram shows how each sensor is connected to the analog pins of the ESP32 development board.

IOT_Garden_SJ_MP_image4.jpg

In this setup, we are monitoring the sensor data and interfacing a relay module to control high voltage devices such as motors and lighting devices. Through the Blynk app, we can remotely monitor various parameters in our garden and activate devices as needed.

If the water level in the tank is reduced to the minimum value, we can switch ON a motor remotely to fill the tank. If the temperature is reduced to the minimum requirement, we can switch ON the lighting to increase the temperature to a certain value. If your plants need more water, you can open a valve remotely to water the plants.

Setting up the Blynk App

Now it’s time to set up the Blynk App to monitor sensor values. The first step is to install the Blynk App on your smartphone.

Upon installation, you’ll need to create a new Blynk account. This step is important as the app will send a unique authentication code to your email. You’ll need this to continue using the Blynk app.

IOT_Garden_SJ_MP_image7.jpg

After creating a new account, create a new project and select your hardware.

IOT_Garden_SJ_MP_image11.png

The Blynk app automatically sends you a unique authentication code for every new project you create. You need this code to connect your smartphone to the hardware. The authentication code will be sent to the email address you used for registration.

IOT_Garden_SJ_MP_image1.png

Creating our Smart Garden Monitoring System in Blynk

Now you have an empty canvas as shown below. We need to add four gauge widgets to monitor temperature, humidity, water level, and soil moisture level.

IOT_Garden_SJ_MP_image17.png

Tap on the canvas to open up the widget box. Now pick a gauge.

IOT_Garden_SJ_MP_image10.png

Tap and drag the widget on to the canvas.

IOT_Garden_SJ_MP_image13.png

Tap on the widget to change its settings. There, you can change the name, size, text size, and color of the gauge.

IOT_Garden_SJ_MP_image5.png

The two most important settings are the pin and the refresh rate. Set a virtual pin for each gauge with two seconds of refresh time for temperature and humidity values. Set five seconds of refresh time for water level and moisture level.

IOT_Garden_SJ_MP_image20.png
IOT_Garden_SJ_MP_image19.png

Now your canvas should look like this:

IOT_Garden_SJ_MP_image6.png

Finally, add a button widget to control the relay. There, change the name of the button, button type, and pin. The pin is the GPIO pin of the ESP32 where the relay is connected.

IOT_Garden_SJ_MP_image15.png
IOT_Garden_SJ_MP_image16.png

Now the Blynk App project configuration is finished and you are ready to go!

Arduino Code

Download the Arduino source code.

The Arduino code is pretty straightforward and easy to understand. I have used the DHT11 sensor library to get the temperature and humidity. Water and soil moisture levels are just analog readings. According to your environment and sensor constraints, these analog values can be mapped into a range.

There are two functions to send data to the Blynk App. The first function sends temperature and humidity values and the second one sends water and soil moisture levels.

IOT_Garden_SJ_MP_image14.png

The Arduino Blynk library has a method called virtualWrite ( ) to write the sensor reading into virtual pins we have already configured in our Blynk app.

Before sending the values, we must configure the Wi-Fi settings.

IOT_Garden_SJ_MP_image8.png

The Blynk timer object sends temperature and humidity readings every two seconds and water and soil moisture levels every five seconds. That data will update in the gauges of the Blynk App.

IOT_Garden_SJ_MP_image12.png

Running the System

Press the Run button to start the Blynk App. You can see that your gauges will start to display the sensor readings and these values update every two and five seconds. You can turn ON and OFF the relay by pressing the button remotely from anywhere.

IOT_Garden_SJ_MP_image3.png
IOT_Garden_SJ_MP_image3.png

Author

Avatar
J W

I am a mechatronics engineer

Related Content

Comments


You May Also Like