Taking Electronics To A Different Level

A circuit diagram in a book on a desk with computers and microcontrollers

One part wants 3.3V logic. Another wants 5V. What do you do? Over on the [Playduino] YouTube channel, there’s a recent video running us through a not-so-recent concern: various approaches to level-shifting.

In the video, the specific voltage domains of 3.3 volts and 5 volts are given, but you can apply the same principles to other voltage domains, such as 1.8 volts, 2.5 volts, or nearly any two levels. Various approaches are discussed depending on whether you are interfacing 5 V to 3.3 V or 3.3 V to 5 V.

The first way to convert 5 V into 3.3 V is to use a voltage divider, made from two resistors. This is a balancing act: if the resistors are too small, the circuit wastes power; if they are too large, they inhibit fast signals.

The second approach to converting 5 V into 3.3 V is to use a bare resistor of at least 10K. This is a controversial approach, but it may work in your situation. The trick is to rely on the voltage drop across the series resistor to either drop enough voltage or limit the current flowing through input protection diodes, which will clamp the voltage but also burn out with too much current flow.

The third approach to converting 5 V into 3.3 V is to use chips from the 74AHC series or 74LVC series, such as inverting or non-inverting buffers. These chips can do the level shifting for you.

The easiest approach for going in the other direction is to simply connect them directly and hope you get lucky! Needless to say, this approach is fraught with peril.

The second approach for converting 3.3 V into 5 V is to make your own inverting or non-inverting buffer using, in this case, an N-channel Enhancement-mode MOSFET. Use one MOSFET for an inverting buffer and two MOSFETs for a non-inverting buffer. Just make sure you pick N-MOSFETs with 3.3 V or 5 V gate drive voltage VGS. Alternatively, you can use a buffer from the 74HCT series.

The video provides a myriad of approaches to level shifting, but you still have to decide. Do you have a favorite approach that wasn’t listed? Have you had good or bad luck with any of the approaches? Let us know in the comments! For more info on level shifting, including things to watch out for, check out When Your Level Shifter Is Too Smart To Function.

24 thoughts on “Taking Electronics To A Different Level

      1. Glad to see it was covered. I only read your description :)

        It works really well if you get the BSS138 in a dual package and use r packs. You can make a 4 channel level shifter from 4 parts. (like I did here https://github.com/Ccecil/3v3-5v-LevelShifter ).

        I stole the dual package idea from the “Arduino nano every” which I was tapping into the RX/TX lines on. They use this setup between the usb MCU and main MCU. Except they don’t use rpacks.

    1. Yes this circuit works like a charm. I’ve used it heaps to drive ws2811 LEDs from 3.3v ESPs.
      Since I’m using it only in one direction to shift up, the voltage left hand resistor isn’t even needed.

      1. Where it doesn’t work is level-shifting some serial buses where one or both ends are expected to be tri-stated (up-down-floating). Sometimes these can be made to work by adding biasing resistors to “fake” it, but it depends on the device.

  1. Zener diode! As long as going from higher to lower voltage. That’s a hack I’ve used in flashlight drivers like in the case of a tiny13 which wants absolutely no more than 6V, but with a supply of 2S/8.4V 18650s. Works fine on mechanical switch lights that physically break the circuit when off, not so great for momentary switch where power is applied 24/7.

      1. Well, thankfully I don’t need to deal with any more resume-related garbage for however much longer I’ll be around, but. If it doesn’t explode or burn up, and the single cell driver works reliably for years and years with 2S input & 6V LED, what’s the problem? It’s a hack. Is there some other definition of that word being used here?

          1. Oh… sorry, I have a bit of PTSD around this, since I honestly do not know how to do it ‘properly’, but still managed to find solutions.

            On a different driver that happened to be a from-scratch design (and not a bodge of an existing part), I used an inductor in an apparently unconventional way. Some EE types on a different forum found the design and tore it a new one, because they could not comprehend that the inductor was being (mis)used as a choke (they are essentially the same thing, right?). I used a relatively big chonky SMD piece rated for something like 18 amps continuous, just from memory.

            The problem the inductor/choke solved was that at the tiny13’s minimum PWM value of 1, the light was still much too bright. The inductor in series with the LEDs (six of them) calmed the min level way down, and didn’t affect the full output not even a little bit. Worked great. Inductor selection was by trial and error – 1.2uH cut it too much, 0.68 was juuuust right. Only added 2 more components to the prior board design.

  2. As long as speed is not important, you can use resistive voltage dividers, opamps or whatever, but if you want both a decent speed, and keep it affordable then the “old” logic families are still interesting.

    Some examples:
    3V3 uC output to LS ttl IC has some extra beef for line driver (stepper motor optocouplers)
    3V3 uC output to HCT logic for “general purpose 5V outputs.

    With 5V to 3V3. I think the good old LS logic is mostly suitable, but you’d have to check the I/O levels. Some 10 to 30 years ago it was quite common to have some tables on hand for voltage levels of different logic families and in which ways they can be combined.

    You can of course also use specifically designed “logic converter” IC’s. But they cost money and take up PCB space. If a circuit can be designed by using a few IC’s of some (old fashioned) logic family, then both the conversion and some extra function can often be done with one IC. (“bytewide” or shift register, etc).

  3. A short paragraph on “this is better than using 2 power supplies because…” would be nice for the slow-witted among us such as myself who still has fond memories of the Radio Shack 9v plug-into-the-wall power supply.

    1. Because it’s not the same? It’s assumed you will have two power supplies. But you need to convert the signal from one voltage level to another, ie your sensor talks in 5v while the mcu burns above 3.3

      1. Perhaps you could use wires to connect the devices each to its appropriate power supply? Your answer doesn’t really sell it, i.e. doesn’t make me understand. I eat with a spoon. My TV, computer, and guitar amp all run on different voltages. What voltage does your notional sensor send its data to the thingamajig at? Do you understand that I don’t understand?

        1. You should connect each device to the appropriate supply voltage, otherwise they might not work. The issue here is when you want the device that is connected to 5V and uses 5V push-pull CMOS logic to talk to the device that is connected to 3V and uses 3V logic. Having two different power supplies is the reason that there is a problem in the first place, not a solution to the problem.

          1. From what you say it sounds like the problem is having two devices using different voltages. Still not helping me understand. If the voltage reducer goes between the higher voltage device and the lower voltage device, Sheet Nocturnal! That’s all you had to say! Of course then due to my not understanding, the question of what happens when the lower voltage device needs to send signal to the higher voltage device is not clear. I should take up dentistry because this is like pulling teeth. No offense.

  4. in the rare case i’ve needed this, i’ve used a pull up resistor on the input, and either configure the output for open drain or use an NPN for the pull down (inverting, of course). Obviously, wastes some current fighting the pull-up. And there’s some caveats if you’re driving it fast, i’m sure. Kind of a braindead approach but i’m surprised it wasn’t mentioned in the write up.

Leave a Reply to CcecilCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.