WeatherDuino Forum
[Pro2 PLUS] Random date changes - Printable Version

+- WeatherDuino Forum (https://www.meteocercal.info/forum)
+-- Forum: WeatherDuino Pro2 Weather Stations (https://www.meteocercal.info/forum/Forum-WeatherDuino-Pro2-Weather-Stations)
+--- Forum: Hardware Questions (https://www.meteocercal.info/forum/Forum-Hardware-Questions)
+--- Thread: [Pro2 PLUS] Random date changes (/Thread-Pro2-PLUS-Random-date-changes)

Pages: 1 2 3 4 5 6 7


RE: Random date changes - Werk_AG - 31-10-2018

I was starting to become crazy with this issue, because these NTP and RTC sync functions are being in use since first WeatherDuino Pro2 PLUS versions, and nobody had reported a problem.
It also explains why I couldn't reproduce the problem, Despite I have installed IDE 1.8.5 and DE 1.8.6, I'm always using IDE 1.8.4

Seems we are in sync with the tests, ehehehe  Smile  Smile  Smile


RE: Random date changes - engolling - 31-10-2018

Since the delivered example of the RTC library is working, there might be somewhere a memory overflow in the sketch which gets "visible" due to some different compiler behavior.

Found this in the changelog:
ARDUINO 1.8.6 2018.08.23

[ide]
* Updated arduino-builder to 1.4.0:
- parallel build (improve compile speed)
- better reuse of already compiled files
- Windows: fixed build for sketch stored under OneDrive cloud folders


RE: Random date changes - engolling - 31-10-2018

Im seeing clearer now:

Compiled with IDE 1.8.7 BUT AVR Board 1.6.10 in the board manager
01:08:48.914 -> ESP8266 FW Version: AT+GMR
01:08:51.914 -> AT version:1.2.0.0(Jul  1 2016 20:04:45)
01:08:51.914 -> SDK version:1.5.4.1(39cb9a32)
01:08:51.961 -> Ai-Thinker Technology Co. Ltd.
01:08:51.961 -> Dec  2 2016 14:21:16
01:08:51.961 -> OK
RTC current date: Oct 31 2018
01:09:05.507 -> RTC current time: 01:09:04
01:09:05.507 -> Sending NTP request to sync clock...
NTP replied
01:09:05.554 -> RTC Time2: 1540948145
01:09:05.601 -> Local Time: 1540948145
01:09:05.601 -> UTC time from NTP server: 00:09:05
01:09:05.601 -> RTC adjusted to local time: 01:09:05
01:09:05.648 -> RTC current date: Oct 31 2018
01:09:05.648 -> RTC current time: 01:09:05
01:09:05.648 ->
01:09:05.648 ->
WiFi connection is ON


Compiled with IDE 1.8.7 BUT AVR Board 1.6.22 in the board manager
01:13:17.994 -> ESP8266 FW Version: AT+GMR
01:13:20.978 -> AT version:1.2.0.0(Jul  1 2016 20:04:45)
01:13:20.978 -> SDK version:1.5.4.1(39cb9a32)
01:13:21.025 -> Ai-Thinker Technology Co. Ltd.
01:13:21.025 -> Dec  2 2016 14:21:16
01:13:21.025 -> OK
RTC current date: Oct 31 2018
01:13:34.541 -> RTC current time: 01:13:33
01:13:34.588 -> Sending NTP request to sync clock...
NTP replied
01:13:34.822 -> RTC Time2: 1573607614
01:13:34.822 -> Local Time: 1540948414
01:13:34.869 -> UTC time from NTP server: 00:13:34
01:13:34.869 -> RTC adjusted to local time: 01:13:34
01:13:34.869 -> RTC current date: Oct 31 2018
01:13:34.916 -> RTC current time: 01:13:34
01:13:34.916 ->
01:13:34.916 ->
WiFi connection is ON

Compiled with IDE 1.8.7 BUT AVR Board 1.6.20 in the board manager
01:16:23.580 -> ESP8266 FW Version: AT+GMR
01:16:26.580 -> AT version:1.2.0.0(Jul  1 2016 20:04:45)
01:16:26.626 -> SDK version:1.5.4.1(39cb9a32)
01:16:26.626 -> Ai-Thinker Technology Co. Ltd.
01:16:26.626 -> Dec  2 2016 14:21:16
01:16:26.626 -> OK
RTC current date: Oct 31 2018
01:16:40.173 -> RTC current time: 01:16:39
01:16:40.173 -> Sending NTP request to sync clock...
NTP replied
RTC Time2: 1540948600
01:16:40.314 -> Local Time: 1540948600
01:16:40.314 -> UTC time from NTP server: 00:16:40
01:16:40.361 -> RTC adjusted to local time: 01:16:40
01:16:40.361 -> RTC current date: Oct 31 2018
01:16:40.361 -> RTC current time: 01:16:40
01:16:40.408 ->
01:16:40.408 ->
WiFi connection is ON


RE: Random date changes - Werk_AG - 31-10-2018

Good point!

On my IDE 1.8.4 I have AVR Board 1.6.21
and AVR Board 1.6.22 with IDE 1.8.6

Seems that the change on boards manager version is what is causing the problem.
At least we have an explanation for the mystery.


RE: Random date changes - Werk_AG - 31-10-2018

Seems that AVR Board 1.6.21 isn't even available to install in IDE 1.8.6

Engolling if you have to work today in the morning maybe its becoming late, we can continue tomorrow. Thank you for this brainstorm.


RE: Random date changes - Werk_AG - 31-10-2018

Some update:

With AVR Board 1.6.21

Code:
RTC.adjust(DateTime(year(), month(), day(), hour(), minute(), second()));

and
Code:
RTC.adjust(local);

both work, and give the same result, with AVR Board 1.6.22 only

Code:
RTC.adjust(local);

works! So, seems we have a fix that works on both versions, however I would like to know why the first instruction doesn't work with AVR Board 1.6.22. Something to investigate later.


RE: Random date changes - 41south - 31-10-2018

Excellent work gentlemen, have a well deserved break and sleep  Shy


RE: Random date changes - Werk_AG - 31-10-2018

Thanks.
Indeed all of this requires countless hours of work, and to make things better, we are always having surprises like this one. Smile


RE: Random date changes - Werk_AG - 31-10-2018

Code:
RTC.adjust(DateTime(year(local), month(local), day(local), hour(local), minute(local), second(local)));

Seems this should be the correct format. Works with IDE 1.8.4 (boards manager AVR Board 1.6.21) and with 1.8.6 ((boards manager AVR Board 1.6.22).
Not tested with IDE 1.8.7

Interestingly this is the format used on v7.0 b006, released 4 days ago (2018-10-27).


RE: Random date changes - engolling - 31-10-2018

Hi Werk,

do you really think that the reason for the misbehavior is, that the RTC is set wrong in association with the new version of AVR board?

Because in compiling with boards manager AVR Board 1.6.22 only the unixtime() function was faulty but the day(), month() and year() function were working properly. So I'm not convinced that this is the main reason. Moreover all functions were working fine with the example sketch provided by RTClib.

My assumption is, that somewhere is a hidden memory overflow somewhere in the sketch and the compiler optimizes differently when writing different code or having some changed code for the board functions.
Another point might be that I did not understand the problem  Blush

What do you think?

engolling