31#if defined(ARDUINO_ARCH_ESP32)
49const char *ssid =
"YOUR_SSID";
50const char *password =
"YOUR_PASS";
52const char *ntpServer1 =
"pool.ntp.org";
53const char *ntpServer2 =
"time.nist.gov";
54const long gmtOffset_sec = 3600;
55const int daylightOffset_sec = 3600;
57const char *time_zone =
"CST-8";
64void timeavailable(
struct timeval *t)
66 Serial.println(
"Got time adjustment from NTP, Write the hardware clock");
80 Serial.println(
"Failed to find PCF8563 - check your wiring!");
87 sntp_set_time_sync_notification_cb( timeavailable );
97 sntp_servermode_dhcp(1);
111 configTzTime(time_zone, ntpServer1, ntpServer2);
114 Serial.print(
"Connecting to ");
115 Serial.println(ssid);
116 WiFi.begin(ssid, password);
117 while (WiFi.status() != WL_CONNECTED) {
121 Serial.println(
" CONNECTED");
135 struct tm hwTimeinfo;
137 Serial.print(
"Hardware clock :");
138 Serial.println(&hwTimeinfo,
"%A, %B %d %Y %H:%M:%S");
142 if (!getLocalTime(&timeinfo)) {
143 Serial.println(
"No time available (yet)");
147 Serial.print(
"System clock :");
148 Serial.println(&timeinfo,
"%A, %B %d %Y %H:%M:%S");
156 Serial.begin(115200);
161 Serial.println(
"Examples only ESP32"); delay(1000);
bool begin(SensorCommCustom::CustomCallback callback)
Initialize device using a custom transport callback.
RTC_DateTime getDateTime() override
Read the RTC date and time.
Driver for the PCF8563 real-time clock (RTC) over I2C.
int hwClockWrite()
Write the current system time to the RTC clock chip.