diff --git a/src/rtctime.cpp b/src/rtctime.cpp index 7bbb4844..0de8e176 100644 --- a/src/rtctime.cpp +++ b/src/rtctime.cpp @@ -65,7 +65,13 @@ time_t get_rtctime(uint16_t *msec) { // if we have a RTC pulse, we calculate msec #ifdef RTC_INT - *msec = lastRTCpulse % 1000; + uint16_t ppsDiff = millis() - lastRTCpulse; + if (ppsDiff < 1000) + *msec = ppsDiff; + else { + ESP_LOGD(TAG, "no pulse from RTC"); + return 0; + } #endif return t; diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 97c63064..ee0a4ed1 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -203,8 +203,10 @@ void timepulse_init(void) { #endif // get time if we don't have one - if (timeSource != _set) + if (timeSource != _set) { + delay(1000); // wait for first PPS time stamp to arrive setTimeSyncIRQ(); // init systime by RTC or GPS or LORA + } // start cyclic time sync timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ);