-->
Page 3 of 6

Re: NTP Client Example, working after bug fix UDP library

PostPosted: Sat Apr 18, 2015 4:24 am
by rvbcrs
I'm probably missing something here, I have downloaded the latest version of the ESP8266 arduino IDE and replaced the ESP8266 directory under hardaware with the latest github stuff.. Now when I run the NTP example I'm not able to get anything else other than: no packet yet Anyone any ideas what can is wrong?

Re: NTP Client Example, working after bug fix UDP library

PostPosted: Thu May 07, 2015 4:23 am
by tanck2
The NTP client example works after I replaced 3 files in the Arduino IDE package with the following files from this link : https://github.com/esp8266/Arduino/tree ... 66WiFi/src

WiFiUdp.h
WiFiUdp.cpp
UdpContext.h (in include directory)

Re: NTP Client Example, working after bug fix UDP library

PostPosted: Fri Aug 07, 2015 2:51 pm
by AcmeUK
Hi gerardwr

Thanks for posting this code, in the main it works for me.

I do have one problem though; on some iterations the time seems 'stuck' and I get the previous value.
See this :-
WiFi connected
IP address:
192.168.1.85
Starting UDP
Local port: 2390
Iteration no : 1 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 2 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 3 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800811 : Unix time = 1438812011 The UTC time is 22:00:11
Iteration no : 4 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800822 : Unix time = 1438812022 The UTC time is 22:00:22
Iteration no : 5 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800822 : Unix time = 1438812022 The UTC time is 22:00:22
Iteration no : 6 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800844 : Unix time = 1438812044 The UTC time is 22:00:44
Iteration no : 7 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800844 : Unix time = 1438812044 The UTC time is 22:00:44
Iteration no : 8 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800855 : Unix time = 1438812055 The UTC time is 22:00:55
Iteration no : 9 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800866 : Unix time = 1438812066 The UTC time is 22:01:06
Iteration no : 10 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800877 : Unix time = 1438812077 The UTC time is 22:01:17
Iteration no : 11 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800899 : Unix time = 1438812099 The UTC time is 22:01:39
Iteration no : 12 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800899 : Unix time = 1438812099 The UTC time is 22:01:39
Iteration no : 13 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800910 : Unix time = 1438812110 The UTC time is 22:01:50
Iteration no : 14 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800932 : Unix time = 1438812132 The UTC time is 22:02:12
Iteration no : 15 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800932 : Unix time = 1438812132 The UTC time is 22:02:12
Iteration no : 16 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800943 : Unix time = 1438812143 The UTC time is 22:02:23
Iteration no : 17 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800965 : Unix time = 1438812165 The UTC time is 22:02:45
Iteration no : 18 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800965 : Unix time = 1438812165 The UTC time is 22:02:45
Iteration no : 19 - sending NTP packet... packet received, length=48
Seconds since Jan 1 1900 = 3647800976 : Unix time = 1438812176 The UTC time is 22:02:56

As you can see I can keep getting the previous value.

I have changed the NTP server group to a UK one with the same result.

Changing the delay to 30 seconds makes no difference.

Any idea what is happening?

Re: NTP Client Example, working after bug fix UDP library

PostPosted: Sat Aug 08, 2015 10:46 pm
by martinayotte
That's a bit odd indeed ...

But is there any reason to request NTP every 30 secs ?
Maybe you should do the request one time per 24hrs, just to be synchronized, and rely on Time library for the rest of the day.