Home / Tutorials / Arduino Tutorial / Using a Water Level Sensor with Microcontrollers
water level sensor

Using a Water Level Sensor with Microcontrollers

A water level sensor is a simple device that is used to measure the level and the volume of water inside a container. This tutorial shows you how to use a water level sensor with microcontrollers like an Arduino or PIC.

Introduction

Water level sensors range from educational to industrial. The most common and frequently seen in stores is this one:

Water Level Sensor

This is a conductive-type water level sensor, where the change in resistance of parallel wires over varying depths of water is converted to voltage. This is not ideal for high precision water level monitoring and is only suitable for hobby projects.

The module has three pins: + (5V), - (GND), and S (Signal). The S pin outputs voltage corresponding to water level.

Wiring Diagram

Connecting the water level sensor to a microcontroller is easy: just connect the S pin to any analog pin. Of course, you must connect the and the + and - pin to power and ground. Here's an example wiring diagram with an Arduino:

Arduino Water Level Sensor Schematic

Arduino Sketch

The sketch for the water level sensor is also simple:

This sketch will display varying numbers on the serial monitor as you vary the depth of the water. You cannot display the actual levels unless you do some actual tests. I suggest you use a calibrated container like this one:

Image result for calibrated cup

Fill up this container with liquid up to each calibration. Then place the water level sensor, open serial monitor and record the number. Add more water reaching each label on the container then record the number again. Continue doing this until you've filled the container.

PIC XC8 Code

To use this water level sensor with a PIC, we can use the code I created in my PIC ADC tutorial:

It is assumed that the S pin of the sensor is attached to channel AN0 of the PIC's ADC. Similar to the Arduino example, you still need to do tests and recording to acquire the levels in metric or english units of measurement.

Check Also

Using an Arduino Turbidity Sensor

Turbidity refers to the haziness of a fluid caused by the increased number of very …

Leave a Reply

Your email address will not be published. Required fields are marked *