Skip to content

SARA R5 clock() function always starts from "15/01/01,00:00:00+00" #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Davefries1966 opened this issue Apr 1, 2025 · 7 comments
Closed

Comments

@Davefries1966
Copy link

Davefries1966 commented Apr 1, 2025

Hi all,
I wish to report a new issue regarding the use of the SparkFun Asset Tracker board (new sample) with an ESP32 processor in the Arduino development environment. When calling the clock() function from the SARA R5 library, I noticed that the time always starts from January 1, 2015, at 00:00:00 UTC, even though the RMC fixes show the correct time (today being April 1, 2025, etc.). Please note that I am using the board in Wi-Fi mode, without a SIM card. I also tried setting the clock using the m-center software, but the board does not retain the setting; every time it is powered off and on again, the time resets to January 1, 2015.

Thank you in advance for your support!

David Frittella

@PaulZC
Copy link
Collaborator

PaulZC commented Apr 1, 2025

Hi David (@Davefries1966 ),

I think this is possibly expected behaviour? If you disconnect the power, the SARA-R5 has no way to maintain its internal clock.

Are you asking if it is possible to sync the clock() from GNSS time (RMC)?

Best wishes,
Paul

@Davefries1966
Copy link
Author

Thank you, Paul, for your immediate feedback. This is the second unit of the Asset Tracker board that I am using. I am quite sure that on the first unit, the clock() function returned a time consistent with the GNSS fix. The only difference is that on the first unit, I had also activated the LTE SIM.

Anyway, the answer is yes, I would like to receive the GNSS time in the clock() function. Would it be possible?

Cheers,
David

@PaulZC
Copy link
Collaborator

PaulZC commented Apr 2, 2025

Hi David,

With the SIM activated, the R5 will sync its clock to the network. If the network is not available, you might expect it to sync to GNSS time instead. But, it seems not to be doing that.

You can set the clock manually. There are two setClock functions. Are you able to copy the ClockData from gpsGetRmc into setClock?

Best,
Paul

@Davefries1966
Copy link
Author

Davefries1966 commented Apr 2, 2025

I think so, actually I already tried. The library exposes two setClock() functions:

SARA_R5_error_t setClock(String theTime);

SARA_R5_error_t setClock(uint8_t y, uint8_t mo, uint8_t d, uint8_t h, uint8_t min, uint8_t s, int8_t tz);

I used the second one inside the gpsGetRmc() handling function, but I had the impression that the board experienced some issues after the modification...

The setClock() function does not alter anything during the board's operation, right? That is, system processes (threads, timers, etc.) remain unaffected?

Cheers,
David

P.S: Maybe I need to improve the validity checks for the RMC sentence...

@Davefries1966
Copy link
Author

Solved ! :-)

It can be closed.

Cheers
David

@PaulZC
Copy link
Collaborator

PaulZC commented Apr 4, 2025

Thanks David,

What was the solution?

Best,
Paul

@PaulZC PaulZC closed this as completed Apr 4, 2025
@Davefries1966
Copy link
Author

Sorry Paul, you are right. The solution was as suggested, that is, set clock (once) by the first valid GNSS fix:

  bool clockSet = false;

  if (valid) { // valid GNSS fix
    if (!clockSet) {
      setClock(clck.date.year, clck.date.month, clck.date.day, clck.time.hour, clck.time.minute, clck.time.second, 0);
      clockSet = true;
    }

  ...
}

Cheers and thanks again! :-)
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants