#411 Ten Fluid Level (Water Level) Sensors and how to use them (Arduino, ESP32, ESP8266)

Andreas Spiess
12 Dec 202112:47

Summary

TLDRThis video explores various sensors for measuring liquid levels, from simple threshold sensors to advanced ultrasonic and pressure sensors. It discusses mechanical and electronic sensors, their mounting inside or outside tanks, and considerations for corrosion resistance and contamination. The video also covers different interfaces like open collector and current loop, and provides insights on connecting these sensors to microcontrollers. It's a comprehensive guide for those looking to monitor liquid levels in different applications.

Takeaways

  • ๐Ÿ” The video discusses various methods and sensors for measuring liquid levels in different settings, such as home appliances, rural water tanks, and industrial chemical storage.
  • ๐Ÿก Two main motivations for the video are presented: monitoring liquid levels remotely in a cottage and avoiding coffee machine water shortages at home.
  • ๐Ÿ”„ The video introduces 10 different types of sensors, including threshold sensors, distance sensors, and pressure sensors, each with their unique applications and mounting requirements.
  • ๐Ÿ›  Mechanical threshold sensors are explained, which work by making contact with the liquid and can be made of metal or plastic, raising concerns about corrosion and contamination.
  • ๐Ÿ“ถ Electronic threshold sensors using capacitive or resistive methods are discussed, with an emphasis on their compatibility with plastic tanks and their open collector (OC) output.
  • ๐Ÿ’ง The importance of considering corrosion resistance and non-contamination when selecting sensors that come into direct contact with liquids is highlighted.
  • ๐Ÿ“Š For more precise liquid level measurement, the video covers distance sensors that use ultrasonic waves or laser light, and the challenges they face such as corrosion and signal reflection.
  • ๐Ÿ”ง Pressure sensors are introduced as an indirect method to measure liquid levels by calculating the pressure at the bottom of a tank, with considerations for sensor placement and compatibility.
  • โš™๏ธ The video also touches on the technical aspects of interfacing sensors with microcontrollers, including the use of resistors, voltage dividers, and analog-to-digital conversion.
  • ๐Ÿ”— The video concludes with a call to action for viewers to share their experiences with different sensors, emphasizing the value of collective knowledge in solving practical problems.

Q & A

  • What types of liquid level measurement sensors are discussed in the video?

    -The video discusses sensors that react to fluid level thresholds, sensors that measure the exact fluid level, sensors mounted inside and outside of tanks, and sensors for the top and bottom of tanks.

  • What are threshold sensors, and how do they function?

    -Threshold sensors detect when a particular fluid level is reached. They come in two types: mechanical switches or electronic sensors, which can use capacitive or resistive methods. They need to be in contact with the liquid to function.

  • What are the potential issues with mechanical sensors in liquid environments?

    -Mechanical sensors can corrode when in contact with liquids, and their material may contaminate the liquid, particularly if they rust.

  • How do open collector (OC) outputs work and why are they beneficial?

    -Open collector outputs allow the sensor's output voltage to be independent of the sensorโ€™s supply voltage. By adding a resistor, the output can be controlled and customized, providing flexibility when dealing with varying voltage levels.

  • What are the differences between time-of-flight sensors using ultrasound and laser light?

    -Ultrasound sensors use slower sound waves, while laser light sensors (often called LIDAR) use faster light waves. Both measure the distance between the sensor and the liquid surface, but are affected by factors like evaporation, pollution, and tank geometry.

  • How can pressure sensors be used to measure fluid levels?

    -Pressure sensors measure the pressure at the bottom of the tank, which correlates to the liquid level based on the specific weight of the fluid. They need access to the tank's lowest point or can be placed directly in the fluid with a long cable.

  • What are the benefits of using current loop interfaces for long-cable sensors?

    -Current loop interfaces are robust and efficient for sensors with long cables. They only require two wires to both power the sensor and transmit data, making them straightforward and reliable.

  • What measures can be taken to prevent sensor corrosion and contamination?

    -Sensors that come into contact with liquids should be corrosion-resistant and not contaminate the tankโ€™s contents. For internal sensors, materials must be selected carefully, especially in sensitive environments.

  • What is the advantage of reducing the number of sensor readings in systems where fluid levels don't change rapidly?

    -By reducing the number of sensor readings, energy consumption is minimized, which is particularly important for electronic sensors that consume power while measuring. This can extend sensor and system longevity.

  • What mounting considerations should be taken into account for different sensor types?

    -Different sensors require specific mounting locations. For example, time-of-flight sensors should be mounted on top of the tank to point towards the liquid surface, while pressure sensors must be mounted at the bottom or submerged.

