0% found this document useful (0 votes)
2 views13 pages

Arduino Water Level Sensor Guide

This document describes the development of a water level sensor using Arduino and an ultrasonic sensor. It explains the necessary components, how to build the circuit, calibrate the sensor by measuring at different water levels, and how to use the sensor measurement to calculate the volume of water. The final goal is to display the measured water level on an LCD screen.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

Arduino Water Level Sensor Guide

This document describes the development of a water level sensor using Arduino and an ultrasonic sensor. It explains the necessary components, how to build the circuit, calibrate the sensor by measuring at different water levels, and how to use the sensor measurement to calculate the volume of water. The final goal is to display the measured water level on an LCD screen.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INTRODUCTION TO ELECTRICAL DESIGN

REPORT: WATER MEASUREMENT SENSOR WITH ARDUINO

TEACHER: ENG. JAMES SKINNER CELADA PADILLA

MEMBERS:

CALLLE HUAMAN, HENRRY GRABIEL 160486J

RUIZ VILCHEZ, JHON ANTHONY 164044J

Edwim Johel Cordova Macedo 160493F

2018

ARDUINO WITH WATER SENSOR


INDEX

. Definition and concepts of water sensor.

. The water level sensor with Arduino allows us to measure any


liquid thanks to the ultrasonic sensor.

. Necessary components for the water level sensor with Arduino

. Electrical circuit

. Mounting the sensor in the bucket

. Calibrating the water level sensor with Arduino

. Displaying data on the LCD

. Conclusions
1. DEFINITION OF WATER SENSOR:

On many occasions, we will want to have the volume controlled.


water that we have somewhere. With this type of sensor we can
to know if it is dry, splashed, partially submerged or completely submerged.

They can be useful in detecting if water is condensing in any


site, to know the water level in a tank (although this model
it has very little range) or to know if it is raining.

These water sensors are extremely easy to connect and program,


and also cheap.

2. THE WATER LEVEL SENSOR WITH ARDUINO US


ALLOWS MEASURING ANY LIQUID THANKS TO
ULTRASONIC SENSOR:

The most important piece in this project will be the Arduino. In this case
we can use any model that has at least 8 inputs
digital. In this tutorial, I will work with the most famous board of
Arduino, the UNO.

The project will consist of different phases where we will be progressing.


to achieve our goal.

. Electrical circuit, connecting the components


. Test all components and connections
. Mounting the sensor in the bucket
. Calibrating the water level sensor with Arduino
. Displaying the data on the LCD
3. NECESSARY COMPONENTS FOR THE LEVEL OF
WATER SENSOR WITH ARDUINO:

The first thing we must do if we want to create a level sensor


with Arduino, is to know the components that we are going to
use. Of course this is just an idea, of all the
components that I will detail below, some are
dispensable.

Arduino UNO

It will be the brain of the application and responsible for managing everything.
sensors through the digital inputs and outputs. In the
Programming resides in its power. We will see what code we should
implement to be able to measure the level in a container.

23.33€
Ultrasonic sensor HC-SR04

We have already seen in different articles and even a chapter of the


podcast how this sensor works. I am not going to go into detail about its
operation just to comment that this type of sensors are based on
measure how long it takes for an ultrasonic wave to travel from
it leaves the sensor until it returns.
Thanks to this time and knowing the speed of sound, it is easy
calculate the distance using the famous formula.

€1.49
16×2 LCD screen

We have also seen this component in several articles.


Displaying moving text and showing the temperature of a
sensor. It consists of a liquid crystal display with 16 columns and 2
rows. In it we will be writing the results obtained from the
measurements, as well as any other useful information in this project.

Price: €2.84

Other electronic components


In addition to the essential components for the water level sensor
with Arduino, we will need the typical components that are usually
to be used in many circuits. I will detail them below.

. Breadboard (€1.92)
. 10kΩ potentiometer (€1.60)
. Resistance 220Ω (3.49€)
. Cables (€8.99)
4. ELECTRIC CIRCUIT:

With all the components in our possession, we can now start to


assemble the circuit. As I mentioned at the beginning of the article,
we will need 8 digital inputs and outputs. In addition, we will use
the 5V pin and the GND (ground).

5. MOUNTING THE SENSOR EN THE BUCKET:

We have already set up the entire circuit, we have checked that everything
it works correctly and now we are going to mount the sensor on top of the
container or bucket where we are going to have the liquid. We can do it
In many ways, I am going to show you a very simple one using
two wooden sticks that are used for cooking. They are the typical ones for
to know if the cake is done or to make skewers.

