omarnas
Posts: 5
Joined: Mon May 02, 2016 7:20 am
Contact: Website

false push buttons press when connecting to long wires

Wed Dec 12, 2018 8:10 am

I'm creating buzzer buttons to control lights through a relay,
when I tested the prototype with small wires to the buttons it's worked fine, but when I try to connect the buttons through 1m-1.5m wire it's give me reads as if all the buttons are pressed

I'm using Node js onoff library
Here is a diagram :
Screen-Shot-2018-12-12-at-11.43.26-AM.gif
Screen-Shot-2018-12-12-at-11.43.26-AM.gif (67.21 KiB) Viewed 516 times
the issue only appear when I connect the buttons to a longer wires

how can I solve this issue ?
can i connect each button to 3v power supply ( 3v battery ) + - instead of ground and 3v from the pi ?

Also, i tried to connect the buttons direct to ground without using 3v & Resistors and the same issue appear.
I really need to use long wires.

drgeoff
Posts: 9761
Joined: Wed Jan 25, 2012 6:39 pm

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 9:20 am

Try putting a 100nF capacitor from GPIO to ground and using twisted pair of wires to each switch.

Maybe just an error in your diagram but your yellow wire is on the wrong end of the 1k resistor. Also your configuration is a bit unusual. Most people would have the switched 3.3v going to 10k resistor to ground. The 1k between non-ground end of 10k and GPIO.

pcmanbob
Posts: 6686
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 11:50 am

Your pull down circuit is no quite correct so you have actually created a potential divider circuit.

Image

So 2 of your switches are wired like diagram A the third has the gpio connected to the wrong end of the 1K resistor.

you should be wiring your pull down circuit like diagram B

and drgeoff is suggesting you add a capacitor as in diagram C
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

omarnas
Posts: 5
Joined: Mon May 02, 2016 7:20 am
Contact: Website

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 1:54 pm

drgeoff wrote:
Wed Dec 12, 2018 9:20 am
Try putting a 100nF capacitor from GPIO to ground and using twisted pair of wires to each switch.

Maybe just an error in your diagram but your yellow wire is on the wrong end of the 1k resistor. Also your configuration is a bit unusual. Most people would have the switched 3.3v going to 10k resistor to ground. The 1k between non-ground end of 10k and GPIO.
Thank you drgeoff, the error is only on the diagram when i draw it,

omarnas
Posts: 5
Joined: Mon May 02, 2016 7:20 am
Contact: Website

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 1:57 pm

pcmanbob wrote:
Wed Dec 12, 2018 11:50 am
Your pull down circuit is no quite correct so you have actually created a potential divider circuit.

Image

So 2 of your switches are wired like diagram A the third has the gpio connected to the wrong end of the 1K resistor.

you should be wiring your pull down circuit like diagram B

and drgeoff is suggesting you add a capacitor as in diagram C
Thank you pcmanbob i will try your suggestion by using capacitor, but for now since i don't have one,
do you think I can use 3v batteries and connect each button to one of the 3v batteries instead of using the pi 3v and ground? or I will damage the device ?

pcmanbob
Posts: 6686
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 3:31 pm

The capacitor suggestion was drgeoff's not mine so credit were credit it due.

I don't understand why you would want to use a battery for the switch 3v supply ?

and a 3v battery might actually be nearer 4v if new.

even if you used a 3v battery you would still need to connect the battery negative terminal to the pi ground.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ElEscalador
Posts: 676
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 5:03 pm

I have run up to maybe 12-14 meters with nothing but the internal pullup/down resistors and have yet to get a false signal. I did, however, use the pullup internally so my input is inverted and a button press feeds ground back to the gpio pin. The idea was that in the noisy environment with power tools that I would be less likely to induce a false ground than a false positive. I don't know know if it actually helped because I couldn't induct a false signal the other way either, but I saw no downside to following that advice I read somewhere and it's a furnace controller so reliability is important. In either case, I can't imagine 1 meter being long enough to have problems.