Outlines

00:00

โ˜• Monitoring Liquid Levels with Sensors

The speaker introduces the concept of measuring liquid levels in various contexts, from coffee machines to water tanks and chemical industries. The video aims to demonstrate 10 different sensors used for this purpose, along with tips and insights into sensor technologies. Two key motivations for the video are mentioned: a request from a colleague to monitor liquid levels remotely in a cottage using LoRa technology, and a personal coffee machine issue. The speaker also hints at addressing various types of sensors, mounting methods, and how to connect them to microcontrollers.

05:00

๐Ÿ“ How Threshold Sensors Work

This section explains how threshold sensors work, focusing on mechanical and electronic versions. The speaker highlights three mechanical sensors (two made of metal and one plastic) and emphasizes their need to be in contact with the liquid, which can lead to corrosion or contamination. The description also touches on how to read these sensors using a microcontroller and resistor. Electronic sensors, such as capacitive ones, can be mounted outside plastic tanks. Open collector outputs are introduced, offering flexibility in managing output levels without depending on the sensorโ€™s VCC voltage.

10:02

๐Ÿ”‹ Flexibility of Open Collector Outputs

The speaker elaborates on the flexibility of open collector outputs, which allow for different output levels based on the voltage applied to the resistor. This section shows how to get either 3.3V or 5V output depending on how the resistor is connected, making it possible to power devices such as LEDs or relays. Additionally, the speaker explains the advantages of using these sensors to detect low or high liquid levels in tanks. Resistive moisture sensors are introduced as another option for measuring levels, but with warnings about corrosion and contamination.

๐Ÿ“ก Measuring Liquid Levels with Sensors

This section dives into sensors that measure exact liquid levels, discussing two main methods: using distance sensors or pressure sensors. The speaker details the time-of-flight principle, either with ultrasound or laser light (LIDAR), and the potential challenges like corrosion, tank geometry, or pollution affecting readings. They also touch on different types of sensors, including waterproof ultrasonic ones, and the importance of testing sensors in specific environments. The focus shifts to pressure sensors, emphasizing their use for measuring liquid levels indirectly based on fluid pressure at the tank's bottom.

๐ŸŒŠ Using Pressure Sensors for Accurate Liquid Monitoring

Here, the speaker continues explaining the use of pressure sensors to measure liquid levels by placing them inside or outside the tank. Pressure sensors must be selected based on their suitability for liquids (not airspeed), and accuracy can be measured using internal or external ADCs. The section also explains how current loop interfaces are advantageous for long cables and robust data transmission. The speaker gives a formula for calculating the appropriate resistor to convert current to voltage and highlights the need for protection against corrosion for both the sensor and the cable.

๐Ÿงช Conclusions and Learnings on Liquid Level Sensors

The final section summarizes the key takeaways from the video, highlighting the differences between digital and analog output sensors. Digital sensors react when a specific fluid level is reached, while analog sensors provide a proportional signal. The speaker stresses the importance of mounting sensors correctlyโ€”inside, outside, at the top, or bottomโ€”and ensuring they are resistant to corrosion and contamination. Various sensor interfaces, including current loop and open collector outputs, are explained. The speaker closes by inviting viewers to share their experiences with different sensors to build collective knowledge.

Mindmap

Keywords

๐Ÿ’กLiquid Level Sensors

Liquid level sensors are devices used to monitor the level of liquids in various containers, such as coffee machines, water tanks, or industrial chemical storage. In the video, these sensors are crucial for automating the monitoring process and preventing issues like running out of water or overfilling. The script discusses different types of sensors, including threshold sensors, which detect when the liquid level reaches a certain point, and distance sensors, which measure the exact level of the liquid.

๐Ÿ’กThreshold Sensors

