Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LED flickering with random color (ESP32) #223

Open
iFiNEXx opened this issue May 21, 2020 · 11 comments
Open

LED flickering with random color (ESP32) #223

iFiNEXx opened this issue May 21, 2020 · 11 comments

Comments

@iFiNEXx
Copy link

iFiNEXx commented May 21, 2020

Hey there,

i have a strange problem with the WS2812FX, the LEDs are flickering with random color. I am using a ESP32 and LED Strip WS2812B. Does anyone know what is wrong?

Video: https://photos.app.goo.gl/dvYWKH25gqZrmHNW8

Code:
`#include <WS2812FX.h>

#define LED_COUNT 56
#define LED_PIN 12

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
ws2812fx.init();
ws2812fx.setColor(255,0,0);
ws2812fx.setMode(2);
ws2812fx.setSpeed(1000);
ws2812fx.start();
}

void loop() {
ws2812fx.service();
}`

@moose4lord moose4lord changed the title LED flickering with random color LED flickering with random color (ESP32) May 21, 2020
@moose4lord
Copy link
Collaborator

The ESP32 is notoriously picky when it comes to WS2812 LEDs. You'd think that with two cores, one for your sketch and one to manage WiFi, it would be more robust than an ESP8266, but not so (at least in my experience). When developing LED sketches on the ESP32, I've never been able to pin a task to one core and have it work properly. Even without monkeying with pinning tasks to cores, you get the weird LED flashing issue as discussed in issue #177.

I would recommend you start with the ws2812fx_esp32 example sketch, which uses the ESP32's RMT hardware (instead of bit-banging) to fix the weird flashing LED issue.

@iFiNEXx
Copy link
Author

iFiNEXx commented May 21, 2020

Thx, it is working now

@iFiNEXx iFiNEXx closed this as completed May 21, 2020
@moose4lord
Copy link
Collaborator

I'm going to leave this issue open for a while, since this issue regarding the ESP32 comes up pretty regularly.

@moose4lord moose4lord reopened this May 21, 2020
@mriksman
Copy link

mriksman commented Jun 8, 2020

I'm using ESP-IDF, and pinning the task that runs ws2812fx.service() to Core 1 fixed my issue.

@moose4lord
Copy link
Collaborator

I'd be interested in seeing your code, if you don't mind posting it.

@mriksman
Copy link

mriksman commented Jun 9, 2020

I'm using ESP-IDF, so I'm not sure if it helps. But I create a task with;

xTaskCreatePinnedToCore(&animation_task, "anim", 2048, NULL, 10, NULL, 1);

And then within that task, I just call service() on a loop with a small task delay to allow the IDLE task to run.

    while(1) {
        ws2812fx.service();
        vTaskDelay(5);

@moose4lord
Copy link
Collaborator

Hmmm, I'm not sure why your code snippet would fix your issue. You're pinning the service() function to core 1, which is the core it would normally run on when using the Arduino IDE. Strange. But I'm glad you got it working.

@silardg
Copy link

silardg commented Jul 30, 2021

This is still a problem. If you have multiple things going on (multiple xtaskcreates) it wont fix it if you have it pinned.

@Buddhika93n
Copy link

Dear all,
I am experiencing the same issue..In my code I have 5 tasks. one of them is main_task... when I include main_task to the code led flickering issue occurs...

xTaskCreate(&blink_led_task, "blink_led_task", 1024 * 10, NULL, 5, NULL);

I am using above function to create the task...

for (j = 0; j < (CONFIG_EXAMPLE_STRIP_LED_NUMBER - 4); j++)
{
led_strip_hsv2rgb(hue, saturation, (brightness / 20), &red, &green, &blue);
// Write RGB values to strip driver
ESP_ERROR_CHECK(strip->set_pixel(strip, j + 4, red, green, blue));
led_strip_hsv2rgb(hue, saturation, (brightness / 16), &red, &green, &blue);
// Write RGB values to strip driver
ESP_ERROR_CHECK(strip->set_pixel(strip, j + 3, red, green, blue));
led_strip_hsv2rgb(hue, saturation, (brightness / 8), &red, &green, &blue);
// Write RGB values to strip driver
ESP_ERROR_CHECK(strip->set_pixel(strip, j + 2, red, green, blue));
led_strip_hsv2rgb(hue, saturation, (brightness / 4), &red, &green, &blue);
// Write RGB values to strip driver
ESP_ERROR_CHECK(strip->set_pixel(strip, (j + 1), red, green, blue));
led_strip_hsv2rgb(hue, saturation, (brightness), &red, &green, &blue);
// Write RGB values to strip driver
ESP_ERROR_CHECK(strip->set_pixel(strip, (j), red, green, blue));
ESP_ERROR_CHECK(strip->refresh(strip, 100));
vTaskDelay(delay/portTICK_RATE_MS);
// ESP_LOGI(TAG, "j:%d", j);
}

when above code executes...led flickering issue with random colors occurs...

@moose4lord
Copy link
Collaborator

Hmmmm...it doesn't look like you're using the WS2812FX lib. You might have better luck posting your question to a forum that deals with ESP32 RMT issues in general.

@Buddhika93n
Copy link

Buddhika93n commented Dec 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants