Measures the water level and switches the pump on and off by itself.
Built and tested by Aboobacker sidheeq K P · Industrial Robotics Institute

An automatic water tank controller. An ultrasonic sensor measures how far the water surface is from the top of the tank. When the tank is nearly empty the buzzer gives a short alert and a relay turns the pump on; when it is full the pump switches off automatically. No more overflowing or dry tanks.
| Component | Qty |
|---|---|
| Arduino Uno | 1 |
| Ultrasonic Sensor (HC-SR04) | 1 |
| Relay Module | 1 |
| Water Pump (AC/DC) | 1 |
| Buzzer | 1 |
| Lithium-ion Batteries | 2 |
| Battery Case with Switch | 1 |
| Jumper Wires | As needed |
| From | Connect to |
|---|---|
| Ultrasonic VCC | 5V |
| Ultrasonic GND | GND |
| Ultrasonic TRIG | Pin 9 |
| Ultrasonic ECHO | Pin 10 |
| Relay IN | Pin 7 |
| Relay VCC / GND | 5V / GND |
| Relay COM | Pump power supply + |
| Pump + | Relay NO |
| Pump − | GND |
| Buzzer + | Pin 8 |
| Buzzer − | GND |
| Battery + (via switch) | Arduino VIN |
| Battery − | GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the Arduino Uno.
#define trigPin 9
#define echoPin 10
#define relay 7
#define buzzer 8
long duration;
int distance;
int emptyLevel = 20; // cm (tank empty threshold)
int fullLevel = 5; // cm (tank full threshold)
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relay, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(relay, LOW);
}
void loop()
{
// Trigger ultrasonic
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
// Tank empty condition
if (distance > emptyLevel)
{
digitalWrite(buzzer, HIGH); // Buzzer 200 ms
delay(200);
digitalWrite(buzzer, LOW);
digitalWrite(relay, HIGH); // Pump ON
}
// Tank full condition
else if (distance < fullLevel)
{
digitalWrite(relay, LOW); // Pump OFF
}
delay(1000);
}An automatic water tank controller. An ultrasonic sensor measures how far the water surface is from the top of the tank.
You need: Arduino Uno (1), Ultrasonic Sensor (HC-SR04) (1), Relay Module (1), Water Pump (AC/DC) (1), Buzzer (1), Lithium-ion Batteries (2), Battery Case with Switch (1), Jumper Wires. Software: Arduino IDE.
Yes. It is rated beginner and takes about 2–3 hours to build, using the Arduino Uno. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-037). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.