Description
Platform
- Hardware: NodeMCU v3.2 ESP8266 (Ebay 252712258856)
- Core Version: 3.0.0
- Development Env: Arduino IDE 1.8.13
- Operating System: Windows 10
Settings in IDE
- Module: NodeMCU 1.0 (ESP-12E Module)
- Flash Mode: Not available in Tools menu
- Flash Size: 4MB
- lwip Variant: v2 Lower Memory
- Reset Method: Not available in Tools menu
- Flash Frequency: Not available in Tools menu
- CPU Frequency: 80Mhz
- Upload Using: Both OTA and serial
- Upload Speed: 115200
Problem Description
NTP sketch from https://randomnerdtutorials.com/esp8266-nodemcu-date-time-ntp-client-server-arduino/ , that worked fine before, suddenly gives incorrect date/year, example output before and after NTP timesync:
08:29:15
Epoch Time: 2085985755
Month day: 6
Week Day: Thursday
Month: 8
Month name: August
Year: -3135390
Current date: -3135390-8-6
19:19:31
Epoch Time: 1622834371
Month day: 2
Week Day: Friday
Month: 12
Month name: December
Year: -3135405
Current date: -3135405-12-2
The time after sync is correct, epoch too, day/month/year are not, in the case of the year it's very obvious something has gone wrong.
No errors were reported and I tracked down the cause to the ESP8266 3.0.0 board library. If I downgrade it, followed by a reflash of the sketch, the problem is gone and output looks as expected:
12:01:52
Epoch Time: 1622894512
Month day: 5
Week Day: Saturday
Month: 6
Month name: June
Year: 2021
Current date: 2021-6-5