Go Down

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



I have been using an Overhead Water Tank Level Indicator and Motor control system based on IC 4049 from last 2 years which was working fine and I thought to have it upgraded to be Controlled by Arduino so that I can enhance the system with some more logics. I did my research for few weeks and finally able to make it with Arduino Nano and Implement the system and it work exactly as I was expected.

Now after 2 weeks of daily use suddenly it just stopped behaving in the way it was made for so after some investigation I found the sensor reading is not stable and started fluctuating from 0 to 1 and vice versa.

Talking about the sensor it just a 5 feet PVC pipe with four steel screws at 4 different levels and one steel screw for +VCC at the bottom and I have managed to seal the PVC pipe in such a way that water cannot enter inside and damage the wire/joints at over the period of time. This might be the best option but I am ok to clean/replace it in few years and it's cost effective.

The reason it stopped working after 2 weeks is because I was using 2 year old sensor which was with Iron screws and telephone line copper cable wrapped "outside" of PVC pipe which was completely burned out because of corrosion but I am not sure why now it is not working with the new sensor setup with steel screws I have described above. To be more precise here, everything works fine with short cable length of 1 feet or less but not when I connect 30 feet CAT5 cable as sensor values just float around.

I am using Arduino Nano with external 10k Pull-down register at pin 9 to 12 and cat 5 cable of around 30 feet attached with the sensor setup described above. I have just downloaded the Fritzing app to make the schematic but yet to see how to make one, if needed I will make the schematic and attach it.

Here are my findings so far:

1. SOMETIME new sensor reading are stable with both short cable length and long cable length wire when the system is powered by my laptops 3.0 USB port running on batteries but its start floating when I attach the laptop charger. Same happens when the system is powered by 5 volt smartphone wall charger. Using of less or high ampere charger does not have any effect here.
2. I have to use both Arduino's Internal Pull-up and External pull-down register ate same time for each pin to get it work which should not be the case I believe.

3. Because of the long wire I have tried to change the External pull-down values from 10k to 1k but it just stop reading values form sensor.

My code is too long to post here and also irrelevant to the actual problem so for debugging I am using below simple and short code nowadays and hoping it to work.

After going through all the section of the forum I have chosen this section to post my question , If this is not the correct section of forum please let me know.

Any help will be appreciated.


Code: [Select]

#define forthLevel    9
#define thirdLevel    10
#define secondLevel   11
#define firstLevel    12

