WeatherDuino Forum

Full Version: Setting date and time problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello all.

I am finishing the construction of the station but I have one (last?) problem with time and date.
It is displayed in the format eg 222-13-2018 or Friday-222-Sunday-2018.
I have already replaced the DS3231 chip and tried different position settings eg:
 LATITUDE     52.475  or  LATITUDE   525,

on and off NPT server  but the problem did not go away.

Can anyone help me?

Sorry for my terrible English.

[Image: f0f29b3ffe70.jpg]
[Image: 268faa3608fd5.jpg][Image: 8f1bda026c5a8.jpg]
Hi jarekh3,

In first place, try to enable the NTP debug options by uncommented the line as show below:


Code:
// --------------------------------------------------------------------------------------
//   Debug helper
// --------------------------------------------------------------------------------------
//#define PRINT_DEBUG_WIFI
#define PRINT_DEBUG_NTP_UPDATE      // Prints to serial monitor messages related to sync time with NTP server

What you get on the serial monitor?
You can also enable the PRINT_DEBUG_WIFI options to check if you are getting WiFi connection, otherwise the NTP will not work.


Next check your auto summer time settings, here:

Code:
// --------------------------------------------------------------------------------------
//   Define rules for Auto Summer Time Display, and clock adjustment
// --------------------------------------------------------------------------------------
// Example for Australia Eastern Time Zone (Sydney, Melbourne)
// TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660};    //UTC + 11 hours
// TimeChangeRule aEST = {"AEST", First, Sun, Apr, 3, 600};    //UTC + 10 hours
// Timezone myTZ(aEDT, aEST);

TimeChangeRule PST = {"PST", Last, Sun, Mar, 1, 60};   //Portuguese Summer Time -  "UTC + 1" or GMT + 1
TimeChangeRule GMT = {"GMT", Last, Sun, Oct, 2, 0};    //Portuguese Winter Time -  "UTC + 0" or GMT
Timezone myTZ(PST, GMT);


There is also another way you could try to force the clock to sync:
On the examples folder of the RTClib library, there is a sketch called ds3231.ino, compile it and upload to your Meduino. Your clock should be working correctly now.
(08-09-2018, 20:07)Werk_AG Wrote: [ -> ]Hi jarekh3,

.........
What you get on the serial monitor?
You can also enable the PRINT_DEBUG_WIFI options to check if you are getting WiFi connection, otherwise the NTP will not work.
......


Monitor:
Code:
21:36:08.713 -> OK
21:36:08.713 -> IP Address: 192.168.1.116
21:36:08.713 -> Broadcast IP: 192.168.1.255
21:36:08.713 -> Start tcp server OK
STATUS:2
21:36:08.821 -> Set tcp server timout 30 seconds
21:36:08.821 -> RTC current date: Mar 109 2018
21:36:08.857 -> RTC current time: 21:36:07
21:36:08.857 -> Sending NTP request to sync clock...
NTP replied
21:36:09.001 -> UTC time from NTP server: 19:36:08
21:36:09.001 -> RTC adjusted to local time: 20:36:08
WiFi connection is ON

Config_Options.H
Code:
// --------------------------------------------------------------------------------------
//   Define your Weather Station location. Use decimal format for Latitude and Longitude
// --------------------------------------------------------------------------------------
#define LATITUDE      52.475    // Put here your Station latitude in degrees North (always use 3 decimal places)
#define LONGITUDE     16.767    // Put here your Station longitude in degrees - minus for West (always use 3 decimal places)
#define ELEVATION     86       // Put here your Station height above sea level in Meters (no decimal places)


// --------------------------------------------------------------------------------------
//   Define rules for Auto Summer Time Display, and clock adjustment
// --------------------------------------------------------------------------------------
// Example for Australia Eastern Time Zone (Sydney, Melbourne)
// TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660};    //UTC + 11 hours
// TimeChangeRule aEST = {"AEST", First, Sun, Apr, 3, 600};    //UTC + 10 hours
// Timezone myTZ(aEDT, aEST);

TimeChangeRule PST = {"PST", Last, Sun, Mar, 1, 120};   //Portuguese Summer Time -  "UTC + 1" or GMT + 1
TimeChangeRule GMT = {"GMT", Last, Sun, Oct, 2, 60};    //Portuguese Winter Time -  "UTC + 0" or GMT
Timezone myTZ(PST, GMT);

