ESP8266 as a realtime clock
Posted: Sat May 09, 2015 5:00 am
Hello everyone.
I'm writing my own firmware for esp8266, so it will be main an only one CPU in my device. I need to realize a realtime clock. When my device is powered off, it is still working on a small battery. When I see power disapperance I'm writing current time in RTC block of memory and then calling system_deep_sleep with a fixed sleeping time, for example 10 seconds. When theese 10 second pass my device wakes up, but if the power is still off my sleeping cycle repeates.
The problem is: system_deep_sleep makes my system to sleep not 10 seconds but 10 seconds plus some time that is taken by system_deep_sleep function to prepare system for deep sleep. I don't know the amount of this time. But this small amount of time introduces some error in my realtime calculation. The more cycles sleep-wake I have, the more error I get.
This problem could be solved, if I could read the value of RTC register after system wake up, but loader or system startup resets it.
Maybe amyone have some ideas how to save time correctly during deep sleep?
I'm writing my own firmware for esp8266, so it will be main an only one CPU in my device. I need to realize a realtime clock. When my device is powered off, it is still working on a small battery. When I see power disapperance I'm writing current time in RTC block of memory and then calling system_deep_sleep with a fixed sleeping time, for example 10 seconds. When theese 10 second pass my device wakes up, but if the power is still off my sleeping cycle repeates.
The problem is: system_deep_sleep makes my system to sleep not 10 seconds but 10 seconds plus some time that is taken by system_deep_sleep function to prepare system for deep sleep. I don't know the amount of this time. But this small amount of time introduces some error in my realtime calculation. The more cycles sleep-wake I have, the more error I get.
This problem could be solved, if I could read the value of RTC register after system wake up, but loader or system startup resets it.
Maybe amyone have some ideas how to save time correctly during deep sleep?