Testing water level sensor


This post is for sharing some details related to measuring water levels using the water level sensor, MCP3008 chip and Raspberry Pi.

The MCP3008 is a low cost 8-channel 10-bit analogue to digital converter. We need MCP3008 because the Raspberry Pi doesn’t have any analogue GPIO pins.

The author nicknamed amber described the wiring diagram well in this blog post:
Design a water level detector through a raspberry pi board and water level sensor.

The code provided in this blog post also works, but I decided to use Adafruit Python MCP3008 package. We can install it this way:

sudo pip install adafruit-mcp3008

The code to read the values from the water level sensor via MCP3008 chip is also simple:

import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008

mcp = Adafruit_MCP3008.MCP3008(clk=11, cs=8, miso=9, mosi=10)


The Raspberry Pi Zero W costs £12.82 (+delivery, in my case £2.99). It’s from here:

MCP3008 DIP16 MCP3008-I/P DIP-16 DIP chip costs $2.35 (free delivery to the UK). It’s from here:

High Sensitivity Water Liquid Level Sensor costs $1.46 (free delivery to the UK). It’s from here:

The code is available here: