Long wire Water Tank Level Indicator, Floating Values when on Electrical outlet

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