How to Build an Automatic Water Tank Refill System That Prevents Overflow

Meta Title: How to Build an Automatic Water Tank Refill System That Prevents Overflow Using Arduino

Meta Description: Learn how to build an automatic water tank refill system using Arduino, an ultrasonic sensor, relay module, and water pump. Includes wiring diagrams, bill of materials, installation guide, troubleshooting tips, and code overview.

An automatic water tank refill system is one of the most practical Arduino projects for homes, schools, farms, and industries. Instead of manually monitoring water levels, this smart system automatically starts the water pump when the tank level becomes low and stops it when the tank is full, preventing overflow and saving water.

Whether you’re a beginner learning Arduino or an engineer looking for a reliable automation project, this guide explains how to build an automatic water tank refill system that prevents overflow using affordable electronic components.


Quick Answer: Automatic Water Tank Refill Wiring Diagram

If you want to build the project immediately, use the following wiring configuration.

ComponentPinArduino Uno Pin
HC-SR04 Ultrasonic SensorVCC5V
HC-SR04 Ultrasonic SensorGNDGND
HC-SR04 Ultrasonic SensorTRIGD9
HC-SR04 Ultrasonic SensorECHOD10
Relay ModuleIND8
Relay ModuleVCC5V
Relay ModuleGNDGND
16×2 LCD I2CSDAA4
16×2 LCD I2CSCLA5
BuzzerPositiveD7
LED (Green)PositiveD5
LED (Red)PositiveD6

Important: The relay controls the water pump. Never connect the pump directly to the Arduino output pins. Always use a properly rated relay module or motor driver for safe operation.

System Workflow

Water Tank → Ultrasonic Sensor → Arduino → Relay Module → Water Pump → Tank Refill → Pump OFF When Full


Image
Image
Image
Image

Why Build an Automatic Water Tank Refill System?

Water overflow wastes thousands of litres of water every year. Manual pump operation can also damage pumps when they run dry or are left running after the tank is full.

An Arduino-based automatic refill system solves these problems by continuously monitoring water levels and controlling the pump automatically.

Benefits

  • Prevents tank overflow
  • Saves water
  • Protects water pumps
  • Reduces electricity consumption
  • Eliminates manual monitoring
  • Suitable for homes, schools, farms, and industries

This project is ideal for smart home automation and IoT learning.


How Does the Automatic Water Tank Refill System Work?

The system consists of four major sections.

1. Water Level Detection

An HC-SR04 ultrasonic sensor measures the distance between the sensor and the water surface.

2. Arduino Processing

The Arduino converts the measured distance into a water level percentage.

3. Pump Control

If the water level falls below a preset value, the Arduino energizes the relay, turning the pump ON.

When the tank reaches the maximum level, the relay switches OFF automatically.

4. User Notification

An LCD displays the water level, while LEDs and a buzzer provide visual and audible alerts.


Image
Image
Image
Image

Bill of Materials (BOM)

ComponentQuantityPurpose
Arduino Uno1Main controller
HC-SR04 Ultrasonic Sensor1Measures water level
Single Channel Relay Module1Controls the pump
Submersible Water Pump1Pumps water into the tank
16×2 LCD with I2C1Displays water level
Green LED1Indicates tank full
Red LED1Indicates low water level
Piezo Buzzer1Alarm indication
Breadboard1Circuit assembly
Jumper WiresSeveralConnections
12V Adapter1Pump power
5V Adapter1Arduino power

Estimated Cost

ItemApproximate Cost
Arduino Uno$10
HC-SR04$3
Relay Module$3
LCD Display$6
Water Pump$12
Miscellaneous$10

Estimated Total Cost: $40–55


Circuit Connections Explained

Ultrasonic Sensor

  • VCC → 5V
  • GND → GND
  • TRIG → D9
  • ECHO → D10

Relay Module

  • IN → D8
  • VCC → 5V
  • GND → GND

LCD Display

  • SDA → A4
  • SCL → A5

Indicators

Green LED → D5

Red LED → D6

Buzzer → D7


Image
Image
Image
Image
Image

Step-by-Step Guide: How to Build an Automatic Water Tank Refill System That Prevents Overflow

Step 1: Install the Ultrasonic Sensor

Mount the HC-SR04 at the top of the tank facing downward.

Ensure there are no obstructions between the sensor and the water surface.


Step 2: Assemble the Arduino Circuit

Connect all components according to the wiring diagram.

Double-check all connections before applying power.


Step 3: Connect the Relay Module

Wire the relay between the power source and the water pump.

The relay acts as an electrically controlled switch that isolates the Arduino from the high-current pump.


Step 4: Upload the Arduino Program

