The IP that is used in the UDP NTP Client is going to be abandoned Dec 17th.

I found out about it by chance, I happened to stumble across this page: http://tf.nist.gov/tf-cgi/servers.cgi. The nice thing about the page is it give a long list of other IP addresses that can be used and their current status.

Ja, I found using the NTP time server was already giving me some hic-cups recently and looked to use another IP.Maybe there needs to be some information regarding this in the documentation for the NTP client.Maybe a hint on how or where to look for suitable NTP servers.

Ja, I found using the NTP time server was already giving me some hic-cups recently and looked to use another IP.Maybe there needs to be some information regarding this in the documentation for the NTP client.Maybe a hint on how or where to look for suitable NTP servers.

Presumably it needs to do a real domain lookup instead of hard-coding the IP address. The DnsWebClient (http://arduino.cc/en/Tutorial/DnsWebClient) contains code that uses the name lookup service for TCP, but I didn't see any support for doing a DNS query via UDP.

It is rather unfriendly that libraries like this use static IP addresses. Using the domain name service allows the NIST (or other organizations) to use round robin scheduling to distribute the load among servers.

Get the time from a Network Time Protocol (NTP) time server Demonstrates use of UDP sendPacket and ReceivePacket For more on NTP time servers and the messages needed to communicate with them, see http://en.wikipedia.org/wiki/Network_Time_Protocol

void loop(){ sendNTPpacket(timeServer); // send an NTP packet to a time server

// wait to see if a reply is available delay(1000); if ( Udp.parsePacket() ) { // We've received a packet, read the data from it Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer

//the timestamp starts at byte 40 of the received packet and is four bytes, // or two words, long. First, esxtract the two words:

// all NTP fields have been given values, now // you can send a packet requesting a timestamp: Udp.beginPacket(address, 123); //NTP requests are to port 123 Udp.write(packetBuffer,NTP_PACKET_SIZE); Udp.endPacket(); }

edit: Corrected time delay loop again. It counts off the minutes and checks time every 10 minutes (was 1 minute). I was on to the second after 10 minutes.

From an internet perspective, you really should not be polling the NTP server every minute. If every device on the internet does this, it will eventually mean people will stop offering NTP servers, and the infrastructure will be clogged with all of these packets to the remaining hosts offering the service.

Also, if you pay for your internet as a metered service, having your device continually polling the NTP server will mean you will get pushed over your limit and either it will slow down your connection, it will start charging you more, or cut off service all together (I've seen all 3 in cell phone contracts).

Poll once when you start up, and then keep local time, and poll every so often (every few hours perhaps) to adjust the time. In terms of keeping local time, perhaps getting one of the real time clocks, and use that. Use NTP occasionally to update the clock.

Also, having the delays in the code means your device can't do anything else while it is waiting for a response, unless you are using interrupts. I do wish the Arduino library provided a standard way of doing blink without delay that all of the library functions used.

Hi Michael. I agree. I used that only as a test. This should really be used with a RTC, and checked every hour or so. The real purpose was to show how close I could come to the correct time just using delay(). The millis routine would probably be even better (more accurate?). It appears the original code may have checked even more often that this.

If this works for most, I will put this code in the wiki with a longer delay and a warning to that effect.

Quote

Also, having the delays in the code means your device can't do anything else while it is waiting for a response, unless you are using interrupts.

Not quite true. That is why I divide that 59 second time up into 1 second delays. A switch-case on the loop counter works well for "time slicing".

edit: I didn't like the one minute thing. I changed it to check every 10 minutes, and count off the minutes since the last check.

When I try to access this url http://arduino.cc/en/Tutorial/UdpNtpClient, I get a 403 Forbidden error.Is that just me? temporary messed apache setup ? I don't know where I should post this problem.I have the same message while trying to access documents in the http://arduino.cc/en/Learning/ sections.