Connecting a 5V Arduino Pins to a 3.3V Raspberry Pi GPIO's pins

Hi All,

I'm trying to work out what circuitry will be required to safely connect a 5V output from an Arduino to a 3.3V input pin on the RPi.

Theoretically, could this be achieved (admittedly with minimal protection) by just connecting the ground pins to each other and using an appropriately sized resistor?

Alternatively, are there more secure ways of doing this using something akin to a Buffer?

Any help gratefully appreciated and the more detail (especially on calculations) the better.

Cheers!

Won’t work with a single resistor but two set out as a voltage divider would be okay. Or you could use a level shifter like found here.

To convert 5V signals to 3.3V you can use 74LCX series logic (powered from 3.3V, 5V tolerant inputs).

To convert 3.3V signals to 5V you can use 74HCT series logic (powered from 5.0V, the inputs have thresholds of 0.8V and 2.4V low and high respeectively).

There are level shifter modules available from various suppliers, and some are even bi-directional.

Hello, the Internet! I ask 7.05billion people for help, and the first one comes from my home county!

Thanks for the quick answer!

Sounds perfect, so this should be fine?

Presumably 3.3V would be still be within the High threshold for the Arduino, so long the GNDs are tie together?

Thanks again.

No those resistors are way too high. I use a 1K and 510R. Note this only works for Raspberry Pi inputs being connected to Arduino outputs.

For the other way round you need a transistor, FET or some other level shifting circuit.

Calorus: Hello, the Internet! I ask 7.05billion people for help, and the first one comes from my home county! I'm closer, so heard the request first. :)

Sounds perfect, so this should be fine? There are dozens of options to choose from and that's one of them, though not ideal. You could also try an online calculator to try and match lower resistor values you may have kicking about.

Presumably 3.3V would be still be within the High threshold for the Arduino, so long the GNDs are tie together? A 5V arduino [u]should[/u] register anything over 3V as a high.

Hi Guys,
Just trying to check if I’m on the right Logic Levels here…
For the Discrete Circuit:

And for the Integrated Circuits:

Let me know if these are in the right kind of zone.

One thing I’m really mystified about is about Resistor selection, what current should I be aiming for?

Many thanks to all, with familial greetings to the chap who’s probably my cousin…

Maybe worth looking at a simple bi-directional logic level conversion that SparkFun use here.

You're definitely right from a practical perspective, but from the other side I kind of want to understand what's what and why, and I think the more I can pick up from you and the other Learned around here as I crash from one bad idea to another, the better. I'm at that frustrating stage where I have lots of ideas, but very few of the skills to implement them. (All code no solder, so to speak)

You're definitely right from a practical perspective,

No you are not!.

That transistor is all wrong. You should have the emitter going to ground and the collector / pull up resistor to the input pin. If you enable the internal pull ups you can do without that 10K altogether.

One thing I'm really mystified about is about Resistor selection, what current should I be aiming for?

You are aiming for as much current as the pin can take, this speeds up the edges of the signal that can be slowed down by stray capacitance.

Grumpy_Mike:

You're definitely right from a practical perspective,

No you are not!.

That transistor is all wrong. You should have the emitter going to ground and the collector / pull up resistor to the input pin. If you enable the internal pull ups you can do without that 10K altogether.

One thing I'm really mystified about is about Resistor selection, what current should I be aiming for?

You are aiming for as much current as the pin can take, this speeds up the edges of the signal that can be slowed down by stray capacitance.

Hi Mike, Sorry, I wasn't suggesting I was right, I was just agreeing with Riva's suggestion that I investigate the Sparkfun boards. Thanks for your help on this one, it's hugely appreciated.

Have gone and re-read some long forgotten things and have had another bash at the discrete circuit, does anything seem obviously wrong here?

Am I being daft, or would this invert the signal to the Arduino from the Pi by connecting the Arduino's Pin 2 to ground when the Pi's Pin 2 went high?

I understand that I can use the internal pull-up resistor, but at the moment, I'm just trying to grasp the electr(on)ics behind it all.

You need the resistor back in the base then you will be fine.

Yes it will invert the signal but most of the time it is easy to compensate for this in the software.

If you need it to be non inverting then the transistor needs to be wired up differently.

Of course it does, not sure why I removed it.

Everyone, thanks a huge amount for your help with this, it's all making a hell of a lot more sense already (not necessarily saying much).

it's all making a hell of a lot more sense already

Good.

Just a point, it is wise not to use pins 0 & 1 on the Arduino as they are used for serial communications.

Not sure what you mean by pin 1 & 2 on the Pi. But in general avoid GPIO 2 & 3 ( or GPIO 0 & 1 on an issue 1 board ) as they are the I2C bus lines and have a 1K8 pull up resistor connected to them. It will still work with these being just I/O pins though.

Very good point and noted, in this instance, I just used 1 & 2 as a shortcut to refer to two arbitrary pins wired for communication but I'll try to be careful as to what I stick where.

Cheers again, I'll no doubt be on the beg for some brainpower again soon.