Water Tank Overflow Alarm System With Arduino

by | Mar 1, 2023 | Arduino, Basic Coding, Coding

Introduction of the Project

In this Arduino project tutorial, we will make a Water Tank Overflow Alarm System with Arduino. Building a water tank overflow alarm system with Arduino is a great project that can be done easily. The system will monitor the water level in a tank and trigger an alarm when the water level reaches a specific level.

Ultrasonic distance sensors work on the principle of sound waves. This sensor measures the distance using ultrasonic sound waves. When the water level of the tank rises above a predefined level, the piezo buzzer will produce sound.

Here’s how you can build a water tank overflow alarm system with Arduino:



To make Water Tank Overflow Alarm System with Arduino, we will require the following components: For the physical projects; we can purchase items from an electronic store or online.

We have used the TinkerCad website for our project.


Circuit Diagram

Water Tank Overflow Alarm System With Arduino

Steps To Build A Water Tank Overflow Alarm System With Arduino

Step 1: Gather all the components on the Digital Board or Physical Table.

Step 2: Plug the Ultrasonic Distance Sensor into the BreadBoard.


Step 3: Connect the Negative Terminal of it to the Ground (GND) pin of the Arduino using a black coloured wire.

Step 4: Connect the Positive terminal of it to the 1 number pin of the Arduino on the Digital side.

Ultrasonic Distance Sensor:

Step 5: Connect the Power terminal of the Ultrasonic Distance Sensor to the 5V pin of the Arduino at its Analog Side.

Step 6: Connect the Trigger Terminal of it to the 2 number pin of the Arduino.

Step 7: Connect the Echo Terminal of it to the 3 number pin of the Arduino.

Step 8: Connect the Ground Terminal of it to the GND pin of the Arduino.

Source Code

int distance = 0;
long readUltrasonicDistance(int triggerPin, int echoPin)
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);

digitalWrite(triggerPin, HIGH);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);

return pulseIn(echoPin, HIGH);
void setup()
pinMode(1, OUTPUT);
void loop()
distance = 0.01723 * readUltrasonicDistance(2, 3);

if(distance < 30)
digitalWrite(1, HIGH);

if(distance >= 30)
digitalWrite(1, LOW);

Explanation of the Code

1. We initially initialized the ‘distance’ variable to 0.

2. After that, we use a function which takes two values from the sensor and produces the Ultrasonic distance.

3. In the second function, namely the setup function, we set the serial connection speed to 9600 bits per second. And then configuring the pin number 1 for Output purpose.

4. In the loop function, we calculate the distance of water from the sensor & printing the same in the serial monitor, and then we use an if statement to produce the sound according to its distance from the top or, say, the range of the sensor.


We will get the following output on successfully completing this Arduino project.

Water Tank Overflow Alarm System With Arduino

If the water level is less than 30cm from the top, in the range of the sensor, the buzzer will produce a buzzing sound.


More Arduino Projects>>>

You May Also Like To Create…

Mini Radar With Arduino

Mini Radar With Arduino

Introduction of the Project Are you fascinated by radar technology and want to build your own...


Submit a Comment

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