10 Fluid Level (Water Level) Sensors and how to use them (Arduino, ESP32, ESP8266)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
measuring levels of liquids is a common problem where i live it's probably more the water level of the coffee machine in rural areas the level of a water tank and in the industry the level of chemical substances there are many different ways to get this job done if you stick around i will show you 10 different sensors and as usual we will learn some new tricks crazy youtubers here is the guy with the swiss accent with a new episode and fresh ideas around sensors and microcontrollers remember if you subscribe you will always sit in the first row two things motivated me to begin this video the first was a colleague who manages a remote cottage he asked me if it would be possible to use laura to monitor two critical levels of liquids from remote instead of always driving to the cottage the second motivation was completely different during my home office days i drink a lot of coffee my wife works out of home and does not often use our coffee machine but she hates it if the machine is out of water when she wants to brew her only cup of coffee in the morning because i did not fill it up the day before of course this is the mistake of the coffee machine it only shows the empty tank if you start the next one inferior engineering which brings me into deep trouble as you can imagine so i need a proactive water level sensor anyway in this video we will cover much more sensors that react on fluid level thresholds sensors that measure the fluid level sensors that have to be mounted inside and sensors that are mounted outside the tanks sensors for the top and for the bottom of the tanks and as usual you get some background info on the sensors interfaces i will not test the accuracy of the sensors in this video but i will show you how you can connect them to a typical microprocessor let's start with the threshold sensors they come in two varieties with a mechanical switch or with electronics the electronic sponge uses either the capacitive or the resistive method these are three typical examples of mechanical sensors two of them are made of metal and the third of plastic all have to be in contact with the liquid to work which can create a few problems first does the liquid corrode the sensors and second can the material of the sensors contaminate the liquid particularly if they start to rust if any of the above questions have to be answered with yes we have to use different sensors but first how can we read these sensors very simple if we connect them through a 10k ohms resistor to vcc we can read the voltage level with an input pin be aware that they bounce so you have to take measures against it in software the easiest is just to wait a few milliseconds before the next reading while open they do not need energy and even could be used to switch your mcu on and off this sensor uses electronics and the capacitive approach it has to be mounted outside the tank but it only works with plastic tanks this sensor will be used for my coffee machine project by the way it is rated from 5 to 24 volts and has a so-called open collector or oc output because this is a commonly used concept we have a look at it most mcus or sensors provide two output levels for low and high in our case 0 and 3.3 or 5 volts this is simple and for many applications the right approach this sensor is different do you know why they choose this interface let's assume we power the sensor with 5 or even 12 volts then the output voltage for high also could be 5 or 12 volts and we would have to deal with it at a later stage usually we would use a voltage divider to reduce the voltage to the appropriate level the open collector output offers a different solution what happens if we add a resistor and connect it to 3.3 volt then the output voltage will be 0 when the transistor conducts and 3.3 volts when open if we connected the resistor to 5 volts we would get 0 or 5 volts you see the output level is independent from vcc of the sensor and if the transistor is strong enough we can replace the resistor with an led or a relay a typical pin of an esp32 only can source or sync 12 milliampere open collector outputs usually are rated higher this sensor supports 50 milliampere for example here are examples of mounting these sensors to detect low or high fluid levels and they even suggest a solution for metal tanks we could also use the moisture sensors discussed in video number 207 for threshold measurement and for small tanks even to measure the level they have to be placed inside the tank and these resistive sensors need a conducting fluid everything said about corrosion and contamination applies here too just remember these sensors corrode very fast electronic sensors other than their mechanical counterparts use energy while measuring if the levels do not move fast you can reduce the number of readings and switch your sensors vcc with a pin of your mcu and only switch it on for the measurements if your sensor does not consume more than 12 milliampere you can connect it directly to an esp output pin if it needs a higher current you have to add a p channel fit to switch it but what if you need more than a low or a high level then we basically have two possibilities we measure the exact liquid level using distance sensors or measure the pressure at the bottom of the tank the pressure method is called an indirect method because it does not measure the fluid level but you can calculate it if you know the specific weight of the fluid we know two ways of measuring distance both use time of flight one uses the slower waves of ultrasound and the other the fast waves of laser light the laser type sometimes is called lidar for both methods the sensors must be mounted on top of the tank and point into the direction of the liquid surface one thing of caution standard ultrasonic sensors will corrode if water evaporates for example and both sensors suffer from pollution created if condensed vapors clock them i assume that a time of flight sensor or a waterproof ultrasonic sensors like this one should survive a few years but you have to try in your particular situation another problem with ultrasonic sensors is when signals are reflected by places other than the surface of the liquid these effects are influenced by the tank geometry and the surface of the inner tank this may be the reason for the unique design of this sensor how do we connect these time-of-flight sensors to our mcus for most of them you find a library and example projects on the internet so i will not cover it here you find the led lidar in video number 119 and the ultrasonic sensors in videos number 40 and 190. the range of the lidars is either 2 or 4 meters the ultrasonic sensors promise a range up to 7 meters but i would not trust these values and try the sensors in your environment particularly the laser sensors can be influenced by sunlight consider also the minimum measuring distance and mount your sensors at least at this distance from the maximum liquid level if the tank is closed at the top maybe you cannot mount one of those sensors fortunately there is another possibility we measure the pressure at the bottom of the tank we get lots of pressure sensors make sure you get one for liquids and not for airspeed like this one and because the sensor usually is in contact with the liquid the same rules apply as for the internal level sensors this is an example of such a sensor it can measure up to 30 psi which means around 20 meters of water this sensor runs on 5 volts and outputs a voltage between 0.5 and 4.5 volts so we can read it either with an internal adc or if we do not trust its accuracy with an external adc as shown in video number 340. obviously with pressure sensors we need access to the tank's lowest point if there is no such possibility we have another possibility we can use a pressure sensor inside the liquid at the bottom of the tank therefore it needs a long cable of course the sensor and the cable have to be protected against corrosion and contamination this sensor by the way uses a so called current loop interface which is a brilliant idea for sensors with long cables it only needs two wires to power the sensor and transmit the data this sensor can be powered by 12 to 24 volts and returns its values as a current between 4 and 20 milliampere if we connect a resistor in series to the sensor we get a voltage that is proportional to the pressure and if we connect the resistor to the ground we can easily measure this voltage with an adc the resistor can be calculated with ohm's law if we want 3.3 volts at 20 milliampere we get a value of 165 ohms if we want to calibrate it to a lower pressure it becomes higher of course these are all possibilities i wanted to cover maybe you add other ones i forgot or i do not know and it would be fantastic if you shared your experience with the different sensors i'm sure that together we will have a lot of knowledge what are the learnings we get fluid level sensors with digital as well as analog output signals digital if they react when a particular level is reached and analog if they output a signal proportional to the fluid level sensors can be mounted inside or outside of the tank if they contact the fluid they have to be corrosion resistant and must not contaminate the tank's content each sensor type has one mounting location time of flight sensors have to be mounted on top and pressure sensors at the bottom for example different sensors use different interfaces the current loop is robust and straightforward for long cables and analog readings open collector is a very flexible way to connect different things to the output pin as well as create different output voltages that was all for today as always you find the relevant links in the description i hope this video was useful or at least interesting for you if true please consider supporting the channel to secure its future existence thank you bye
Info
Channel: Andreas Spiess
Views: 28,442
Rating: undefined out of 5
Keywords: arduino, arduino project, beginners, diy, do-it-yourself, eevblog, electronics, esp32, esp32 datasheet, esp32 project, esp32 tutorial, esp32 weather station, esp8266, esp8266 datasheet, esp8266 project, greatscott, guide, hack, hobby, how to, iot, lorawan, nodemcu, project, simple, smart home, ttgo, wemos, wifi, level sensors, water level sensors, pressure sensors, pressure, water
Id: KawRd5evHyY
Channel Id: undefined
Length: 12min 47sec (767 seconds)
Published: Sun Dec 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.