Rasperry Pi3 x1
|water level sensor x1|
|Analog to digital convertor(ADC) 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 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 --no-check-certificate http://osoyoo.com/driver/waterlevel.py
2)Execute python program
sudo python ./waterlevel.py
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.
You must be logged in to post a comment