NTPClient icon indicating copy to clipboard operation
NTPClient copied to clipboard

Increase time accuracy

Open WhymustIhaveaname opened this issue 5 years ago • 6 comments

  • increase time accuracy to not above 100ms
    • complete decimal part of NTP
    • use high-freq polling
    • add _current_epoc_dec and get_millis() so that ms can be known
  • rewrite update()
    • solved overflow problem
    • change update()'s return type to byte in order to carry more info
    • add a not-request-too-fast feature by adding _last_fail in update()

I also add a demo program. I set an NTP Server in my LAN. In this network condition, the time error can be reduced to no more than plus-minus 10ms.

WhymustIhaveaname avatar Apr 24 '20 07:04 WhymustIhaveaname

Any plan to fix and merge this PR soon ?

fededim avatar May 12 '20 19:05 fededim

The build fails for these 2 errors:

/home/travis/build/arduino-libraries/NTPClient/examples/ntp_demo.ino: In function 'void connect_wifi(char*, char*)':
ntp_demo:28:25: error: 'class WiFiClass' has no member named 'channel'
     Serial.println(WiFi.channel());
                         ^
ntp_demo:30:25: error: 'class WiFiClass' has no member named 'getAutoReconnect'
     Serial.println(WiFi.getAutoReconnect());

Unluckily the functions channel and getAutoReconnect exist in WiFi, so it's strange that gives such errors. @Testato can you do a check and let us know ?

fededim avatar May 13 '20 07:05 fededim

I have tested these codes on my esp32. It works very well. It has run for half a month without a bug or crash.

These prints are not important. They are just showing what information one can get from WiFi.

WhymustIhaveaname avatar May 13 '20 08:05 WhymustIhaveaname

According to log the build is done with platform esp8266, which is a little bit different from esp32. I hope that all Arduino library functions are present in every supported platform.

fededim avatar May 13 '20 10:05 fededim

Any plans to get this merged?

wujiang avatar Feb 08 '21 15:02 wujiang

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 09 '21 13:04 CLAassistant