Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ethercard getNtpTime
unsigned long getNtpTime() {
unsigned long timeFromNTP;
const unsigned long seventy_years = 2208988800UL;
ether.ntpRequest(ntpServer, ntpMyPort);
Serial.println("NTP request sent");
while(true) {
word length = ether.packetReceive();
if(length > 0 && ether.ntpProcessAnswer(&timeFromNTP,ntpMyPort)) {
Serial.println("NTP reply received");
return timeFromNTP - seventy_years + timeZoneOffset;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.