Yet Another ESP32 NTP Question (Looping / Update Interval)

Pardon my complete ignorance, but I'm guessing that by referencing time.h and/or configTime and setenv I am including references to the esp_sntp.h library because that code itself calls on or relies on sntp library functions?

I mention this because I have seen a few examples that have includes for sntp.h libraries, and many others (such as the one that I borrowed) that do not. And yet if I understand correctly all of them have sntp code running in the background simply by referencing time.h or calling configTime or other functions that are related.

What throws me off is that if the existing code already required sntp functionality, I would have expected one of those libraries to have an include <esp_sntp.h> themselves, and adding the sntp_set_sync_interval() line should not have thrown an error.

That's a false assumption. Consider the simple example below. The setup() function calls function1() which in turn calls function2(). But setup() can't call function2() directly:

Main .ino:

#include "Library_1.h"

void setup() {
  function1();    // <--- Call OK
  //function2();  // <--- Causes error 
}

void loop() {
}

Library_1.h:

#ifndef LIBRARY_1
#define LIBRARY_1

void function1();

#endif

Library_1.cpp:

#include <Arduino.h>
#include "Library_1.h"
#include "Library_2.h"

void function1() {
  function2();
}

Library_2.h:

#ifndef LIBRARY_2
#define LIBRARY_2

void function2();

#endif

Library_2.cpp:

#include <Arduino.h>
#include "Library_2.h"

void function2() {

}

C is new(er) to me, so I usually learn something every day. I thought that because the include <> reference existing anywhere in the chain of files that it could be referenced by any other module.

Unsurprisingly, I've got more reading to do lol.

Thanks for clearing this up for me.

I finally got a few minutes to play around with this... among other things, I confirmed that the ESP32 time functionality does account for DST - even if WiFi has been disabled... I used the Offset command to set the time to 11/2/25 01:59, which is a minute before DST ends in my timezone. You can see the ESP32 clock transitions at what would be 2AM back to 1AM for the 'fall back' time change. This is perfect - and means I don't have to worry about and DST logic myself.

Thanks so much for the help !!!

09:17:59.609 -> Local Time: Sunday, November 02 2025 01:59:58 EDT
09:17:59.609 -> Sync Status: Reset, Remaining Time to Adjust: 0us
09:17:59.654 -> 
09:18:00.656 -> Local Time: Sunday, November 02 2025 01:59:59 EDT
09:18:00.656 -> Sync Status: Reset, Remaining Time to Adjust: 0us
09:18:00.656 -> 
**09:18:01.612 -> Local Time: Sunday, November 02 2025 01:00:00 EST**
**09:18:01.612 -> Sync Status: Reset, Remaining Time to Adjust: 0us**
09:18:01.612 -> 
09:18:02.648 -> Local Time: Sunday, November 02 2025 01:00:01 EST
09:18:02.648 -> Sync Status: Reset, Remaining Time to Adjust: 0us

Yes, that was an implication of what I said in Post #9:

I'm a simpleton lol - implication and confirmation / understanding are two different things in my feeble mind :wink:

Appreciate the help!