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

Byamber

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

Overview

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

Experimental Parts

PI
Rasperry Pi3 x1
2016000500
water level sensor x1
MCP3008
Analog to digital convertor(ADC)  x1
LACC2006AD-12
Breadboard x1
LACC2006AD-31
male to male jumper wires
19
male to female jumper wires

Hardware

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:

waterlevel

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)

Software

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

1)Write the code

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

sudo nano waterlevel.py

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

sudo wget http://osoyoo.com/driver/waterlevel.py

2)Execute python program

sudo python ./waterlevel.py

3)Test

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.

2017-03-28-084637_1824x984_scrot

About the Author

amber administrator

You must be logged in to post a comment