Introduction: Water Level Monitor With Raspberry Pi


Hello everybody, I am Shafin, a member of Aiversity. I am going to share about how to build a water level sensor for water tanks with a Raspberry pi. This project is going to help you to understand the working of Raspberry pi in detail.



Water Jug

Raspberry pi


Jumper Wires

Ultrasonic Sensor

Step 1: Connections


Now let’s talk about the connections of the raspberry pi, ultrasonic sensor and Buzzer.Please follow the circuit diagram as given


Ultrasonic sensor vcc to 5v of Raspberry Pi

Ultrasonic sensor Gnd to Gnd of Raspberry Pi

Trigger to GPIO 2

Echo to GPIO 3

Buzzer + to GPIO 4

Buzzer – to Gnd

Step 2: Structure


· Attach a scale to the bucket.

· Next attach the buzzer and ultrasonic sensor to the scale

Step 3: Code


Now you know the connections and the structure, let’s build the code.

1. Open the Thonny Python IDE

2. Download the Github code: --

3. Open and run the code.

Step 4: Testing


Fill water in the bucket. When the distance of ultrasonic sensor from the water is around 4 centimetre, the buzzer will beep, alerting the bucket is almost full.

If you have any queries, please ask at

To know more, visit

First Time Author Contest

Participated in the
First Time Author Contest