Water Level Monitor With Oled Display Using Raspberry Pi

Water Level Monitor With Oled Display Using Raspberry Pi

Project link


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.


  • Raspberry Pi Model 3B 
  • Ultrasonic Sensor
  • Oled Display (4 pins)
  • Jumper Wires
  • Buzzer

Raspberry Pi 3 Model B

Raspberry Pi is a credit card-sized programmable computer that fits in your pocket. In this project, I am using a Raspberry Pi model 3B. It has 40 Gpio pins, 4 USB ports, charging and an HDMI port with an Ethernet port. It is compatible with almost all projects.


Ultrasonic Sensor:

Ultrasonic Sensor is a sensor that can measure the distance between the sensor and the object using echolocation i.e the principle which bats use.


A buzzer is a small component that gives out a sound wave when is switched on. We are going to use this to alert if our water tank is full  

In addition to these, we will need a bucket and a jug


Oled Display:

OLED Display is a component that can display images and words clearly. I have used a 128 x 64 display.

In addition to this, we need:

A bucket

A water jug


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




· 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.

1. Open the Thonny Python IDE

2. Download the Github code below or from the end of the page:


. 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