1
\$\begingroup\$

Hi I've got a Raspberry Pi, that's 3.3V device, and a Nextion display, which is a 5V device. They are talking over UART. Obviously RPi's UART RXD link can be damaged if connected directly to the Nextion display output.

Long time ago I read somewhere an explanation that it's not the voltage that damages the lower voltage devices but the current that can flow through. And therefore for input pins like this it's enough to put a big enough resistor between the 5V output pin and 3.3V input pin to limit the current and be done with it. No resistor dividers, no level shifters, just a single resistor. Makes sense to me, but I can't find the original article for reference.

How can I tell what value should such a resistor have?

\$\endgroup\$
  • 1
    \$\begingroup\$ ohm's law, considering the impedance of each side without adjustment. often times loads are dynamic, so a single resistor can't produce the same result in all modes of operation; ex: too much while in sleep mode, not enough during boot... a lot of noob-targeted 3.3v hobby electronics are 5v tolerant anyway, and your RX likely already has a high impedance that would curtail damage; the only issue is threading the schitt-trigger voltage window. \$\endgroup\$ – dandavis Jul 24 '17 at 4:46
  • 7
    \$\begingroup\$ @dan a lot of noob-targeted 3.3v hobby electronics are 5v tolerant anywayblatantly untrue. The four biggest, 3.3V arduinos, esp8xxx, msp430 launchpads, and raspberry pis all lack 5v tolerant inputs. \$\endgroup\$ – Passerby Jul 24 '17 at 5:34
  • \$\begingroup\$ I'm sorry but I personally disagree with this. If a 3.3V chip says it can accept on its pins a maximum voltage of let's say 4V, then if you apply 5V signals you violate this requirement. Current has nothing to do with it. And also ask yourself this: if it is that simple, why everyone is using a level-shifter instead of a single resistor? \$\endgroup\$ – nickagian Jul 24 '17 at 6:24
  • \$\begingroup\$ The single resistor trick can be used, when done right, for applying higher voltages to some series/generations of Atmel/AVR chips, as they themselves indicate, and as such define the behaviour. This then applied to a bunch of Arduinos, and through limited understanding of what is universal and what is not, that has now become the rule, dangerous as it may be. \$\endgroup\$ – Asmyldof Jul 24 '17 at 7:10
  • \$\begingroup\$ @Asmyldof Oh, I didn't know this but I find it really sad. This is one of the negative aspects of Arduinos being so widespread used. \$\endgroup\$ – nickagian Jul 24 '17 at 7:21
3
\$\begingroup\$

For high-impedance inputs, you can use a voltage divider to level shift downwards. The requirements are that the resistor values need to be large enough to not strain the source too much, and small enough so the impedance of the input does not affect the resulting voltage.

That usually gives you a wide range, at least if there is no internal pull-up or pull-down on that input.

The single resistor approach can work with some components, but in general it means that some transistor will have current flowing from base to collector, which is generally a bad idea, even if it is only a little. The circuit simply is not designed for this case, and what happens is therefore undefined.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the explanation, I'll use a voltage divider then :) \$\endgroup\$ – MLu Jul 24 '17 at 22:49
0
\$\begingroup\$

Originally I gave an answer which calculated a minimum safe resistance to ensure that the current into the pin did not exceed 10mA. However, as Simon says above, allowing a GPIO pin to go above its rated voltage, regardless of how much you limit the current is a bad idea. See this article for an explanation. In short, the internal over voltage protection is for transients and will fail if a sustained over or under voltage is applied even at very small currents. Its also silly, as a voltage divider is only one extra resistor.

Finally the Nextion may not be 3.3V tolerant, and may need a step up converter to take the Rpi Tx from 3.3V to 5V. see here for how to do this.

\$\endgroup\$
  • \$\begingroup\$ I wouldn't call it a "step up converter"! :-) This refers to something else normally. \$\endgroup\$ – nickagian Jul 24 '17 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.