Interfacing a Water Level Sensor with Arduino to Prevent Water Tank Overflow

Circuit Digest
3 min readJun 18, 2024

--

Water level sensor with Arduino

Water tank overflow is a common issue that often goes unnoticed in many households, leading to significant water wastage. While traditional solutions like ball valves can help, as an electronic engineer, I prefer a more modern approach using sensors and automation. In this tutorial, we’ll explore how to interface a water level sensor with an Arduino to measure water levels effectively. Let’s dive into the details!

Understanding the Water Level Sensor

The water level sensor module operates similarly to a rain sensor, with a straightforward pinout and easy-to-understand functionality.

Pinout of the Water Level Sensor:

VCC: Power supply pin, connected to 5V.

GND: Ground pin, connected to the Arduino ground.

OUT: Analog output pin, providing a signal between VCC and ground.

Pinout of Water Level Sensor

Specifications:

Operating Voltage Range: 3 to 5V

Current Consumption: 3 to 41 mA

Output Voltage Range: 0 to 3.85V

Output Type: Typically Analog, can interface with Digital Pins

Water Detection Area: 40mm Height x 16mm Width

Operating Humidity: 10% to 90%

Working Temperature: -30 to 50°C

It’s important not to operate the sensor above 5V to avoid increasing current consumption and electrolysis in the liquid medium, which can alter the liquid’s characteristics. While the output voltage might fluctuate over time due to electrolysis, it’s generally stable in moving water.

How Does the Water Level Sensor Work?

The sensor consists of long conductive plates on a PCB. When water reaches a certain level, the resistivity between these plates changes, altering the output voltage. This change can be visualized as a parabolic and exponential graph.

The sensor’s design includes ten conductive plates — five power tracks and five sensor tracks. As water touches these plates, current flows from the 5V supply to the base of an NPN transistor, turning it on. The more submerged the sensor is, the higher the output voltage.

Circuit Diagram and Connection

Connecting the water level sensor to an Arduino is straightforward. Here’s how you can do it:

Connect the sensor’s VCC to the Arduino’s 5V pin.

Connect the sensor’s GND to the Arduino’s ground.

Connect the sensor’s OUT pin to the Arduino’s A0 pin.

Connect an LED to the Arduino’s PWM pin 6.

Here’s the circuit diagram for reference:

Circuit of Water Level Sensor

In this setup, the LED’s brightness will change based on the water level detected by the sensor.

Arduino Code for Water Level Sensor

The Arduino code to read data from the sensor and control the LED is simple and easy to follow. This code initializes the LED and sensor pins, reads the sensor value, and adjusts the LED brightness based on the water level. For a more detailed indication of water levels, you can use three LEDs to show low, medium, and high levels.

Pros and Cons of Using a Water Level Sensor

Pros:

Simple to integrate with microcontrollers.

Cost-effective for budget projects.

Versatile, working with both analog and digital input pins.

Cons:

Accuracy issues due to electrolysis.

Potential for false readings from water sticking to the PCB.

Non-linear output requires complex calculations.

Working of Water Level Sensor

By interfacing a water level sensor with an Arduino, you can create an efficient system to monitor and manage water levels, preventing overflow and conserving water. Experiment with different setups to find what works best for your needs, and enjoy the process of building and learning with this practical application of electronics.

--

--

No responses yet