Go Down

Topic: Long wire Water Tank Level Indicator, Floating Values when on Electrical outlet (Read 5960 times) previous topic - next topic

shantanuonline

My reply on this was strangely disappeared after posting so posting again.

My existing old cable was brand new and i had bought it just for my IC 4049 setup i have described initially and it was hanging outside from then only. Said setup was working on 12 volts and i am not sure if that can disturb any property of cat 5 in longer use.

As you suggested i will see the availability and budget before buying one today.

For sure my next test and investigation on Arduino setup will be on brand new cat5.

Byork

I also have another suggestion. If short wire works, maybe you can also consider using an ESP8266 instead of Arduino. You can leave one ESP near your tank and connect your sensor wires to it, then send the data over to another ESP, where you can connect your LCD etc. I have personally run an ESP-12 in a waterproof enclosure in a garden for 2 months without issue so far.

I have encountered similar problems as you in the past. My Arduino input readings were unstable, because they experienced signal interference from wires. I have many wires cluttered together, reading many sensors going into the Mega. My sensor network was also growing rapidly. So I decided to once and for all to use ESP8266s to transmit data. For me, it has solved all my data communication issues involving having to lay wires over long distances, cluttering mess, interference and managing the sensor network. I now connect my sensor(s) to ESPs, and use them as client nodes. They then transmit the data to my Raspberry Pi as a central server and database. If my project requires a lot of pins, I will still use an Arduino, then connect an ESP-01 to it via I2C to transmit the data.

Something you can consider for the future perhaps.

shantanuonline

Yes Byork, that is a good suggestion on adding one ESP on both end for any similar future project.

Steve, now here is what I got with new cable. instead of cat5 now I have brand new DLINK cat6 30 meter cable but i did not noticed any significant change so the issue is remain same with this new wire in existing setup.

But...it looks like to facilitate things with such long and the issue you both have figured out which is long wire/interference/noise I have to do something with my pull down's because when I change the values of pulldown it started stabling the whole system, not fully stable but bit of progress.

Like you talk about 4.7 k before i tried that but no luck, now at this point I don't know what should be the calculation and if I have to use same value registers for all 4 sensor wire,I have replaced all 10 k with 15 k and things started stabling out.

then i have replaced 15 k with 27 k and it show some more stability. I will keep investigating this with different values but it will be great if you or Byork can guide me if this is the right approach of overcoming the issues you both have already figured out and if yes then how should i got to know what will be the suitable value of registers on long run?

like 4 different values for 4 sensors? because with 27 k, first 3 reading are showing correct every time but when i submerge the last sensor in water, the "first sensor" reading start fluctuating, although this is not a big issue because by logic if the value of next sensor is HIGH then by default it can be consider that the value is previous sensor is also HIGH so by changing the logic of code it will work but this is just a workaround and not a solution i believe.

Thanks
Shantanu

steve_mcdonald

Hi Again,
That was a helpful experiment - good idea.  It has given me an idea I want to test here as well so I'll set up a copy of your set up to try out. 

I'm keen to have a look but it is holiday time here and i might be a week or two.  I am also looking back at the code  along with what we now know about the cable and what the change in resisitance is doing.  I will contact you as soon as I have a chance to do some more work.
Steve

steve_mcdonald

Hi Shantanu,
I did the numbers and can see why it is variable.  The arrangement I used to work with is your 20,000 (20k) pullup resistors (built-in), turned on by code lines 9-13 INPUT_PULLUP, and 27k external pull-down resistors.  Water resistivity varies a lot, due to changes in temperature, turbidity, mineral content etc.  It will vary with electrical current in the water as well due to the ionisation process introduced by the dc current between the probes.

Let's say the water resistance is somewhere around 18k per 10cm.  The circuit (+5 - probe - gnd) is a voltage divider with 20k probe to vcc and 10k8 probe to ground. The 10k8 is the combined parallel resistance of 18k in the water and 27k external pull down.  Seen this way, the level probe is at about 1.75 volts above ground and 5v vcc is 3.25 volts above the probe. 

Assuming a 10 cm gap, the current in the water will be in the range of 300 microamps. Any change in the water resistance will have an effect on the current, which will drive a change in the voltage seen at the pin, as it is the centre of a voltage divider.

When the AVR reads an input pin, a small but meaningful change in current results, since a small amount of power is consumed to make the reading.  Since your current in the water is so small it may be affected by the read current, causing varying readings.  In addition, the current in the water is ionising the water and that in itself causes a change in resistance which contributes to instability at the probe.

Thinking about how I would proceed, I would remove the INPUT_PULLUP directive and set the pins as INPUT.  I cannot see why your code needs to set the pins HIGH (lines 15 - 18) because it is the same thing as setting the internal pullups on.  I would advise we turn them off. To do that remove lines 15 - 18 and change lines 9 - 13 to   pinMode(firstLevel, INPUT); would also suggest we use an external pull down value that will give us a bit more current in the water - while this will increase ionisation somewhat, it will also reduce any effect during the microprocessor read cycle. I would try either 10k or 4k7 pull downs. (An alternative approach would be to use the internal pullups and discard the external pull down, then measure from ground to pin rather than vcc to pin - I like that approach better, but it makes no technical difference other than removing the potential introduced because the water is grounded as mentioned in earlier posts).

This way, the only factor affecting the readings is the variance of water resistivity.  Since you are only interested in whether the probe is covered or not, then you can interpret the change in pin voltage (which will now be significant) as covered or uncovered. 

shantanuonline

Thinking about how I would proceed, I would remove the INPUT_PULLUP directive and set the pins as INPUT.  I cannot see why your code needs to set the pins HIGH (lines 15 - 18) because it is the same thing as setting the internal pullups on.  I would advise we turn them off. To do that remove lines 15 - 18 and change lines 9 - 13 to   pinMode(firstLevel, INPUT); would also suggest we use an external pull down value that will give us a bit more current in the water - while this will increase ionisation somewhat, it will also reduce any effect during the microprocessor read cycle. I would try either 10k or 4k7 pull downs.
I have tried this in past before moving to 27k pulldowns but it did not work as expected.


shantanuonline

