← index #5623Issue #8408
Related · high · value 0.336
QUERY · ISSUE

esp32: RMT timing glitches

openby carstenbltopened 2020-02-08updated 2021-11-11

I am getting semi-random glitches in the RMT output. I am trying to use it to drive Neopixels and I get wrong pulse lengths sometimes. The glitches occur less frequently when I have longer delays between writing the pulses and if I write less data. I say semi-randomly because when I am running an animation for the Neopixels it has a high tendency to glitch at the same time and the same LEDs seem to be glitching when repeating the run.

Here are two captures at the position that the glitch first occurs. The first 300 us are fine, then I start getting pulses that are longer than expected. In total it adds up to 70 us more (from 560 us).

Bad frame:
<img width="939" alt="Bildschirmfoto 2020-02-08 um 14 45 45" src="https://user-images.githubusercontent.com/11031419/74086417-f089fb80-4a82-11ea-9f96-d31a989ae814.png">

Good frame:
<img width="939" alt="Bildschirmfoto 2020-02-08 um 14 45 55" src="https://user-images.githubusercontent.com/11031419/74086421-f67fdc80-4a82-11ea-8555-22facd5c2f01.png">

Interestingly I also see the power go up at the end. Right now I have a level shifter attached to the output, because my first guess was that this was responsible for the glitches.
<img width="430" alt="Bildschirmfoto 2020-02-08 um 14 53 03" src="https://user-images.githubusercontent.com/11031419/74086436-0eeff700-4a83-11ea-8fdd-8c0c2008a983.png">

Some people here are reporting similar problems: https://esp32.com/viewtopic.php?f=2&t=3980&start=10
Disabling power management did however not resolve the it.

CANDIDATE · ISSUE

Error with a script (RMT and neopixel)

closedby dnecodeopened 2022-03-12updated 2026-03-19

Hello,
I've started a project a few days ago, the aim is to control with a smartphone via bluetooth LE and an android app, that I created, a strip of leds. Everything works fine except that some leds are flashing with different colors randomly. I searched on the internet and I finally found it's a problem with RMT. Note that to control the leds, I need to use only this firmware esp32-idf3-20200411-v1.12-357.bin because the library I use https://www.gcworks.fr/tutoriel/esp/files/esp_ble_uart_v2.zip works only with this firmware.

So I added this to my script :

r = esp32.RMT(1, pin=machine.Pin(p), clock_div=80)
r
r.send_pulses((100, 2000, 100, 4000), start=0)

but it leads me to an error :

Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
OSError: ESP_ERR_INVALID_STATE
>
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Type "help()" for more information.

Here is the full script :

from esp_ble_uart import *
import machine, neopixel, time, esp32

n = 49
p = 13
np = neopixel.NeoPixel(machine.Pin(p),n)

r = esp32.RMT(1, pin=machine.Pin(p), clock_div=80)
r
r.send_pulses((100, 2000, 100, 4000), start=0)

nom = 'neonconnect'
UUID_UART = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
UUID_TX = '6E400003-B5A3-F393-E0A9-E50E24DCCA9E'
UUID_RX = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E'

uart = Bleuart(nom, UUID_UART, UUID_TX, UUID_RX)
uart.close()

val_rx = "0,0,0"

def rcp_rx():
    global val_rx
    val_rx = uart.read().decode().strip()
    print(val_rx)

uart.irq(handler=rcp_rx) # Interruption

while True :
    color = val_rx.split(",")
    print(color)
    r = int(color[0])
    g = int(color[1])
    b = int(color[2])
    for i in range(n):
        np[i] = (r, g, b)
    np.write()
    time.sleep(1)

Could someone help me.

Thx

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied