NeoPixels are great when they work, but I’ve managed to create many circuits that didn’t.
They failed in every imaginable way — NeoPixels that wouldn’t turn on, NeoPixels that flickered, NeoPixels stuck on a color (blue seems to be my NeoPixels’ favorite) and — the most baffling of all — NeoPixels that worked when powered from one USB port, but not when powered from a different USB port.
Despite the wide range of symptoms, almost every one of these failures had the same underlying cause: powering NeoPixels with 5V, but connecting their data line to a 3.3V microcontroller.
The root of the problem here is that — according to the NeoPixel data sheets — the NeoPixel data line voltage (in logic-high state) has to be at least 0.7× the NeoPixel power voltage.
In other words, the power voltage has to be at most 1.43× (= 1 / 0.7×) of the data line voltage. Therefore, if the data line is at 3.3V, then the highest voltage you can put on the power line and still have a reliable NeoPixels is 1.43 × 3.3V = 4.71V.
As a result, if your NeoPixel power is close to 4.7V, the NeoPixels will be unreliable in interpreting its data line, resulting in flicker and random color changes.
Similarly, if your NeoPixel power is substantially higher than 4.7V, then the NeoPixels will not see any data on the data line, which will lead to it being stuck on black (for most NeoPixels) or blue (for some older NeoPixels).
Most notably, powering from USB (which provides 5V) does not work if your microcontroller logic is at 3.3V.
Power NeoPixels from the microcontroller
Most microcontrollers output regulated power that matches their logic level. You can use this to power your NeoPixels.
This is a good solution for a relatively small number of NeoPixels (10 or fewer), because microcontrollers’ regulated output is typically limited to around 150-200mA.
The main downside is that the number of NeoPixels you can run is limited by the on-board voltage regulator on your microcontroller. Also, because NeoPixels technically require 3.5V supply, powering them from 3.3V will result in mild color distortion, but you are unlikely to notice this, as high color fidelity is usually not needed in NeoPixel projects.
For example, if you connect a 3.3V microcontroller to USB 5V power, you can power the NeoPixels from the microcontroller’s 3.3V output, as long as you don’t exceed the maximum current it can provide (check the documentation for the microcontroller).
Match power supply voltage to logic level
Your NeoPixels will work if you use a power source that is <1.35× the microcontroller logic voltage1 to power both your microcontroller and your NeoPixels.
This is a good solution if you have flexibility about your power supply, and need to use ~10 or more NeoPixels.
The main downside is that is limits your choice of power supplies.
For example, for a 3.3V microcontroller, keep the power supply below 4.5V. A single-cell lithium polymer battery works (they have voltage up to 4.2V), as does a 3-pack of AA or AAA batteries (they stay below 1.5V individually and therefore below 4.5V in a 3-pack).
1.35× = 1.43× with a 5% safety margin↩
Use a separate regulator for NeoPixels
You can also power NeoPixels from a separate regulated voltage that is <1.35× the microcontroller input/output voltage.
This is a good solution if you have lots of NeoPixels in a portable project, or you need long battery lifetime in your project.
The main downside of this approach is that it adds a part to your project.
For example, you can easily get a 3.3V regulator rated for up to 1A output current; this will let you power upwards of 50 NeoPixels attached to a 3.3V microcontroller.
Here, too, powering NeoPixels from <3.5V will result in mild and usually insignificant color distortion.
Use a level-shifter on the NeoPixel data line
You can use a level-shifter IC to bring the NeoPixel data line to NeoPixel power voltage.
This is a good solution if you have a very large number of NeoPixels, and are already using a large power supply to meet your NeoPixel power demands.
The downside here is that NeoPixel-compatible level-shift circuitry is somewhat inconvenient. Many level-shifter ICs are not fast enough to meet timing demands of NeoPixel data transmission; the ones that are either come in a bulky quad configuration (such as 74AHCT125) — whereas you often need to level-shift a single data line — or they are only available in a surface-mount package.
- If you have few enough NeoPixels that you can power them directly from your microcontroller, and don’t mind the color distortion of NeoPixels powered at 3.3V, do it.
- Otherwise, if you have more NeoPixels than your microcontroller can supply, and you can easily change your power supply to be <1.35× the microcontroller I/O voltage (for a 3.3V microcontroller, this means <4.5V power supply, such as Li-Po, AA, or AAA batteries), do it.
- Otherwise, if you have a medium-sized NeoPixel installation (10-50 NeoPixels) — especially a portable/wearable one — use a separate voltage regulator (rated to meet your NeoPixel current needs) to supply your NeoPixels at the microcontroller I/O voltage. Be mindful of heat-sinking requirements of your voltage regulator; you don’t want your project to catch fire. If color distortion at 3.3V is a problem, use a 4.0V regulator.
- Finally, if you have a large NeoPixel installation (50+ NeoPixels), usually with a dedicated power supply, use a level-shifter to bring your microcontroller’s data output to the voltage level of the NeoPixel power supply.