ESP32 RMT LED Flickering

Hi all,

I have a staircase with 16 steps, which I have illuminated with WS2812B (NEOPIXEL) LEDS (24 leds/step). these fade in if motion is detected, and after 20 seconds the fade out (as if following you up or down the staircase).

However, I have some problems with ESP32 RMT LED, namely that the LEDs flicker. This happens at a more or less constant rate and it appears to be a problem with interrupts. Looks like it is linked to Wifi activity. I can reproduce the problem 100% of the time.

Now, before I dive deeper. I have a workaround that is working, proving my hardware setup is working as it should. And I will get into the details on why I want this on ESP32 RMT.

Current (workaround) working solution (snippets that are relevant):

esphome:
  includes: common/staircase/myled.h

esp32:
  board: wemos_d1_mini32
  framework:
    type: arduino

light:
  - platform: fastled_clockless
    chipset: NEOPIXEL #WS2812B
    pin: GPIO16
    num_leds: 384
    name: "Staircase-internal"
    id: light1
    default_transition_length: 1s
    internal: true

myled.h contains:

#define FASTLED_SHOW_CORE 1

Using the arduino platform + FastLED library and a single #define removes all flickering from the setup. Great! Problem fixed! But there are 2 issues here:

  1. Arduino platform + ESP32 has an issue with mDNS (I have a workaround in place for that too). Solution here is ESP-IDF as that fixes mDNS.
  2. FastLED compiles, but gives heaps of warnings and it is an older version. I tried 3.5.0 but the LEDs would not turn on. ESP-IDF and FastLED are incompatible.

My gut feeling is that if I move to ESP32 RMT + ESP-IDF that will be more future proof.

Future solution:

esphome:
  includes: common/staircase/myled.h

esp32:
  board: wemos_d1_mini32
  framework:
    type: esp-idf # cannot use esp-idf and fastLED
    version: recommended 

light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: GPIO16
    num_leds: 384
    rmt_channel: 0
    chipset: ws2812
    name: "Staircase-internal"
    id: light1
    default_transition_length: 1s
    internal: true

This “works” in the way that it compiles without warnings/errors, mDNS is fixed and the LEDs do actually turn on. But, as mentioned, there is a lot of flickering going on which is very annoying and distracting.

I tried the following options to pin the RMT task to a single core:

// For RMT driver
#define ESP_INTR_FLAG_IRAM 1
#define CONFIG_USE_CORE_AFFINITY = 1

But these settings do not fix my problem. And now, I am completely stuck as I have been searching the internet for a solution, reading through tons of code in the hopes to find the right setting.

Oh and I rewrote my YAML to include the automation of the steps in scripts, reducing the wifi traffic, which helped a bit (about 50% less flickering).

There has to be some way to make this work like the FastLED solution. Who can help me with this problem? I would appreciate it very much!

I wish I was coming with a solution, but actually am having the same problem! Did you ever find a solution to the ESP32 RMT LED flickering?

Hi @contagon.

In short, no I have never managed to fix it unfortunately.

I did do some reading up on what the problem could actually be. I have no reference material at hand right now. I believe the issue is with interrupts from the hardware (such as wifi, bluetooth etc) interfering with the RMT library. Apparently the way to solve this problem is to use DMA (Direct Memory Access), which is not a feature on the ESP32 (ESP32-D0WDQ6) I am using now.

I have bought and received the newer ESP32-S3 chip. ESPHome support is still a bit limited. I got it to connect to the wifi, but I have not tested this with the LEDs since it still under development. When and if I come around to this , I will update this topic :slight_smile:

Some information on the different models can be found here:

A datasheet on the ESP32 can be found here:

Should you want to try the ESP32-S3, this code will work to get it into ESPHome:

esphome:
  name: s3test
  friendly_name: s3test

  platformio_options:
    platform: https://github.com/platformio/platform-espressif32.git
    board: lolin_s3_mini
    framework: espidf
    board_build.flash_mode: dio
    
esp32:
  variant: esp32s3
  board: lolin_s3_mini
  framework:
    type: esp-idf  
    version: latest

I managed to find a solution! (and better understand what’s happening) - version 2024.11.2
My flickering issues stopped when I configured the logger as follows:

logger:
  level: INFO
  logs:
    # main: DEBUG
    wifi: NONE
    esp-idf: NONE

In case you’re wondering (or if you’re a developer on the ESPHome team) why this works:
The RMT library uses bit-banging to send data to the LEDs, meaning all communication is done in software. When an interrupt occurs (eg. logging event sending out data), the communication with LEDs is delayed/disrupted, resulting in a corrupted configuration arriving to the LEDs.

By disabling unnecessary logging (or preferably, all of it) you reduce the chance of an interrupt happening during LED communication, thus reducing the chance of flickers.

I hope this helped! :sparkling_heart:

4 Likes

Hi Jamie,

this helped a lot! Seems to be 99% OK.

I never got around to install the S3 as I made a mistake while soldering (and had to throw the board in the bin). So that may still be a valid option.

1 Like

Hi Jamie,

Just a quick Gracias! your comment was very helpful.

1 Like