Page 1 of 1

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

Posted: Tue Jul 02, 2019 2:14 pm
by rcolistete
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).

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

Posted: Wed Jul 03, 2019 7:34 am
by pythoncoder
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.