Wangmaster
Posts: 16
Joined: Wed Nov 27, 2019 2:42 am

Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 3:16 am

I want to use a GPIO pin on my Pi to send a simple on/off signal to my Arduino board.

My approach would be to connect the GPIO to an Arduino analog pin (to get around the 3.3V max of the Pi GPIO) pulled high, and signal it by setting the GPIO as required.

I heard many warnings that connecting 5V directly to any GPIO will fry the Pi. But the 5V pullup on the Arduino is behind a 100 MOhm resistor, therefore I want to ask if this configuration is dangerous for the Pi?

hippy
Posts: 8232
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 9:06 am

Wangmaster wrote:
Fri Dec 06, 2019 3:16 am
I heard many warnings that connecting 5V directly to any GPIO will fry the Pi. But the 5V pullup on the Arduino is behind a 100 MOhm resistor, therefore I want to ask if this configuration is dangerous for the Pi?
That's the official line; never connect anything over 3V3 to the Pi GPIO. Turn the 5V output from the Arduino into a 3V3 compliant voltage and problem solved.

Or, try it and see, which is what I would do.

If the 5V Arduino can read a 3V3 signal as high you don't need to read that through an ADC.
Last edited by hippy on Fri Dec 06, 2019 9:09 am, edited 1 time in total.

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 9:08 am

Wangmaster wrote:
Fri Dec 06, 2019 3:16 am
I want to use a GPIO pin on my Pi to send a simple on/off signal to my Arduino board.

My approach would be to connect the GPIO to an Arduino analog pin (to get around the 3.3V max of the Pi GPIO) pulled high, and signal it by setting the GPIO as required.

I heard many warnings that connecting 5V directly to any GPIO will fry the Pi. But the 5V pullup on the Arduino is behind a 100 MOhm resistor, therefore I want to ask if this configuration is dangerous for the Pi?
If you are reading the PI pin output voltage with an analogue input on the Arduino then you don't need a pull up. Your code just needs to detect a voltage above 1.65V and call that a one and anythign less is a zero.

Can you turn off the pull-up on the Arduino input ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

hippy
Posts: 8232
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 1:30 pm

Thinking about it, any resistor between the GPIO pin and 0V ought to make it 3V3 safe, whether 5V coming in from the Arduino power rail or the Arduino I/O pin if set as an output high ...

Code: Select all

     5V ---.-
          .|.
          |_|
           |   ____
Arduino <--^--|____|---.------< Pi GPIO
               100M   .|.
                      |_| 10K
                       | 
     0V ---------------^------- Pi 0V
Arguably the internal pin resistance of the GPIO pin would probably make it safe but adding a resistor ensures it explicitly complies with 'never more than 3V3' doctrine.

That 100M seems a little on the high-side to me. I'd probably drop it to 100K.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13278
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 1:47 pm

hippy wrote:
Fri Dec 06, 2019 1:30 pm
Thinking about it, any resistor between the GPIO pin and 0V ought to make it 3V3 safe, whether 5V coming in from the Arduino power rail or the Arduino I/O pin if set as an output high ...
Not true, if you claim that a largish pullup to 5V is safe, you only need a microscopic current flow from a >4V source to trigger a latch up.

True, if you claim that a pulldown resistor that lowers the voltage below 4V is safe, not true if the pulldown is too weak compared to the 5V source to bring the voltage down below the trigger limit (4.0V).

hippy
Posts: 8232
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 5:54 pm

mahjongg wrote:
Fri Dec 06, 2019 1:47 pm
you only need a microscopic current flow from a >4V source to trigger a latch up.
Fair enough; back to the "never apply more than 3V3 to a GPIO pin".

I guess that means always needing an active level converter because the Arduino pin could potentially leak minuscule amounts of greater than 4V current through itself and latch-up the PI.

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 6:05 pm

Taken from https://www.arduino.cc/reference/en/lan ... constants/
Arduino (ATmega) pins configured as INPUT with pinMode() are said to be in a high-impedance state. Pins configured as INPUT make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 Megohms in front of the pin. This makes them useful for reading a sensor.
It is fine to connect a Pi GPIO output pin to an Arduino input pin as long as it is not a 5V Arduino and the pin is configured with a pull-up.

The same page gives details of the minimum voltages needed to register as a "1" and 3.3V from a pi is adequate.