In addition, I have used two wires of the typical ones that come in
any packaging to hold cables. I usually collect this type of
you grab them as they are very useful on many occasions. The result it
you can see in the following images.
Thanks to these two poles we can position the ultrasound down below.
on top of any container or bucket. In the next image you
I show an example of how it would look.

6. CALIBRATING THE WATER LEVEL SENSOR WITH


ARDUINO:

The time has come to start programming. The first thing we must
to calibrate the water level sensor with Arduino. For this, I am going to
to use a measuring cup, that is, a cup that has markings on it
measures. This way we can assign a measurement from the ultrasonic sensor.
to a quantity of liquid. This will allow us to know how much of
liquid we have in the container.

Something you need to keep in mind is that the ultrasonic sensor


measure the amount of empty space in the container. Therefore, if
we know the total capacity of the container by subtracting the amount of
We will know how much liquid there is in the empty space. Look at the general diagram.
So, according to this general scheme, we must know what value
we obtain with the ultrasound sensor when it is empty, when
it is full and a known measurement. We will make this last measurement with
measuring cup calculating the value for 100 ml.

Before starting with the measurements, we must take into account that
the glass must be cylindrical, that is, the base must be the same
diameter than the top part. If we try to measure in a container
that is not cylindrical, conical in shape, the measurements do not
they will be proportional.

Calculate the average to eliminate noise:

In all electronic systems, noise is generated due to the


movement of the electrons, to the sensor itself, the Arduino board,
etc... This translates to a variation or fluctuation in the measurements.
what we are obtaining through the sensor. To eliminate this type of
Noise is usually filtered using a low-pass filter that eliminates the frequencies.
low, right where the noise is. The simplest way to
applying it through programming is averaging the values
that are being obtained.
But not only to eliminate the noise, by calculating the average we can
eliminate the fluctuations due to the movement of the container.
Imagine a car's gas tank. When it is running
the fuel is not still, it is moving. If you want to measure it with
An ultrasonic sensor would be complicated if some are not used.
technique like this.

Depending on the number of samples we use to obtain the


media, we may have a more accurate or less accurate value. But
this also influences how long it takes to stabilize the measurement when
a change occurs. Therefore, if we take a high number of
samples, the average will be more precise, but it will take longer to
reflect the changes. On the contrary, if we take a low number of
samples, the average will be less precise, but we will see more reflected
The changes are quick. Choosing one or the other will depend on what we want.
achieve, speed or precision.

Another factor to consider is the size of the data type that we are going to
to store. We must be very careful as we can cause
an overflow. All samples will be stored in a
variable to then calculate the mean, therefore, if we choose a
we must ensure that we do not go out
of range.

In this case, I will choose precision, I will take a range of


samples of 100. The code is very similar to what we have used
to test the ultrasonic sensor to which I have added the calculation of
the average of every 100 values. I will not go deeper into this technique,
if you want to learn everything that lies behind, I advise you to watch the
lesson where I show how to stabilize the temperature sensor
LM35.
Calculating the liquid level

With the data obtained in the previous phase, with the container empty,
full and with 100 ml, we can now obtain a formula for the sensor of
water level with Arduino. The measurements obtained indicate the
amount of empty space in the container. Let's get started
changing the range to bring it to 0 by eliminating the offset of 2.20 cm.
It's as if the liquid is at 0 cm when the container is zero.

EMPTY FULL 100 ML

11.41 cm 2.20 cm 9.26 cm

9.21 cm 0 cm 7.06 cm

The next step is to calculate how much 100 ml of liquid takes up in


our container. This is done by subtracting the distance when it is empty
less the distance when it has 100 ml.

9.21 - 7.06 = 2.15 cm / 100 ml

This measure tells us that every 2.15 cm there are 100 ml of liquid. With
It is now easy to calculate how much liquid is inside the container.
Let's do it with an example. Let's suppose that the sensor of
Ultrasound gives us a distance of 7.11 cm. That would be the space.
empty, but we want to know how much space remains filled. It
we calculate by subtracting the distance in a vacuum from the obtained distance.

11.41 - 7.11 = 4.30 cm


As we know, every 2.15 cm there are 100 ml, applying a simple
Using the rule of three, we will know the amount of liquid we have.

Well, we already have the mathematical basis to calculate the liquid level.
in our container, now we only have to apply those calculations in
our sketch.

7. DISPLAYING LCD DATA:

Lastly, and although it is not necessary, we are going to show the information.
on a 16×2 LCD screen. The information we are going to display is
the amount of liquid in ml and the fill percentage. These data are
fundamentals of the water level sensor with Arduino.

The following code is just mixing the previous code.


where we obtain the amount of liquid and the code with which we have
tested the LCD.

You might also like