ESP32 RMT LED Strip
The esp32_rmt_led_strip light platform drives most addressable LED strips using the RMT peripheral.
Here’s a comparison of some alternatives for driving these strips:
- This component, the ESP32 RMT LED Strip, uses the RMT peripheral to precisely control the timing of the output and ensure compatibility with a wide range of LED strips. However, there is only enough RMT symbol memory to buffer a few pixels at a time. Flickering may occur when the microcontroller is busy performing higher priority tasks and the RMT interrupt cannot be serviced soon enough to refill the buffer for subsequent pixels.
- The I2S Clockless LED Strip component uses the I2S peripheral and DMA to drive the output with larger buffers that are more immune to flickering caused by interrupt latency. However, the resulting waveform diverges slightly from the datasheet timing recommendations although in practice it is close enough for the LED pixels to work reliably.
NOTE
The ESP32-C2 and ESP32-C61 do not have RMT hardware and are not supported by this component.
# Example configuration entrylight: - platform: esp32_rmt_led_strip channel_colors: GRB pin: GPIOXX num_leds: 30 chipset: ws2812 name: "My Light"Configuration variables
Section titled “Configuration variables”-
pin (Required, Pin Schema): The pin for the data line of the light.
-
num_leds (Required, int): The number of LEDs in the strip.
-
chipset (Optional, enum): The name of the chipset used; determines signal timing. Not required if specifying the timings manually.
WS2811WS2812SK6812APA106SM16703
-
channel_colors (Required, string): The order in which the strip expects its color channels. List each of
R,GandBexactly once, optionally with a singleWin any position; for exampleGRB,BGR,GRBW,WRGBorRWGB. The value is case-insensitive. Including aWmakes this a four channel RGBW strip. -
max_refresh_rate (Optional, Time): A time interval used to limit the number of commands a light can handle per second. For example,
16mswill limit the light to a refresh rate of about 60Hz. Defaults to sending commands as quickly as changes are made to the lights. -
use_psram (Optional, boolean): Set to
falseto force internal RAM allocation even if you have the PSRAM component enabled. This can be useful if you’re experiencing issues like flickering with your leds strip. Defaults totrue. -
rmt_symbols (Optional, int): When
use_dmais enabled, this sets the size of the driver’s internal DMA buffer. When DMA is disabled, it specifies how much RMT memory is allocated to the component. RMT memory is shared across all components and should be allocated in multiples of the block size. On theESP32andESP32-S2variants, RMT memory is shared between RX and TX components. On other variants, RX and TX have their own RMT memory, but a TX component can also use RX memory that no RX component uses.
| ESP32 Variant | Available Memory | Block Size |
|---|---|---|
| ESP32 | 512 symbols | 64 symbols |
| ESP32-C3 | 96 symbols | 48 symbols |
| ESP32-C5 | 96 symbols | 48 symbols |
| ESP32-C6 | 96 symbols | 48 symbols |
| ESP32-H2 | 96 symbols | 48 symbols |
| ESP32-H21 | 96 symbols | 48 symbols |
| ESP32-H4 | 96 symbols | 48 symbols |
| ESP32-P4 | 192 symbols | 48 symbols |
| ESP32-S2 | 256 symbols | 64 symbols |
| ESP32-S3 | 192 symbols | 48 symbols |
| ESP32-S31 | 192 symbols | 48 symbols |
Each component uses its own RMT channel: remote_receiver uses an RX channel, remote_transmitter and
esp32_rmt_led_strip use a TX channel. A channel uses at least one block of memory, so the number of channels is the
available memory divided by the block size, for example 8 on the ESP32 and 2 on the ESP32-C3. On the ESP32 and
ESP32-S2, RX and TX components share these channels. On other variants, RX and TX each have this many channels.
ESPHome checks all esp32_rmt_led_strip, remote_transmitter and remote_receiver components together. Validation
fails if:
- they need more channels than are available
- more than one RX or more than one TX component sets
use_dma, since only one channel per direction supports DMA rmt_symbolsis an odd number or smaller than one block- without
use_dma,rmt_symbolsis larger than one channel can use. On theESP32andESP32-S2that is all the RMT memory; on other variants it is the RX memory for an RX component, or the TX and RX memory together for a TX component - a transmitter or LED strip with
use_dmasetsrmt_symbolsabove 2046
A component with use_dma uses one block. When it compiles, ESPHome also works out which memory each channel gets when
the components are set up: by setup_priority, then in the order of the configuration. A component that refers to
another component by ID, such as a power_supply, can be set up after the ones that follow it. If a channel does not
fit, ESPHome logs a warning that suggests an rmt_symbols value that fits, or a setup_priority that sets up the
smaller ones first. esphome config does not show this warning. The order matters because a TX channel can extend into
memory that the next one would need: on an ESP32-S3, a 48 symbol strip followed by a 288 symbol strip fits, but not
the other way round.
-
use_dma (Optional, boolean): Enable DMA on variants that support it. If enabled
rmt_symbolscontrols the DMA buffer size and can be set to a large value, up to 2046. -
All other options from Light.
Manual Timings
Section titled “Manual Timings”These can be used if you know the timings and your chipset is not set above. If you have a new specific chipset, please consider adding support to the codebase and add it to the list above.
-
bit0_high (Optional, Time): The time to hold the data line high for a
0bit. -
bit0_low (Optional, Time): The time to hold the data line low for a
0bit. -
bit1_high (Optional, Time): The time to hold the data line high for a
1bit. -
bit1_low (Optional, Time): The time to hold the data line low for a
1bit. -
reset_high (Optional, Time): The time to hold the data line high after writing the state. Defaults to
0 us. -
reset_low (Optional, Time): The time to hold the data line low after writing the state. Defaults to
0 us.