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:
Supplies
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.
Components
- Arduino Uno R3
- Ultrasonic Distance Sensor
- 1 Small Breadboard
- 1 Piezo (Buzzer)
- Connecting wires
Circuit Diagram
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.
Piezo:
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); delayMicroseconds(2); digitalWrite(triggerPin, HIGH); delayMicroseconds(10); digitalWrite(triggerPin, LOW); pinMode(echoPin, INPUT); return pulseIn(echoPin, HIGH); } void setup() { Serial.begin(9600); pinMode(1, OUTPUT); } void loop() { distance = 0.01723 * readUltrasonicDistance(2, 3); Serial.println(distance); 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.
Output
We will get the following output on successfully completing this Arduino project.
If the water level is less than 30cm from the top, in the range of the sensor, the buzzer will produce a buzzing sound.

Cisco Ramon is an American software engineer who has experience in several popular and commercially successful programming languages and development tools. He has been writing content since last 5 years. He is a Senior Manager at Rude Labs Pvt. Ltd.
0 Comments