Skip to main content
added 454 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

YouThe esp8266 Arduino 3 has breaking changes so library authors need to adjust their libraries to this changes. Check the repository of the library for the fixes.

The NtpClient library was marked as deprecated by the author. The reason was that there is a better way to work with NTP on ESP. Now the library was 'restarted' as an alternative to SDK functions because the author solved microseconds accuracy.

If you don't need microseconds accuracy, you don't need to use Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }

You don't need to use Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }

The esp8266 Arduino 3 has breaking changes so library authors need to adjust their libraries to this changes. Check the repository of the library for the fixes.

The NtpClient library was marked as deprecated by the author. The reason was that there is a better way to work with NTP on ESP. Now the library was 'restarted' as an alternative to SDK functions because the author solved microseconds accuracy.

If you don't need microseconds accuracy, you don't need to use Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }
Post Undeleted by Juraj
added 8 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

Don'tYou don't need to use any Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }

Don't use any Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }

You don't need to use Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }
Post Deleted by Juraj
added 194 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

Don't use any Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The essentialNTP part isshould be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }

Don't use any Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The essential part is in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

Don't use any Arduino NtpClient library on esp8266 or esp32. The Espressif SDK have support to get the NTP time to internal RTC.

Both ESP Arduino cores have examples for NTP. For esp8266 it is the esp8266/NTP-TZ-DST example.

The NTP part should be in setup()

configTime(TIME_ZONE, "pool.ntp.org");

TIME_ZONE should be value from TZ_ constants from TZ.h, for example I have

#include <TZ.h>
#define TIME_ZONE TZ_Europe_Bratislava

The SDK will keep the time with the internal RTC of the ESP and adjust it periodically from NTP server.

You can get the esp8266 RTC time time with

time_t t = time(nullptr); // epoch
struct tm *tm = localtime(&t);
uint8_t minute = tm->tm_min;
uint8_t hour = tm->tm_hour;

if you want to wait in setup() until the time is retrieved you can use

  time_t now = time(nullptr);
  while (now < SECS_YR_2000) {
    delay(100);
    now = time(nullptr);
  }
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50
Loading