ESP32 Projects

I Built a Solar-Powered Water Tank Level Sensor

Last Updated on September 8, 2026 by Engr. Shahzada Fahad

Description:

Today, we are going to make the most versatile solar-powered water tank monitoring system.



Solar-powered water tank level sensor with ESP32 and ultrasonic sensor
I Built a Solar-Powered Water Tank Level Sensor

I said versatile because we can define the water tank lower and upper limits in real time through a mobile application created using Blynk IoT. Based on these limits, the water pump will automatically start and stop.




Water level monitoring on a mobile phone using Blynk IoT
Water Level Monitoring on Cell Phone

There are hundreds of thousands of different types and sizes of water tanks, so that’s why I added the lower and upper limits, which are completely adjustable during runtime. You set these limits once unless you want to change them again, because these values are stored in the EEPROM. So, it doesn’t matter if the controller is reset or powered off; these values won’t go anywhere. If these values were reset due to a power failure or accidental reset, then this entire system would be useless.

You can not only see the percentage and actual distance in cm in the application, but also on the OLED display module, which is optional.



Water level monitoring on OLED display using ESP32 and WiFi
Water Level Monitoring on OLED Display Using ESP32 and WiFi

Along with the distance and percentage values, you can also see the lower and upper limits. If I am going to change any of these values, they are quickly updated on the OLED display module, and the updated values are also stored in the EEPROM.



Setting water tank level limits via phone with ESP32 solar-powered water level sensor
Setting Water Tank Limits via Phone with ESP32 Solar-Powered Water Tank Level Sensor

Let me reset the controller so that you can see these values are not lost.

ESP32 restarted while retaining water tank level settings
Restarting the ESP32 Without Losing Water Tank Level Settings

In the image above, you can see, I restarted the controller.



Water tank lower and upper level limits stored in EEPROM
Water Tank Lower and Upper Limits Stored in EEPROM

Great! You can see the lower and upper limits are still there.

In the application, you can also see a button, which you can use to manually control the water pump.




Water pump control using ESP32 and relay
Water Pump Control Using ESP32

Let me quickly connect this bulb to the relay so that you can practically see what happens, because during the practical demo, you won’t be able to see how the water pump turns ON and OFF. So, right now, you can think of this bulb as the water pump.

Make sure to wear protective gloves while performing such high-voltage experiments, and don’t touch the relay contacts. Because safety first.

Before I show you this entire system in action, first let me tell you about the hardware. What makes this project unique is the hardware selection.



Xiao ESP32C3 for solar-powered water tank level sensor
Xiao ESP32C3 for Solar-Powered Water Tank Level Sensor

For this project, I selected the Xiao ESP32C3. Well, you can use any ESP32 variant, but the reason I selected the Xiao ESP32C3 is that in the Xiao series, you also get the Xiao ESP32C5 and Xiao ESP32C6.



Xiao Series ESP32 boards for IoT and wireless projects
Xiao Series ESP32 Boards

So, later, if you decide to switch to WiFi 6, you can simply use the ESP32C5, and if you don’t want to use this flexible PCB antenna, then you can switch to the Xiao ESP32C6. And let me tell you, since all these boards share the exact same pin layout, there is no need to make any changes on the hardware side. I have already demonstrated this in my previous video. I will add a link in the description below.

If you ask about my personal recommendation, I would select the Xiao ESP32C3 because its Bluetooth range, due to the flexible PCB antenna, is great. I have an article on its range test.

For water level monitoring, I am using the most accurate, highly reliable, and completely waterproof ultrasonic sensor, the “A02YYUW.”



A02YYUW ultrasonic sensor UART and PWM versions for water level monitoring
A02YYUW UART and PWM Ultrasonic Sensors

There are two versions of the same ultrasonic sensor: one is UART, and the other is PWM. The one I am using is the UART version. Its measurement range is from 3 cm to 450 cm. And when it comes to the voltage, it is compatible with 3.3V and 5V controller boards. It is a little bit more expensive than the HC-SR04 and the JSN SR04T ultrasonic sensors. Personally, I have used all these sensors, but my recommendation is the A02YYUW waterproof ultrasonic sensor.

Mini solar panel for solar-powered water tank monitoring system
Mini Solar Panel for Water Tank Monitoring

You will also need a solar panel, a bigger one or a mini solar panel like this. You don’t need to worry about the voltage because the 5V 3A power supply on my designed board can take input voltages up to 28 volts.




Xiao ESP32C3 PCB board for solar-powered water tank level sensor
Xiao ESP32C3 PCB Board for Water Tank Level Sensor

And the battery charging and management are done by the Xiao ESP32C3. So, that’s why I didn’t add any battery charging circuit to this board.

For how to make this board, I have also made a dedicated video about it, and you can download the original schematic, PCB design files, BOM, and all the other resources from my Patreon page.

Solar Powered Water Tank Level Sensor Wiring:

