In this post we will go over how to use a water level sensor with Arduino. We’ll go over sensor basics, how to connect it to an Arduino, programming it in Arduino IDE, and testing.
The water level sensor works due to its exposed traces, which are used to sense the water level. The water level is measured across a full spectrum, meaning is the sensor isn’t simply confirming the presence of water, it is actually measuring the level. Since the sensor is measuring the level, let’s look at the sensor length (since it’s important to make sure it will meet the needs of your project!).
Water Level Sensor Length
The sensor being used as part of this post has a total measuring length of ~1.6in (41mm) (see image on the right showing in inches and mm). This is pretty consistent with other water level sensors sold for Arduino, Raspberry Pi, etc… This is important so you know the total range over which you will be able to measure.


Sensor Pins & Connections to Arduino
(+) – Positive pin, goes to +5V. Acceptable voltage is 3.3V – 5V.
(-) – Negative pin, goes to GND
S – Signal pin, goes to the Analog IO Pin A0

*Note that Analog IO pins work different than Digital IO pins. Analog pins will provide a numeric value (over a numeric range) associated with the signal being read at the pin. This range will cover all integers from 0 to 1023. The 0 corresponding to a 0 volt signal, and 1023 corresponding to a 5.0 volt signal. In contrast, the Digital pin can only provide two values 0 or 1 (Off or On). This allows you to take action in case you want to have different operating scenarios (maybe level 1 alarm once the sensor starts sensing water and critical level 2 alarm once the sensor reaches 80% of the total length, up to you!).
Arduino Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//Arduino Code - Water Level int Lvl = A0; //Define the Analog pin# on the Arduino for the level sensor signal void setup() { Serial.begin(9600); // Start the serial communication } void loop() { int water_lvl=analogRead(Lvl); Serial.print("Water level: "); Serial.println(water_lvl); delay(200); } |
Run Arduino Code – Water Level Sensor Testing
All you need to do now is copy the code that was provided above, run it and open the Serial Monitor.


Click to enlarge
Components used in this example
*As an Amazon & Ebay Associate I earn from qualifying purchases.
Component | Link |
Arduino UNO | https://amzn.to/3uYVAMC https://ebay.us/veZdKX |
Water level sensor | https://amzn.to/2QeI4Wt https://ebay.us/JjrZEA |
I every time spent my half an hour to read this webpage’s posts all the
time along with a mug of coffee.