ropg / ezTime

ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
MIT License
327 stars 92 forks source link

Not able to Synchronize Time #102

Open pcegli82 opened 3 years ago

pcegli82 commented 3 years ago

Hello

First of all, thanks for this great library, the synchronization to milliseconds is what I have been looking for!

Unfortunately I'm still failing with the basic functions. I loaded the example sketch for milliseconds and included the Ethernet Ehield. I am connected to the internet, another sketch for NTP synchronization works fine.

It seems that the sketch for the time synchronization hangs, means I see "got DHCP IP 192.xxx" and after that nothing happens.

What am I doing wrong?

I also tried the example sketch for the Ethernet Shield, it hangs in exactly the same place.

Any help is appreciated.

Greetings Erwin

my code:

`

include

include

// Enter a MAC address for your controller below. (Or use address below, just make sure it's unique on your network) // Newer Ethernet shields have a MAC address printed on a sticker on the shield

define MAC_ADDRESS { 0xBA, 0xDB, 0xAD, 0xC0, 0xFF, 0xEE }

void setup() {

Serial.begin(115200);
while (!Serial) { ; }       // wait for Serial port to connect. Needed for native USB port only

while (!Serial) { ; } // wait for serial port to connect. Needed for native USB port only Serial.println();

// You can use Ethernet.init(pin) to configure the CS pin //Ethernet.init(10); // Most Arduino shields (default if unspecified) //Ethernet.init(5); // MKR ETH shield //Ethernet.init(0); // Teensy 2.0 //Ethernet.init(20); // Teensy++ 2.0 //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet

Serial.print(F("Ethernet connection ... ")); byte mac [] = MAC_ADDRESS; if (Ethernet.begin(mac) == 0) { Serial.println(F("failed. (Reset to retry.)")); while (true) { ; }; // Hang } else { Serial.print(F("got DHCP IP: ")); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000);

setInterval(60);
waitForSync();

Serial.println();

for (int n = 0; n < 10; n++) {
    Serial.println(UTC.dateTime("l, d-M-y H:i:s.v T"));
}

Serial.println();
Serial.println("Those milliseconds between the first and the last line ...");
Serial.println();
Serial.println("     ... most of that is spent sending to the serial port.");

Serial.println();
Serial.println();
Serial.println();
Serial.println("And ezTime is not making those milliseconds up either.");
Serial.println();
Serial.println("      ... Stick around as we do an NTP request every minute.");
setDebug(INFO);

}

void loop() { events(); } `

jkmssoft commented 2 years ago

I had the same problem. The solution was to uncomment #define EZTIME_ETHERNET in the ezTime.h.

Putting #define EZTIME_ETHERNET before

include

did not work.