Threshold sensors are a type of liquid level sensor that trigger an action or send a signal when the liquid level reaches a certain pre-set level. They are essential for preventing overflows or detecting when a container is empty. The video mentions two varieties of threshold sensors: those with mechanical switches and those with electronic sensors, which can use capacitive or resistive methods to detect the liquid level.

๐Ÿ’กMechanical Switches

Mechanical switches are a component of some threshold sensors that physically move or change state when the liquid level reaches a certain point. They are typically made of metal or plastic and must be in contact with the liquid to function. The video discusses how these switches can be connected to a microcontroller through a resistor to read the voltage level, indicating the liquid's presence or absence.

๐Ÿ’กCapacitive Method

The capacitive method is an electronic approach used in some liquid level sensors to detect the presence of a liquid by measuring changes in capacitance when the liquid comes into contact with the sensor. This method is non-contact and can be used with plastic tanks. The video explains how this type of sensor can be used for a coffee machine project and how it works with an open collector output.

๐Ÿ’กOpen Collector Output

An open collector output is a type of electronic output used in some sensors, including the capacitive liquid level sensor discussed in the video. It allows for a flexible connection to a microcontroller, as the output voltage level can be set independently of the sensor's power supply voltage. This is useful for interfacing with different voltage levels in a system, as the output can be adapted to match the microcontroller's input requirements.

๐Ÿ’กMoisture Sensors

Moisture sensors are a type of sensor that can detect the presence of moisture or liquid. In the context of the video, they are suggested for use in threshold measurement and, for small tanks, even for measuring the level of the liquid. These sensors need to be placed inside the tank and require a conducting fluid to operate. The video cautions about the potential for corrosion and contamination with these sensors.

๐Ÿ’กTime of Flight Sensors

Time of flight sensors measure the distance to an object by emitting a signal and measuring the time it takes for the signal to return after bouncing off the object. In the video, these sensors are used to measure the liquid level by mounting them on top of the tank and pointing them towards the liquid surface. The script mentions both ultrasonic and laser (LIDAR) types, which have different ranges and applications.

๐Ÿ’กPressure Sensors

Pressure sensors are used to measure the pressure exerted by a fluid at a certain point, such as the bottom of a tank. In the video, pressure sensors are discussed as an indirect method for determining liquid level, as the pressure at the bottom of a tank is related to the height of the liquid column above it. The script explains how these sensors can be used with a current loop interface for long cable runs and how they output a voltage proportional to the pressure.

๐Ÿ’กCurrent Loop Interface

A current loop interface is a type of electrical interface used for transmitting analog signals over long distances with high reliability. In the video, it is mentioned as a method used by some pressure sensors to send data. The sensor outputs a current between 4 and 20 milliamperes, which can be converted to a voltage by connecting a resistor in series. This method is robust against electrical noise and is suitable for sensors with long cables, as it only requires two wires for both power and signal transmission.

๐Ÿ’กMicrocontroller

A microcontroller is a small computer on a single integrated circuit that can be programmed to perform specific tasks, such as reading sensor inputs and controlling outputs. In the video, microcontrollers are central to connecting and utilizing the various liquid level sensors discussed. The script explains how different sensors can be interfaced with a microcontroller, whether through digital or analog inputs, and how to handle different output types like open collector or current loop.

Highlights

Measuring liquid levels is a common problem across various settings, from coffee machines to industrial chemical tanks.

The video showcases 10 different sensors for liquid level measurement, each with unique applications and methods.

Threshold sensors are available in mechanical or electronic forms, with the latter using capacitive or resistive methods.

Mechanical sensors must be in contact with the liquid, raising concerns about corrosion and contamination.

Electronic sensors offer the advantage of not needing contact with the liquid, reducing the risk of contamination.

The video demonstrates how to read mechanical sensors using a 10k ohms resistor and an input pin on a microcontroller.

Open collector output sensors are highlighted for their flexibility in output voltage levels, independent of the sensor's VCC.

The video explains the use of moisture sensors for threshold measurement, especially suitable for small tanks.

Electronic sensors consume energy during measurement, but power consumption can be managed with smart switching.

For precise liquid level measurement, distance sensors using ultrasound or laser light are discussed.