(An alternative approach would be to use the internal pullups and discard the external pull down, then measure from ground to pin rather than vcc to pin .  

sorry didn't get it, how can I read between ground to pin instead of vcc to pin? I can try it this weekend but it sounds like it will always show "0" ..how come I get "1" ?

steve_mcdonald

That's a good question and it brings up assumptions I made but did not clarify. 

1.   The bottom probe is currently connected to vcc.  In my arrangement we would connect it to ground.
2.   I forgot you are using digital i/o pins (9 - 13). I would use analogue pins (A1 - A4 for example) set to inputs with 'pinmode(A1, INPUT_PULLUP)'. 

The voltage divider approach depends on using analogue pins configured as inputs with pullups.  These pins will return an integer between 0 and 1023, depending on the voltage read at the pin.  In my approach, the lowest probe in the water is connected to ground.  The next probe is connected to analogue pin A1 (let's say) with its pullup set. This pin will be at vcc when it is out of the water due to the pullup.  The pin will read integer value 1023. When that probe is covered by water, the voltage at the pin will be pulled down due to current flow between the pin (driven by the pullup) and the ground probe.  The voltage at the pin will be (referring to my earlier calculation) 1v75 above ground. The analogue read of that pin would give an integer value of 1.75 / 5 x 1024 = 358. 

So, a reading of 1023 (or anything nearly that, say over 1000, would indicate the probe is uncovered, and a reading under 500 would indicate the probe is in the water.

All these estimates are made using the internal pullups with your original 27k external pulldowns.  I'd dispose of the external pulldowns, in which case, the value of 358 (1v75) would be even lower than that, so the difference is even more notable.

I hope this makes sense. I am using this approach with multiple sensors at up to 20 metres. In my case I read the values at the analogue pins and can resolve daylight readings between integer values of 16 to 1022. 
   
Let me know what I can do to help.
Steve

shantanuonline

Thanks Steve,

I did read between "ground and pin" this time and understood that the readings vary on tank capacity and distance between probes. In my test setup I am using the "actual probe" in a small and long PVC container where I manage submerge all 4 probes and below are the readings of my 10 different attempts.

1st Probe - 400-450
2nd Probe- 400-450
3rd Probe- 450-500
4th Probe- 600- 700

I had test the same is a glass of water with a small setup of probes and it show completely different readings.

I also found that readings fluctuate a bit and then stabilize itself in 5-10 seconds when I move from battery power to wall socket power and vice versa while reading values in my laptop, but this should be fine.

For now I have choose to read anything below 800 is a "HIGH" in my code and its working perfectly but my next plan is to put my "actual probe setup" in my "actual 1000 liter overhead tank" and then read values. I will run it on different intervals and log the reading in my laptop just to see if there is any big change in readings and then I can fix which value I should put to get a "HIGH" correctly every time.

By the way 700 is way to high when the probe is completely submerged in water ..its a huge difference.

steve_mcdonald

Okay, that sounds liek good progress.  Let me know how your test inthe real tank goes...

shantanuonline

in my actual setup now things are more stable and it's currently under observation, I am getting a good reading between 350-500 from all 4 probes and there is not much fluctuation.

By saying actual setup I am saying the complete system and approx. 500 lines of code including different sensor modules, display and buttons e.t.c I have mentioned in my first post so its a LIVE environment now.

Not sure if it is too early but I think its safe to say that my challenge around unstable readings is now fixed, even if not then also I have that level of control to read what It suppose to.

I am going on vacation soon and will do a full cycle of testing after one week to fix some other bugs.

Thank you for your help on this Steve.

steve_mcdonald

It's a pleasure and I've enjoyed working out the answers with you.  Good luck with the rest of your project.

Paul_KD7HB

I just finished reading through the entire thread because I was curious about the use of the conductivity of water as a level sensor.

Last summer I planned to upgrade my garden irrigation system to use a similar system. It is fed by our domestic water well. I cannot afford to overflow the tanks and create a lake. Has happened before.

So, after buying two of the conductivity sensor boards on Ebay, I built a sensor probe similar to what the OP has, but used float switches. One at the bottom of the pvc pipe to indicate the tank was nearly empty, and one near the top to indicate the tank was almost full. The top of the pipe is fixed to the top of the tank.

Using a Nano to watch the two switches and control a SSR that controls a solenoid valve to fill the tanks. Worked flawlessly all last season.

My suggestion to the OP is to change his sensor stack to use float switches to indicate the water levels. Then the off/on is truly solid on or off.

Paul

steve_mcdonald

Hi Paul,
Your thinking aligns with mine.  I resist the idea of sinking probes (particularly dc fed) into water tanks because of the electrolysis effect for one thing, although that can be reduced using ac or even reverse polarising dc every alternate sampling.  In situations where I've used wet probes, I've used that reversing the polarity approach along with only powering the probes during measurements. 

That way, the life of the probes can be extended quite significantly.  Despite that, electrolysis also causes changes in the water chemistry, which I only understand superficially, but which I'd rather avoid. 

I use floats in my water tanks for that reason.  Mostly I care if there's risk of overflow or risk of empty tank, and I am less concerned about reading intermediate levels, but then I live in a country that never goes long without rainfall!  In addition, I built an ATMEGA based weather station with a rain gauge so I always have a clue how much rainfall we're getting. 

With respect to the model the OP has chosen, the probes do give a clear distinction between covered and uncovered, so it can be interpreted as on or off (although it is not exactly that).  The difficulty is always that the actual readings will change over time as the probes are degraded by electrolysis.  That's my ongoing concern and why I also avoid using wet probes too.   

Hey, interesting discussion and thanks for your comment.  Good luck with future projects and best wishes to you.

Steve

Go Up