I have been trying to figure out how ESP32 Built in "time.h" library Syncs with NTP. Mainly I am trying to figure out the interval at which it syncs. I have seen some forums state that the getLocalTime function sends an NTP request. I don't know if that is the case. the way I currently understand it is the following:
configTime called in the setup loop syncs time with NTP server.
getLocalTime function reads the internally kept Time.
"behind the scenes" the ESP32 library periodically synchronizes with NTP Server.
Is this understanding correct?
If so, how often does the ESP32 sync it's time. If it does not sync it's time, what function do I need to use to sync it every couple days?
If the getLocalTime function is making an NTP request on every call, How do I stop that so that I don't do that every 10 ms or whatever my sample time is set to? Seems that would not be good practice to make an NTP request every 10mS but I need to get a fast update time in my script.
I found the answer. it appears that it does work as I suspect. SNTP ESP32 info
An application with this initialization code will periodically synchronize the time. The time synchronization period is determined by CONFIG_LWIP_SNTP_UPDATE_DELAY (default value is one hour). To modify the variable, set CONFIG_LWIP_SNTP_UPDATE_DELAY in project configuration.
and in the arduino ESP32 module the config time calls the init function.
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
//tcpip_adapter_init(); // Should not hurt anything if already inited