In today’s project, we will learn to build an IoT Plant Watering System using an ESP8266 NodeMCU board and which comes with the latest Blynk 2.0 version. In this project, we used a soil sensor and a relay module to get the input and output as well.
Using those, we can get the moisture value and control the water pump with the help of the relay. In today’s tutorial, a mini water pump is used as an example. But, you can connect any other water pump like AC or DC as required (Please use a relay with more amperage than the water pump).
Also, this system has a feature to monitor or control our smartphone or computer using the Blynk 2.0 platform from anywhere in the world. This is a very cost-efficient project and very helpful for our home garden, small greenhouses and etc where labour is way costly. Now let’s begin to make the project step by step.
Previously we have already discussed two automatic plant watering systems. You can check it out.
- ESP8266 NodeMCU
- Soil Moisture Sensor
- 5 Volt Relay Module
- 16×2 LCD Display
- I2C Display Module
- DC Water Pump
- 7mm Silicon Pipe
- Connecting Wires
- 9 Volt Battery
- 9 Volt Battery Clip
Identification of IoT Plant Watering System Project Parts
First, we have to identify these components.
Circuit Connection for IoT Plant Watering System
First, we have to put the NodeMCU board on the breadboard and connect the VIN and GND pins to the breadboard respectively.
Now we have to put the soil moisture sensor on the breadboard and connect it to the NodeMCU board. For that, use the reference circuit diagram below Then connect the 16×2 LCD display and relay module to the NodeMCU board.
You have to connect all the required components as per the circuit diagram. The circuit is very simple, you can directly give AC supply to the DC circuit. Before designing the PCB I also checked the IoT Plant Watering System circuit on a breadboard. After testing the circuit, I designed a PCB layout by using EasyEDA software to make the circuit compact and look professional.
Now come to the main part, where we need to order our PCB prototype. I always prefer PCBWay for its quality assurance, fastest delivery, and 24/7 customer support.
PCBWay is a Chinese-based PCB manufacturing company which is providing prototypes, PCB assembly, SMT Stencil and Flexible PCBs. I am in collaboration with them for about recent 1.5 years, and I feel like PCBWay gives an excellent price and customer service factor in one single serving. What is also spectacular about PCBWay to me, as an electronics hobbyist and customer, is their on-time service. In this review, I will explain my personal opinion regarding the quality and processing aspects of PCBWay.
When I first approached PCBWay, I found their PCB prototyping and customisation options capture huge areas with every aspect of you can customize the PCB as per your wish. You can choose different types of solder masks, silkscreen, surface finish, materials and much more. Below, I have attached some solder mask quality provided by PCBWay.
Addressing their SMT stencil service, it is often ordered with your standard PCB boards if your design includes surface mount components being soldered on. Really it is too professional and accurate also checked by their engineers. It is like a template which makes it easy for your project as surface mount soldering isn’t the easiest skill to grasp. Besides the prototype customization, PCBWay also offers different interchangeable options such as the stencil type, thickness, existing fiducials, whether you like electropolishing or not etc.
Now come to the PCB Assembly service, where components can be assembled by them, and your PCB board will come ready to be used. Also here you could choose the option to have PCBWay supply all the components on your design or have the option for your own where you need to supply all the components. Alternatively, you could choose the combo option where PCBWay supplies some parts, along with you will have to supply the rest of the components. I strongly recommend going for the combo option if you have some of the parts you need for that project.
The best part of PCBWay in my opinion, their engineers check your Gerber file and if there is a correction needed, they might contact you or correct it with their PCB expertise. Pointing to that, I think this is the most valuable service that they are providing you than other companies.
Now, once you have done all your customisations and made your final choices, you can receive a quote along with a rough price estimate directly from their website. The price of your product will be based on the options you choose, with the higher, more expensive options contributing to your price more heavily. Shipping is also included separately, DHL is the expensive method and standard airmail is the cheapest method of shipment. The nice thing about PCBWay’s website is that you can see how the final price is broken down by certain costs. Furthermore, there is a choice for you to select your build time and shipping method so that when you change it, you can instantly see the price difference.
Setup Blynk Web Dashboard for IoT Plant Watering System
First, enter the Blynk website and create a new account using your Gmail id. Then sign in to your account and tap on the new Template button. Then enter your project name and click on the done button.
Now click the “Datastreams” tab and have to create two data streams, you can take reference from the information below.
|V0||Moisture Level||Min-0, Max-100|
|V1||Water Pump||Min-0, Max-1|
Next, click on the “Web dashboard” tab and then we have to include the one button and one Gauge widget in the dashboard.
Now, arrange these widgets as you like and select the data streams that we created earlier. Then save it.
Now, click the search icon button and create a “New device”. For that, select the template you created earlier. Finally, the Blynk Web Dashboard has been created successfully.
Next, we have to connect ESP8266 to the computer and upload the program to it. To compile the code, we have to install the below libraries.
#define BLYNK_PRINT Serial
//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);
//LiquidCrystal_I2C lcd(0x3F, 16, 2);
char auth = "*********"; //Enter your Blynk Auth Token
char ssid = "*********"; //Enter WiFi Name
char pass = "*********"; //Enter WiFi Password
bool Relay = 0;
#define sensor A0
#define Pump D3
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
for (int a = 0; a <= 15; a++)
//Call the function
//Get the button value
Relay = param.asInt();
if (Relay == 1)
//Get the soil moisture sensor values
int value = analogRead(sensor);
value = map(value, 0, 1024, 0, 100);
value = (value - 100) * -1;
Blynk.run();//Run the Blynk library
timer.run();//Run the Blynk timer
Copy the Blynk “auth token” from the Blynk website and paste it into the code section. Also, you have to enter your WiFi SSID and password. Finally, we have to select correct the board and port and hit the upload button to upload this code into the NodeMCU board.
Setup Blynk Mobile Dashboard for IoT Plant Watering System
First, we have to install the Blynk application from Google Play Store. Then, sign in to the account which you already login into your web dashboard and click on the template we created earlier.
Now, add the widget to the dashboard. For that click the “+” icon at the top right corner. And then, add one button and one Gauge widget to the dashboard. After that, arrange these widgets as you like.
Now, click the one-by-one widgets and select the data streams you created in the Blynk web dashboard. Blynk mobile dashboard is now ready for use.
As the last step, we have to connect the water pump to the relay module and place the soil moisture sensor into the soil.