Electronic – Help understanding 3.3v logic vs 5v logic with Raspberry Pi GPIO

logic-levelraspberry pi

This will probably be an extremely easy question for the seasoned EE's of you in the community. My question is this, I have 5v and 3.3v devices I want to interface with my Raspberry Pi's. I'm paranoid about burning out my Pi with some dumb wiring.

1) If I set a Raspberry Pi GPIO pin HIGH (3.3v) to a device that requires 5v logic only to be driven, do I still need a logic level converter in the mix? Or is that only required when I am accepting 5v logic (sensor or bidirectional).

2) Is there a safe way to accept 5v logic into a Raspberry Pi GPIO if the current is low enough, or do I always need to convert it down to 3.3v?

I'm just looking for some words of wisdom on how to handle logic levels and general rules of thumb. If a simple link answers this feel free to shoot it my way. I appreciate the help!

Best Answer

From RPi 3.3V to 5V input, depends on the input IC's Input Logic High minimum. Most ICs are 0.7 * VCC, or 3.5V. So the 3.3V won't be enough to register as a Logic High. Some ICs are 0.6 * VCC, or 3V. It will be enough, maybe. Sometimes it will act in weird ways at such a low voltage. You need a level translator circuit. A simple NPN transistor can do it, but inverts the logic (3.3V Output = 0V Input, 0V Output = 5V Input). You could fix that in code, or you need a more complex circuit or dedicated IC for non-inverting.

From 5V output to RPi 3.3V input, you always want to convert it, as the RPi does not have 5V tolerant inputs. NEVER connect it directly, even with a serial current limiting resistor, unless you want to buy a new RPi. A simple way could be a resistor voltage divider. A better way would be a real logic level translator circuit.