ESP32: Timer and sleep cause hang
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
creating virtual timer on MicroPython v1.25.0 on esp32 s3 fails
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