Sensing water levels reliably

Linear and non linear

Sensing water levels reliably

Postby Doug Coulter » Tue Jun 19, 2018 1:34 pm

This has been a decades-long slog with many attempts that might last a few days, or a few years. I finally have one that lasts "forever" if implemented correctly.
At least it's lasted, in a nasty place, for 6-7 years now with no signs of issues. This really matters if you depend on it for your water supply and if it's in a place where you have to fight snakes, spiders, and low steel beams to get to...there's a lotta ouch involved.

Initially the challenge was to measure the level in a hot water tank (with an open top, it was solar heated water) which has got to be the hardest thing to pull off reliably there is - floats stick and swell, crud builds up on float systems and on optical ones, forget ultrasonics in a steamy place...and so on. Maybe a then un-affordable and now still hard to find hydraulically isolate low pressure liquid sensor would have worked. Thermometers up and down the sides of the tank depend on a thermal gradient which isn't there if either the water isn't hot or you did your job with insulating and so on. Any DC sensing in the water depends on dissolved salts and dies due to electrolytic action while contaminating the water with whatever conductors you used...

Now for what works...
Theory first:
Water, almost no matter what's dissolved in it - has a huge dielectric constant compared to, well, almost everything. It's around 80 where more normal stuff hovers around 2 to 4. We can sense this!
If you don't want electrolysis - I'm drinking this water - and I don't want to have to replace (or even check if they need it) electrodes - no DC can be used.
Materials-wise, while some version of stainless steel might be fine - Titanium (pure, grade 2) doesn't electrolyze or react with much of anything in water, so why not use the best? It's not super expensive at McMaster Carr, and I had some left over after some fusor experiments, so my opportunity cost was zero.

The only thing you have to absolutely avoid is "sneak paths" between the sensor electrodes -each other, and the driver signal as well. Enough condensation on the mounting surfaces for example could fake it out, if things are too close together.

While you'll have to tune this for your own application somewhat, the example I'm using is good for a lot of things. Some cases might need re arranging the block diagram compared to what I did, as you can't drive something grounded with a signal very well - but you could instead make sure the grounded thing is well grounded, and then couple a little bit of the driver signal into the electrodes instead, and when they "see" ground, the output goes to zero, instead of going high as my current lashup does (my water tank is insulated from ground, so I drive the water itself with a Ti wire along the bottom of the tank).

What you need is a fairly "stiff"(or low impedance) source of some AC signal - I'm using the old 555 chip setup to make almost-square waves at 12 volts in my setup.
That's capacitively coupled to the drive electrode in my topology - I just used a generic .1uf cap as I had those lying around - it's much lower impedance at 100khz than needed, but hey, those are ubiquitous in everyone's junk box.

Elsewhere on the tank, I have in my case, 4 pieces of Ti wire sticking down from the top - just glued into holes drilled into the tank top (it's a big tank for agriculture use but makes a nice cistern) and sealed up with silicone gasket maker (eg not the type that makes ammonia when curing). I just bent the wire ends into circles outside the tank to make a lug on each.

The sensor circuit is super-simple - it's just a capacitor input voltage doubler - 2 more .1uf caps and two 1n4148 diodes, with a 100k load to ground on the output. When this signal goes "high" (and it works with either 5v or 3.3 v logic, it's very robust) - you have water reaching that electrode. So 4 sensor wires give me 2 bits worth of level resolution, which is enough for my management needs.

An alternative approach that would take a little more refined tuning would be to have just one (or heck, for increased range, still a few) electrode and feed that into an a/d - you'd have to adjust either the coupling C or the load R or both to get the range you want with a particular sensor length and diameter - instead of my .1 uf drive cap coupler, you'd be down in the small picofarads most likely.

Here's a block diagram of what I actually implemented for my particular case - the concept is actually the important thing here.
Nope, no schiz for the 555 oscillator. If you can't do that, you have no business on this board at all. Any source of medium HF will do here, if it'll drive the load,
it doesn't even need to be 50% duty cycle - that's what the capacitors will take care of to prevent ANY DC current in the sensed system.

WaterBlock.jpg
Block diagram


Here are some gratuitous pictures of my setup, including the ESP8266 board (which controls plumbing valves and also senses weather indoor/outdoor) - it acts as a slave to my LAN of things, where a raspberry pi runs a web server (NGINX) and has CGI's to make plots and let me set things like valves.
20180619-Water-7.jpg
The sensed object - a 225 gallon tank

20180619-Water-5.jpg
Electronics overview, including the UPS and water pump

20180619-Water-9.jpg
Why'd it have to be snakes? Board in lower right of pic

20180619-Water-6.jpg
ESP8266 LOT slave/sensor/controller


I used an MCP 23017 i/o expander on the ESP-8266 to get more IOs for this and valve control. This part doesn't need to be fast, so an I2C interface is fine.


Now, let's generalize this. The point is that AC can be used to prevent any chance of electrolysis. High frequency (ultrasonic, anyway) means any one half-cycle doesn't create much electrolysis anyway.
So, what if you can't drive the sensed medium, as in, it's already grounded by the earth (or it IS the earth) or plumbing? Can we still do this? You bet.
Instead of using your signal source to drive the media - you couple it into each detector probe with a tiny capacitor (in the pF range) - using just enough pF to make your probe go "high" as you want when there's basically no moisture present. Adding moisture will then make that voltage go down...and you just use negative logic if you're doing bits, or an a/d converter (in either lashup) if you want some kind of pseudo-linear output - in that case I'd suggest any one electrode might not have a lotta range, but you can put some further away or make the exposed area different and do the software accordingly.

In any case, with grounded media - make sure your signal ground and the media are a low resistance connection (use a ground rod..). And of course, make sure your ground floats from the power company ground, which will often have some volts AC at the line frequency on it - and noise that WILL get into this.

Another trick is to use a smaller input capacitor for the voltage doubler inputs to reduce the effects of LF stuff.

You will, of course, have to tune the coupling caps and the load resistance to fit your particular situation, what's important here is the concept.

Enjoy! (Now if I can get Andreas Speiss to spread this around so it helps someone other than the rarefied air here...he explains things better than I do.)

Edit, these are the valves I'm using for letting water in and dumping any dirty stuff out - https://www.amazon.com/gp/product/B06XD ... UTF8&psc=1
They only have brass ones in stock at this moment, which should be fine. These are AMAZING and only draw ~~ 80ma while actuating. You can just leave the open or close wire energized and they go open circuit when they are at whatever stop...so, little power needed and control is super simple. I used relays as it was a little simpler for me than wiring up a couple transistors to deal with 3.3 to 12 logic conversion.

Here's a shot of what I see when I go to the environment page for this building in my LAN of things. There are other pages to control things, and to monitor things like the solar system as well..another day, another post, maybe.
Screenshot at 2018-06-19 16-25-15.png
Screenshot of what I see when I surf to this part of my LAN of things.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Sensing water levels reliably

Postby Donovan Ready » Tue Jun 19, 2018 1:42 pm

huge dielectric constant compared to, well, almost everything.


You had me right there. My son and my best friend were water and wastewater operators for an MUD near here, and they often bitched about having float and level problems both in the wet wells and in 'cleaned up' effluent to the purification plant. I know that's a different thing at that scale, but they knew there was an easier way.

No one they tried to sell it to was interested, of course..
Donovan Ready
 
Posts: 239
Joined: Thu Apr 17, 2014 1:22 pm
Location: Austin, Texas


Return to Analog

Who is online

Users browsing this forum: No registered users and 13 guests