vidapura
Posts: 3
Joined: Mon Mar 25, 2019 3:45 pm

GPIO pull up resistors.

Tue Sep 03, 2019 9:09 am

Hi,
bit of a newbie with the pi.
I'm working on connecting an old phone to the pi.
Found a good article on it here:
https://www.instructables.com/id/Raspbe ... ary-Phone/

Used their simple circuit like this...

Image

Code examples with this are in nodejs.. and I'd rather use python...

I'm a little confused about the settings I need to use on the GPIO in relation to pull up resistors...
From that circuit , I have connected pull up resistors to the GPIO .. is that correct?

So when initialising the pins on the GPIO .. do I do this?

Code: Select all

GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Or do I leave out the pull_up_down bit?
Cos I've already go my own resistors??

Sorry now.. but I'm just not clear on what the pull_up_down part does? Does it enable internal resistors or something?

Thanks

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

Re: GPIO pull up resistors.

Tue Sep 03, 2019 9:22 am

vidapura wrote:
Tue Sep 03, 2019 9:09 am
but I'm just not clear on what the pull_up_down part does? Does it enable internal resistors
Yes.

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

Re: GPIO pull up resistors.

Tue Sep 03, 2019 9:31 am

Internal 50k resistors can be applied as pull-ups or pull-downs, and before anything else happens, most GPIOs have pull-downs by default.

If you leave them as-is, the internal 50k pull-downs together with your external 10k pull-ups give a potential divider, ending up with a pull to about 2.75v through about 8k - not ideal.
Applying GPIO.PUD_UP makes sure it's properly pulled up to 3.3v (through about 8k) whatever happens.

vidapura
Posts: 3
Joined: Mon Mar 25, 2019 3:45 pm

Re: GPIO pull up resistors.

Tue Sep 03, 2019 10:33 am

Ok,
So leave the code as-is with the GPIO.PUD_UP.

Great stuff.

Thanks very much everyone.

boyoh
Posts: 1327
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: GPIO pull up resistors.

Tue Sep 03, 2019 2:41 pm

A GPIO in/put with no internal or external
Resistance set, As a very high impedance
(Resistance) called Floating , it will not
Sink or source a signal, For it to work you
Must set it to to a working impedance
(resistance) to do this you set the Internal
Resistance or use a external 10k resistor..
To set the in/put to except a Logic 1/high
Connect the 10k resistor to the 0v Ground
To set the in/put to except a Logic 0/low
Connect the 10k resistor to to the 3.3v rail
0v rail-------(10K)-----(GPIO)
3.3vRail-----(10k)-----(GPIO)

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

Return to “Beginners”