foul_owl
Posts: 33
Joined: Sun Aug 11, 2013 10:29 pm

Do I need a series resistor using gpio pins for inputs?

Thu Jul 18, 2019 11:24 pm

I'm trying to connect 20 buttons to my rpi.

The buttons will connect the gpio pin to ground if pressed, or float if not pressed.

I use the internal pull up resistors then to avoid the float, like so:

Code: Select all

GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP) (et al)
which works great. But I'm currently using a series resistor for the single button I'm testing.

I know people will say "resistors are cheap" but the issue here is that I would prefer to not have any resistors hanging directly off one side of the switch, it's a bit annoying and a design weakness imo. My chassis doesn't have anything in it besides my rpi and the buttons. I would prefer to not have to etch a circuit board with headers and resistors...seems asinine.

So I would strongly prefer to omit the series resistors if they are not needed.

Is that acceptable?

trejan
Posts: 862
Joined: Tue Jul 02, 2019 2:28 pm

Re: Do I need a series resistor using gpio pins for inputs?

Thu Jul 18, 2019 11:34 pm

You don't strictly need the resistors but they're cheap insurance in case of mistakes. They'll limit the current if you ever misconfigure the GPIO to be an output. Pressing the button would cause the GPIO to be shorted to 3.3V or ground.

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

Re: Do I need a series resistor using gpio pins for inputs?

Fri Jul 19, 2019 7:37 am

foul_owl wrote:
Thu Jul 18, 2019 11:24 pm
would prefer to not have any resistors hanging directly off one side of the switch, it's a bit annoying and a design weakness imo.
It is not a design weakness. If series resistors were designed in, the current available from GPIOs when used as outputs would be markedly less.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Do I need a series resistor using gpio pins for inputs?

Fri Jul 19, 2019 8:03 am

foul_owl wrote:
Thu Jul 18, 2019 11:24 pm

So I would strongly prefer to omit the series resistors if they are not needed.

Is that acceptable?
It's up to you, or anyone else that will use it, whether it's acceptable or not.


The series resistors are protection in case the GPIO pins are configured as output and the switch is closed. The consequence of that is likely a broken Pi, but they aren't expensive. It might be a price you would be prepared to pay.
The chances of GPIO configured as outputs and switched closed is something you have to estimate and something you might have a lot of control over. If the Pi is dedicated to one task and you will control what SD cards are inserted you could probably make the risk negligible.


If SD cards might be changed or other applications run and you have little control, or might forget about the issue or not always check exactly what programs do with GPIO before running it,, then the risk could be quite high that directly connected switches damage the Pi at some stage.

foul_owl
Posts: 33
Joined: Sun Aug 11, 2013 10:29 pm

Re: Do I need a series resistor using gpio pins for inputs?

Sat Jul 20, 2019 10:56 pm

drgeoff wrote:
Fri Jul 19, 2019 7:37 am
foul_owl wrote:
Thu Jul 18, 2019 11:24 pm
would prefer to not have any resistors hanging directly off one side of the switch, it's a bit annoying and a design weakness imo.
It is not a design weakness. If series resistors were designed in, the current available from GPIOs when used as outputs would be markedly less.
I meant it's a design weakness (mechanically) to have some resistors hanging off one side of my buttons, not a design weakness of the pi.

foul_owl
Posts: 33
Joined: Sun Aug 11, 2013 10:29 pm

Re: Do I need a series resistor using gpio pins for inputs?

Sat Jul 20, 2019 10:58 pm

PiGraham wrote:
Fri Jul 19, 2019 8:03 am
foul_owl wrote:
Thu Jul 18, 2019 11:24 pm

So I would strongly prefer to omit the series resistors if they are not needed.

Is that acceptable?
It's up to you, or anyone else that will use it, whether it's acceptable or not.


The series resistors are protection in case the GPIO pins are configured as output and the switch is closed. The consequence of that is likely a broken Pi, but they aren't expensive. It might be a price you would be prepared to pay.
The chances of GPIO configured as outputs and switched closed is something you have to estimate and something you might have a lot of control over. If the Pi is dedicated to one task and you will control what SD cards are inserted you could probably make the risk negligible.


If SD cards might be changed or other applications run and you have little control, or might forget about the issue or not always check exactly what programs do with GPIO before running it,, then the risk could be quite high that directly connected switches damage the Pi at some stage.
This makes sense. I feel like the risk is very low, considering that two simultaneous failures would have to happen (both the code being wrong and the button pressed at the same time)

The code is never going to change (It's for an art project) and the pi itself is sealed and inaccessible to the end user.

As long as the pi itself is fine with an input gpio pin being grounded with no series resistor, I'm happy with that.

Thank you!

Return to “Beginners”