Set with sketch from library:
Code:
2018/9/8 (Saturday) 20:50:0
21:50:01.782 ->  since midnight 1/1/1970 = 1536439800s = 17782d
21:50:01.836 ->  now + 7d + 30s: 2018/9/16 9:20:6
21:50:01.882 ->
2018/9/8 (Saturday) 20:50:3
21:50:04.847 ->  since midnight 1/1/1970 = 1536439803s = 17782d
21:50:04.894 ->  now + 7d + 30s: 2018/9/16 9:20:9
21:50:04.948 ->
2018/9/8 (Saturday) 20:50:6
21:50:07.904 ->  since midnight 1/1/1970 = 1536439806s = 17782d
21:50:07.957 ->  now + 7d + 30s: 2018/9/16 9:20:12
21:50:08.004 ->
2018/9/8 (Saturday) 20:50:9
21:50:10.973 ->  since midnight 1/1/1970 = 1536439809s = 17782d

Results:
Without NPT  date :  06-13-2018
With NPT  date: 109-03-2018
Time is ok.
I did all these steps yesterday ..... Huh
Hi,
It seems that the ds3231.ino sketch was set the date and time correctly.

Please check if you are using the Time library supplied with the software package and not any other (newer or older).
(09-09-2018, 22:08)Werk_AG Wrote: [ -> ]Hi,
It seems that the ds3231.ino sketch was set the date and time correctly.

Please check if you are using the Time library supplied with the software package and not any other (newer or older).

Yes, this library from software package. I remove all old libraries before install.

Today is date: Sunday 1 April 2018  Sleepy

Time is wrong, set UTC+120 min but display UTC+60min
Code:
23:38:50.415 -> Set tcp server timout 30 seconds
23:38:50.451 -> RTC current date: Apr 01 2018
23:38:50.451 -> RTC current time: 22:38:48
23:38:50.487 -> Sending NTP request to sync clock...
NTP replied
23:38:50.595 -> UTC time from NTP server: 21:38:50
23:38:50.595 -> RTC adjusted to local time: 22:38:50
Code:
TimeChangeRule PST = {"PST", Last, Sun, Mar, 1, 120};   //Portuguese Summer Time -  "UTC + 1" or GMT + 1
TimeChangeRule GMT = {"GMT", Last, Sun, Oct, 2, 60};    //Portuguese Winter Time -  "UTC + 0" or GMT
Timezone myTZ(PST, GMT);
 Aaaa...    Arduino 1.8.6
[Image: c62ea37d7973.jpg]
Unfortunately I can't understand why the date isn't set properly.
Everything in your TimeChangeRule seems correct, so the time should also be set correctly.

Lets try another approach: Put the Program/Run switch in Run position, connect the USB cable to PC and start Cumulus (configure it first, at least the com port and station type). When Cumulus starts is should also sync the station clock with the PC clock.
Cumulus ver. 1.9.4
port 15
Vantage Pro Vue
switch VP1 -
close

" Error -32701 while trying to initialise the station...."
Perhaps Serial Monitor is open, it should be closed before starting Cumulus.
(10-09-2018, 00:03)Werk_AG Wrote: [ -> ]Perhaps Serial Monitor is open, it should be closed before starting Cumulus.

No, Arduino is closed.

moment....

i set COM 7 and connected!


.....
....

And now 2 April 2018   Big Grin


Cumulus receives data but second dot on display RX is red (green-red-green)
I really don't know what is happening...

Take a look at in the Cumulus diags folder, open the file cumulus.xxx with a text editor.
around line 80 you should see something like this:

Code:
01-09-2018 06:04:27.414 : VP2: Setting station clock
01-09-2018 06:04:27.415 : y=2018 m=9 d=1 h=6 m=4
01-09-2018 06:04:28.581 : VP2: SetStationTime_V res = 0
01-09-2018 06:04:28.581 : VP2: Getting station clock
01-09-2018 06:04:29.153 : VP2: GetStationTime_V res = 0
01-09-2018 06:04:29.153 : y=2018 m=9 d=1 h=6 m=4

Cumulus tries to set the clock too.


Quote:Cumulus receives data but second dot on display RX is red (green-red-green)

Don't worry with this for now, its related to WU upload, which should be disabled until you have everything working properly. Anyway it will fail, as the data and time is on the past.
Pages: 1 2 3