Water level sensor

Water level sensor

Use a Calliope Mini and a cheap water level sensor to sense water levels and potentially react on reaching a water limit.


30 mins

from 8 years on


This Calliope mini project is a great introduction to variables and basic math using Calliope mini. A cheap (<1€) water level sensor is used to sense analog input and plot it using the 5x5 LED matrix. Using the buttons you can set the max level and also a threshold level above which the LED will turn red.

A quick video can be seen here. The water level sensor can be purchased here.

To begin this project, first identify the required pins for the water level sensor. The sensor needs VCC (the 3.3V provided by Calliope), GND and has an analog output which can be sensed by one of the calliope pins. In case you want to use the pins at the bottom of the calliope mini, you will need to solder some male/female header pins to your Calliope Mini.

The C17 pin is exposed via the right grove port but also via the pins at the bottom. C17 is the third pin for the top pin row from the right (here: blue cable). The top right pin is GND (here green cable) and the bottom right pin is GND (orange cable).

When the program starts up it will set the max, limit and level variables to default values.

  • max: based on my testing, the max analog input value was 430. The range of analog input is 0-1023, but the water level sensor has a certain base resistance as well as the water/cables used.
  • by default, the limit is set to half the max value.
  • the level variable will hold the current C17 analog reading, initialized to 0.

Turn on the calliope mini and wait for it to initialize. Now put the water level sensor into a glas of water until the sensors pins are fully covered with water. Press Button A to set the max value and a default limit.

Using button B is optional, but you can use it to change the limit threshold. For example take out the water level sensor until only 1/3 is covered and press B to set the limit to this level.

In the forever loop, the calliope mini is instructed to show a green LED if the current level is below the limit, RED otherwise. You could easily extend the program to send a radio message to notify another calliope mini of rainy weather or a rising water level (alarm for the washing machine room?).

This text as well as the images were published under a CC BY-SA 3.0 DE license. It was originally published in English by Sven Haiges and edited by the Calliope team.

You can find the finished file below.

The program can be opened directly with the MakeCode editor.