The video addresses the challenges of ultrasonic sensors, including corrosion and signal reflection issues.

Pressure sensors are introduced as an indirect method to measure liquid levels by calculating fluid pressure at the tank's bottom.

The video provides practical advice on mounting sensors, considering factors like tank geometry and liquid surface conditions.

Current loop interface is recommended for sensors with long cables due to its robustness and simplicity.

The video concludes with a call to action for viewers to share their experiences with different sensors, fostering a community of knowledge exchange.

The video provides a comprehensive overview of fluid level sensors, their interfaces, and practical considerations for various applications.

Transcripts

play00:00

measuring levels of liquids is a common

play00:02

problem

play00:03

where i live it's probably more the

play00:05

water level of the coffee machine

play00:08

in rural areas the level of a water tank

play00:11

and in the industry the level of

play00:13

chemical substances

play00:15

there are many different ways to get

play00:17

this job done

play00:19

if you stick around i will show you 10

play00:21

different sensors and as usual we will

play00:24

learn some new tricks crazy youtubers

play00:28

here is the guy with the swiss accent

play00:30

with a new episode and fresh ideas

play00:32

around sensors and microcontrollers

play00:35

remember if you subscribe you will

play00:38

always sit in the first row

play00:40

two things motivated me to begin this

play00:43

video

play00:44

the first was a colleague who manages a

play00:47

remote cottage

play00:48

he asked me if it would be possible to

play00:50

use laura to monitor two critical levels

play00:54

of liquids from remote instead of always

play00:57

driving to the cottage

play00:59

the second motivation was completely

play01:01

different

play01:02

during my home office days i drink a lot

play01:05

of coffee my wife works out of home and

play01:08

does not often use our coffee machine

play01:11

but she hates it if the machine is out

play01:14

of water when she wants to brew her only

play01:16

cup of coffee in the morning because i

play01:19

did not fill it up the day before

play01:22

of course this is the mistake of the

play01:25

coffee machine

play01:26

it only shows the empty tank if you

play01:29

start the next one

play01:31

inferior engineering which brings me

play01:33

into deep trouble as you can imagine

play01:36

so i need a proactive water level sensor

play01:40

anyway in this video we will cover much

play01:43

more

play01:44

sensors that react on fluid level

play01:46

thresholds

play01:47

sensors that measure the fluid level

play01:51

sensors that have to be mounted inside

play01:53

and sensors that are mounted outside the

play01:56

tanks

play01:57

sensors for the top

play01:59

and for the bottom of the tanks

play02:02

and as usual you get some background

play02:04

info on the sensors

play02:06

interfaces i will not test the accuracy

play02:09

of the sensors in this video but i will

play02:12

show you how you can connect them to a

play02:14

typical microprocessor

play02:16

let's start with the threshold sensors

play02:19

they come in two varieties with a

play02:22

mechanical switch or with electronics

play02:25

the electronic sponge uses either the

play02:27

capacitive or the resistive method

play02:30

these are three typical examples of

play02:32

mechanical sensors two of them are made

play02:35

of metal

play02:42

and the third of plastic

play02:45

all have to be in contact with the

play02:47

liquid to work

play02:48

which can create a few problems

play02:51

first does the liquid corrode the

play02:54

sensors and second

play02:56

can the material of the sensors

play02:58

contaminate the liquid

play03:00

particularly if they start to rust if

play03:04

any of the above questions have to be

play03:06

answered with yes we have to use

play03:08

different sensors

play03:10

but first how can we read these sensors

play03:14

very simple if we connect them through a

play03:16

10k ohms resistor to vcc we can read the

play03:20

voltage level with an input pin

play03:23

be aware that they bounce so you have to

play03:26

take measures against it in software

play03:29

the easiest is just to wait a few

play03:31

milliseconds before the next reading

play03:35

while open they do not need energy and

play03:37

even could be used to switch your mcu on

play03:40

and off

play03:42

this sensor uses electronics and the

play03:44

capacitive approach

play03:46

it has to be mounted outside the tank

play03:49

but it only works with plastic tanks

play03:53

this sensor will be used for my coffee

play03:55

machine project by the way

play03:57

it is rated from 5 to 24 volts and has a

play04:01

so-called open collector or oc output

play04:05

