← index #5778Issue #17973
Related · high · value 2.950
QUERY · ISSUE

lightsleep results in machine reset on ESP32

openby jdstroyopened 2020-03-20updated 2020-03-23
port-esp32

Hello,

I'm running this version of MicroPython on ESP32:

MicroPython v1.12-262-g19ea30bdd on 2020-03-20; ESP32 module with ESP32

And I'm observing unexpected behavior with machine.lightsleep().

I would expect the following program code:

import machine
import time
while True:
    machine.lightsleep(10)

to behave in the same way as:

import machine
import time
while True:
    time.sleep_ms(10)

However, the prior always results in a WDT reset on my platform:

>>> import machine;
>>> while True:
...     machine.lightsleep(10);
...
...
...
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

This seems like a bug in machine.lightsleep(), as I can reproduce this with any value given to lightsleep, and even performing consecutive machine.lightsleep(100); calls directly without a loop.

CANDIDATE · ISSUE

ESP32-S3 PWM in lightsleep mode does not works as expected

openby yoann-darcheopened 2025-08-22updated 2025-08-23
bug

Port, board and/or hardware

ESP32S3

MicroPython version

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

Reproduction

import esp32
from machine import Pin, I2C, ADC, Timer, PWM, deepsleep, lightsleep
from neopixel import NeoPixel
import time

# Internal Led
INTERNAL_LED = const(47)

PWM_PIN_NORMAL = 1
PWM_PIN_SLEEP  = 12

# Init
LED = NeoPixel(Pin(INTERNAL_LED, Pin.OUT), 1)



# Test 26 Version
#    On ESP32-S3 : the pwm_ligthsleep goes to 1 when ligthsleep


pwm1 = PWM(Pin(PWM_PIN_SLEEP), freq=5000, duty_u16=32768, lightsleep=True)
pwm0 = PWM(Pin(PWM_PIN_NORMAL), freq=5000, duty_u16=32768)


# Init : LED = Blue
LED[0] = (0,0,32)
LED.write()

time.sleep_ms(10*1000) # Wait 10 Sec

while True:
    
    LED[0] = (32,0,0) # Green
    LED.write()
    time.sleep_ms(10*1000) # Wait 10 Sec
    
    LED[0] = (0,64,0) # Red
    LED.write()
    lightsleep(10*1000)

Expected behaviour

The option set on the pwm1 instance (lightsleep=True) should keep the pwm signal on while the ESP32 is in ligthsleep.
But when performing the test we see that the pwm1 pin goes to high value when the ESP32 enter in ligthsleep.

Observed behaviour

I've worked on this subject (https://github.com/micropython/micropython/pull/10854) and (https://github.com/micropython/micropython/pull/16102). On my local repository, I reloaded an old firmware with the same machine_pwm.c (ESP port) code as in the current repository, and it is working as expected! I haven’t yet found the difference - maybe it’s related to the IDF framework version ?

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