Basic LED Strip test problems

Can anyone give me any tips on what could be wrong here. Teensy 4.1 and WS2812B Led strip. Seems like a pretty simple setup and I've tried different test code, different data pins, powering over USB or from a separate supply, basically everything I can think of. I've only rarely seen activity from the first few LEDs on the strip right after programming/rebooting, but they went dark right away. Mostly I'm just getting no response at all.

IMG_0791.jpg

IMG_0792.jpg

Code:
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#define DATA_PIN 1
#define NUM_LEDS 20

CRGB leds[NUM_LEDS];
elapsedMillis tic;

void setup() {
  //Serial.begin(115200);
  //Serial.println("FastLed Test");

  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); 
  FastLED.setBrightness(50);
  for (int i=0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Black;
  }
}

void loop() {
  if (tic >= 333) {
    /* Shift prior colors down all the LEDs */
    for (int i=NUM_LEDS-1; i > 0; i--) {
      leds[i] = leds[i - 1];
    }
    /* Turn the first LED on with a random color */
    uint8_t red = random8();
    uint8_t green = random8();
    uint8_t blue = random8();
    Serial.printf("R=%3d G=%3d B=%3d\n", red, green, blue);
    leds[0].setRGB(red, green, blue);

    FastLED.show();
    tic = 0;
  }
}
 
Ah, true! I'll try this tomorrow when I'm back with it. I did try powering it directly from the board several times though, presumably that would have worked if this is the only issue, right?
 
Besides the ground question: There are (older) LED chips which were less tolerant to 3.3V logic levels and needed something more towards 5V on the data line to work.
 
Ok, also good info, thanks. These are recently purchased BTF Lighting strips, so I would assume that's not it. Also, it's kind of hard to see in the images, but the resistor on the data line in 330 ohm, and the capacitor is 220 uF. I did try with and without each of those and saw no difference.
 
Pictures don't show a common ground to the light strip.

Agree with Defragster, you're definitely missing a required ground wire.

groundwire.jpg


I did try powering it directly from the board several times though, presumably that would have worked if this is the only issue, right?

You could have had a different problem. Trying to power 20 LEDs from a USB cable sometimes works, but sometimes is too much. You might have triggered the over-current production in your PC or USB hub. That would be consistent with "activity from the first few LEDs on the strip right after programming/rebooting, but they went dark right away".

Of course this is just guesswork. There's no photo for your prior attempts without the power supply.

But the point is a prior failure is no reason to discount Defragster's ground wire advice. I just want to echo that advice, because it is absolutely correct. The breadboard photos you showed definitely are missing the required ground wire between Teensy and the LEDs, so even if something else is also wrong, please know you do need the ground wire.


Also, it's kind of hard to see in the images, but the resistor on the data line in 330 ohm, and the capacitor is 220 uF. I did try with and without each of those and saw no difference

Just to be clear, all attempts made without the required ground wire are expected to fail. Please don't make any conclusions about the capacitor or resistor from any tests you tried without the ground wire.
 
Understood, yeah I definitely will add the ground wire and wasn't discounting that at all, was just trying to provide extra info and find out if there's anything else I might be missing in the meantime since I can't get back to it until tomorrow. Hopefully I'll be all sorted once I add that common ground. Thanks everyone!
 
A couple of issues with WS2812B's, assuming the ground issue is not the real problem (or things that may bite you further down the road).

As others have mentioned, there are versions of the chips that are sensitive to voltage differential (when the Teensy data signal is 3.3v and the LEDs are running at 5 volts). A lot of the vendors have switched from the original WS2812B chips to SK6812 (which uses the same protocol). Generally, the SK6812 chips are more robust.

For example, Adafruit switched their neopixels in 2016. But even if you bought from say Adafruit, it is possible the LEDs you got have been sitting on a shelf for 10 years. There are various ways to solve this:

  • There are voltage level shifters designed for WS2812B. You want to avoid the bi-directional shifters made for I2C and SPI buses, because they are too slow for WS2812Bs. Let me know, if you want a list of the ones I'm familiar with.
  • If you power the Teensy and LEDs with a single cell lipo battery, the voltage range is 4.2 to 3.7 volts. That is a lot closer to the 3.3v data signal that Teensy put out. Some 10 years ago, I happened to be doing a ring with a AVR powered Gemma, and the ring was sensitive to voltage. I had to program the Gemma, but I couldn't see the ring when it was powered with USB, so after programming it, I removed the USB cord and ran it off of the battery to see the lights.
  • If you are only running a few lights at minimal power, and the chips are SK6812's, you can power the LEDs with the Teensy 3.3v pin and the the VIN (typically 5v) or external power.

Another thing is to check your wires, breadboards, and soldering. It may be things aren't making contact like they should. I have had to replace both wires and breadboards over time. And unfortunately, I have had to re-solder things every so often.

Like all electronic components, perhaps you shorted it out and the magic smoke came out, and perhaps you need to get new LEDs.

I could imagine if you have a lot of electrical noise, it can cause problems.

I noticed you are using Fastleds. There have been issues with the Fastled library and Teensy in the past. Try using a test that uses the Adafruit library instead of Fastled to verify that the hardware works.
 
A very (very) crude hack if it is a voltage level issue:

On paper the WS2812 requires 0.8*Vcc for a signal to count as high. So with a 5V supply it needs 4V. In practice this the threshold is a bit lower so you're normally right on the edge with 3.3V outputs.
But each WS2812 re-generates the signal that is passed on to the next LED in line and will output very close to the input power level.

So if you get one extra LED, power it off around 4.5V and put that between the 3.3V processor and the rest of the LED strip then it will often all start working.
How do you get 4.5V? Take your 5V power and put a diode in series.

Is this good practice? No. Does it work? Normally.
 
Back
Top