Turning off external PSU powering neopixel while dataline connected to powered arduino

I'm building a fairly basic addressable LED setup with an arduino mega hooked up to a PC and a neopixel ring with 12 LEDs hooked up to an external 5V/2.5A PSU using a setup like in the following image you have likely all seen on this forum many times already:

I have some question related to the two following "best practices" mentioned for neopixels:

  • Avoid connecting NeoPixels to a live circuit. If you simply must, always connect ground first, then +5V, then data. Disconnect in the reverse order.
  • If powering the pixels with a separate supply, apply power to the pixels before applying power to the microcontroller

From some searching around I've found that the LEDs might try to parasitically draw power through the dataline if they are not powered up, potentially damaging the arduino. Is this correct? If so, is there a way to build the circuit so the arduino is protected in case my PSU gets disconnected while the arduino is still connected to the PC (and possibly still trying to control the LEDs)?

The 470 Ohm resistor will limit the current that the LEDs can draw from the Arduino pin to a safe level.

Homework question for you though:
What is the maximum possible current that the LEDs could draw from the Arduino pin with the circuit you posted?
You will need to understand Ohm's law to answer.

You can power the Uno through its 5V pin from the LED power supply, that way they will both be powered at the same time.

1 Like

You know, I was so focused on unraveling those two practices that I completely forgot to think about the resistor. (mostly because the adafruit neopixel uberguide mentions it being there to catch voltage spikes).
The arduino is connected to the PC because I also want to use it as a USB input device, so even if I powered it with the PSU I'd still run into the parasitic draw if the PSU were to disconnect at any point.

If I'm calculating this correctly, 5V with 470 Ohms would limit it to 10.64mA?

A follow-up question out of curiosity: if I were interested in completely eliminating any possible draw when the PSU goes out but not the arduino, what would be a good practice to achieve this?

Looks right to me.

I will leave you to think about that and post your answer later.

@earendill ,
Did you make any progress on this:

I've been toying with the idea of using a mosfet with the gate hooked up to the 5V of the external PSU like this:


(apologies for the fritzing, I find it easier to use when making a lot of changes than doodling)

I hate Fritzy pictures! No matter, at least you are making the effort.

I like that you are trying but you are on the wrong track. Here's a clue: The answer is in software, not the the wiring.

You mean something like reading the PSU into a pin and turning the LEDs off if no signal? Because these leds' quiescent current is ~0.6 mA per led even when "off" so my 12 LEDS would still try to take 7.2mA. Though I guess this would be stopped if I switched the data pin over to input?

I considered this as well, but can't a mosfet achieve a similar result, except without taking up a pin? (and leaving the arduino doing some unnecessary led logic).

Under what condition does a pin output (almost) no current?

When you put it to INPUT_PULLUP?

Almost.
When you make it an input without the pull up.

Alright. So the idea is then to read the PSU into a pin, and if its low putting the led data pin into input mode?

Yes. If the pin is an input then the current into or out of it is negligible. You could also leave it as an output and make sure it is LOW, meaning 0V / ground, so no voltage across the resistor.

1 Like

The 470 Ω also prevents possible damage to the Arduino pin if the Arduino is turned off and the pixel power supply is turned on. (back-feeding)


In fact, for new people, suggest they always add a series resistor to all digital pins to prevent that inevitable short circuit situation.


It does limit the rise time of output signal going to the strip.

1 Like

Does that mean that if I had enough of these rings connected to different pins, the arduino could turn on at some point even with the USB disconnected (and I assume cause havoc)?

Most likely under powers the Arduino.

How would the input pin of a NeoPixel feed power (Voltage) back to the Arduino? :astonished:

Only if the ground was disconnected.

One of the reasons the resistor needs to be physically at the input of the first pixel.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.