presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Pushbutton multiple inputs

Thu Aug 29, 2019 10:10 pm

Hi Group,

I have my pushbutton connected to 5V and the other leg to GPIO 20. I have a RISING edge detect event added that calls a function. I have other components attached to the Pi as well: motor board, stepper motor, camera, and 4 LEDs. Many times I don't even push the button but the interrupt event is triggered. I have a pull-down resistor setup through software on the GPIO pini. I have a bouncetime of 60s but I don't think that prevents multiple inputs from being registered. I only need the button to be registered one time. Any ideas what I have done wrong or should do

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Pushbutton multiple inputs

Thu Aug 29, 2019 10:13 pm

If you connect 5V to any GPIO pin (without using a voltage divider) you will burn out your Raspberry.

The GPIOs run at 3.3V, anything higher than that will let the magic blue smoke escape.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Thu Aug 29, 2019 10:16 pm

Will that wiring cause interrupts to be triggered? Do you advise 5V+divider+SW pull down or GND+SW Pull Up?

PhatFil
Posts: 1437
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Pushbutton multiple inputs

Thu Aug 29, 2019 11:46 pm

presish wrote:
Thu Aug 29, 2019 10:16 pm
Will that wiring cause interrupts to be triggered? Do you advise 5V+divider+SW pull down or GND+SW Pull Up?
OR JUST USE THE +3.3v pin as the +v source like everyone else.. Only when using more sophisticated modules that provide a 5v signal should you need to supply 5v and use a voltage divider or logic level shifter to protect your pi inputs.

if your pi is ok its a fluke and your very lucky..

To clarify your Q, providing 5v on a gpio should be catastrophic, if you only suffered an occasional glitch be grateful..

If the glitches (false interrupts) occur when wired up with 3.3v as the +ve voltage source, it could be as a result of the overvoltage already applied? simplest way to confirm would be to use a 2nd pi that has not had 5v fed into its gpio pins

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Thu Aug 29, 2019 11:56 pm

So basically you are saying if the button was wired to 3.3V and GPIO from the beginning with PD resistor enabled via SW, I should not see random inputs triggered on that pin?

JohnsUPS
Posts: 129
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Pushbutton multiple inputs

Fri Aug 30, 2019 12:26 am

So basically you are saying if the button was wired to 3.3V and GPIO from the beginning with PD resistor enabled via SW, I should not see random inputs triggered on that pin?
Not exactly.

With the way you stated that this push button is wired, with one side going to +5V, then pushing the button will put +5V on the GPIO pin which could ruin the Pi, or pop that particular GPIO pin at the least. Please don't do this.

The high side of the push button should be to the 3.3V pin. Then pushing the button will only pull the GPIO pin up to 3.3V, which would be safe.

As far as random inputs are concerned, correcting the voltage probably won't fix that problem, but it will prevent you from damaging the Pi.
If you are using a GPIO with an internal pull down resistor, it could be that the pull down isn't strong enough to keep the voltage on the wire(s) stable. Try using a stronger pull down resistor (try about 10K or so to see if that helps). Don't use too low of a resistor (say, keep it above about 3K), because this will be in parallel with the internal pull down.

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Fri Aug 30, 2019 5:24 pm

Would the external pull down resistor connect GPIO on Pi to GND on Pi? Or External Ground?

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

Re: Pushbutton multiple inputs

Fri Aug 30, 2019 5:52 pm

What, precisely, do you mean by "External Ground"?
If you mean the pin labeled Earth on your mains supply (or some soil outside your house, which ought to be similar) then it may be at a very different voltage from the pin labeled GND on your Pi.

The idea behind the pull-down resistor is to make sure, unless your switch is closed, the GPIO is held at 0v referenced to the Pi's GND pin
If you connect it to anywhere else, you won't know (and nor will the Pi) what voltage it's being held at.

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Fri Aug 30, 2019 10:26 pm

by External Ground I mean the Ground for my Power supply for the Pi .

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Fri Aug 30, 2019 10:27 pm

So I need to connect a resistor between the GPIO pin and one of the Ground Pins on the Pi to keep it at 0?

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

Re: Pushbutton multiple inputs

Sat Aug 31, 2019 8:59 am

presish wrote:
Fri Aug 30, 2019 10:26 pm
by External Ground I mean the Ground for my Power supply for the Pi .
Almost certainly, your power supply is what is known as "floating".

That means there is no connection between its input and its output - if you were to use a multimeter to measure the resistance between either of the output wires and any of the input pins, the reading would be infinite.

The Ground pin of your supply may not even be metal. In the UK, it's only there to open the shutter on the socket to allow access to the other connections - and the shutter's there to prevent a child with a knitting needle hurting themself.

The ground on the socket should really be called "safety earth". The rules about it are fairly complex, but in essence nothing should be connected to it, except metal cases that the consumer could touch.
presish wrote:
Fri Aug 30, 2019 10:27 pm
So I need to connect a resistor between the GPIO pin and one of the Ground Pins on the Pi to keep it at 0?
Yes.

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

Re: Pushbutton multiple inputs

Sun Sep 01, 2019 9:14 am

May be these diagrams will help.

Image

So in the pull up circuit the gpio pin is held high by the 3.3v until the switch is pressed then the 3.3v is connected to ground the 10K resistor limits the current flowing and all the the voltage is dropped across the resistor resulting in the gpio input now seeing 0v.

but in the pull down circuit the gpio input is held low by the 10K resistor that's connected to ground, but when the switch is pressed the 3.3v is connected to the gpio input so it now sees a high.

So in both circuits there is no point at which the gpio input is left in a floating state, it is always high (3.3V) or low (0V)

the 1K resistor is just there as a protection should you set the gpio pin to output.

All connections are made on the pi gpio.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

presish
Posts: 93
Joined: Mon Nov 17, 2014 9:40 pm

Re: Pushbutton multiple inputs

Thu Sep 12, 2019 9:41 pm

THANK YOU! That appears to have fixed it. I used the Pull down Circuit. Wiring the open circuit to GND was the part I needed to hold the signal LOW.

Return to “Other projects”