The ultrasonic sensor red and black wires are connected to the 3.3V and GND of the Xiao ESP32C3, and the TX and RX wires are connected to the D2 and D3 pins on the Xiao ESP32C3.

A 5-volt SPDT-type relay is connected to the D0 pin.

The SSD1306 OLED display module voltage and ground pins are connected to 3.3V and GND, and the SDA and SCL pins are connected to D4 and D5.



Circuit diagram:

Solar-powered water tank level sensor circuit diagram with ESP32 and ultrasonic sensor
Solar-Powered Water Tank Level Sensor Circuit Diagram

Since we are using the Blynk application, we can monitor the water level and adjust the lower and upper limits from anywhere in the world.

A quick demo before the practical implementation.

I have powered up the project using a 12V adapter. Later, we will use a solar panel.

The Ultrasonic Sensor is in its place, the ESP32 and Blynk application are connected to the WiFi.

ESP32C3 and mobile phone connected to WiFi for water tank monitoring
ESP32C3 and Mobile Phone Connected to WiFi for Water Tank Monitoring

Let me also tell you, there is no need to connect to the same WiFi, you can use a different WiFi network or a mobile hotspot on the mobile side. It is an IoT based Water Level monitoring system, you can connect to your ESP32 board from any part of the world.

The lower and upper limits are already set.

Now watch as I move this tablet.



Water tank reaches lower limit and turns on the water pump
Water Pump Turns On at the Lower Water Tank Limit

Think of it as the water level. The bulb is ON because the water level is below 20%. It will remain ON until the water level increases above 85%.

Water pump automatically turned off when the water tank reaches the upper limit
Water Pump Automatically Turned Off at the Upper Water Tank Limit

Now, the water pump will remain off until the water level decreases below 20%. As you can see, the entire system is working as expected. And one more thing:

if I don’t want the water tank to fill completely, I can use the relay button to turn OFF the water pump, or if I want, I can use it to turn ON the water pump.

Now, let’s connect the solar panel.

Solar panel connected to ESP32C3 for solar-powered water tank level sensor
Solar Panel Connected to ESP32C3 for Water Tank Level Sensor

I am going to connect the red wire to VIN and the black wire to GND.

Now, before the final demonstration, let me show you how to create your Blynk application.

Blynk Web Dashboard Setup:

Watch Video Tutorial on my YouTube Channel Electronic Clinic; link is given at the end of this article.

If this is your first time using the Blynk IoT Cloud and ESP32 WiFi + Bluetooth; I highly recommend reading my getting started article on the ESP32 and New Blynk.

Solar Powered Water Tank Monitoring Code:



Practical Demo of my Solar Powered Water Tank Level Sensor:

I have re-adjusted the lower and upper limits according to the size of the water tank.

Real-time water level monitoring using solar-powered ESP32
Real-Time Water Level Monitoring Using Solar-Powered ESP32

Right now, you can see the exact water percentage inside the tank in real time.

Now let’s test it properly. I am going to open the water taps and drain some water; and this is where things get interesting. Let’s see how fast and accurately this DIY solar-powered water tank level sensor responds.

A few moments later




Water level monitoring via cell phone using ESP32 as the tank water level decreases
Water Level Decreased in the Tank During ESP32 Mobile Monitoring

Look at that. The water level has dropped and the system detected it instantly.

Now obviously, I don’t want to completely empty the tank. So instead of waiting for the water pump to turn ON automatically, I am going to manually start the water pump using the control button.

Water pump manual and automatic control using ESP32 and Blynk
Water Pump Manual and Automatic Control Using ESP32 and Blynk

A few moments later…

And there you go.

Solar-powered water tank level sensor using ESP32 and Blynk IoT
Solar-Powered Water Tank Level Sensor Using ESP32 and Blynk IoT

The water percentage is increasing again. Smooth, automatic, and fully controlled.

This is exactly how a smart solar-powered water tank monitoring system should work.

So, that’s all for now.

Support me on Patreon:

If you enjoy my work and find these projects helpful, please consider supporting me on Patreon. With just $1, you can get access to all project source codes, schematics, and extra resources that I share with my supporters. Your support helps me continue creating new electronics tutorials, experiments, and open projects for the community. Thank you so much for being part of this journey and for supporting my work!

Watch Video Tutorial:

I Built a Solar Powered Water Tank Level Sensor with ESP32, A02YYUW, and Blynk


Discover more from Electronic Clinic

Subscribe to get the latest posts sent to your email.

Engr. Shahzada Fahad

Engr. Shahzada Fahad is an Electrical Engineer with over 15 years of hands-on experience in electronics design, programming, and PCB development. He specializes in microcontrollers (Arduino, ESP32, STM32, Raspberry Pi), robotics, and IoT systems. He is the founder and lead author at Electronic Clinic, dedicated to sharing practical knowledge.

Related Articles

Leave a Reply

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

Back to top button

Discover more from Electronic Clinic

Subscribe now to keep reading and get access to the full archive.

Continue reading

Electronic Clinic
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.