Acoustic level sensing in a pipe - Page 1
Forum section: electronics / projects

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 07:43:33 am
content: I want to add a level sensor to my rainwater cistern. It's outside, away from power connections, so I plan to build a battery-operated gadget that measures the level, say once an hour, sends data via a radio link, and goes back to sleep. The sensor and electronics should live in the underground concrete tank -- above the water level, but in a damp environment with various critters about.Acoustic sensing looks promising: No moving parts and a reasonable linear range. Since there is an additional concrete support structure inside the tank, I think simple distance sensing from the top down to the water level would be messed up by the additional reflections. So I thought I might try acoustic sensing in an open-ended tube (see the attached sketch).I could either measure the time until a signal burst returns -- not sure whether the returning signal will be strong enough in a tube with small diameter/length ratio? I would prefer a single transducer to emit and receive the sound. Or I could measure the resonance frequency of the air column, like in an organ pipe or when blowing on a beer bottle: Let the microcontroller emit various short sound bursts and measure the transducer impedance.The air column in the tube would be between 0.5 m and 2.5 m long, depending on the water level. Hence a sound travel time (to and fro) between 3 ms and 15 ms, or a resonance frequency between 165 Hz and 33 Hz, if I am not mistaken. (The air column represents 1/4 of the wavelength for a resonance measurement.)Before I start playing with this, I am looking for your experience:Has anyone done this before?Any recommendations in favor of travel time or resonance frequency measurement?Is a minimum time of 3 ms easily achievable with a single ultrasound emitter/receiver, or would that mean asking for trouble?Any reasons why the whole concept is stupid anyway?Any recommendations for transducers which can withstand the damp environment long-term? The frequency ranges (and hence transducers) would be quite different for ultrasound travel time vs. acoustic resonance, of course.Many thanks!

author: ataradov
author_rank: Super Contributor
timestamp: May 01, 2022, 07:55:15 am
content: No practical experience from my side, but this video came to mind:He used the standard distance sensor for oil level measurement in a tank. Not sure of other obstacles would be an issue, but those sensors are fairly directional.

author: RoGeorge
author_rank: Super Contributor
timestamp: May 01, 2022, 08:09:53 am
content: Similar project:

author: CatalinaWOW
author_rank: Super Contributor
timestamp: May 01, 2022, 08:47:00 am
content: Look into products from MaxBotix.

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 11:50:27 am
content: Thank you all -- three very helpful suggestions, covering different flavors of a possible implementation.I will at least try one of the cheap ultrasound distance sensors, either in free space or in a tube, because it would be such a simple, low-cost solution. Am concerned about the longevity of the sensors though, they will probably corrode quickly. Leo's "sound in a pipe" design is very close to what I have in mind, and the use of a cheap but waterproof speaker and microphone is neat.And then there is, of course, the option of using a decent ultrasound transducer right away. I am reluctant to spend the > $100, but that might well be where I end up anyway, if not now, then two years from now when my homebrew solutions have failed for the third time...Maxbotix look like a good choice, and I have found a distributor in Germany. I will ping them for advice regarding measurement in the presence of obstructions, and also how to deal with condensation. (I came to realize that in cold weather, when the sensor is colder than the water below, I should probably expect condensation right on the sensor.)

