# How to shift-up logic signal from 3V3 to 5V for NeoPixel [duplicate]

I'm working with NeoPixel led strip and a microcrontroller which run at 3.3V. As you can read in the NeoPixel documentation using a micro with 3.3V out on pin require the DATA signal to be shifted up from 3.3V to 5V to avoid unexpected behaviour. On the Adafruit page they suggest to use a 74AHCT125 converter IC.

Is it possible to achieve same result avoiding IC? (eg. with mosfet or similar).

NeoPixel data protocol is very strict about timing (800 KHz signal), so I think solution needs fast ON/OFF switching time.

• What you need is a levelshifter. Google "levelshifter circuit" and press "Images" to see images of such circuits. Note that the most simple ones invert the signal. On Ebay you can also buy modules that do this for very little money. Do realize that you might get yourself into trouble or have issues if you do not use a "proper" levelshifter like the IC based ones. Especially with timing sensitive signals like Neopixels. They don't suggest that 74AHCT125 for no good reason. Jun 29, 2017 at 15:10
• @ Noisemaker, have you finished with this question now? Is there anything that you still need answering regards this question? Dec 9, 2020 at 10:50

## 2 Answers

Here's quite a simple one and it is bi-directional too: -

When the data input from the 3.3 volt side is low, U1 turns on and connects the right hand data pin to the input data pin hence the output is also 0 volts. When the input pin is high, the transistor is turned off and the output on the right is pulled up to 5 volts.

Only thing to watch out for is speed of data - the rise time on the output 5 volt side is limited a little bit in reaching 5 volts from 3.3 volts. The first 3.3 volts is OK because the capacitance of the MOSFET couples the rising 3.3 volt data input signal to the output but, once the input side has settled at 3.3 volts, the remaining 1.7 volts are only attained via R3 charging up the internal parasitic capacitance of the BSS138 (about 20 pF including reverse transfer capacitance). RC time is therefore 200 ns which will be good for data rates up to 1 or 2 Mbps.

If you think you need faster then you can lower R3 maybe to 1 kohm. Then the only limiting factor is the specified rise and fall times of the MOSFET itself and these are maximums of 18 and 14 ns respectively but, watch out for the turn-off delay time - it is 36 ns compared to 5 ns for turn on-time. The effect of this will be to slightly alter the mark-space ratio of your data. It could be a problem but I suspect not at 2 Mbps if you lower R3 to 1 kohm.

• That's what I was looking for. (Lots of these same solutions here, though.) Also addressed speed, which the OP needed addressed. +
– jonk
Jun 29, 2017 at 15:55
• One thing that bothers me is that the OP will probably need to go with $1\:\textrm{k}\Omega$ pull-ups to get the speed. And the I/O pins of MCUs are, to my mind, typically about $100\:\Omega$. Which means there will be an input divider operating, keeping it from getting close to ground, therefore keeping the output from getting close to ground. Depends on the input source impedance, though. Just annoying.
– jonk
Jun 29, 2017 at 16:27
• Will this invert data? Jun 29, 2017 at 18:10
• No, it doesn't invert data. Jun 29, 2017 at 19:30
• If you search for "logic level shifters" you should find many like this one: shop.pimoroni.com/products/…. If you look at the schematic it's the same as the one in this answer above. That should give you lots of confidence (this is a common approach _ bidirectional + maintains polarity + neopixel compatible). You can either buy it ready made or make one using a BS138 and resistors. An alternative is to use the one diode trick (search for "one diode level shift neopixel"). Dec 6, 2021 at 16:01

simulate this circuit – Schematic created using CircuitLab

This would be a simple FET driven circuit that will level shift your data line. You need two FET's to maintain the signal 'polarity'. The first FET "M2" will invert the signal and "M1" will invert again.

• Can you address the speed of this circuit? The OP specifically mentioned very near 1 MHz rates and not merely level shifting.
– jonk
Jun 29, 2017 at 15:52