time.sleep() vs machine.lightsleep()

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

time.sleep() vs machine.lightsleep()

Post by kwiley » Mon May 25, 2020 5:58 am

Is time.sleep() (or utime.sleep()) the same thing as machine.lightsleep()? They take slightly different arguments (float seconds vs. int milliseconds), but functionally are they doing the same thing? Is there a recommendation between the two? Are the functions under the machine module meant to supplant the sleep() function in the time module and we aren't intended to use time.sleep()?

What about time.sleep_ms() (which is conceptually even more similar to machine.lightsleep()) and time.sleep_us()?

Relatedly, ESP8266 is often described in terms of "modem sleep" in other environments (Arduino), a term that doesn't appear in the MicroPython docs excerpt as a constant in the esp module. How is modem sleep achieved in MicroPython? Is it simply tantamount to deactivating the network interfaces?

Thanks.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: time.sleep() vs machine.lightsleep()

Post by pythoncoder » Tue May 26, 2020 6:03 am

The sleep methods of the time module provide accurate delays but do not provide power saving.
Peter Hinch
Index to my micropython libraries.

kwiley
Posts: 140
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: time.sleep() vs machine.lightsleep()

Post by kwiley » Tue May 26, 2020 7:39 pm

Thanks.

Post Reply