author: nali
author_rank: Frequent Contributor
timestamp: May 01, 2022, 02:50:16 pm
content: It might be even easier to stick a load cell under the whole tank and measure the weight of the thing.Resonance might be interesting... if you can find a suitable transducer or speaker you might just be able to generate a sweep or chirp, then look for a notch in the drive current? That would save messing about with tx/rx.

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 04:30:31 pm
content: Quote from: evb149 on May 01, 2022, 02:37:16 pmThat's the idea I started with, actually. But I could not find an affordable, fully submersible pressure sensor which looked like it could be trusted for a few years. Any pointers appreciated! (The relevant pressure range is 0.1 bar per meter of water level, plus 1 bar for the atmosphere of course. So 1.0 to 1.2 bar in my application, with a desired resolution of 1 to a couple of mbar.)Quote from: nali on May 01, 2022, 02:50:16 pmIt's an underground concrete cistern, so weighing it is unfortunately not an option. (It has been in the ground for 50 years and I don't feel like digging it up...)The resonance measurement you describe is exactly what I had in mind. I did an off-the-cuff experiment today with a small 8 Ohm speaker and series resistor, sweep generator and oscilloscope, and various lengths of 40 mm PVC pipe with a blocked end. That did not look promising unfortunately; no significant resonance peak or dip.

author: StillTrying
author_rank: Super Contributor
timestamp: May 01, 2022, 06:05:52 pm
content: Quote from: ebastler on May 01, 2022, 04:30:31 pmCould you measure theair pressureat the top of an air filled tube.At a very rough guess the air pressure reading at +2m of water would be low by around 20%, because of the air compressing and allowing water into the bottom end of the tube.

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 06:40:28 pm
content: Quote from: StillTrying on May 01, 2022, 06:05:52 pmAh, I see -- thank you for the idea! It would require the tube's top end to be sealed perfectly and permanently vs. the sensor, right? But it would avoid the need for a submerged sensor, allowing for much more affordable options.Vapor pressure in the tube might cause some deviations, but since the temperature in the cistern is reasonably stable, that is probably not a big issue. I will look into this option!

author: magic
author_rank: Super Contributor
timestamp: May 01, 2022, 06:42:56 pm
content: Quote from: StillTrying on May 01, 2022, 06:05:52 pmYou could, but air will diffuse slowly through water out of the tube.

author: Marco
author_rank: Super Contributor
timestamp: May 01, 2022, 06:54:36 pm
content: They usually do that with a high pressure air pump I think, so it just keeps bubbling.The term you want to search for for industrial bottom of tank sealed pressure meter is hydrostatic level sensor.

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 06:54:57 pm
content: Quote from: magic on May 01, 2022, 06:42:56 pmGood point, that's another potential error source. Maybe a drop of oil in the bottom end of the tube could help to avoid that?I am aware of a related level sensor (with an open-ended tube running to the bottom of the tank) which avoids the leakage problem: At the remote end of the tube, provide a small air pump and a pressure sensor. When you activate the pump, the pressure will settle at an equilibrium when air starts to bubble out of the submered end of the tube, and that equilibrium pressure is what you measure.Nice when you want to use the tube as the conduit to a dry environment where you place the pump and sensor, and where you read the value. One could even do this without electrical power, using a hand pump and mechanical manometer. But for my intended design, with a battery-powered remote sensor, the pump seems to add more complexity and current draw than I like.Edit: Ah, Marco beat me to it regarding the pump option!

author: ledtester
author_rank: Super Contributor
timestamp: May 01, 2022, 07:31:28 pm
content: Andreas Spiess on repurposing a blood pressure monitor:

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 07:57:45 pm
content: Neat idea with the blood pressure monitor, even if it is only used for salvaging the pump. I am encouraged to try the "tube + pressure sensor" approach. If I can't get air leakage under control, I can always add such a cheap pump (and a larger battery...).

author: ebastler
author_rank: Super Contributor
timestamp: May 01, 2022, 08:13:48 pm
content: Quote from: Marco on May 01, 2022, 06:54:36 pmThank you, that brought up a few more brands.Submersible pressure sensororsubmersible level sensoralso gave relevant results.The problem remains that these are not products you buy, but products where you "request a quotation"; very much addressing an industrial market. The few prices which I have seen are several hundreds of USD per sensor. Even the Chinese knock-offs on Alibaba end up at well above $100 including shipping, for uncertain quality.I struggle to justify that cost for a "nice to have" personal project -- where IP6x enclosure, radio link, a display etc. would still come on top. From a purely financial perspective, I'd probably be better off using tap water to water my garden for the next decade...

author: Marco
author_rank: Super Contributor
timestamp: May 01, 2022, 09:25:51 pm
content: On the original topic, a quick google found "Leak detection in pipes using acoustic pulse reflectometry". They used a pressure pulse from a normal speaker rather than ultrasonics.https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.501.5098&rep=rep1&type=pdf

author: langwadt
author_rank: Super Contributor
timestamp: May 01, 2022, 09:40:27 pm
content: Quote from: ebastler on May 01, 2022, 08:13:48 pmhttps://www.ebay.com/itm/333677645766?

author: ebastler
author_rank: Super Contributor
timestamp: May 02, 2022, 05:07:01 am
content: Thanks! That particular seller does not ship to Germany, but I did find others on ebay at a similar price. Must have used the wrong search terms for ebay before?That's one of the Chinese knock-offs I mentioned above, but at a better price around $50. I am tempted to give it a try -- although I am wondering whether I should expect to get more than a year of use out of it. If the reviews of low-cost "stainless steel submersible pumps" are anything to go by, I should not...

author: robert.rozee
author_rank: Frequent Contributor
timestamp: May 02, 2022, 01:54:47 pm
content: cut a length of 2" plastic downpipe to a length that is a little less than the depth of the water tank. glue an endcap to one end, then fill the downpipe with sand (or some other weighting material) such that the total weight is a little more than the volume of water that the pipe would displace when fully submerged. now glue another endcap to the other end, sealing the downpipe.if you suspend this weighted pipe, upright, within your tank from a load cell weight sensor (for instance:https://www.ebay.com/itm/165132623369), the measured weight will vary linearly between the tank being empty and full. when empty, the measured weight will be the actual weight of the pipe. when full, the measured weight will be the residual of actual weight minus the weight of displaced water.to bereallyclever, build the load cell and associated electronics into the top of the pipe, so that you just have a pipe with a hook at the top to suspend it from, with a cable coming out that carries power and data out.cheers,rob :-)

author: RoGeorge
author_rank: Super Contributor
timestamp: May 02, 2022, 02:17:07 pm
content: Weighting a rock suspended with a nylon (fishing) wire just above the bottom of the tank would do it, as well.

author: magic
author_rank: Super Contributor
timestamp: May 02, 2022, 07:43:04 pm
content: The rock would have to be fairly tall to cover the whole range of possible water levelsBut then it could work, I guess.

author: ebastler
author_rank: Super Contributor
timestamp: May 02, 2022, 07:45:09 pm
content: Quote from: robert.rozee on May 02, 2022, 01:54:47 pmNice one, thank you!I am quite pleasantly surprised how many ways there are to measure a liquid level -- measuring different physical properties of the liquid, or measuring in the same property (mass density) in quite different ways. And we have not even gotten into electrical properties (dielectric constant); or how about viscosity? Stir the water with a rotating vertical paddle which runs the full height of the tank, and measure the drag on the paddle. ;-)Who would have thought that this is such a rewarding topic! Now all I need to do is make up my mind which way to actually implement...

author: RoGeorge
author_rank: Super Contributor
timestamp: May 02, 2022, 08:24:17 pm
content: Quote from: magic on May 02, 2022, 07:43:04 pmMy bad, not a rock. I was having in mind something like in the video, that tends to float at a certain pressure (depth). Has to be heavier so it will tend to float lower than the total depth of the tank, and suspended near the bottom:

author: CatalinaWOW
author_rank: Super Contributor
timestamp: May 03, 2022, 12:23:59 am
content: Another very simple idea is as old as water tanks. Put a float on a rope in the tank. At the top of the tank put a pulley and then put a weight on the end of the rope so it hangs down the outside. Water level is read from an inverted scale on the outside of the tank, with full at the bottom and empty at the top.The classic version involves lots of fiddly details if such things as wanting the tank to be fully enclosed etcetera are in the requirement set. But by having two vertical pipes inside the tank all the issues are avoided. Pipe one is open to the tank at the bottom, pipe two is not. Both are open at the top. Pipe two holds the weight, pipe one the float. And a position encoder on the pulley reads the tank level.This cat can be skinned in many ways. For this project it is all really very dependent on what the OP finds interesting.

author: exmadscientist
author_rank: Frequent Contributor
timestamp: May 03, 2022, 04:22:50 am
content: Quote from: ebastler on May 01, 2022, 07:43:33 amWe did this ~12 years ago with commercial ultrasonic sensors and astrictno-fluid-contact rule. Just sticking a pipe into the tank worked absolutely perfectly. The pipe length was somewhere around 4m and pipe diameter was, I think, 1-1/2 in (~40mm). That ratio gave no trouble, the whole thing worked like a charm. It wasn't quite as accurate as we'd have liked (I think we got 1mm accuracy out of it, and we wanted sub-mm?), and it turned out to be super sensitive to the gas composition in the pipe (this is not likely to be a problem for most people...), but it was wonderfully reliable.

author: ebastler
author_rank: Super Contributor
timestamp: May 03, 2022, 05:13:07 am
content: Quote from: exmadscientist on May 03, 2022, 04:22:50 amThank you, that is reassuring. I am just waiting for a standard ultrasound sensor to arrive.I can certainly guarantee "no fluid contact" as in "no immersion" -- but did you also need to (and manage to) avoid condensation on the sensor? Some high-end sensors are specified as being self-cleaning, which I assume means they shake off droplets via the ultrasound emission. But lower-cost transducers probably don't work well when droplets are sticking to them?

author: Marco
author_rank: Super Contributor
timestamp: May 03, 2022, 07:51:17 am
content: How long would some cling film last in the dark? It's ultrasonic transparant AFAIK.

author: exmadscientist
author_rank: Frequent Contributor
timestamp: May 03, 2022, 08:02:10 am
content: Quote from: ebastler on May 03, 2022, 05:13:07 am"No immersion" was for the other end of the business: the liquid was high-purity, clean-room stuff. (Also it hated iron, and stainless steel contains iron. Yes, this was amassiveheadache.) This liquidadditionallyhated oxygen, so it was kept under a dry nitrogen blanket. (That one was surprisingly little headache.) So, condensation was not a concern for us, and I'm afraid I can't provide any guidance for you there.If it helps, the sensor we used wasthis guy, the ToughSonic 30, or one of its close relatives. I didn't select it, so I can't tell you why it was chosen. I can just tell you that it works pretty well. It's probably out of your price range, though (it's out of mine if I'm paying!).Quote from: Marco on May 03, 2022, 07:51:17 amI have a hard time believing that, given that something as simple as a boundary layer between two different gases will royally destroy the poor sensors.

author: Marco
author_rank: Super Contributor
timestamp: May 03, 2022, 10:23:10 am
content: The boundary layer is an impedance jump, as long as the loss factor for the cling film isn't significant it's too thin for impedance to be relevant AFAICS.Also it depends on if the processing has a blanking interval for close reflections. If you DIY the processing there's more flexibility.

author: David Hess
author_rank: Super Contributor
timestamp: May 03, 2022, 02:55:06 pm
content: The acoustic thermometer circuit shown on page 5 of Linear Technology application note 7 gives some idea of the circuit requirements and waveforms for an ultrasonic transducer. In the example it is used to measure temperature but it would also work for distance.Quote from: StillTrying on May 01, 2022, 06:05:52 pmOr measure the buoyancy force of a sealed tube or float.

author: MarkL
author_rank: Unknown
timestamp: May 04, 2022, 06:06:31 pm
content: Another possibility is to sense the capacitance of the water level with two plates. This is used in some RV water tank sensors. The usual method is to attach two metal strips to the outside of a plastic tank and measure the capacitance between them.But in your case of a cistern, this company makes a PVC pipe that has the plates inside, along with a built-in capacitance to voltage converter:https://tankedge.com/accessories.html#pvcThe pipes are custom made to the length you need up to 50" (1.2m) and you would mount the pipe to dip into the cistern to the bottom.You can use the pipe sensor with their display panel, or supply the sensor with 10V and read the output voltage with your own system. The output voltage varies linearly with the sensed level. You would use two or more known levels to calibrate the output voltage for your panel (or theirs).I have their system on our RV tanks. It works well.

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: May 04, 2022, 10:03:24 pm
content: Quote from: ebastler on May 01, 2022, 04:30:31 pmA pressure sensor doesn't need to be submersible. A pressure sensor at the top of a sealed pipe in place of what you have shown above would produce the same results. Although you may need to occasional verify the pipe is not filling with water.

author: ebastler
author_rank: Super Contributor
timestamp: May 05, 2022, 05:41:47 am
content: Quote from: Ground_Loop on May 04, 2022, 10:03:24 pmThanks, that's actually what I will build -- the pressure sensor just arrived in the mail. This thread is getting to a length where it's difficult to keep track of all possibilities that have been considered. The pressure sensor on top of a pipe is discussed in replies #9 to #15.

