Tutorial: Water Moisture level Sensor

In this guide you will create a water moisture level monitoring sensor using ESP32 Dev module. The values of water level will be sent to a web application, it’s access and setup will be explained step by step using screenshots and understandable instructions. At the end of this tutorial you can easily check and reset your water moisture level sensor on your mobile phone from anywhere anytime.

Project Overview

In this project you will create a water moisture level sensor for your hydroponic garden plants using simple over the counter hardware. After setup this tutorial will teach you to create a mobile application to access the information of your sensor, its status and values. By the end of this tutorial you will be hands on creating multiple sensors and their monitoring along with changing basic preferences and fonts and other settings easily by just a few clicks.


Before starting to create the water moisture level sensor and application you need to check the following prerequisites

Used Software

  1. Arduino
  2. blynk Cloud
  3. Secure and stable internet connection

Hardware Component List

1ESP32 Dev Module1
2Moisture sensor1
3USB Cable1
4Connecting Wires1 pack

1. Schematics

The following diagram shows a overview of the project we will build-programming the ESP32 Dev and setting up of the Arduino will be explained under.

2. Instructions for setup

3. App Setup

Follow the next steps to setup your water level sensing application using blynk cloud

a. Go to blynk Cloud :
Signup on blynk cloud

b. Install the blynk cloud app on your phone from android studio or app store.

c. Blynk will send confirmation email on your email, verify that email and set password.

d. After that login on blynk cloud.

e. Select personal project.

f. Click on New Template.

g. A new pop-up window will appear, name the project as you wish, in this case I am naming it as Moisture meter. Once done with name select Hardware as ESP32 and Connection Type as WiFi and then click Done.

h. Save the Blynk template id and template name from side and note it down for future use.

i. Then click on setup data stream and then click New Data stream then select Virtual Pin.

j. Set the name and max value of the field and then click create.

k. Then click save.

l. On the blynk cloud app go to the developer zone.

m. Click on moisture meter.

n. A blank canvas will open.

o. Tap on the side of screen and select Labeled Value display.

p. Drag it to the center of the screen or wherever you prefer.

q. Click on the label.

r. Select the data stream we have created in step j.

s. Go back from developer zone and follow the next section.

4. Setup Code

Now you have successfully created the application on blynk cloud, follow the below steps to build up code in Arduino

a. Access the Library Manager by going to Arduino IDE >  Sketch  > Include library > Manage libraries

b. Utilize the search function to locate the blynk, then click the “Install” button corresponding to “ESP32 by Espressif Systems.”

c. Click on install and in few seconds library will be installed

d. In Arduino IDE > Go to file > Example > Blynk > Blynk Edgnet > Edgent_ESP32

e. A file like this will open.

f. Add the blynk Template ID and Template name as screenshot below.

g. Change the line 38 like screenshot below.

h. Add the readMoisture(); line in loop like the screenshot below.

i. Add the following lines in the code.

