fbpx

Most orders for IN STOCK items placed by 12PM CST M-F ship SAME DAY. Orders for custom items and prints may take additional time to process.

Sensor Wiki: Water Level Sensor (Leak Detection)

This wiki article covers the water level sensor (sometimes called a leak detection sensor). Included are wiring diagrams, code examples, pinouts, and technical data. This sensor connects to an an analog input pin and provides an integer value generally from 0 to 500 indicating the level of water.  When used with a digital pin and a pull up resistor, it can give an indication of the presence of water without reporting its depth.

Content

  •  Sensor/Module Image Gallery
  •  Description and Technical Data
  •  Device Pinout
  •  Projects that use this Sensor/Module
  • Code Examples
    • Code example for Arduino
    • Code example for Raspberry Pi

 Description and Technical Data

The water level sensor / leak detection sensor is a 3-pin module that outputs an analog signal (generally 0 to 500) that indicates the approximate depth of water submersion.  When used in conjunction with a pull up resistor, it can be used as a digital device to indicate the presence or water.

Tech Specs for the Water Level Sensor module: 

  •  Operating Voltage: +5V
  • Working Current : <20mA
  • Sensor Type : Analog or Digital
  • Water Detection Area :. 1.58in X .63in (40mm X 16mm)
  • Mounting Hole Size : .12in (3mm)
  • Operating Humidity: 10% to 90% (non-condensating)
  • Working Temperature: -22f to 122f (-30c to 50c)
  • Weight :. 3 grams
  • Product Dimensions : 2.56in X .79in (65mm x 20mm)

 Device Pinout & Schematics

This module has three pins: GND, Vcc+, and Signal.

water level sensor pinout for arduino

 Our Projects that Use this Sensor

The following Geek Pub projects include the water level sensor (leak detection sensor):

 Code Examples

You’ll find below code examples of using the KY-010 photo interrupter / light barrier module with both Arduino and Raspberry Pi (Python).

Water Level Sensor / Leak Detection Sensor Code Example for Arduino

In this water level sensor module (leak detection sensor) example code.  We will detect a range of integers from 0 to 500 and display Empty, Low, Medium, or High to the serial console.  See the related project for using an LCD character display.

Arduino Wiring:

  • Water Level Sensor GND to Arduino GND
  • Water Level Sensor Signal to Arduino PIN A5
  • Water Level Sensor Vcc+ to Arduino 5V


int resval = 0; // holds the value
int respin = A5; // sensor pin used

void setup() {

// start the serial console
Serial.begin(9600);
}

void loop() {

resval = analogRead(respin); //Read data from analog pin and store it to resval variable

if (resval <= 100) {
Serial.println("Water Level: Empty");
}
else if (resval > 100 && resval <= 300) {
Serial.println("Water Level: Low");
}
else if (resval > 300 && resval <= 330) {
Serial.println("Water Level: Medium");
}
else if (resval > 330) {
Serial.println("Water Level: High");
}
delay(1000);
}

WATER LEVEL SENSOR / LEAK DETECTION MODULE CODE EXAMPLE FOR RASPBERRY PI

The following code example is for the Raspberry Pi using the Python programming language. This code will write “Detected!” to the terminal window when water is detected.

Raspberry Pi Wiring:

  • Coming Soon!

We hope this wiki article has been helpful to you. Please leave a comment below if you have any questions or comments, as we try to keep these articles constantly up to date.

 Back to List of Arduino Sensors and Modules

Upgrade to Premium

If you like our content maybe consider upgrading to Premium. You’ll get access to

  • Free access to all plans
  • Member only videos
  • Early access to content
  • Ad free Experience
  • Discounts on store merch
  • Direct hotline contact form

Leave a Reply