Hey guys I have a quick question. I recently bought a ws2812b strip.

Hey guys I have a quick question. I recently bought a ws2812b strip. I firstly tested it with an Arduino and everything worked fine but I really want to control it with an ESP32. The problems appeared when I tried the ESP32.
My strip has 300 leds but I want to control only 90. But when I define the NUM_LEDS 90 somehow more than 90 LEDs turn on. Can’t understand why.
Thanks! And a great year everyone!

You need to share your code, no way we can help without that.
Please put it on github, or at least https://gist.github.com or pastebin if needed.

@Marc_MERLIN the code I used was the DemoReelESP32. The only thing I changed was the value of NUM_LEDS to 90.

@Joao_Valente you still need to post links. Where did you get it from? Which ESP32 FastLED library are you using? (there at least 3) . For further reading, see http://www.catb.org/esr/faqs/smart-questions.html

Hi, did you have an external power supply?

@Joao_Valente now I just see again “somehow more than 90 less turn on.” Did fewer than 90 light up? Please restate the sentence.

@Patrick_Aversenq Yes. I tried with a 5V-1A power supply and without it (powered by the ESP). Same results in both scenarios.

@Marc_MERLIN Sorry, didn’t notice the mistake. Just fixed it. “Somehow more than 90 LEDs turn on”.
I experimented some more things and I realised that what is happening is that the ESP is considering that the strip has two start LEDs because If I change a bit the code just to light up the first LED, it turns on the first LED and the LED number 91 at the same time. Don’t know if I’m explaining myself clearly.

@Marc_MERLIN and I’m sorry if I am not posting all the info, it is my first time posting something like this, because it is the first time I don’t anything that can help me on the Internet…

@Joao_Valente I’ve never seen this and I use ESP32. Again, please post the exact code what you’re compiling as well as the arduino compile output that shows which ESP32 FastLED library you are using. There are 3 drivers they don’t work the same and they have different bugs.

@Marc_MERLIN So this is the code I made to understand what was going on.

#include “FastLED.h”

#define DATA_PIN 12
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 90
#define BRIGHTNESS 60
#define FRAMES_PER_SECOND 120
#define FASTLED_SHOW_CORE 0

CRGB leds[NUM_LEDS];

static TaskHandle_t FastLEDshowTaskHandle = 0;
static TaskHandle_t userTaskHandle = 0;

uint8_t gHue = 0;

////// Setup //////
void setup() {
delay(3000);
Serial.begin(115200);
pinMode(12,OUTPUT);
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);

xTaskCreatePinnedToCore(FastLEDshowTask, “FastLEDshowTask”, 2048, NULL, 2, &FastLEDshowTaskHandle, FASTLED_SHOW_CORE);
}

void loop() {
delay(20);
digitalWrite(12,HIGH);
for (int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Blue;
FastLEDshowESP32();
FastLED.delay(10000/FRAMES_PER_SECOND);
}
delay(20);
digitalWrite(12,LOW);

}

void FastLEDshowESP32()
{
if (userTaskHandle == 0) {
// – Store the handle of the current task, so that the show task can
// notify it when it’s done
userTaskHandle = xTaskGetCurrentTaskHandle();

    // -- Trigger the show task
    xTaskNotifyGive(FastLEDshowTaskHandle);

    // -- Wait to be notified that it's done
    const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 200 );
    ulTaskNotifyTake(pdTRUE, xMaxBlockTime);
    userTaskHandle = 0;
}

}

void FastLEDshowTask(void *pvParameters)
{
// – Run forever…
for(;:wink: {
// – Wait for the trigger
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

    // -- Do the show (synchronously)
    FastLED.show();

    // -- Notify the calling task
    xTaskNotifyGive(userTaskHandle);
}

}

This is what happens missing/deleted image from Google+

@Joao_Valente code is one half, second half is still “which FastLED library are you using?” Where did you get it from? Did you check in your compile logs that you are using the one you meant to use (in case you have more than one)

@Marc_MERLIN this is the library that I used.

and I honestly don’t know how to see if I am using the right one…

@Joao_Valente ok, thanks. So, you are not using Yves’ code which is the only one that requires the complicated ESP32 code you pasted (FastLEDshowESP32 and showtask).
Try removing all of this and just defining your single strip like you would for another CPU (not ESP32). Remove everything ESP32 specific.
Hopefully that should just work.

@Marc_MERLIN omg it works! Thanks a lot! :grin:

@Joao_Valente great.
I’m assuming you used https://github.com/FastLED/FastLED/tree/master/examples/DemoReelESP32 ?
@Sam_Guyer / @Daniel_Garcia looks like that example ought to be removed now that ESP32 in master does not require this complicated code, which in this case even seems to be negative.
I now see that you opened https://github.com/FastLED/FastLED/issues/711 FYI you should not open an issue to ask for help. It’s only if you’re pretty sure there is a bug that isn’t your fault.

@Joao_Valente however in your first bug report message, you didn’t state which test code you were using. Did you use DemoReelESP32 all along, or were you using something else then?

@Marc_MERLIN sorry… I didn’t knew that. Yes I used the DemoRellESP32 from the FastLED in the first time I tried in the ESP32

@Joao_Valente thanks for confirming. This is not something you should have known. I think this example should be removed. Thanks for confirming.