Help with UdpNtpClient /Arduino 1.06

I would really appreciate some help on a problem I’m tackling getting a NTC timestamp for a Ethernet based datalogger. I am using the UdpNtpClient example sketch (attached) with a standard Arduino Wiznet Ethernet shield. The example runs correctly if I start the Ethernet client using DNS as below:

// start Ethernet and UDP
if (Ethernet.begin(mac) == 0) {
Serial.println(“Failed to configure Ethernet using DHCP”);
// no point in carrying on, so do nothing forevermore:

But it will not run if I start the client using the local IP address of the shield:

Ethernet.begin(mac, ip);

In this case there is no error, and no Serial output. I conclude that no UdP packets are received in response to the UdP.send

The IP address was taken from the router’s list of devices connected to the LAN. Other examples from the Ethernet library, Web client, Web server, run as expected.

Any ideas about what I could try? Many thanks. RobJW

UdpNtpClient.ino (5.17 KB)

Is that IP in the router’s localnet? Is the router’s IP (gateway) Here is a test sketch to check your localnet network settings. If you don’t understand the output, post it here.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {

  // disable SD SPI

  Serial.print(F("Starting ethernet..."));
  if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  else {
      Serial.print(F("IP: "));
      Serial.print(F("Subnet: "));
      Serial.print(F("Gateway: "));
      Serial.print(F("DNS server: "));

void loop() {

edit: This may not have been a good idea.

The IP address was taken from the router’s list of devices connected to the LAN.

You need an IP that is not used by another device. I recommend using an IP that is not in the localnet dhcp server’s range. That can cause real problems if the router doesn’t check the dhcp IP first. My routers dhcp servers do check by pinging the IP before issuing it to a device, but that is not normal.

And some routers are picky. They won’t respond to an IP within the DHCP server’s lease range if the IP was not issued by the server ( no DHCP lease).