void setup() {

  pinMode(firstLevel, INPUT_PULLUP);                                        //PULLUP to avoid floating values when input is low, addition 10 k register is connected between
  pinMode(secondLevel, INPUT_PULLUP);                                       //each pin and ground
  pinMode(thirdLevel, INPUT_PULLUP);
  pinMode(forthLevel, INPUT_PULLUP);

  digitalWrite(firstLevel, HIGH);
  digitalWrite(secondLevel, HIGH);
  digitalWrite(thirdLevel, HIGH);
  digitalWrite(forthLevel, HIGH);

void loop() {

  int firstLevelReading = digitalRead(firstLevel);
  int secondLevelReading = digitalRead(secondLevel);
  int thirdLevelReading = digitalRead(thirdLevel);
  int forthLevelReading = digitalRead(forthLevel);

  Serial.println("--------Status--------"); //reading it via Putty from my laptop.
  Serial.print("firstLevelReading - ");
  Serial.print("secondLevelReading - ");
  Serial.print("thirdLevelReading - ");
  Serial.print("forthLevelReading - ");
  Serial.write(27);       // ESC command
  Serial.print("[H");     // cursor to home command



You may find that your water supply is earthed (connected to the same ground potential as your computer or Arduino power supply), thus effectively short-circuiting the supply if VCC is immersed in the water. Even if it is not earthed by design, the water in the tank may be at an unpredictable potential with respect to the supply voltage which is almost certainly ground-referenced.   

Either situation can fully explain the problem you are encountering.

You could try isolating the tank water from ground (although I suspect that will be difficult or impossible, and may not actually cure the problem, depending on the volume of water).

You could try a fully isolated supply.  I think you have done that with batteries and found that worked.

You could design a probe that does not rely on being immersed in the ground referenced water tank.  There's many options that would allow that.



Thank you for your reply Steve,

Yes i can't isolate the water tank completely but i have stimulated it with a small capacity tank laying in a completely different floor  and different location but the problem remain same.

When powered by battry sometime it work but not always. Sensor value still float around but not very rapidly but it should not float at all by design.

As i indicated earlier,  i have similar setup in past which work for more than 2 year without any complain and now with Arduino its not helping me.

The only alternative  and cheap solutions i can think of is reed switch based magnetic floats but reading    feedback from other people it sound like it does stuck sometime like 2 times out of 100 attempt or so.
Pressure/capacitance/ultrasonics have there own problem's and frankly i just dont want to go in that direction.

Apart from all these, the cheap diy sensor should work but just have to figure out how to stabilize the floating values.


Okay, understood.  Can you provide a schematic of the wiring and connection arrangements?  That will help diagnose the problem. 

Long lines (I don't know how long your signal line is) can introduce capacitance effects and may be subject to external RF that can affect the signal. We may need to look at how to isolate that.  I am using multiple signals into a weather station and these are up to 15 metres in length, but have no interference or irregular readings, so we can fix this.  On long lines I tend to use strong pullup or pulldown resistors (4k7) rather than weak ones (10k, 100k).  I also in some cases use a latch or buffer to stabilise and reconstruct the signal before delivering it to the microcontroller inputs.  Happy to share all that design stuff, but let's isolate the problem you're having. 

A schematic will help me understand.


Sorry, missed the point it is 30 feet of CAT5.  Can I check you are using a true CAT5 pair (white/whiteBlue) for example?  That's important for these signal types.

Dropping the pulldown to 1k will be too much and will affect the input reading range.  I'd not go under 4k7.


Thanks for sticking into this Steve

Please note that my final project involve RTC Clock, Rain drop sensor, single channel relay module, buzzer, push switch, IR module, I2C .96 OLED soldered on  general purpose PCB with a RJ45 socket for CAT5 connection but after the problem I have dismantled all including the sensor and back to solderless breadboard for troubleshooting and just reading the sensor values via putty with the help of the sketch I have mentioned in my initial post , please see attached "Actual Project.jpg" to get an idea what I want to achieve.

CAT5 is UNSHIELDED twisted pair one, see attached "cat5.jpg"

schematic "Sketch.jpg" is attached which is showing the portion on which I am doing the troubleshooting, it's bare minimum to avoid any clash/interface with other components.

I have attached the reference image "Reference Image for Sensor.jpg" inspired from below blog.

I have also attached pics from those good days when it was working :) at least 2 weeks.


Your images do not yet give me an overall picture of the project.  None of these is a schematic diagram.  A schematic shows the electronic components, power supply and all sensors and connections.  I am happy to diagnose from a schematic, but not from separate and incomplete pictures. 

Specifically, the picture of the four pairs of Cat5 is typical, so tells me nothing. Which wire pair are you using for what connections?

In your code, have enabled or disabled the inbuilt pull-up resistors?  If enabled, then you have 10k pullups and 1k pulldowns on the inputs. 

The image of the "actual project" tells me nothing.  I need a full schematic, not a picture. 

I am keen and happy to help, but there is not enough information.


ok understood, I will make a start to end full schematic then and show you by coming weekend.


somehow I have managed to create full wiring, this is the fist time i am creating such wiring I am not very good in it, if something is not cleat please let me know.

before posting this wiring diagram I have again tested it in breadboard and result are below.

For testing, I submerge +VCC wire in a glass of water then submerge other 4 sensor wires one by one and it shows HIGH values correctly for each pin and values are stable every time, but when i connect the 30 meter long wire in similar way i got HIGH for the 1st level but then it start fluctuating for 2-3 seconds and then freeze at LOW. Putting other 3 sensor wire in glass of water have either dose not show any effect or it just fluctuate form high to low and unstable.

I am not sure if changing the arrangement of CAT5 pairs will have any effect because i have tried different random combination but results were same.


I've a couple of thoughts that I want to prove or disprove before we go any further.  Can you please ground (zero volts ) all wires not in use in the CAT5.  Preferably ground all unused wires at both ends.  Do only that as a first check to see if we are dealing with noise on the cable or something else.   


Okay, i will test it in next few days or by weekend.

Although i did checked one thing in past, connected all unused wire to Arduino GND but did not noticed any difference. The only thing i did not check what you suggested is to GND  both side of unused wires and i will test this and let you know.


I have seen some very cheap Cat 5 cables from China which have atrocious build quality. The wires weren't even twisted properly, and placed loosely in the sheath. I did not check the wires themselves, but they are probably not made of copper as well. At that length, you might want to consider trying it on a good quality cat5e if all else fails.


Byork makes a good point, have you tested with the same arrangements but with short wire?  I mean take the arduino and power supply near  the tank and wire a short connecting wire - if that cure sit, then we are looking at something introduced on the long wire.


Hi Byork and steve, thank you for your suggestions
Yes i did check the arrangement with short  wire near the tank and it was working ok, issue start when i connect the wire in question.

My cat5 is of a good quality single thread copper wire from DLINK, but its  2-3 year old wire exposed in open atmosphere and i doubt it may have build some sort of resistance or something so today i am going to buy a new cat5 and will test it and will post result.


That's useful info, thanks.  CAT5 is not exterior rated so it's sheathing will fail when exposed to weather or sun.  In addition,  the internal insulation (Polythene) and the make up of the cable (it's tightly twisted but loosely bundled) makes it prone to capillary action which draws moisture along the internal channels.  Water and copper are a bad mix, resulting in what's commonly called verdigris, which causes "low insulation"  which can be tricky to find - and one usually needs an insulation tester or "megger" (essentially a high voltage test meter). 

Low insulation is exactly the kind of thing that can cause the erratic symptoms you are seeing.  Cat5 is cheaper, but fails fast.  If you can, source an external rated, grease filled cable for a lasting solution. 

Out of interest, was the cable out of service for some time before you re-used it?     

Go Up