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
  • 898
  • 1
  • 13
  • 39
  • I just compiled that example fine no problem with 3.0.2. Maybe there's something broken about your Arduino / ESP8266 installation. – Majenko Jul 30 '21 at 18:17
  • Or maybe your libraries are out of date...? – Majenko Jul 30 '21 at 18:30
  • @Majenko - see installed version, IDE, and Example sktech fails – guyd Jul 30 '21 at 18:40
  • 1
    Don't use the library manager to install libraries. Download it direct from Github. You can pretty much guarantee that whatever is in the library manager will be out of date. – Majenko Jul 30 '21 at 18:50
  • @Majenko - Amazing!! You were right. I delted all NTPClient libraries, and reinstalled only from github... and its OK now. Thnk you – guyd Jul 30 '21 at 19:19

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
  • 17,050
  • 4
  • 27
  • 43
  • Firstly, thank you very much. Second, is there a way to update daylight saving automatically ? – guyd Jul 30 '21 at 20:20
  • 1
    @Guy.D, it adjusts for day light saving time automatically. I built an alarm clock with esp8266 and these functions. https://github.com/jandrassy/SunriseClock – Juraj Jul 31 '21 at 05:19
  • Tough your answer avoids the use of the library asked, but to mark it as an Answer, I need you to reff to Majenko's answer, that actually solved it. – guyd Jul 31 '21 at 07:39
  • @Guy.D, I updated the answer – Juraj Jul 31 '21 at 08:44