because this is a commonly used concept

play04:08

we have a look at it

play04:09

most mcus or sensors provide two output

play04:12

levels for low and high in our case 0

play04:16

and 3.3 or 5 volts

play04:18

this is simple and for many applications

play04:21

the right approach

play04:23

this sensor is different

play04:25

do you know why they choose this

play04:27

interface

play04:29

let's assume we power the sensor with 5

play04:31

or even 12 volts

play04:33

then the output voltage for high also

play04:36

could be 5 or 12 volts and we would have

play04:39

to deal with it at a later stage

play04:41

usually we would use a voltage divider

play04:44

to reduce the voltage to the appropriate

play04:46

level

play04:47

the open collector output offers a

play04:49

different solution

play04:51

what happens if we add a resistor and

play04:53

connect it to 3.3 volt then the output

play04:57

voltage will be 0 when the transistor

play05:00

conducts and 3.3 volts when open

play05:04

if we connected the resistor to 5 volts

play05:06

we would get 0 or 5 volts you see the

play05:10

output level is independent from vcc of

play05:13

the sensor

play05:15

and if the transistor is strong enough

play05:17

we can replace the resistor with an led

play05:20

or a relay

play05:22

a typical pin of an esp32 only can

play05:25

source or sync 12 milliampere

play05:28

open collector outputs usually are rated

play05:31

higher

play05:32

this sensor supports 50 milliampere for

play05:35

example

play05:36

here are examples of mounting these

play05:38

sensors to detect low or high fluid

play05:41

levels and they even suggest a solution

play05:45

for metal tanks

play05:47

we could also use the moisture sensors

play05:49

discussed in video number 207

play05:52

for threshold measurement

play05:54

and for small tanks even to measure the

play05:57

level

play05:58

they have to be placed inside the tank

play06:00

and these resistive sensors need a

play06:02

conducting fluid

play06:04

everything said about corrosion and

play06:06

contamination applies here too

play06:09

just remember these sensors corrode very

play06:12

fast

play06:13

electronic sensors other than their

play06:16

mechanical counterparts use energy while

play06:19

measuring if the levels do not move fast

play06:22

you can reduce the number of readings

play06:25

and switch your sensors vcc with a pin

play06:28

of your mcu and only switch it on for

play06:31

the measurements

play06:32

if your sensor does not consume more

play06:34

than 12 milliampere you can connect it

play06:37

directly to an esp output pin

play06:40

if it needs a higher current you have to

play06:42

add a p channel fit to switch it

play06:45

but what if you need more than a low or

play06:48

a high level

play06:49

then we basically have two possibilities

play06:52

we measure the exact liquid level using

play06:55

distance sensors or measure the pressure

play06:58

at the bottom of the tank

play07:00

the pressure method is called an

play07:02

indirect method because it does not

play07:04

measure the fluid level

play07:06

but you can calculate it if you know the

play07:08

specific weight of the fluid

play07:11

we know two ways of measuring distance

play07:14

both use time of flight

play07:16

one uses the slower waves of ultrasound

play07:20

and the other the fast waves of laser

play07:22

light

play07:23

the laser type sometimes is called lidar

play07:27

for both methods the sensors must be

play07:29

mounted on top of the tank and point

play07:32

into the direction of the liquid surface

play07:35

one thing of caution standard ultrasonic

play07:38

sensors will corrode if water evaporates

play07:41

for example and both sensors suffer from

play07:44

pollution created if condensed vapors

play07:46

clock them

play07:48

i assume that a time of flight sensor or

play07:50

a waterproof ultrasonic sensors like

play07:53

this one should survive a few years but

play07:56

you have to try in your particular

play07:58

situation

play08:00

another problem with ultrasonic sensors

play08:02

is when signals are reflected by places

play08:05

other than the surface of the liquid

play08:07

these effects are influenced by the tank

play08:10

geometry and the surface of the inner

play08:12

tank

play08:13

this may be the reason for the unique

play08:16

design of this sensor

play08:18

how do we connect these time-of-flight

play08:20

sensors to our mcus

play08:22

for most of them you find a library and

play08:25

example projects on the internet

play08:28

so i will not cover it here

play08:30

you find the led lidar in video number

play08:33

