# Long cable run experiments

I ran an experiment today, how long a run of cable I could stick a switch on the end of. I think my cable run is maybe 20 metres. As I kind of feared, I get no response when I press the switch at the end of the cable. (I know this isn’t the device’s fault). Curiously, though, when I FIRST connect the switch to the board I reliably get a “false positive” - ie the device thinks the switch was pushed. Is this due to the cable length? Because I don’t get this false positive when I hot connect switches to the board with much (much) smaller runs?
For the record, I am using pinMode(pin, INPUT_PULLUP); rather than an on board resistor.

what kind of cable? (awg) Have you measured the voltage at both ends of the cable?

when you attach the long cable with an open switch to your pin, a voltage will have to be established at the switch… so one cable will seek to go from zero to 3.3volts. To energize the entire wire will require some current to flow from the pin (pulled up to 3v3). During that time the voltage at the pin drops… eventually recovers once the cable is fully energized.

you could try some software debouncing; add the time required to “notice” the drop, add some RC filter or even an optocoupler

@daneboomer, to understand what is going on with a 20m cable, you need to understand a) Resistance of the wires and the voltage drop across them, b) the capacitance created by those cables and c) the “antenna” effect of those longs wires which create unwanted voltages on those same wires.

These issues are what plague power transmissions and why superconductors are so important. In your case, that poor weak (40K) pull-up and the 3.3v supply is asked to supply current down 40m of wire (since I assume you connect on wire to GND). However, the voltage drop accross the wires is so large, the voltage at the pin doesn’t drop low enough to be a “LOW”.

Now, as for your false positive, with static electricity and other electrical fields (eg. wifi), the stored charge in the wires was enough to kick the pin LOW when connected. There is no mystery here, just electronics aka physics!

2 Likes