You Reply: Will the standard UdpNtpClient sketch included with Arduino 22 Ethernet library execute using this board?
I compiled it and tried it with both an Arduino Uno and an Arduino Mega. For unclear reasons, the setup function repeatedly executes. I demonstrated that with the following patch which includes code specific to my network: and longer delay between sending the NTP packet and checking for a response in case there is some sort of latency problem:
[i]diff -u /usr/share/arduino/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde UdpNtpClient/UdpNtpClient.pde[/i]
[tt]--- /usr/share/arduino/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde2011-07-15 12:45:24.000000000 -0700
+++ UdpNtpClient/UdpNtpClient.pde 2012-02-21 11:09:51.013474267 -0800
@@ -25,8 **5,9 @@
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
- 192,168,1,177 };
-
+ 192,168,123,11 };
+byte gateway[] = {
+ 192, 168, 123, 254 };
unsigned int localPort = 8888; // local port to listen for UDP packets
@@ -39,11 +40,11 @@
void setup()
{
+ Serial.begin(9600);
+ Serial.println("Starting up....");
// start Ethernet and UDP
- Ethernet.begin(mac,ip);
+ Ethernet.begin(mac,ip,gateway);
Udp.begin(localPort);
-
- Serial.begin(9600);
}
void loop()
@@ -51,7 +52,7 @@
sendNTPpacket(timeServer); // send an NTP packet to a time server
// wait to see if a reply is available
- delay(1000);
+ delay(3000);
if ( Udp.available() ) {
Udp.readPacket(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer
[/tt]