NTPClient
NTPClient copied to clipboard
Incorrect date/year with ESP8266 board 3.0.0
Recently I ran into the problem that the NTP-sketch from https://randomnerdtutorials.com/esp8266-nodemcu-date-time-ntp-client-server-arduino/ suddenly displays incorrect dates and year, time is correct. Example output before and after 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
I thought I'd tracked down the cause of the problem, this issue appeared after having updated the ESP8266 boards platform to 3.0.0, downgrading it and reflashing the sketch solves the problem.
Yesterday I reported it at https://github.com/esp8266/Arduino/issues/8118, but according to who responded, this problem is in the NTP library, it might have something to do with 32 and 64 bit time_t.
Exactly the same bug here, with the exception that no downgrade helped in my code. I've tried 3.2.0, 3.1.0 and 3.0.0. The version 2.0.0 seemd to be too old, since this doesn't even compile my code, which worked fine, the last months.
3.2.0? I wasn't referring to the version of the NTP library, but the ESP8266 board library. The most recent version for that is 3.0.0, To fix this problem that library (not the NTP library) has to be downgraded to 2.7.*
Oh, I'm sorry, I didn't read your post carefully enough and yes you're right, I downgraded the board library and the error disappeared.
this is scary, I did a grep -r for time_t in my $HOME/.arduino15 area and it was a random mix of 32 unsigned, 32 signed, and 64 unsigned (good!) types.
some from lwip, some from esp, some from other areas.
my god, this should really be cleaned up, somehow ;)
in this day and age, I'm not sure why we're not all using 64bit time_t types. anyone have a good reason why we're still stuck in 32 bit land for time types? didn't we already fix things back in y2k days? (half serious).
same problem here :(
I noticed that when I reboot the ESP8266 the date is correct at first, it's only when I update it that it goes wrong...
is someone working on this issue, or did you guys found a temporary fix (excluding the downgrade)?
Hello, I am having the same problem. I did downgrade the ESP8266 to 2.3.0 but it still showing me different date after a while.
Today is : friday
Current Time : 16:40:22
Current Time : 1636130422
Today is : friday
Current Time : 16:40:43
Current Time : 1636130443
Today is : thursday
Current Time : 14:28:16
Current Time : 2086007296
Today is : thursday
Current Time : 14:28:37
Current Time : 2086007317
Today is : thursday
Current Time : 14:28:58
Current Time : 2086007338
Today is : friday
Current Time : 16:42:08
Current Time : 1636130528
Use 2.7.4.
Use 2.7.4.
Changed to 2.7.4 but the time still changes and addition with error exception(9)
Exception (9):
epc1=0x4020c270 epc2=0x00000000 epc3=0x00000000 excvaddr=0x5a51327b depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffc40 end: 3fffffc0 offset: 0190
3ffffdd0: 00000000 00000001 3ffffe94 3ffeeb48
3ffffde0: 0000000b 3ffeeb10 3ffefc60 40206628
3ffffdf0: 3ffe88ef 000001bb 3ffefc60 40207550
3ffffe00: 3ffe89a3 0000003b 3ffefc60 40207980
3ffffe10: 0000003b 3ffffed0 0000002e 402043a0
3ffffe20: 3ffffe68 0000003b 3ffffe50 40208404
3ffffe30: 3ffeeb0c 3ffffe50 3ffe89a3 3ffffed0
3ffffe40: 3ffeeb0c 3ffffe94 3ffefc5c 40205c5b
3ffffe50: 3fff02c4 003b003f 00fffe94 3ffefd5c
3ffffe60: 0042004f 00000000 3fff01b4 004b004f
3ffffe70: 00fffee0 00000002 3ffefbd2 3ffffed0
3ffffe80: 3ffeeb0c 3ffe8920 3ffefd1c 402039dc
3ffffe90: 402079fc 3fff0168 3ffffed6 3ffe8540
3ffffea0: 3fffff40 3ffffed0 3ffe8764 40204364
3ffffeb0: 3ffffed8 4bc6a7f0 f3b645a1 3ffe8540
3ffffec0: 3fffff40 3ffefd1c 3ffeeb08 40204c55
3ffffed0: 3ffeeb48 3fff00f0 732f0029 4020a1ad
3ffffee0: 00000018 3ffeeb08 3fffff64 40204c96
3ffffef0: 00000001 3ffefbc4 3fffff40 40208404
3fffff00: 3fffff70 3fffff70 3fffff40 3ffe8540
3fffff10: 00000018 3ffeea5c 3fffff40 402089ce
3fffff20: 3ffe888e 3ffeea5c 3ffeeb68 40207dec
3fffff30: 00000018 3ffeea5c 3ffeeb68 40201366
3fffff40: 3ffefbc4 000e000f 06fe8a00 333a3000
3fffff50: 3ffe0037 80000028 3f003000 40208221
3fffff60: 807a1200 9e8c1342 3ffeeb00 80208240
3fffff70: 646e7573 00007961 86feeb68 333a3031
3fffff80: 00000037 85000000 00000001 40100154
3fffff90: 3fffdad0 00000000 3ffeeba4 3ffeebe4
3fffffa0: 3fffdad0 00000000 3ffeeba4 40209284
3fffffb0: feefeffe feefeffe 3ffe85fc 40100c75
<<<stack<<<
I think this is unrelated, for me it works fine, please post your code.
I commented out Firebase related stuff, and It works fine for me after hours of testing as well, I got no errors, the time is correct too on my Wemos D1 mini.
MEDICINE REMINDER SYSTEM Today is : sunday Current Time : 20:51:07 Current Time : 2021-11-7 Medicine For sunday is here (Medicine Not Taken) 0 0 1 20:51 Medicine for Today is taken! :)
Either your module is corrupted, or you don't use the 2.7.4 esp8266 board or this error is Firebase related.
Time is ok, but date is wrong for me too.
Really no intention to fix this since 2 years??