This is a water level monitor project with an OLED display that will show the percentage of the bucket filled.
Hello everybody, I am Shafin, a member of Aiversity. I am going to share how to build a water level sensor with an OLED display for water tanks with a Raspberry pi. The OLED display will show the percentage of the bucket filled with water.
Now let’s talk about the connections of the Raspberry Pi, ultrasonic sensor, OLED display, and the buzzer.
Please follow the circuit diagram given below.
- Ultrasonic sensor Vcc to 5V of Raspberry Pi
- Ultrasonic sensor Gnd to Gnd of Raspberry Pi
- Trigger to GPIO 14
- Echo to GPIO 15
- Buzzer + to GPIO 4
- Buzzer – to Gnd
- Sda of OLED display to GPIO 2 of Raspberry Pi
- Scl of OLED display to GPIO 3 of Raspberry Pi
- Vcc of OLED display to 3.3v of Raspberry Pi
- Gnd of OLED display to Gnd of Raspberry Pi
Attach a scale to the bucket. Next attach the buzzer and ultrasonic sensor to the scale.
Now you know the connections and the structure, let’s build the code.
- Open Thonny Python IDE.
- Download the Github code, also found at the end of this article.
- Run the code.
You will have to add your distance from the ultrasonic sensor to the base of the bucket on the line:
Line 25. dist_from_base = #Write the distance from the sensor to the base of the bucket
Fill water in the bucket. When the distance of the ultrasonic sensor from the water is around 4cm, the buzzer will beep, alerting the bucket is almost full and the OLED display will show the percentage of the bucket filled.
If you have any queries, please leave a comment!