Skip to content

sntp NIST time server #231

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

Closed
kas2 opened this issue Feb 24, 2017 · 3 comments
Closed

sntp NIST time server #231

kas2 opened this issue Feb 24, 2017 · 3 comments

Comments

@kas2
Copy link

kas2 commented Feb 24, 2017

Hi,

I am currently getting date and time using NIST Internet Time Service with my ESP8266.
when porting my code to ESP32, I get following error messages:

error: 'sntp_set_timezone' was not declared in this scope
error: 'sntp_get_current_timestamp' was not declared in this scope
error: 'sntp_get_real_time' was not declared in this scope

I checked the ESP32 "sntp.h", and strangely enough, those 3 functions are not declared in this file

What am I missing ??
Any sntp demo code available ??
TIA

@me-no-dev
Copy link
Member

Not a clue :) maybe ask in ESP-IDF? sntp.h is part of IDF.
Here is what I use to setup/read time

#include "time.h"
void printLocalTime()
{
    struct tm timeinfo;
    if(!getLocalTime(&timeinfo)){
        Serial.println("Failed to obtain time");
        return;
    }
    Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}

configTime(-7200, 3600, "pool.ntp.org");

You can check the configTime source for how it works.

@kas2
Copy link
Author

kas2 commented Feb 24, 2017

Thanks me-no-dev for your fast response,
and kudoos for your ongoing hard work

@kas2 kas2 closed this as completed Feb 24, 2017
@me-no-dev
Copy link
Member

:) glad it helped

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