Introduction: Water Level Monitor Using Oled Display 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 with an Oled display for water tanks with a Raspberry pi. The oled display will show the percentage of the bucket filled with water.

Supplies

Hardware components

Raspberry Pi 3 Model B

Buzzer

Ultrasonic Sensor - HC-SR04 (Generic)

ElectroPeak 0.96" OLED 64x128 Display Module

Jumper wires (generic)

Water Jug

Bucket

Step 1: Connections

Now let’s talk about the connections of the raspberry pi, ultrasonic sensor, oled display and the buzzer.

Please follow the circuit diagram given.

Connections:

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

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 below or from end of the page: -- https://github.com/Aiversity/Raspberry-pi-project...

3. Run the code

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

Step 4: Testing

Fill water in the bucket. When the distance of ultrasonic sensor from the water is around 4 centimeter, 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 ask at Shafin@Aiversity.com.

To know more, visit Aiversity.com.