author: PaulAm
author_rank: Frequent Contributor
timestamp: May 05, 2022, 03:46:47 pm
content: This thread got me to look into something to check out the salt level in the water softener tank and I ran across the VL53L0X which is an infrared laser TOF sensor. It's I2C with readout in mm, maybe good to 2m or so and looks like it also works with liquid levels. You can get them on breakout boards for a few USD out of China.These look remarkably useful.

author: exmadscientist
author_rank: Frequent Contributor
timestamp: May 05, 2022, 04:31:11 pm
content: Quote from: PaulAm on May 05, 2022, 03:46:47 pmNote that if you want to do laser level sensing in a tank, and the tank liquid is at all choppy, you'll probably need a float in a tube to provide a stable surface to range off of. This gets more important the more accuracy you need and less important the less bandwidth you need.

author: BillyD
author_rank: Regular Contributor
timestamp: May 05, 2022, 05:05:48 pm
content: Quote from: ebastler on May 01, 2022, 11:50:27 amI used one of those cheap ultrasonic transducers to measure the level in a heating oil tank. It worked ok but, as you mention, longevity was a problem. I used up 3 or 4 of them with none lasting longer than a few months.I have since replaced it with a VL53L0X Laser Time of Flight sensor and so far it has been working fine for a little over a year. My one needs to cover a range of about 7cm to 140cm and the only real problem I've had is that as the distance increases, the accuracy degrades. For example the distance reading will flunctuate quickly between 120cm to 130cm. It may be due to the of reflectivity of the kerosene, and also I've never gotten around to tuning the parameters of the laser. It seems to be a bit worse at lower temperatures. I've worked around it by taking an average of readings which suffices for my needs.

author: ebastler
author_rank: Super Contributor
timestamp: May 05, 2022, 06:02:05 pm
content: That VL53L0X sensor looks amazing! Laser, optics, and TOF detector all integrated in a 4*2*1 mm³ package, less than $5, 50000 in stock at Mouser.The 2 meter range may be a bit marginal in my application, but I will get this thing anyway and come up with an excuse to use it.

author: metrologist
author_rank: Super Contributor
timestamp: May 05, 2022, 07:45:19 pm
content: "The VL53L0X can detect the "time of flight", or how long the light has taken to bounce back to the sensor."must have one too

author: ebastler
author_rank: Super Contributor
timestamp: May 05, 2022, 09:33:27 pm
content: Quote from: evb149 on May 05, 2022, 09:09:07 pmMaybe I did not express myself well, I don't plan to use the time-of-flight sensor for the water level measurement, but will find some other use for it. It's just too cool a toy to miss out on...The 2 m maximum sensing distance is specified for a white reflecting surface. It is reduced to 0.8 m for gray surfaces, hence most likely well below 2 m for a water surface too. The effect of a tube would probably depend heavily on the wall's optical properties. The sensor's field of view is 25 degrees, narrower than most ultrasound sensors.

author: ataradov
author_rank: Super Contributor
timestamp: June 08, 2022, 02:12:10 am
content: I've added a couple of VL53L0X to my recent Mouser order and was excited to try them, but as it turns out there is no documentation of the registers. You are supposed to use their API library that you can download only after accepting the EULA. I did not bother and I have no idea if there is some closed source stuff or what. I don't really care that much to deal with inevitably incompetent software.

author: PaulAm
author_rank: Frequent Contributor
timestamp: June 08, 2022, 02:19:15 am
content: There are a couple of Arduino libraries for the VL53L0X that do not use the API. There are some limitations, but looking at the code may prove helpful.

author: ataradov
author_rank: Super Contributor
timestamp: June 08, 2022, 02:26:49 am
content: I'm sure it is possible to figure it out, I just don't want to waste time on this. There is no fun in digging through random code when there is no documentation.

author: metrologist
author_rank: Super Contributor
timestamp: June 08, 2022, 04:00:55 am
content: I bought a pack of these TOF sensor modules. I must be an ogre because I just used whatever Arduino code I found. They work, but the beam width is problematic for me. I don't have an application for them.