[Solved] Photon + WS2812 LED strip = no blinky lights

Update: Uh, so I was plugging the Photon into the wrong data wire on the WS2812. :sob: Fixing that fixed everything. So, for reference: I’m able to control a strip of WS2812 LEDs directly from the Photon. The Photon is powered via USB and I’ve connected the +5V WS2812 wire to the VIN pin on the Photon, and GND to GND. The WS2812 data wire is connected directly to an output pin on the Photon. Finally, I’m using the NeoPixel fork to control everything. Blinky Lights!

I’m troubleshooting lighting up an LED strip (this one from Sparkfun). I’ve got it hooked up to my Photon…and no luck. So, let me cover some basics:

  • I’ve read that this strip needs 5V. A lot of the Particle info relates to the Core, which outputs 3.3V, but the Photon will do 5V when powered via USB, right?
  • Which NeoPixel / FastLED library should I be using? There seem to be forks of these specifically for the Particle environment. I used the NeoPixel fork and got everything to compile, but nothing lights up. When I tried to use the FastLED library, I couldn’t get it to compile because it has nested directories and files, and Particle Dev doesn’t seem to like that.
  • I have seen the LEDs flash when I plug in the power and ground, so it seems like it’s potentially getting power.
  • I am powering the Photon via USB, and then I’ve got the Photon plugged into a breadboard and I’m powering the LED strip with the VIN from the Photon, connecting to GND (next to VIN), and driving data from A0.
  • I’m only trying to light 5 or so of the LEDs, not the full strip of 60, so I don’t think current is an issue.
  • Ultimately, the plan is to power the LED strip in parallel with the Photon, both being powered from a 5V, 2A wall wart. But for now, I’m just testing with USB power.

Does any of this sound wrong? Any sort of beginner/basic mistake I’m making here? Does anyone have an example project that I could compile and test on my Photon? I just want to see the pretty lights…

1 Like

The WS2812’s generally need to be level shifted to work with a 3.3v device - the threshold for logic 1 is 0.7xVDD, or 3.5v according to the datasheet https://cdn-shop.adafruit.com/datasheets/WS2812.pdf

Some strips work fine, some don’t. Maybe worth trying a level shifter?

Nope, the logic level of the Photon is just as on the Core 3.3V, but the Vin pin (on both devices) will deliver 5V power if powered via USB.

1 Like

i was under impression VIN if using just USB is going to provide very little to the LEDs

If you power via a USB power supply (not a USB port) then you can get up to 3A via Vin (limited by the protection diode, so leave some margin ;-)).
Given 60mA per NeoPixel you should be able to drive 5 at a time easily.

1 Like

ok. that was where i was misunderstanding terms.

Aaaah, this makes sense. So to make sure I understand, when powered via USB, a function call like digitalWrite(HIGH) or other output from a data pin will be 3.3V, but constant power supplied from VIN will be 5V, correct? That makes sense.

I will see if I can find a level shifter. My main concern is that I’m soldering this all together on a single small protoboard and space is tight. I don’t think I have room for a level shifter with 14 pins. Maybe I can just trim off the pins I don’t need and mount it slightly hanging off the edge of the protoboard…something like that.

Here’s another basic question: Could I create a very basic level shifter with a transistor? I’m very new to this, working mainly with basic LEDs and resistors, so transistors are a bit of a level-up for me, but the basic idea would be:

Assuming NPN transistor, connect 5V VIN to C, connect 3.3V output pin (A0) to B (with a resistor), and connect WS2812 data pin to E. When the 3.3V data signal comes in on B, that will open the transistor to allow 5V to flow from C to E, correct?

Maybe I have some aspect of this wrong, but I’m just wondering if I have the basics correct.

@micahwedemeyer, yes you can make a level-shifter with a transistor, either a MOSFET or bipolar:

This is a bidirectional, non-inverting level-shifter.

This uses an NPN transistor.

Level-shifter boards you can buy on Adafruit and Sparkfun use the MOSFET design.


Update: Make sure you’re connecting the right wires before you assume something’s wrong. :sweat:

I was connecting to the DOUT wire on the WS2812, not the DIN. No wonder I didn’t get any light. Once I swapped that, it worked fine with the signal coming directly out of the Photon. The BJT level shifter also worked, but it’s unnecessary.