The Arduino program should:

  • Measure water level
  • Display the percentage on the LCD
  • Turn the relay ON when the tank is low
  • Turn the relay OFF when the tank is full
  • Activate alarms when necessary

Example logic:

If Water Level < 30%

Pump ON

Else If Water Level > 95%

Pump OFF

Step 5: Test the System

Fill and empty the tank gradually while monitoring the LCD.

Verify that:

  • Water level readings are accurate.
  • LEDs indicate the correct status.
  • The buzzer sounds when required.
  • The pump switches automatically.

Image
Image
Image
Image

Arduino Program Logic

The Arduino continuously repeats the following process:

  1. Trigger the ultrasonic sensor.
  2. Measure water distance.
  3. Calculate water level percentage.
  4. Compare with preset thresholds.
  5. Turn the relay ON or OFF.
  6. Update the LCD display.
  7. Repeat every few seconds.

This closed-loop control system ensures the tank remains within safe operating levels.


Applications

This automatic water refill system is suitable for:

  • Homes
  • Schools
  • Apartment buildings
  • Irrigation systems
  • Livestock farms
  • Industrial storage tanks
  • Rainwater harvesting systems

Advantages and Limitations

Advantages

  • Prevents water wastage
  • Fully automatic operation
  • Affordable components
  • Low maintenance
  • Easy to upgrade for IoT monitoring

Limitations

  • Ultrasonic sensors may be affected by condensation.
  • Requires stable power.
  • Pump selection depends on tank size.
  • Periodic sensor cleaning may be necessary.

Safety Tips

  • Disconnect power before servicing the circuit.
  • Use waterproof enclosures for outdoor installations.
  • Install a fuse for pump protection.
  • Keep high-voltage wiring isolated from Arduino circuits.
  • Test the relay before connecting the pump.

Frequently Asked Questions

Can I Use Float Sensors Instead?

Yes. Float switches are simpler but provide fewer water level measurements compared to ultrasonic sensors.

Can I Monitor the Tank Remotely?

Yes. Replace the Arduino Uno with an ESP32 to add Wi-Fi monitoring using platforms like Blynk or MQTT.

What Is the Maximum Tank Height?

The HC-SR04 typically measures up to 4 meters, making it suitable for most domestic tanks.


How to Fix Common Arduino Upload Errors

Error: “avrdude: stk500_recv(): programmer is not responding”

Solutions

  • Select the correct COM port.
  • Disconnect modules using TX/RX pins.
  • Replace the USB cable.
  • Restart the Arduino IDE.

Error: Relay Does Not Switch

Solutions

  • Verify the relay input pin.
  • Check the power supply.
  • Confirm the relay is rated for the pump voltage.

Error: Incorrect Water Level Readings

Solutions

  • Mount the sensor vertically.
  • Remove obstructions inside the tank.
  • Recalibrate the tank height in the code.

Error: LCD Shows Blank Screen

Solutions

  • Adjust the I2C module contrast.
  • Verify SDA and SCL wiring.
  • Check the LCD address using an I2C scanner.

Image
Image
Image
Image
Image

Final Thoughts

Learning how to build an automatic water tank refill system that prevents overflow is one of the most practical Arduino automation projects for everyday use.

With an Arduino Uno, an HC-SR04 ultrasonic sensor, a relay module, and a water pump, you can create a reliable system that automatically maintains water levels while conserving water and protecting your pump.

As your skills improve, you can enhance the project by adding ESP32-based Wi-Fi monitoring, cloud data logging, mobile app notifications, solar-powered operation, or multiple tank management, turning a simple refill controller into a complete smart water management system.

mbeva

Dominic Mbeva is a science teacher, experienced researcher, innovator, and creative technologist with expertise in STEM education, digital media, and scientific research. As a Kenya Science and Engineering Fair (KSEF) advisor and projects manager, he mentors young scientists, guiding them in developing award-winning innovations. He is also an IC Technorat, leading advancements in science and technology. Beyond education, Dominic is a skilled photographer and video editor, using visual storytelling to make science more engaging. His philosophy, “If you take care of minutes, hours will take care of themselves,” reflects his belief in consistent effort, strategic thinking, and innovation to drive success in both research and creativity.

Related Posts

How to Build a Smart Kitchen Tap That Saves Water Automatically

How to Build a Smart Kitchen Tap That Saves Water Automatically Using Arduino Meta Description: Learn how to build a smart kitchen tap using Arduino, an infrared sensor, solenoid valve,…

Read more

How to Build a DIY Quadcopter Flight Controller with ESP32

How to Build a DIY Quadcopter Flight Controller with ESP32: Complete Step-by-Step Guide Meta Description: Learn how to build a DIY quadcopter flight controller using ESP32, an MPU6050 IMU, ESCs,…

Read more

Leave a Reply

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