Water Level Sensor
In this article, we will discuss the water level sensor, which is also known as a leak detection sensor. We will cover wiring diagrams, code examples, pinouts, and technical data. The sensor is connected to an analog input pin and provides an integer value between 0 and 500 to indicate the water level. When connected to a digital pin and a pull-up resistor, it can detect the presence of water but not its depth.
The water level sensor/leak detection sensor is a 3-pin module that outputs an analog signal (generally 0 to 500) indicating the approximate water submersion depth. When used in conjunction with a pull-up resistor, it can be used as a digital device to indicate the presence of water.
Tech Specs for the Water Level Sensor module:
To connect the Water Level Sensor to an Arduino, follow these steps:
- Connect the GND pin of the sensor to the GND pin of the Arduino.
- Connect the Signal pin of the sensor to PIN A5 on the Arduino.
- Connect the Vcc+ pin of the sensor to the 5V pin of the Arduino.
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);
}