J
@jalperin
This works to restore RTC after pysense go-to-sleep.
py.setup_sleep(sleepsec)
pycom.nvs_set('gtsSec',sleepsec)
pycom.nvs_set('ttSec',time.time())
py.go_to_sleep()
rtc = RTC()
ttSec = pycom.nvs_get('ttSec') # time.time() previous value
if ttSec:
gtsSec = pycom.nvs_get('gtsSec') # go to sleep seconds
# reset clock to prior saved time plus length of sleep (both in seconds)
rtc.init(time.gmtime( ttSec + gtsSec ))
else:
# Initialize your wifi, then
rtc.ntp_sync("pool.ntp.org")
# rtc.ntp_sync("23.239.26.89")
while not rtc.synced():
time.sleep(1)
Since I can't distinguish awakening from reset, I am currently setting ttSec manually before running code. pycom.nvs_set('ttSec',0)