Design a water level detector through a raspberry pi board and water level sensor


Design a water level detector through a raspberry pi board and water level sensor


This tutorial is to design a water level detector through a raspberry pi board and water level sensor.It can detect if the amount of water in container reach the specific level.This device collect the relevant data through water level sensor and output the data through raspberry pi.

Experimental Parts

Rasperry Pi3 x1
water level sensor x1
Analog to digital convertor(ADC)  x1
Breadboard x1
male to male jumper wires
male to female jumper wires


As only the digital signal can be processed by raspberry pi, we need to add a analog to digital converter (ADC) to process the analog signal from water level sensor.It can detect the smoke in the air according to the valtage value. MCP3008 as ADC chip is very common and recommended highly.

Water level sensor is simple and cheaper sensor that identify the amount of water through exposed parallel line track.Easy to complete analog signal change from the water level detection.The work voltage of this sensor is DC 3V-5V and use 3.3V in this tutorial.
The schematic diagram is as follows:


Pay more attention to the anode and cathode, otherwise it would burnout your raspberry pi board and sensor.You can connect the GND of the sensor to OV, VCC to 3.3V. You could visit the article for your referenc if you want to learn more about the raspberry pi IO port : How to read Raspberry Pi i/o pin diagram (GPIO pin graph)


You could choose the connect the raspberry pi to monitor, or login in pi via SSH.

1)Write the code

Add new file named under the /home/pi file path via nano editor (the name is arbitrary)

sudo nano

Write the sample code in new file, the code can be obtained by executing shell commands.

sudo wget --no-check-certificate

2)Execute python program

sudo python ./


Put the water level sensor into the container and ensure that the water can not exceed the max height.When there is no water in container,it will show no water.The number will increase with the deeper water.


About the Author

amber administrator

3 Comments so far

MarcusPosted on  7:04 am - Apr 19, 2018

Please send me the complete details of wire connections from raspberry to breadboard.


hckennedyPosted on  4:43 pm - Nov 11, 2020

Can you send me the sample py code please?

You must be logged in to post a comment