I have function to start an NTP service, right after obtaining wifi connection ( using ESP8266 board ).
from time to time, I get an error saying date and time is01-01-1970
... which I assume is due to not reaching the server as intended.
A retry counter was added to give few more retries, but somehow I does not do the trick since I never get the expected message NTP CHECK: #
and retry number ( while get an invalid date ).
I know that NTP.begin()
returns a bool to describe success/ failure obtaining a NTP server
EDIT1: using NtpClientLib
How can it be done ?
void startNTP() {
int counter = 0;
while ( !NTP.begin("pool.ntp.org", 2, true) && counter <=2){
Serial.print("NTP CHECK: #");
Serial.println(counter);
counter +=1;
delay(1000);
};
NTP.setInterval(clockUpdateInt); // in seconds
}
never get the expected message NTP CHECK: # and retry number
- that suggests that that NTP.begin returns trueNtpClientLib
- and YES I know that result istrue
but still date is as noted...NTP.getLastNTPSync()
and skip the code if the result is0