Reliable long distance push button wiring

Hello,

I'm using a Pro Mini Arduino with a push button wired with a very long cable to a digital pin 2 which is enabled with CHANGE interrupt.
I'm also using an external pull-up resistor with 10k and a electrolytic capacitor 2,2uF to have some hardware debouncing.

For the long distance (about 40 Meters) I have used twisted pair cable. Half of the distance is covered by a S-UTP network cable, so this part should be shielded well. The cable is located outside approx. 5cm into the ground.

The problem is that the CHANGE interrupt is called but the button was not pressed. By default the button is closed, if I press the button the connection gets disconnected.

Here is a wiring schematic

Do you have any idea how to improve the reliability of the interrupts called? Btw, I'm pretty much of a newbie regarding electronic wiring, so please try to keep you answer simple :slight_smile: Thanks

I would try with some thicker cable.
My dad got some of the same problems with his modeltrain, solved it with better cables..

your switch will get hurt! avoid shorting the condensor,
Add series R to switch and think of reducing C (timeconstant now >2,5 sek)

Using a 10K pull down resistor is a bit silly at that distance.

Wire up the button between the input and ground.
Have a 1K pull up resistor at the arduino end. Also at the arduino end have a 100R series resistor in line with the input pin. Also have a 0.1uF ceramic capacitor direct from the input to ground.

Try not to post pictures on sites that bombard the visitor with adverts when they try and look at your pictures.

Thanks for the reply and sorry for the weird image-hoster.

I have wired up the circuit on my breadboard for testing. I used a 120ohm resistor instead of 100ohm.
Could you please just have a look over it if the wiring equals your description Grumpy_Mike?

Thanks

IMG_0061.jpg

Close but you have mixed up the values of the two resistors.
Try and make the leads on the capacitor shorter.

Are you sure with the mixed values?
The blue resistor is 1k, the brown one is 120ohm.

It was hard to see on my screen but I think you are right on a second look.

i think there is a more complicated problem when u want to detect failed wire/button.

if it's a simple task like lighting up a LED or ringing a doorbell, it might be okay. (u just makes ppl think there's a ghost passed by, or checked at the front door and finds no one there...)
if it's a critical task like controlling a high power motor, you may get killed by false signal.

i suggest:

  1. use higher volt to drive the button circuit, isolates the signals with transistors or even photocouplers.
  2. encode the signal in some way, so a false signal gets filtered.

Thanks for the hint Palatis.

I'm just trying to implement a notification sensor for my letterbox. Not highly critical but it's annoying if the sensor is telling me "hey, you got mail" and I walk down all the stairs to see that there is nothing and the sensor was triggered by some error :slight_smile:

Using Photocouplers/Optocouplers would require to have an additional power supply somewhere near the letterbox - which has to be driven by battery. Currently I'm trying to avoid having two power supplies (one for the arduino itself and one for the optocoupler), especially if the engery source is a battery)

I'll try to implement the circuit Grumpy_Mike showed me above and change all UTP twister pair cables for better shielded S/FTP twisted pair cables. I will also move the pull-up circuit directly to the arduino end (without 20 meters between pull-up and arduino pin). I think this will provide more reliability to the whole circuit.

If you have another idea how to improve reliability please feel free to give me some suggestions. If my current idea is not working I'm happy to have another "Plan B" :slight_smile:

Thanks so far

you can have the 20 or 24V power source near your arduino:

                                     24V  5V
                                      |    |
                              R1 10k+ |    > R2 10k+
 +-----{ long cable }----------v^v^v--+    <
SW                                         |
 +-----{ long cable }---------[  Opto   ]--+--o to arduino
                              [ Coupler ]
                                |     |
			     GND24V  GND5V

why 24v? because 24v the highest voltage that human don't get shocked.
you can try 12 or 18v, that's easier to regulate down to 5V (with a 7805 or lm2985).

another simple idea is to route 2 buttons over, and requires both button to get triggered before you decide to perform some action.
usually one pull-up another pull-down.
other encoding methods might require more complex hardware setup so it might not suit your situation.

I would not recommend connecting 24V to an arduino input even through a 1K resistor.
This would put about 20mA through the clamping diodes of the Pi. The maximum should be less than 1mA.

  1. sorry i was gonna type 10k+... edited.
  2. no 24v into arduino input, the input is 5v from optocoupler.