Hi Guys, I had a similar challenge for our https://RainAmp.com system. Would you believe that you can solve the problem with a 3 foot long piece of wire and a $2.00 micro controller?
I needed something that was cost effective that could give me very refined measurement changes of how water levels were changing in the tank. I plan to sell thousands of these RainAmp systems so I needed something highly reliable, highly accurate, very low cost and very low power. I have quite a lot of expertise in capacitive sensors for electronics so that is where I turned.
Many modern Micro controllers include what they call touch-sense or Cap-sense technology. The topic area get’s insanely complex quick but it is actually pretty easy to use. I built my tank level sensors using an ESP32 S2 which cost me $2.00 plus a single 36" long insulated wire that went from the top of the barrel to the bottom.
I wrote code to call their Cap-Sense feature I found there was a continuous increase in the cap-sense readings as the barrel filled from empty to full. In addition there was a huge jump in readings as soon as the water touched the bottom of the wire.
My first attempt had a minor issue of the wire not hanging straight so I switched to 24 gauge silicone wire which is hangs nice and straight. I Tied a stainless steel nut on the end and suspended it in the barrel. I seal the end of the wire with some glue to try and avoid having it eat the copper of the wire. It is important to understand that this is non-contact sensing the water is only supposed to touch the silicone of the wire. There is never supposed to be any contact between the water and the copper of the wire. We are sensing capacitance not resistance.
I calibrated the system by recording the readings every 2 inches as I filled the barrel with water. I had the micro-controller remember these readings and then use interpolation to compute the values between each 2 inch Mark. This Micro-controller includes quite a lot of storage which I use to data log the levels as they change.
The sensor works just hanging through the threaded opening but I wanted something permanent so I drilled a hole large enough for the wire about 1/8" in the center of the barrel so it is undisturbed by other wires and tubes. I also 3D printed a case to hold the electronics, battery, lcd display and small solar panel. I screw the entire assembly to the top of the barrel with stainless screws. I seal it all with a TPU gasket.
I am still refining the total RainAmp system but I can currently tell within about 1/8" what the water level is in the system and can detect changes smaller than 1/8". I think that with some further refinement I can get it down to a granularity of about 1/64" change in water level. I use additional wires that are long enough to reach to 3/4, 1/2, 1/4 level so I can use the huge jumps in readings as the water touches to tipple check the primary wire readings.
A single inch of water in a standard 55 gallon drum is 1.528 gallons so at 1/8" I have a resolution of 0.191 gallons or 24.5 ounces. For RainAmp we want to allow users to control watering resolution down to 8 ounces so I to I need to improve our resolution down to 1/24" if I want to measure water dispensed by measuring water change in the barrel. I have other options but they all require extra parts so trying to avoid them.
This CPU also gives me WiFi and Bluetooth so I can broadcast the readings when in WiFi range. I use BLE to offer the feature to download the data logged to mobile phones for remote barrels. One
The cap-sense readings are initially erratic and are impacted by people standing near or touching the barrel. They can also be affected by strong electromagnetic fields so they would probably not be reliable below high voltage transmission lines. To overcome the jumpy readings which we also see from many ADC circuits I use a technique called oversampling which is essentially taking the average of a 1000 readings then taking the average of the last 10 average readings. This burns a bit more power since it requires keeping the CPU awake for few extra milliseconds but it helps smooth out the readings so we can use them reliably in control logic.
These kinds of capacitive sensors can be very finicky when the wires run further than absolutely essential or when they run next to other wires carrying any kind of power. The key design rule is to keep any wires between the sensor and the micro-controller as short as possible. Since I use capacitive sensors in several parts of the RainAmp system I use several cheap micro controllers right next to what they are sensing. I deliver the data between the micro-controllers using OneWire, RS422 or BLE. This takes a lot of the variability out of the system at the cost of several smaller circuit boards and the complexity of coordinating data exchange between the different micro-controllers. Short wires are so important that I take this to the extreme where we have buried soil moisture sensors and actually encapsulate the micro-controller so it get’s buried with those sensors.
T.I. has chips that appear to provide superior cap-sense technology and which consume far less power but the ESP32 S2 chips are so powerful at such a low cost that the T.I. chips are hard to justify until we can buy them at 10,000 unit quantities where the T.I chips become cost competitive.