This project aims to automate the process of water level monitoring of water tank and water pump control using an ESP32 microcontroller, a waterproof ultrasonic sensor, a relay module, and the Blynk IoT app. By integrating these components, you can remotely monitor and control the water level in your tank via your smartphone. The system will also ensure that the pump turns on and off automatically based on the water level, preventing water overflow or the pump running dry.

This ESP32 water tank automation project demonstrates how an IoT-based controller can monitor water levels and automatically operate a water pump. For homes, commercial buildings, agricultural applications, or more advanced requirements involving multiple tanks, additional sensors, and mobile notifications, explore our Smart Water Tank Level Monitoring System Development Services. ArduinoExpert develops customized monitoring and pump automation solutions using ESP32, Arduino, STM32, Wi-Fi, GSM, LoRa, and IoT platforms.
Components used in Water Tank and Water Pump Automation Project:
- ESP32:
- The microcontroller that connects to the internet and interfaces with the sensors, relay module, and Blynk app.
- It supports both WiFi and Bluetooth, making it ideal for IoT projects.

- Waterproof Ultrasonic Sensor (JSN-SR04T):
- Used to measure the water level in the tank by calculating the distance between the sensor and the water surface.
- The JSN-SR04T is waterproof, making it ideal for outdoor or wet environments.

- Relay Module:
- A relay module will be used to control the water pump. It acts as a switch, turning the pump on or off based on the water level in the tank.
- You can use a 5V relay module, which can handle the switching for an AC-powered water pump.
- Water Pump:
- The water pump will be controlled by the relay module. The pump starts filling the tank when the water level is low and stops when the tank is full.
- Blynk IoT App:
- This app provides real-time monitoring and control of the water level and pump status. It is an IoT platform that allows you to create a graphical user interface (GUI) on your smartphone to interact with your ESP32 device.

- Jumper Wires and Breadboard for connections.
- Power Supply:
- A power supply (typically 5V or 12V, depending on the pump and relay) is needed to power the relay module and pump.
Working Principle of Water Tank and Water Pump Automation Project:
The automation process follows a basic flow:
- The ultrasonic sensor continuously measures the distance between itself and the water surface in the tank.
- Based on the distance (converted to a percentage of the water level), the ESP32 sends commands to the relay module to either turn the water pump ON or OFF.
- You can monitor the water level in real-time using the Blynk IoT app, which connects to the ESP32 via WiFi.
- The system also provides remote control of the pump, allowing the user to manually turn it on or off through the app.
The same water tank automation concept can also be implemented using other Wi-Fi-enabled microcontrollers. For example, our IoT Water Pump Tank Automation Using NodeMCU ESP8266 project combines ultrasonic water level sensing, automatic pump control, temperature monitoring, an LCD display, and Blynk IoT. This provides another practical reference for developing smart water management systems.

1. Ultrasonic Sensor to Measure Water Level
The JSN-SR04T ultrasonic sensor works by emitting ultrasonic waves and calculating the time it takes for the waves to bounce back from the water surface. This time is converted to distance using the formula:
distance = ((speed of sound in the air)*time)/2
In this project:
- The sensor is placed at the top of the water tank.
- It measures the distance from the sensor to the water level.
- By subtracting this distance from the total height of the tank, the system calculates the current water level.
2. ESP32 Microcontroller
- The ESP32 will receive data from the ultrasonic sensor.
- Using the data, the ESP32 will decide whether to turn the pump on or off, depending on the predefined water levels (e.g., turn on when the tank is 20% full, turn off when 90% full).
- The ESP32 is connected to the internet via WiFi, allowing it to send data to the Blynk app.
3. Relay Module for Pump Control
- The relay module acts as a switch for the pump. When the ESP32 decides to turn the pump on or off, it sends a signal to the relay module.
- The relay opens or closes the circuit, turning the water pump on or off.
4. Blynk IoT App for Remote Monitoring and Control
- Create a Blynk Account: Download the Blynk app (available for both iOS and Android) and create an account.
- Create a New Project: Set up a new project on Blynk with ESP32 as the board. Blynk will generate an authentication token, which you’ll use in your ESP32 code.
- Add Widgets:
- Use a Gauge widget or Vertical Level widget to show the current water level in the tank.
- Add a Button widget to manually control the pump (ON/OFF).
- Add LED indicators to show pump status (running or stopped).