void readMoisture() {
  static unsigned long timer;
  if (millis() – timer > 250) {
    int sensorVal = analogRead(34);
    int percentageHumididy = map(sensorVal, 0, 4095, 100, 0);
    Blynk.virtualWrite(V0, percentageHumididy);
    timer = millis();
Arduino Code

5. Instructions to test code

After setting up Arduino and Blynk cloud app now follow the simple instructions to run and test it.

a. Press the compile button to compile code

b. Connect your ESP32 with computer

c. Select the com port from Arduino IDE > Tools > Serial port

d. Press the upload button and code will first start compiling and then start uploading.

e. In some ESP board you need to press and hold the BOOT/IO button on ESP board when it says connecting.

f. Code uploading is done.

6. Demonstration

Congratulations! You successfully deployed your app. Now its time to connect it and check the moisture level value. The web app is responsive, and you can access it using your smartphone, computer, or tablet.

a. Open the blynk cloud app.

b. Click on add new device

c. Find nearby device

d. Allow the Bluetooth permission to blynk and turn ON Bluetooth

e. Start the scan

f. Blynk will find the moisture device, connect with it.

g. Add the wifi details and continue

h. Blynk will start configuring

i. Click on finish

j. Moisture will start showing on screen.

k. If you want to change the font and style of moisture display you can click on settings icon and then click on moisture label and then switch to design tab and edit the settings.

7. Project Conclusion

In this tutorial, you learned how to create a water moisture level sensor, both its hardware and software setup along with web application setup was provided with easy and understandable steps.

If you have any questions or need assistance at any step you can always reach us!

Thanks for reading. Happy smart gardening!

Good and Bad of Hydroponic Systems

What are 5 advantages of hydroponics?

With the changing environmental factors more people are inclining towards healthier and fresh produce. Hydroponics systems are designed to provide complete indoor growth systems as well as commercial systems.

Saves Space

Hydroponics systems conserves space as compared to soil based plants. You can save up to 98 % of land as they can be grown both vertically and horizontally. As roots don’t have to spread out in search of nutrients and food because liquid rich food solution is delivered to them directly depending upon the hydroponic technique used. This results in growing more number of plants in relatively less space and in better controlled environment. Hydroponic farming techniques can be applied everywhere even if you are living in a small and cozy space.

Prevents water wastage

Plants grown in complete hydroponic systems use only 9-10 % water as compared to traditional field plants, because it is reused. The excess water is sterilized and revitalized to be used again. So only forms of water loss are through evaporation and leakage if any. Due to current water shortage issues conserving maximum amount of water is crucial which conventional irrigation systems makes impossible.

Calculations suggests that using traditional farming methods a single cup of lettuce uses about 3 gallons of water, 3 ounces of broccoli serving uses about 11 gallons of water.

Quality product in lesser time

A major advantage of hydroponic system is that it guarantees fast growth as you are completely in control of all environmental factors including temperature, moisture, minerals intake. Plants are placed in favorable conditions were their energies aren’t wasted on finding nutrients deep rooted within soil and can focus on thriving. In conventional farming ways fruits and vegetables are picked before they are ripe and stored in warehouses were sometimes they are sprayed with ethylene gas to artificially ripen as crops comes from far off places. Hydroponic farms contains own microbiomes, so these systems don’t need artificial ripening and  can be enjoyed at very instant.

Less time and labor

hydroponic technology is efficient as you don’t have to spend ours prepping soil or maintain it during yield. Hence it offers significantly lesser load for laborers and can easily be managed in few man ours. A small hydroponic plant system can easily be managed my one worker.

Optimal use of nutrients free from pests

In ydroponics systems you ave complete control over your plants nutrient requiremnets. You can find out minerals are best for your plants growt and can mix it in water at desired intervals. As excess nutrient filled liquid is stored in tanks, there is minimal possibility of loss. Since no soil is involved, use of chemicals, insecticides, pests is eliminated. This allows clean and healthy growth.

Why hydroponics is bad?

A common complaint from hydroponic systems is the taste of its produce, as we aren’t used to rich nutritious vegetation. Hydroponic plants root have stunted growth because of limited space as compared to soil grown plants, as their roots get slow release of nutrient from soil in comparison to hydroponically grown, therefore the different in texture. You need to be vigilant while growing a hydroponic farm as a lot of artificial factor are involved. A minute mistake can break the entire system.

What are 3 disadvantages of hydroponics?

Requires proper expertise and commitment

Just like any other farming method hydroponics system also require sheer commitment and patience. Even a slightest mistake can totally jeopardize the entire system, so firm grip over all the technology and products involved is necessary.

Water and electricity

Water and electricity are the two main necessary components in hydroponics systems. You will need to ensure proper safety precautions as electricity is required for running water pumps, grow lights, depending upon the type of system you are using.

Expensive installation cost

Unfortunately hydroponic farming involves expensive equipment for first installation, so you can’t set it up if empty handed. You will require quality nutrients, water tanks, lighting solutions, filters and many other products.

Shopping Cart