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

Cannot compile RTC.ino example #27

Closed
patfelst opened this issue May 1, 2022 · 2 comments
Closed

Cannot compile RTC.ino example #27

patfelst opened this issue May 1, 2022 · 2 comments

Comments

@patfelst
Copy link

patfelst commented May 1, 2022

Hi there, thanks for your great library. My question is related to PR #20

I cannot get the basic RTC.ino example to compile when I uncomment these lines to sync Core2 RTC with NTP

/* /// setup RTC ( NTP auto setting )
M5.Display.print("WiFi:");
WiFi.begin( WIFI_SSID, WIFI_PASSWORD );
configTzTime(NTP_TIMEZONE, NTP_SERVER1, NTP_SERVER2, NTP_SERVER3);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print('.');
delay(500);
}
Serial.println("\r\n WiFi Connected.");
M5.Display.print("Connected.");
while (sntp_get_sync_status() != SNTP_SYNC_STATUS_COMPLETED)
{
Serial.print('.');
delay(1000);
}
Serial.println("\r\n NTP Connected.");
time_t t = time(nullptr)+1; // Advance one second.
while (t > time(nullptr)); /// Synchronization in seconds
M5.Rtc.setDateTime( localtime( &t ) );
//*/

It is failing on line 55. I'm unsure how this can compile when it is an IDF framework function, not an Arduino framework function?
while (sntp_get_sync_status() != SNTP_SYNC_STATUS_COMPLETED)

I acknowledge this is not a M5 Unified issue, but any help would be appreciated because I get inconsistent results using a 1sec delay after calling sync with NTP. Sometimes it works, other times it syncs to an incorrect time.

Thankyou.

@lovyan03
Copy link
Collaborator

lovyan03 commented May 1, 2022

@patfelst
Thanks for reporting this Issue.
It seems that there was a missing header file that should be included.
Please try adding the following code to the top of the sample code.

#include <esp_sntp.h>

@patfelst
Copy link
Author

patfelst commented May 1, 2022

Yes thanks, that fixed the problem! And it works reliably now, good NTP sync every time!

In case anyone else is reading this, for my home location in Adelaide, Australia, this is the function call that's working for me:
configTzTime("ACST-9:30ACDT,M10.1.0,M4.1.0/3", "pool.ntp.org");

@patfelst patfelst closed this as completed May 1, 2022
@lovyan03 lovyan03 mentioned this issue Dec 24, 2022
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