I can't make sense of your drawing on my phone, but I believe these guys if they say you've accidentally made a voltage divider. I suggest just using the internal and maybe a 5 or 10k inline and forget the external pulldown for the most simplicity. I skip the inline too but can't recommend that because one code hiccup and you've accidentally shorted that gpio... Anyway, pulling up with just the internal has worked flawlessly for two years on both my garage(1 switch, 5 meters and a noisy garage opener adjacent) and my buddy's furnace controller (reading 10 pins from 5-14 meters away, the basement is his workshop with saws and drills and fans etc).
My Autonomous Robot Project and a few of my other projects below.

https://lloydbrombach.wordpress.com/

User avatar
Burngate
Posts: 5972
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: false push buttons press when connecting to long wires

Wed Dec 12, 2018 6:14 pm

Using pcmanbob's 2nd & 3rd diagrams (which are clearer than the type of diagram you posted, once you get used to them) I would be inclined to reduce the value of the pull-down resistors from 10k to, maybe, 1k.

That would mean any stray interference would have to work harder to cause false triggering.

omarnas
Posts: 5
Joined: Mon May 02, 2016 7:20 am
Contact: Website

Re: false push buttons press when connecting to long wires

Fri Dec 14, 2018 10:28 am

I want to update you on this,
i tried pcmanbob suggested diagram (C) it worked better for me the false tigers reduced but still it's happening.
I noticed that when I plug or unplug any large electric device (like laptop charger as ex) near the buttons and the raspberry pi it's triggering the buttons!

do have any other suggestions for this situation?
I'm planning to place one pi for each button in this way I can reduce the length of the wire and hopefully prevent the false triggers
and will connect them through tcp ip socket.

pcmanbob
Posts: 6686
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: false push buttons press when connecting to long wires

Fri Dec 14, 2018 11:07 am

Did you try reducing the value of the 10K pull down resistor as suggested ?

if not try 5K if you still have problems try 2.2K and finally 1K but I would not go lower than 1K.

you could always try switching from a pull down circuit to a pull up circuit that way your input is normally high and goes low on switch operation, you would have to change your wiring and software.

https://github.com/raspberrypilearning/ ... up_down.md
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: false push buttons press when connecting to long wires

Fri Dec 14, 2018 11:21 am

And how did you connect everything together. So, where did you place all the components. Close to the input of the Rpi, or did you connect it close to the switch.
For the best result, every components need to be as close as possible to the Rpi, expect the switch of course.

You could also try to twist the cable that is going to your switch, like you ethernet cable.

If everything doesn't help, you could also try to add a resistor, higher than your pull down resistor, directly over the switch.

danjperron
Posts: 3393
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: false push buttons press when connecting to long wires

Fri Dec 14, 2018 1:42 pm

35 Years ago one of my friend made a system using utra-sonic sensors , panel and push button to tell people which of the bank clerk is free and he had problem with push button. Sometimes the push button triggers by itself for no reason.

Then I solved the problem using opto isolator.

1 - Be aware that very long wires act like an antenna and any signal from radio, lightning and big emf devices will be inserted into the wires.

2- Use capacitor, resistor and a small ferrite to kill high frequency. You should think also about protecting your GPIO inputs with protection diode or transorb. I lost 2 TVs, one router , one modem and a couple of network devices by just one lightning!

3- Optocoupler is a very convenient way to isolate devices . It protect against ground loop, back emf, and lightning.

4- You could use shield cable. The shield itself create a capacitive load and a faraday cage. but it doesn't protect against electrical discharge.

After saying that a simple debounce algorithm will take care of the false push button. But good practice tell me that you should protect your system. It's not fun to wakeup after a storm and found out that your raspberry Pi is dead.


Are your device ready for the next big solar storm
https://en.wikipedia.org/wiki/March_198 ... etic_storm

User avatar
Burngate
Posts: 5972
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: false push buttons press when connecting to long wires

Fri Dec 14, 2018 6:00 pm

omarnas wrote:
Fri Dec 14, 2018 10:28 am
I noticed that when I plug or unplug any large electric device (like laptop charger as ex) near the buttons and the raspberry pi it's triggering the buttons!
When something gets unplugged - or just switched off - the nice and gentle mains sinewave current suddenly stops.
That cliff-edge radiates RF like mad - mains cable wasn't designed with RF in mind.
And your cable to/from your button picks that up, unless you take steps to stop it.

I normally recommend either ethernet cable or screened audio cable in that situation. Both have been designed to reduce pick-up.

Return to “Troubleshooting”