← index #18034Issue #17577
Related · medium · value 0.753
QUERY · ISSUE

ESP32: Timer and sleep cause hang

openby lightopened 2025-09-03updated 2025-09-05
bugport-esp32

Port, board and/or hardware

ESP32_GENERIC-20250809-v1.26.0, NodeMCU ESP32-WROOM-32

MicroPython version

MicroPython v1.26.0 on 2025-08-09; Generic ESP32 module with ESP32

Reproduction

The following code causes the sleep() to hang consistently on iteration 254 on both esp32 boards I tested this on. After this hang any other call to sleep() will hang too, a hard reset is needed to recover.

from machine import Pin, Timer
import time

LED = Pin(2, Pin.OUT)
TIMER = Timer(0)

def blink():
    LED.on()
    TIMER.init(mode=Timer.ONE_SHOT, period=5, callback=lambda timer: LED.off())

i = 0
while True:
    blink()
    i += 1
    print(f"Loop {i}")
    time.sleep(0.01)

This code does not hang on v1.25.0.

Expected behaviour

The loop should run indefinitely

Observed behaviour

Hang on iteration 254

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

ESP32-C6 timers not working on custom build

closedby AndreoBotelhoopened 2025-06-28updated 2025-08-29
bug

Port, board and/or hardware

esp32-c6 custorm pcb

MicroPython version

MicroPython v1.25.0 on 2025-06-28; ESP32C6 module with ESP32C6

built with espidf v5.3.2 or 5.4.1, trying v1.26 preview form master branch gives same result

Reproduction

  1. create a timer ( 0 or 1)
  2. init it and set a callback
  3. wait for callback result
def mycallback(t):
    print('timer')

tim = Timer(0)

tim.init(period=100, callback=mycallback)

Expected behaviour

Expected print "timer"

Observed behaviour

nothing happens, working fine on espidf 5.2.5

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

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