I am working on ESP32 And want to set RTC from the NTP server. How can I get epoch value I have done this thing on CC3200 launchpad and used an NTP server library to obtain epoch value.


this snippet from setup() sets on esp32 the NTP for internal RTC and uses epoch seconds to set time to TimeLib library.

  configTime(gmtOffset_sec, daylightOffset_sec, "pool.ntp.org");
  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    now = time(nullptr);

The ESP32 examples library in IDE examples folder has example SimpleTime.

  • 1
    Is configTime() a blocking function? Seems like it would have to be, seeing as how the Arduino is not a multi-tasking system.
    – Duncan C
    Jul 23 '20 at 12:07
  • @DuncanC, it is not blocking as you can see on the following while cycle. esp32 core is on esp32 RTOS SDK. arduino is one thread but configTime is a C function from SDK, so the function only activates SNTP
    – Juraj
    Jul 23 '20 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.