Lab05 - Water Level Sensor Works and Interface It With Arduino
Lab05 - Water Level Sensor Works and Interface It With Arduino
Objectives:
▪ Detect the presence and level of water using Arduino
Introduction:
If you have ever had a water heater explode or ever tried to make submersible electronics, then you know how important it is to
detect when water is around. With this Water Level Sensor shown in Figure 1, you can do just that! This sensor can be used to measure
the water level, monitor a sump pit, detect rainfall, or detect leakage.
Figure 1
As shown in Figure 2, the sensor has a series of ten exposed copper traces, five of which are power traces and five are sense
traces. These traces are interlaced so that there is one sense trace between every two power traces. Usually, these traces are not
connected but are bridged by water when submerged.
Figure 3
Digital Electronics 2: Microprocessors and Microcontrollers
Darwin D. Mañaga, Meng-ECE, PECE, ACPE
Components:
▪ Breadboard
▪ Arduino Uno R3
▪ Water Level Sensor
▪ LEDs
▪ 330 ohm resistors
Let’s hook the water level sensor up to the Arduino. First you need to supply power to the sensor. For that you can connect
the + (VCC) pin on the module to 5V on the Arduino and – (GND) pin to ground. However, one commonly known issue with these
sensors is their short lifespan when exposed to a moist environment. Having power applied to the probe constantly speeds the rate of
corrosion significantly. To overcome this, we recommend that you do not power the sensor constantly, but power it only when you take
the readings.
An easy way to accomplish this is to connect the VCC pin to a digital pin of an Arduino and set it to HIGH or LOW as per your
requirement. So, we’ll connect the VCC pin to the digital pin #7 of an Arduino. Finally, connect the S (Signal) pin to the A0 ADC pin on
your Arduino. Figure 4 shows the wiring.
Figure 4
// Sensor pins
#define sensorPower 7
#define sensorPin A0
void setup() {
// Set D7 as an OUTPUT
pinMode(sensorPower, OUTPUT);
void loop() {
//get the reading from the function below and print it
int level = readSensor();
Serial.print("Water level: ");
Serial.println(level);
delay(1000);
}
Figure 5