If your main requirement is to switch a water pump ON and OFF remotely using a smartphone, you can explore our dedicated IoT Water Pump Control System Using ESP32 and Blynk App. This project demonstrates how ESP32-based electronics, embedded firmware, and a mobile IoT dashboard can be combined to create a practical wireless pump-control system.
Custom Mobile App and Cloud Integration
Although Blynk provides a convenient interface for IoT projects, some applications require a fully customized Android or iOS application. A custom water tank monitoring app can include real-time tank levels, pump ON/OFF controls, automatic and manual modes, scheduling, alerts, historical graphs, and multiple-device management.
Advanced solutions can use MQTT, Firebase, ThingsBoard, or custom cloud infrastructure to connect ESP32 controllers with mobile applications and web dashboards. Through our Custom Mobile and Web App Development Services, ArduinoExpert can develop IoT interfaces and backend systems according to specific project requirements.
Circuit Diagram of Water Tank and Water Pump Automation Project:

Code of Water Tank and Water Pump Automation Project:
#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_DEVICE_NAME "Water Tank Automation"
#define BLYNK_AUTH_TOKEN "YourBlynkAuthToken"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// Blynk auth token
char auth[] = "YourBlynkAuthToken";
// Your WiFi credentials
char ssid[] = "YourWiFiSSID";
char pass[] = "YourWiFiPassword";
#define TRIG_PIN 4
#define ECHO_PIN 5
#define RELAY_PIN 2
long duration;
float distance, waterLevel;
const float tankHeight = 100; // Example tank height in cm
BlynkTimer timer;
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
// Start Blynk
Blynk.begin(auth, ssid, pass);
// Timer to measure water level every 5 seconds
timer.setInterval(5000L, measureWaterLevel);
}
Alternative Wireless Water Pump Control Options
Not every water pump controller needs Wi-Fi or cloud connectivity. For nearby smartphone operation, Bluetooth is another useful option. ESP32 controllers with supported Bluetooth functionality can receive local control commands without requiring an internet connection.
Our Bluetooth Pump Control System Using ESP32 demonstrates another approach to smartphone-based pump operation. Bluetooth control may be suitable for local installations, maintenance interfaces, and systems where an internet connection is unnecessary.
GSM and SMS Pump Control
For agricultural fields, remote tubewells, or pumping systems without reliable Wi-Fi, GSM/SMS-based control may be more appropriate. A cellular controller can receive authorized SMS commands and control compatible pump equipment using relay outputs or VFD communication.
Our IoT Tubewell Water Pump Control Through SMS or Smartphone App project explores remote pump operation using mobile communication technologies. This approach can be especially useful for irrigation and water management systems installed far from the operator in locations where broadband internet is unavailable, SMS-based remote pump control provides an alternative to cloud-dependent systems. Our detailed guide, How to Control a Solar Tubewell Water Pump by SMS Without Internet, explains GSM-based pump operation, VFD control, and remote monitoring for agricultural pumping applications.
Applications of Water Tank Automation Project:
The project “Water Tank and Water Pump Automation using ESP32, Waterproof Ultrasonic Sensor, Relay Module, and Blynk IoT App” can have a wide range of applications across different sectors and environments. Below are some practical and impactful applications:
1. Domestic Water Tank Automation
- Description: This system can be used in homes to automate water tanks, ensuring that the water pump operates only when the water level drops below a certain threshold. This helps avoid water overflow or the pump running dry.
- Benefit: It saves water and electricity by ensuring that the pump runs only when necessary. Additionally, remote monitoring through the Blynk app allows users to check the water level from anywhere.
2. Apartment and Building Water Management
- Description: In multi-story buildings or residential complexes with shared water tanks, this system can automate the filling process and provide residents or maintenance teams with real-time monitoring of water levels.
- Benefit: It helps ensure a continuous water supply to all residents while preventing unnecessary pump usage, thereby reducing water wastage and energy consumption.
- Automatic water pump control can also be integrated with scheduled irrigation systems, soil moisture sensors, and local touchscreen interfaces. Our Irrigation Scheduling and Water Pumps Control Using Touch LCD and Arduino Uno project demonstrates how pump operation can be managed through a programmable irrigation schedule and touchscreen interface.
- For agricultural projects requiring customized wireless monitoring, automated irrigation schedules, and sensor integration, explore ArduinoExpert’s Smart Irrigation System Development Services.
3. Agricultural Irrigation Systems
- Description: In agriculture, water storage tanks are often used to supply water to irrigation systems. Automating the water pump based on the tank’s water level ensures a consistent water supply to crops, improving irrigation efficiency.
- Benefit: Automating irrigation systems helps optimize water usage, reduce manual intervention, and prevent the risk of the pump running dry, which is particularly beneficial in water-scarce areas.
4. Industrial Water Supply Systems
- Description: Industries that require large volumes of water for cooling, manufacturing, or processing can use this automated water management system to maintain optimal water levels in their storage tanks.
- Benefit: It ensures the continuous availability of water for industrial processes, minimizes human supervision, and prevents operational downtime caused by water shortages or tank overflows.
5. Rural and Remote Water Management
- Description: In rural or remote areas, where water supply and pump maintenance might be difficult, this system can automate the process and provide remote monitoring via the Blynk IoT app. Even in off-grid locations, solar-powered versions of this system can be implemented.
- Benefit: It reduces the need for manual water level monitoring and pump operation in remote areas, making water management more reliable and efficient..
6. Rainwater Harvesting Systems
- Description: This system can be integrated with rainwater harvesting setups where collected rainwater is stored in tanks. Automated control ensures that the tank does not overflow and can activate a pump to move excess water to secondary storage or use it for irrigation.
- Benefit: By automating the system, rainwater is effectively stored and used, reducing reliance on freshwater sources, and contributing to sustainable water management practices.
7. Commercial Buildings and Office Complexes
- Description: In office buildings, commercial complexes, or shopping malls, large water storage tanks are used for both regular water supply and firefighting systems. Automating the water supply to these tanks ensures adequate water levels for emergencies and day-to-day use.
- Benefit: It eliminates the risk of running out of water for essential operations and improves the reliability of the building’s water management system.
8. Hotel and Hospitality Water Systems
- Description: Hotels and resorts often require large quantities of water for their operations. This system can automate the monitoring and refilling of water tanks used for guest rooms, laundry, swimming pools, and landscaping.
- Benefit: It ensures that water supply remains consistent and avoids disruptions in service, contributing to improved guest satisfaction and operational efficiency.
9. Smart City Water Management Systems
- Description: In smart city projects, IoT-enabled water management systems can be deployed to monitor and control multiple water storage tanks in real-time across urban areas, optimizing the overall distribution of water.
- Benefit: It helps reduce water wastage, ensures efficient distribution, and supports the sustainable management of urban water resources.
10. Emergency Water Storage Systems
- Description: This project can be used in areas prone to natural disasters (e.g., droughts, floods) to automate the management of emergency water storage systems. During emergencies, the water supply can be managed more effectively, ensuring availability when needed.
- Benefit: It enhances the resilience of communities by ensuring that emergency water storage systems are kept at optimal levels without requiring constant manual supervision.
11. Water Distribution Systems for Parks and Gardens
- Description: Public parks, gardens, and landscapes often rely on stored water for irrigation. This system can automate water distribution to ensure that plants are watered based on the available water in the tank.
- Benefit: It saves water by optimizing irrigation schedules and preventing unnecessary pump usage, leading to better plant health and reduced water consumption.
12. Fish Farms and Aquaculture
- Description: In fish farms and aquaculture, where water levels in tanks or ponds need to be carefully monitored and maintained, this system can automate water refilling and pumping processes.
- Benefit: It ensures a stable water level, which is critical for the health of aquatic animals, and reduces the need for manual water management, allowing for more efficient farm operations.
13. Smart Homes Integration
- Description: For homes that are part of a larger IoT ecosystem, this project can be integrated into a smart home system, enabling it to work with other IoT devices like water leak detectors, smart irrigation systems, and home automation platforms.
- Benefit: It adds another layer of automation to smart homes, making the home more efficient in water usage and control. Homeowners can manage their water systems from their phones, along with other smart devices.
14. Municipal Water Supply and Sewage Systems
- Description: In municipal water supply systems, automation of water tanks and pumps can help optimize the distribution of water across different parts of a city or town, reducing water wastage and ensuring a consistent supply to residents.
- Benefit: Automated water management can help municipalities better manage their resources, reduce water shortages, and monitor the overall system performance in real time.
Benefits of Water Tank and Water Pump Automation Project:
Energy Savings: By automating the control of the pump, energy is saved since the pump is only turned on when necessary, reducing unnecessary operation time.
Water Conservation: Preventing water overflow helps conserve water, especially in areas where water is a scarce resource.
Remote Monitoring and Control: Using the Blynk IoT app, users can monitor the water level and control the pump remotely, adding convenience and flexibility.
Reduced Manual Labor: The system eliminates the need for constant manual supervision, making it highly useful in remote areas or large systems.
Safety: Automated systems reduce the risk of pump damage due to dry running or other malfunctions, extending the lifespan of the pump.
Developing a Custom ESP32 Water Tank Automation System
This project provides a foundation for developing more advanced water tank monitoring and automatic pump control solutions. Depending on the application, the system can be extended with multiple water level sensors, source-tank monitoring, independent overflow protection, dry-run detection, custom PCB design, local displays, and smartphone or cloud connectivity.
ArduinoExpert provides Custom ESP32 Project Development Services for IoT devices, sensor integration, embedded firmware, wireless automation, and complete electronics development.
Conclusion:
With this project, you’ll be able to automate the water pump and monitor the water tank level in real-time using the Blynk IoT platform. This setup ensures efficient water usage and prevents overflow or the pump running dry, all while providing remote control via the internet.
Need a Custom ESP32 Water Tank Monitoring or Pump Automation System?
Do you want to build this ESP32 water tank automation project or modify it for your specific requirements?
ArduinoExpert can assist with ESP32 firmware, sensor integration, automatic pump control, custom PCB design, IoT connectivity, mobile applications, and hardware prototyping.
Whether you need a basic water tank controller, a complete smart monitoring system, or a customized IoT product, we can help develop a solution based on your requirements.
We can also discuss project-code support, remote setup assistance, or assembled prototype development according to the agreed project scope.
Frequently Asked Questions (FAQs)
How does an ESP32 automatic water tank and pump control system work?
An ESP32 automatic water tank controller uses a water level sensor to monitor the amount of water in a storage tank. The ESP32 processes the sensor readings and controls a relay or suitable motor-control interface to automatically switch the water pump ON when the level is low and OFF when the tank is full. With Blynk IoT integration, users can also monitor water levels and pump status through a smartphone.
How can I automatically turn OFF a water pump when the tank is full?
You can use an ESP32 with a waterproof ultrasonic sensor or a suitable float switch to detect the water level. When the water reaches the configured maximum level, the ESP32 switches OFF the pump-control output. For greater reliability, an independent high-level cutoff can provide additional overflow protection.
Which water level sensor is used in this ESP32 water tank automation project?
This project uses a JSN-SR04T waterproof ultrasonic sensor to measure the distance between the sensor and the water surface. The ESP32 uses this measurement to estimate the tank’s water level and determine when the pump should start or stop. The sensor must be correctly positioned and calibrated for the tank dimensions.
Can I monitor my water tank level using a mobile phone?
Yes. By connecting the ESP32 to Blynk IoT through Wi-Fi, water level readings and pump information can be displayed on a smartphone. Users can monitor the system remotely when the ESP32 and mobile application have the required internet connectivity.
For more details, explore our IoT Water Pump Control System Using ESP32 and Blynk.
Can an ESP32 water pump controller work without internet?
Yes. An ESP32 can perform automatic water level monitoring and pump switching locally without internet connectivity, provided the firmware is designed for standalone operation. However, remote monitoring and control through Blynk IoT require network connectivity. Essential pump protection should not depend on the cloud connection.
Can ESP32 directly control an AC water pump?
No. An ESP32 GPIO pin cannot directly power or switch an AC water pump. The ESP32 must connect to an appropriate control interface, such as a properly rated motor contactor, starter, or compatible VFD control input. Suitable electrical protection and professional installation are necessary for mains-powered pumps.
How do I calculate the water level percentage using an ultrasonic sensor?
An ultrasonic sensor measures the distance between its mounting position and the water surface. After calibrating the empty and full tank distances, the water level percentage can be calculated as:
Water Level (%) = [(Empty Distance − Measured Distance) / (Empty Distance − Full Distance)] × 100
For example, if the empty distance is 100 cm, the full distance is 20 cm, and the measured distance is 60 cm, the calculated water level is 50%. This represents the percentage of the calibrated water-depth range, which may differ from the volume percentage in irregularly shaped tanks.
Can I manually turn the water pump ON and OFF using the Blynk app?
Yes. An ESP32 and Blynk system can be programmed with manual and automatic control modes. In manual mode, the user can request pump operation through a smartphone button. However, essential protections, including overflow prevention and low-source-water protection where installed, should remain active in both modes.
You can also explore our Bluetooth Water Pump Control System Using ESP32 for another smartphone-control approach.
Does this ESP32 water tank automation system prevent pump dry running?
The destination-tank ultrasonic sensor helps monitor filling and prevent overflow, but it cannot independently detect whether water is available at the pump’s source. Dry-run protection requires additional measures, such as a source-tank float switch, flow or pressure monitoring, or compatible motor/VFD protection.
Can I monitor both underground and overhead water tanks using ESP32?
Yes. An ESP32 can monitor both underground and overhead water tanks using separate water level sensors. With appropriate firmware and hardware, the controller can start the pump when the overhead tank requires water and prevent operation when the underground source tank is too low.
Such systems can also be integrated with a mobile application or IoT dashboard for remote monitoring.
Can I control a water pump from anywhere using ESP32?
Yes. An ESP32 connected to a suitable internet-enabled IoT platform can receive authorized pump-control requests from a smartphone at a remote location. Platforms such as Blynk or custom cloud applications can provide this functionality.
For locations without reliable internet, cellular SMS-based control is another option. Explore our Remote Tubewell Water Pump Control Through SMS or Smartphone App.
Can I add a custom mobile app, cloud dashboard, or notifications to this ESP32 project?
Yes. This project can be extended with a custom Android or iOS application, MQTT communication, a cloud database, water level history, pump scheduling, fault alerts, and multi-device monitoring.
ArduinoExpert provides Custom Mobile App Development Services for ESP32, Arduino, STM32, and other IoT-based embedded systems.
Where can I get a custom ESP32 water tank monitoring and pump automation system developed?
ArduinoExpert provides customized electronics and IoT solutions involving ESP32 firmware, water level sensor integration, automatic pump control, PCB design, mobile applications, and cloud monitoring.
Explore our Smart Water Tank Level Monitoring System Development Services or contact ArduinoExpert to discuss your project requirements.