Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NTP:NACK" #3

Open
b18062a opened this issue Mar 17, 2019 · 2 comments
Open

"NTP:NACK" #3

b18062a opened this issue Mar 17, 2019 · 2 comments

Comments

@b18062a
Copy link

b18062a commented Mar 17, 2019

Incredible work, thank you! I was wondering, is the NTP server still working in your build? I've not had any success and I've not edited your code.

@proddy
Copy link

proddy commented Mar 17, 2019

if you're using an ESP32 its probably easier to use the NTP built into the core library. I did something like:

struct tm    timeinfo;
const char * ntpServer1 = "95.211.212.5";  // "nl.pool.ntp.org"
const char * ntpServer2 = "91.148.192.49"; // "pool.ntp.org"
const char * tz         = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; // get from https://remotemonitoringsystems.ca/time-zone-abbreviations.php

configTzTime(tz, ntpServer1, ntpServer2);

if (!getLocalTime(&timeinfo, 3000)) {
        Serial.println("Error getting time"); // will timeout after 3 seconds
}

Serial.printf("Time is %02d:%02d:%02d on %02d/%02d/%02d weekday %d\n",
            timeinfo.tm_hour,
            timeinfo.tm_min,
            timeinfo.tm_sec,
            timeinfo.tm_mday,
            timeinfo.tm_mon,
            1900 + timeinfo.tm_year,
            timeinfo.tm_wday);

@b18062a
Copy link
Author

b18062a commented Mar 17, 2019

Thank you very much, I'll give that a go in the near future :)

As a follow-up, for anyone else, I found that the first time the code runs on the ESP32 I get the "NACK" outcome but the following time around it works. I also found using a local NTP server (TPG) worked. Not sure why at this stage but it works.

#define NTP_SERVER 203,12,160,2 //TPG Server

and

#define TIMEZONE 0.5 // (for South Australia)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants