Open Jorfuenst opened 5 years ago
Hi can you suggest me an Arduino board which has the clock frequency at least 48 Mhz from the Arduino AVR families? Raju KC
On Tue, Feb 26, 2019 at 10:07 AM Jorfuenst notifications@github.com wrote:
For example, ESP32 deep-sleep.
Thanks a lot.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PaulStoffregen/Time/issues/118, or mute the thread https://github.com/notifications/unsubscribe-auth/AiC9nG5mYJobLrsY7PKkjMf8KxP5f1Viks5vRU2_gaJpZM4bSZAe .
It relies on millis()
which in turn uses:
system_get_time()
on ESP8266 (see nonos-sdk pdf, there's also system_get_rtc_time
)esp_timer_get_time()
on ESP32, see docsBoth functions return time that is reset on deep sleep. So no, it's incompatible, you can use it, but it resets after deep sleep.
As "rtc clock", which continues to work in deep sleep mode, is too imprecise and unreliable (quartz oscillator is disabled in deep sleep), it requires sophisticated handling. Nodemcu has implementation for it, and it's quite complex.
I am having great luck using this time library with pwrDownMode() from Sleep_n0m1 library. I go into pwrDownMode ( "deep sleep" ) for 10 seconds and then I ADVANCE the millis() timer directly to account for the milliseconds lost during the sleep. Some forum posts say it's bad to do that, but it works in practice for me. YMMV
extern volatile unsigned long timer0_millis; //<<this line before setup() !
#include <Sleep_n0m1.h> //<<this line before setup() !
Sleep cpu_sleep; //<<this line before setup() !
//following in setup/loop:
cpu_sleep.pwrDownMode(); //set sleep mode
cpu_sleep.sleepDelay(10000); //actual sleep
noInterrupts ();
timer0_millis = millis()+9988L; //long int 9988
interrupts ();
For example, ESP32 deep-sleep.
Thanks a lot.