If you want to be paranoid you can add a buffer of some sort (powered from the Pi's 3V3 rail) between the Pi and the Arduino,

PeterO
Last edited by PeterO on Fri Dec 06, 2019 6:20 pm, edited 1 time in total.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Fri Dec 06, 2019 6:08 pm

Wangmaster wrote:
Fri Dec 06, 2019 3:16 am
I heard many warnings that connecting 5V directly to any GPIO will fry the Pi. But the 5V pullup on the Arduino is behind a 100 MOhm resistor, therefore I want to ask if this configuration is dangerous for the Pi?
I think you've misunderstood some of the details of input pins. The 100 MΩ resistor you mention is not real. It's the figure used as an approximation to the input impedance of the pins when configured as an input without a pullup.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Connecting 5V pullup to Pi GPIO

Sat Dec 07, 2019 1:44 am

When interfacing a Pi GPIO to anything else, I just play it safe and put in a level translator. I normally don't care about the added parts count on what is usually a single project anyway.

User avatar
Milliways
Posts: 570
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Connecting 5V pullup to Pi GPIO

Sat Dec 07, 2019 2:25 am

It is perfectly safe to connect a Pi GPIO (or any other 3.3V logic level) to an Arduino (or any other 5V logic level) INPUT

There is NO 100mΩ (or any other) pullup!

Putting the Arduino pin in OUTPUT mode is another matter - if this is likely to happen a 10kΩ series resistor will provide adequate protection; if you want to be absolutely sure include a diode clamp to 3.3V.

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

Re: Connecting 5V pullup to Pi GPIO

Sat Dec 07, 2019 10:40 am

Milliways wrote:
Sat Dec 07, 2019 2:25 am
Putting the Arduino pin in OUTPUT mode is another matter - if this is likely to happen a 10kΩ series resistor will provide adequate protection
Read Mahjongg's post.
mahjongg wrote:
Fri Dec 06, 2019 1:47 pm
... you only need a microscopic current flow from a >4V source to trigger a latch up.
A 10k series resistor would allow 100μA to flow - hardly microscopic

emma1997
Posts: 985
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connecting 5V pullup to Pi GPIO

Sat Dec 07, 2019 2:37 pm

I would personally love to know exactly (or even approximately) what "microscopic" means. Looking at scope trace where I am located shows just picking up a Pi with your hand puts far more than 5v and 100ua across more than a couple pins. Every time. Over and Over.

Back when I was in the industry latchup generally became a problem when powering up with input above threshold. Not just applying voltage. Forward biasing a parasitic junction (triac). One of my products, 74sc series, when abused like that was notorious for spalling chips straight out at supersonic speed. Sounds like a spark or firecracker. Don't touch the crater or you'll burn your pinky. It was a long time ago and maybe laws of IC physics have changed.

ATM I'm inclined to adopt Milliways belief system. However in practice staying 3v is a safe bet. Nearly all my AVR circuits are 3v anyway because in modern times it's The New Five Volts. Of course arduinoids will scream and wring hands claiming these chips don't run at 16mhz. However for hobby use I will continue to run them at 16mhz, 20mhz, or even double that should the need arise. But then again I am known to be a wild and crazy mustang. lol

Wangmaster
Posts: 16
Joined: Wed Nov 27, 2019 2:42 am

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 3:00 am

Thanks for the replies all. I actually tried it out and Pi successfully transmitted without sustaining any (immediate) damage. In any case I will switching to a more reliable method of communication, maybe serial.
PeterO wrote:I think you've misunderstood some of the details of input pins. The 100 MΩ resistor you mention is not real. It's the figure used as an approximation to the input impedance of the pins when configured as an input without a pullup.
I worded my statement poorly. I am aware that the 100MOhm resistance is equivalent, not a physical resistor. I'm not too familiar with electronics, but can I safely make the assumption that it might as well be a physical 100MOhm resistor in series with the input? The current flow between input and output will still be V/ESR correct?

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 8:53 am

It's only a safe assumption as long as the voltage on the pin stays between 0V and 3.3V. Outside the "safe zone" other components come into play and the input becomes non-linear so ohms law doesn't apply any longer (*).

PeterO


(*) Well ohms law still applies, but effectively the circuit has changed so value of R looking into the pin will be different.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 10:16 am

Wangmaster wrote:
Mon Dec 09, 2019 3:00 am
... but can I safely make the assumption that it might as well be a physical 100MOhm resistor in series with the input?
Possibly. But the pull-up is before that notional 100M resistance.

Code: Select all

     ----5v
     |
     -
    | |
    | | 20k
    | |
     -
     |    ----
o--------|    |---->
          ----
          100M

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 10:33 am

Burngate wrote:
Mon Dec 09, 2019 10:16 am
Wangmaster wrote:
Mon Dec 09, 2019 3:00 am
... but can I safely make the assumption that it might as well be a physical 100MOhm resistor in series with the input?
Possibly. But the pull-up is before that notional 100M resistance.

Code: Select all

     ----5v
     |
     -
    | |
    | | 20k
    | |
     -
     |    ----
o--------|    |---->
          ----
          100M
In your diagram it's not clear which side is the pin and which side is the internal logic.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 10:59 am

Well, draw a better one!

Text sucks for drawings, which was probably why woodcuts lasted far longer than Caxton would have expected.
But creating a woodcut is difficult and time-consuming, even though the forum can handle the out-put image.

I was intending the o- to be the physical bit of wire, with the -> being into the rest of the Arduino. I can see the confusion, though, so perhaps I should be ignored.

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 11:15 am

Not sure it's better though :-)
PullUp.png
PullUp.png (7.34 KiB) Viewed 1473 times
PeterO
PS: Any excuse to play with my graphics tablet :lol:
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

hippy
Posts: 8232
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 3:25 pm

My take on it would be ...

Code: Select all

.-----------------.
|              5V |<----.----< Pi 5V
|                 |    .|.
|                 |    |_|
|        __       |     |
|     <-|__|-- IO |<----^----< Pi GPIO
|       100M      |
|                 |
|                 |
|              0V |----------< Pi 0V
`-----------------'
      Arduino

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 3:58 pm

hippy wrote:
Mon Dec 09, 2019 3:25 pm
My take on it would be ...

Code: Select all

.-----------------.
|              5V |<----.----< Pi 5V
|                 |    .|.
|                 |    |_|
|        __       |     |
|     <-|__|-- IO |<----^----< Pi GPIO
|       100M      |
|                 |
|                 |
|              0V |----------< Pi 0V
`-----------------'
      Arduino
It depends if we thinking about internal (my diagram) or external (your diagram) pull up resistors.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Connecting 5V pullup to Pi GPIO

Mon Dec 09, 2019 5:31 pm

To interface between the Pi GPIO O/P and the
Arduino you could use a Opto Isolator to give
You voltage levelling and total isolation,

GPIO 3.3v O/P--------(R)------(a OPTO c )----0v
3.3v/5v-------------------------- ( c T e )----Arduino

R = 220r
C Transistor E ( opto )
General purpose voltage levelling

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

emma1997
Posts: 985
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connecting 5V pullup to Pi GPIO

Tue Dec 10, 2019 4:48 pm

Am I the only one giggling at these resistor model representations of bias current? Highly unlikely there is actually any 100meg resistor in series with any logic. Considering gate capacitance it would take a month for the logic to switch. lol

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connecting 5V pullup to Pi GPIO

Tue Dec 10, 2019 6:19 pm

emma1997 wrote:
Tue Dec 10, 2019 4:48 pm
Am I the only one giggling at these resistor model representations of bias current?
Yes.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Connecting 5V pullup to Pi GPIO

Tue Dec 10, 2019 6:21 pm

I don't know about giggling; maybe just sighing gently

PeterO's quote from the Arduino reference
Pins configured as INPUT make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 Megohms in front of the pin.
does say "equivalent to", not that it's really there. Though if I were writing the manual, I wouldn't have written that.
I get the impression they're trying to say "if you replace the Arduino with a 100M resistor, you'll get much the same effect - i.e. not much effect at all"

But then, in your scenario, why should it take that long to switch, if the gate capacitance is before the (nonexistant) resistor?

This, though is getting silly. So just ignore me. Or giggle at me - my daughter does it all the time, when she's not scooping me off the kitchen floor and into the ambulance.

emma1997
Posts: 985
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connecting 5V pullup to Pi GPIO

Tue Dec 10, 2019 6:41 pm

Burngate wrote:
Tue Dec 10, 2019 6:21 pm
why should it take that long to switch, if the gate capacitance is before the (nonexistant) resistor?
Actually in those diagrams it's after, not before. PIN capacitance might be before but who cares about hundredths of a puff.

IMO that resistor is not even close to how CMOS actually behaves. Might be more understandable (and accurate) to say there is no resistor at all and Pi inputs are just open circuit. It eliminates and totally hides the real capacitance which is there and which is much more significant for most designs. If there's PWM etc involved better not ignore Ciss and Mr Miller.

PS Hope that kitchen floor incident worked out ok.

Return to “Beginners”