0

Since Core of ESP8266 upgraded to v.3.0 (now it is 3.0.2), I encounter errors using this library.

First, the deprecation of byte to uint8 (hoped that an upgrade of NTP lib to 3.0.2 beta will solve it ), but now even using library's built in example file fails, show the same message regarding byte error.

Is there a workaround ?

In file included from /home/guy/Documents/git/Arduino/libraries/NtpClientLib/examples/NTPClientESP8266/NTPClientESP8266.ino:38:
/home/guy/Documents/git/Arduino/libraries/NtpClientLib/src/NtpClientLib.h:501:32: error: reference to 'byte' is ambiguous
  501 |     bool summertime (int year, byte month, byte day, byte hour, byte weekday, byte tzHours);
      |                                ^~~~
In file included from /home/guy/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/cmath:42,
                 from /home/guy/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/math.h:36,
                 from /home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/Arduino.h:34,
                 from sketch/NTPClientESP8266.ino.cpp:1:

EDIT 1 :: VERSIONS

pic1 pic2 IDE+Sketch file

guyd
  • 1,049
  • 2
  • 26
  • 61

1 Answers1

1

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);
  }
Juraj
  • 18,264
  • 4
  • 31
  • 49