← index #18034Issue #17203
Related · high · value 1.466
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

creating virtual timer on MicroPython v1.25.0 on esp32 s3 fails

closedby NilsBeopened 2025-04-28updated 2025-04-28
bug

Port, board and/or hardware

esp32 s3

MicroPython version

MicroPython v1.25.0 on 2025-04-15; Generic ESP32S3 module with ESP32S3

Reproduction

import machine
t = machine.Timer(-1)

Expected behaviour

no error on MicroPython v1.24.1 on 2024-11-29; Generic ESP32S3 module with ESP32S3

Observed behaviour

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid Timer number

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