-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Debug SNTP #4122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you have a look to another example appeared after the sntp fix |
Hej Thanks Here is the serial output. Looks like it works super fast. First is wrong but I guess that's because the script does not wait for wifi. So what has been fixed? and how can I use this fix in the library? Just need to sync the time with ntp as easy and small size as possible.
|
It does not wait for wifi on purpose. This example shows how to get accurate time without external library. You can use the callback to know when current time is set. Regarding the external library, I have no information myself, that should be asked in its repo. |
@jhagberg - it's true, external libs like tandem https://github.com/gmag11/NtpClient + https://github.com/PaulStoffregen/Time do not get/set time from ntp servers but timeStatus() return "timeSet" - strange! (when lwIP v2 is selected) but the same libs works ok on lwIP 1.4 |
@jhagberg - with 2.4.0 there is no longer need for 3rd party libs. |
@reaper7 Thanks. Aha that strange but that explains that the lib owner did not have any issues. And that also might explain why my efforts to turn on lwip debug in version 1 did not work since I am now using lwip 2. |
@5chufti Good to know. I am updating an old sketch that I had running on an Arduino Uno and a Sparkfun WiFly Sheild to a SonOff TH10 esp8266 module. I used timelib and TimeAlarms library. If I want to implement some TimeAlarms what is the best way now to do it without using https://github.com/PaulStoffregen/Time and https://github.com/PaulStoffregen/TimeAlarms ? |
If all former NTP libs do not work with 2.4.0 then I guess something should be done here for the sake of coherency and compatibility. |
since time functions (apart from setup) are "compatible" in most "former NTP" libs, I see no reason why TimeAlarms shouldn't work with "core" sntp implementation |
Yes They work but it takes long time to get an accurate time. |
can you define "long time"? |
|
and what if fixed ip is used? |
I admit I have not tested this precisely, but it should work. |
@5chufti Several minutes. Sometimes shorter sometimes longer. |
Thanks for testing this. [edit:if you don't plan to try and fix this,] Can you provide your sketch ? |
I tested it with this modified sketch form #1679
I experienced different behaviour at work than at home for static IP, at home I get periods of relativ fast (~7s) syncs and then some with longer waits; seems to depend on AP. |
@d-a-v @igrr
so against my yesterdays statement I have to say it is working as intended. |
@5chufti what do you call "giving IP for timeserver" still not working ? |
one can't use
or
|
@5chufti I have tested your sketch with dynamic IP and I get time sync direct after wifi connection. So it works very well. I have understood the SNTP code right that it will update and sync time from NTP server about every hour that is the default TIMEOUT? |
|
hmmm, that could be the setup after a long compiling session: resets esp and keeps in flashing mode until restart after successfull flashing ... else I wouldn't know. |
SNTP support and example have receive updates, and this thread is old. Current code allows to update sntp startup and update time,
|
Basic Infos
Hardware
Hardware: SonOFF TH10 and Adafruit HUZZAH
Core Version: 2.4.0
Description
Running on SonOFF TH10 and one Adafruit HuzZazh I got a problem with delayed first sync using the sntp client with for example this library. https://github.com/stelgenhof/NTPClient/
[NTP] First synchronization: 1970-01-01T17:00:00.
Got NTP time: 1970-01-01T17:00:00
after a while, It gets the right sync. Same problem with different time servers both local and on the internet. Using the example ntp sketch that is not using the sntp part I get the right time at once.
Problem description
Other users report no problem so I would like to debug this but have a problem to turn on the debug of sntp.
I have added
in my sketch that is the example sketch from the above lib.
the Hello is printed out. I have also added debug outputs in lwipopts.h found in my
bin/arduino-1.8.5/hardware/esp8266com/esp8266/tools/sdk/include
as this comment state:
#2330 (comment)
But I am unable to get any DEBUG from the lwip or sntp.
What am I missing.
The text was updated successfully, but these errors were encountered: