(30-10-2018, 23:44)Werk_AG Wrote: [ -> ]Yes, maybe the problem resides in the conversion form NTP time to unixtime
No, no... also no.
Timestamp from NTP is converted to Unixtime Timestampd here:
Code:
epoch = secsSince1900 - seventyYears;
I continue to get right values:
Code:
RTC Time: 1540939832
RTC Time2: 1540939848
Local Time: 1540939848
RTC Time: 1540939892
RTC Time2: 1540939908
Local Time: 1540939908
RTC Time: 1540939952
RTC Time2: 1540939969
Local Time: 1540939968
RTC Time: 1540940013
RTC Time2: 1540940028
Local Time: 1540940028
Hello, I still think the unixtime() function is behaving different.
I have an offset of 32659200 seconds which are exactly 378 days. So the time is always right and also the days, month and year is right, when i get it from RTClib with their special functions.
I flashed the ds3231 example provided by the library:
2018/10/31 (Wednesday) 0:0:36
since midnight 1/1/1970 = 1540944036s = 17835d
now + 7d + 30s: 2018/11/7 12:30:42
Returning the correct unixtime with
1540944036, so it is getting even more strange…
Update:
I tried to make my code exactly like in the example writing the result in "testvar"
Code:
DateTime testvar = RTC.now();
Serial.print("Timestamp: ");
Serial.println(now());
Serial.print("Timestamp RTC Unix: ");
Serial.println(testvar.unixtime());
Serial.println(RTC.now().year());
Serial.println(RTC.now().month());
Serial.println(RTC.now().day());
Serial.println(RTC.now().hour());
Serial.println(RTC.now().minute());
Serial.println(RTC.now().second());
same stuff:
Timestamp: 1540944934
Timestamp RTC Unix: 1573949734
2018
10
31
0
15
34
Can I send you the beta version with the serial prints that I'm using now, just to see what you get from it?
If yes, please send me you email again by PM.
Got it and uploaded it.
First response:
RTC current date: Oct 31 2018
RTC current time: 00:29:41
Sending NTP request to sync clock...
NTP replied
RTC Time2: 1595204982
Local Time: 1540945782
UTC time from NTP server: 23:29:42
RTC adjusted to local time: 00:29:42
RTC current date: Oct 31 2018
RTC current time: 00:29:42
WiFi connection is ON
Result of syncProvider_RTC(): 1595205026
Second response:
RTC current date: Oct 31 2018
RTC current time: 00:30:58
Sending NTP request to sync clock...
NTP replied
RTC Time2: 1595205058
Local Time: 1540945858
UTC time from NTP server: 23:30:58
RTC adjusted to local time: 00:30:58
RTC current date: Oct 31 2018
RTC current time: 00:30:58
Result of syncProvider_RTC(): 1595205102
Very interesting... however a mystery!
I'm always getting RTC Time2 = Local Time
Code:
RTC Time2: 1540942182
Local Time: 1540942182
Result of syncProvider_RTC(): 1540942226
RTC Time2: 1540942242
Local Time: 1540942242
Result of syncProvider_RTC(): 1540942286
RTC Time2: 1540942302
Local Time: 1540942302
Result of syncProvider_RTC(): 1540942346
RTC Time2: 1540942362
Local Time: 1540942362
Result of syncProvider_RTC(): 1540942406
RTC Time2: 1540942422
Local Time: 1540942422
Result of syncProvider_RTC(): 1540942466
RTC Time2: 1540942482
Local Time: 1540942482
Result of syncProvider_RTC(): 1540942527
RTC Time2: 1540942542
Local Time: 1540942542
Result of syncProvider_RTC(): 1540942586
To make it even worse… the same compiled and flashed with IDE 1.8.7 (added timestamp function of the serial monitor)
RTC current date: Oct 31 2018
00:40:33.270 -> RTC current time: 00:40:32
00:40:33.270 -> Sending NTP request to sync clock...
00:40:33.317 -> NTP replied
00:40:33.364 -> RTC Time2: 1573605633
00:40:33.364 -> Local Time: 1540946433
00:40:33.364 -> UTC time from NTP server: 23:40:33
00:40:33.410 -> RTC adjusted to local time: 00:40:33
00:40:33.410 -> RTC current date: Oct 31 2018
00:40:33.410 -> RTC current time: 00:40:33
00:40:33.457 ->
00:40:33.457 ->
WiFi connection is ON
Result of syncProvider_RTC(): 1573605677
So wrong epoch time varies with IDE version in my case
Update: Just downloading v1.8.4...
Yes! Yes.
I tested it right now with 1.8.6 and it mess everything!
Code:
Result of syncProvider_RTC(): 1550447026
ESP8266 FW Version: AT+GMR
AT version:1.2.0.0(Jul 1 2016 20:04:45)
SDK version:1.5.4.1(39cb9a32)
Ai-Thinker Technology Co. Ltd.
Dec 2 2016 14:21:16
OK
RTC Time2: 1550447041
Local Time: 1540943041
WiFi connection is ON
Result of syncProvider_RTC(): 1550447085
RTC Time2: 1550447120
Local Time: 1540943120
Result of syncProvider_RTC(): 1550447164
RTC Time2: 1550447180
Local Time: 1540943180