Hello
I'm starting with GPIO programming in python, and I can light a led and do that in a pattern, but now I want to use the input with a button.
My question is: can I directly give the 3.3 volt the pi gives back to an input pin, or do I need to use a resistor(and how much ohm)?
DirkWillem
-
- Posts: 10
- Joined: Tue Feb 12, 2013 11:56 am
Re: gpio with python - input voltage
Hi Dirk,
a resistor would be safer, but not essential. The value is not too critical, anything from 1K to 10K would be sensible values. Also don't assume that the line will be at 0volts when not connect via the switch to 3v3. If the line is floating, it may give unpredictable results. I would recommend you use either internal or external pull up or down resistors to maintain the correct 'off' voltage level.
Texy
a resistor would be safer, but not essential. The value is not too critical, anything from 1K to 10K would be sensible values. Also don't assume that the line will be at 0volts when not connect via the switch to 3v3. If the line is floating, it may give unpredictable results. I would recommend you use either internal or external pull up or down resistors to maintain the correct 'off' voltage level.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
- Grumpy Mike
- Posts: 942
- Joined: Sat Sep 10, 2011 7:49 pm
- Location: Manchester (England England)
- Contact: Website
Re: gpio with python - input voltage
You need a resistor somewhere. Read this, it was written for the Arduino but it applies to other things as well. Just replace 5V with 3V3.a resistor would be safer, but not essential.
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
Re: gpio with python - input voltage
Yes a pull up or pull down, either internal or external, I agree. But an inline series resistor? What are you thoughts?
Texy
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555
-
- Posts: 24
- Joined: Thu Dec 20, 2012 10:04 am
- Location: Brasil
Re: gpio with python - input voltage
Dirk if you wish to use only a button, use a pullup resistor of 10K ohms.
If you dont use it , the input will float.
IMPORTANT CAUTION: (from RPI Wiki page) :
GPIO voltage levels are 3.3 V and are not 5 V tolerant. There is no over-voltage
protection on the board - the intention is that people interested in serious interfacing
will use an external board with buffers, level conversion and analog I/O rather than
soldering directly onto the main board.
If you need interface 5V level circuits, use opto couplers or Buffers to down-converted to 3.3V logic levels. I think you can use 74HC4050, but source power must be 3,3V, not 5V.
Gustavo (Brasil)
If you dont use it , the input will float.
IMPORTANT CAUTION: (from RPI Wiki page) :
GPIO voltage levels are 3.3 V and are not 5 V tolerant. There is no over-voltage
protection on the board - the intention is that people interested in serious interfacing
will use an external board with buffers, level conversion and analog I/O rather than
soldering directly onto the main board.
If you need interface 5V level circuits, use opto couplers or Buffers to down-converted to 3.3V logic levels. I think you can use 74HC4050, but source power must be 3,3V, not 5V.
Gustavo (Brasil)
Re: gpio with python - input voltage
yes i've noticed that - i followed quite a few tutorials which didn't use a 10k pull-up and it simply did not work - the button press was not detected.Gustavo_Murta wrote:Dirk if you wish to use only a button, use a pullup resistor of 10K ohms.
If you dont use it , the input will float.
i also use a 1k series resistor on gpio inputs but its not 100% needed as the gpio pins already have a small resistors inline as i understand, but hey its a 1k resistor, often easier to use than making up jumper wires on the breadboard

- Grumpy Mike
- Posts: 942
- Joined: Sat Sep 10, 2011 7:49 pm
- Location: Manchester (England England)
- Contact: Website
Re: gpio with python - input voltage
No there is no internal series resistance for inputs. Maybe you are mixing this up with the concept of drive capacity for a pin when used as an output. This is often modeled by a theoretical series resistor but it is not real. See:-sej7278 wrote:i also use a 1k series resistor on gpio inputs but its not 100% needed as the gpio pins already have a small resistors inline as i understand,
http://www.thebox.myzen.co.uk/Raspberry ... tputs.html
I would go further and say that not only is a 1K series resistor not 100% needed, I would say it is not even 1% needed. The only protection it could offer is if you were dumb enough to set the pin as an output and then set that output high and then bush a button that grounded the pin. So that is three things going wrong, normal safety legislation only requires you to consider one thing going wrong.
Protection against that is best done with a 330R resistor as it minimizes the degradation of the input pin's characteristics.
Re: gpio with python - input voltage
Total agreement from me, series resistors are for those who try to contact silly voltages to inputs..Grumpy Mike wrote:No there is no internal series resistance for inputs. Maybe you are mixing this up with the concept of drive capacity for a pin when used as an output. This is often modeled by a theoretical series resistor but it is not real. See:-sej7278 wrote:i also use a 1k series resistor on gpio inputs but its not 100% needed as the gpio pins already have a small resistors inline as i understand,
http://www.thebox.myzen.co.uk/Raspberry ... tputs.html
I would go further and say that not only is a 1K series resistor not 100% needed, I would say it is not even 1% needed. The only protection it could offer is if you were dumb enough to set the pin as an output and then set that output high and then bush a button that grounded the pin. So that is three things going wrong, normal safety legislation only requires you to consider one thing going wrong.
Protection against that is best done with a 330R resistor as it minimizes the degradation of the input pin's characteristics.
For all other things it is overkill. Sometimes makes things worse as low signals do not go low enough at Pi pin to be recognised.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/