time.monotonic() Wakeup from Deep Sleep

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ISI_BOB
 
Posts: 40
Joined: Tue Jan 11, 2022 3:14 pm

time.monotonic() Wakeup from Deep Sleep

Post by ISI_BOB »

import time
import alarm
print(time.monotonic())
time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 30)
alarm.exit_and_deep_sleep_until_alarms(time_alarm)

If I run this test code, it appears that the monotonic timer is getting reset back to zero on wakeup. I thought I ran this test a few weeks ago and determined the timer keeps going during deep sleep.

I am currently using 8.0.0-beta.4-41-g73a43aa30 on a ESP32-S2 Qt Py. Not sure what version I was using when ran the tests a few weeks ago.

Does the timer reset, or is it supposed to keep going? Not sure which is the intended operation.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: time.monotonic() Wakeup from Deep Sleep

Post by dastels »

After chasing through the CircuitPython source, it seems to get into the ESP apis (see https://docs.espressif.com/projects/esp ... timer.html), specifically:
int64_t esp_timer_get_time(void)
Get time in microseconds since boot.

Returns
number of microseconds since underlying timer has been started
Further reading deeper yields this:
Unlike gettimeofday function, values returned by esp_timer_get_time():

- Start from zero after the chip wakes up from deep sleep
- Do not have timezone or DST adjustments applied
Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”