119 and the ultrasonic sensors in videos

play08:37

number 40 and 190.

play08:40

the range of the lidars is either 2 or 4

play08:43

meters the ultrasonic sensors promise a

play08:46

range up to 7 meters but i would not

play08:49

trust these values and try the sensors

play08:51

in your environment particularly the

play08:54

laser sensors can be influenced by

play08:56

sunlight

play08:57

consider also the minimum measuring

play08:59

distance and mount your sensors at least

play09:02

at this distance from the maximum liquid

play09:05

level

play09:06

if the tank is closed at the top maybe

play09:08

you cannot mount one of those sensors

play09:11

fortunately there is another possibility

play09:13

we measure the pressure at the bottom of

play09:15

the tank

play09:17

we get lots of pressure sensors make

play09:19

sure you get one for liquids and not for

play09:21

airspeed like this one

play09:24

and because the sensor usually is in

play09:26

contact with the liquid the same rules

play09:28

apply as for the internal level sensors

play09:32

this is an example of such a sensor it

play09:34

can measure up to 30 psi

play09:37

which means around 20 meters of water

play09:40

this sensor runs on 5 volts and outputs

play09:43

a voltage between 0.5 and 4.5 volts

play09:48

so we can read it either with an

play09:50

internal adc or if we do not trust its

play09:53

accuracy with an external adc as shown

play09:56

in video number 340.

play09:59

obviously with pressure sensors we need

play10:01

access to the tank's lowest point

play10:04

if there is no such possibility we have

play10:06

another possibility we can use a

play10:09

pressure sensor inside the liquid at the

play10:11

bottom of the tank

play10:13

therefore it needs a long cable of

play10:16

course the sensor and the cable have to

play10:18

be protected against corrosion and

play10:21

contamination

play10:23

this sensor by the way uses a so called

play10:26

current loop interface which is a

play10:28

brilliant idea for sensors with long

play10:30

cables it only needs two wires to power

play10:34

the sensor and transmit the data

play10:37

this sensor can be powered by 12 to 24

play10:40

volts and returns its values as a

play10:42

current between 4 and 20 milliampere if

play10:46

we connect a resistor in series to the

play10:48

sensor we get a voltage that is

play10:51

proportional to the pressure

play10:53

and if we connect the resistor to the

play10:55

ground we can easily measure this

play10:58

voltage with an adc the resistor can be

play11:01

calculated with ohm's law if we want 3.3

play11:04

volts at 20 milliampere we get a value

play11:07

of 165 ohms

play11:10

if we want to calibrate it to a lower

play11:12

pressure it becomes higher of course

play11:16

these are all possibilities i wanted to

play11:18

cover

play11:19

maybe you add other ones i forgot or i

play11:22

do not know

play11:24

and it would be fantastic if you shared

play11:27

your experience with the different

play11:28

sensors i'm sure that together we will

play11:31

have a lot of knowledge

play11:33

what are the learnings

play11:35

we get fluid level sensors with digital

play11:38

as well as analog output signals

play11:40

digital if they react when a particular

play11:43

level is reached and analog if they

play11:46

output a signal proportional to the

play11:48

fluid level

play11:50

sensors can be mounted inside or outside

play11:52

of the tank

play11:54

if they contact the fluid they have to

play11:56

be corrosion resistant and must not

play11:59

contaminate the tank's content

play12:02

each sensor type has one mounting

play12:04

location time of flight sensors have to

play12:07

be mounted on top and pressure sensors

play12:10

at the bottom for example

play12:12

different sensors use different

play12:14

interfaces the current loop is robust

play12:17

and straightforward for long cables and

play12:19

analog readings open collector is a very

play12:23

flexible way to connect different things

play12:25

to the output pin as well as create

play12:28

different output voltages

play12:30

that was all for today as always you

play12:33

find the relevant links in the

play12:34

description

play12:36

i hope this video was useful or at least

play12:38

interesting for you if true please

play12:40

consider supporting the channel to

play12:42

secure its future existence thank you

play12:45

bye

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Liquid SensorsTech DIYMicrocontrollersIndustrial SensorsCoffee MachineRemote MonitoringCapacitive SensorsPressure SensorsTime of FlightOpen Collector