pyb.stop() / machine.lightsleep() time to wake up

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

pyb.stop() / machine.lightsleep() time to wake up

Post by rcolistete » Tue Jul 02, 2019 2:14 pm

One fantastic feature of Pyboard D is a very short time to wake up from lightsleep, which has very low current (170 uA) while retaining the RAM state.

I've measured 344-404 us using the software :

Code: Select all

from pyb import RTC
rtc = RTC()
rtc.datetime((2019, 6, 30, 7, 17, 23, 30, 0))
t1 = rtc.datetime()
rtc.wakeup(1)
pyb.stop()
t2 = rtc.datetime()
print(t1, t2)
With output (last field is in microseconds) : (2019, 6, 30, 7, 17, 23, 30, 30) (2019, 6, 30, 7, 17, 23, 30, 1434)
Without 'pyb.stop()' (as comment) : (2019, 6, 30, 7, 17, 23, 30, 30) (2019, 6, 30, 7, 17, 23, 30, 91)
So the time to 'pyb.stop()' wake up is about (1404-1000-61=344) us.

Alternatively, using 'machine.lightsleep()', gives almost the same result :

Code: Select all

from pyb import RTC
rtc = RTC()
rtc.datetime((2019, 6, 30, 7, 17, 23, 30, 0))
t1 = rtc.datetime()
machine.lightsleep(1)
t2 = rtc.datetime()
print(t1, t2)
With output : (2019, 6, 30, 7, 17, 23, 30, 30) (2019, 6, 30, 7, 17, 23, 30, 1434)
Without 'machine.lightsleep(1)' (as comment) : (2019, 6, 30, 7, 17, 23, 30, 30) (2019, 6, 30, 7, 17, 23, 30, 30)
So the time to 'machine.lightsleep()'' wake up, discarding the 1 ms pause, is about (1404-1000=404) us.

A better measurement would be made using an oscilloscope measuring the timings and current (voltage on a shunt resistor).
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

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

Re: pyb.stop() / machine.lightsleep() time to wake up

Post by pythoncoder » Wed Jul 03, 2019 7:34 am

My fast_io uasyncio fork can be configured to use this mode. Whenever the application is idle, waiting for a task to be scheduled, the power drops. As you say, the Pyboard D exceeds its specification substantially: I see values of ~180μA too.
Peter Hinch
Index to my micropython libraries.

Post Reply