# \`card.location\` time in UTC?

**URL:** <https://discuss.blues.com/t/card-location-time-in-utc/565>\
**Category:** Uncategorized\
**Created:** [December 17, 2021, 6:35pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565 "2021-12-17T18:35:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gauteh](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/gauteh/32/269_2.png) [@gauteh](https://discuss.blues.com/u/gauteh)\
**Post date:** [December 17, 2021, 6:35pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/1 "2021-12-17T18:35:41Z")

</div>

I need time in UTC as accurately as possible, is the `time` from `card.location` always UTC as retrieved from the GPS?

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [December 18, 2021, 6:14pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/2 "2021-12-18T18:14:21Z")

</div>

Yes, it’s “always UTC” in the sense that it’s a UNIX timestamp (specifically elapsed seconds since Jan 1st 1970 00:00 UTC). The Notecard will always update its internal clock to maintain the most accurate time whenever it connects to a cell tower.

---

<div class="post-metadata">

**Author:** ![gauteh](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/gauteh/32/269_2.png) [@gauteh](https://discuss.blues.com/u/gauteh)\
**Post date:** [December 18, 2021, 6:30pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/3 "2021-12-18T18:30:56Z")

</div>

Ok, thanks. So it is based on cellular and not GPS? From the docs I can see that [card Requests - API Reference - Blues Wireless Developers](https://dev.blues.io/reference/notecard-api/card-requests/#card-time) is based on cellular, but that one is also not UTC.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [December 19, 2021, 5:22pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/4 "2021-12-19T17:22:26Z")

</div>

The Notecard uses the cellular network time the first time it connects after initial power-up. Upon syncing with Notehub, it uses the time provided from Notehub. We do trust the GPS and the Notehub-provided times equally. All of the times are UNIX timestamps, which are based on UTC.

---

<div class="post-metadata">

**Author:** ![vstadmin](https://avatars.discourse-cdn.com/v4/letter/v/439d5e/32.png) [@vstadmin](https://discuss.blues.com/u/vstadmin)\
**Post date:** [December 20, 2021, 2:18pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/5 "2021-12-20T14:18:33Z")

</div>

So, what happens in Y2038? I’ve have begun hearing a lot of chatter about Unix Datestamps and the 2038-pocolypse.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [December 20, 2021, 3:46pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/6 "2021-12-20T15:46:52Z")

</div>

Valid question, even though we are a few years away 🙂

In a nutshell:

- Notehub should have few, to no, issues.
- Notecard will have some issues but nothing involving more than several days of work
- The integrated cjson portion of the C API libraries, which are currently focused on being optimal for MCUs with very small amounts of SRAM, will need to be enhanced to default to 64-bit, and we will likely do this through a compilation flag.

---

<div class="post-metadata">

**Author:** ![vstadmin](https://avatars.discourse-cdn.com/v4/letter/v/439d5e/32.png) [@vstadmin](https://discuss.blues.com/u/vstadmin)\
**Post date:** [December 20, 2021, 3:53pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/7 "2021-12-20T15:53:25Z")

</div>

OK. Just asking. I was around for and quite active in fixing Y2K for a company back then and that was 22 years ago now. 22 years from NOW will be 2044.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [December 20, 2021, 3:56pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/8 "2021-12-20T15:56:08Z")

</div>

Yes, that is surreal (and mildly depressing 🙂)

---

<div class="post-metadata">

**Author:** ![gauteh](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/gauteh/32/269_2.png) [@gauteh](https://discuss.blues.com/u/gauteh)\
**Post date:** [May 30, 2022, 9:14am UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/9 "2022-05-30T09:14:04Z")

</div>

Does that mean that GPS time is never used, but only cellular time? So if the notecard connects to a tower, gets the time, and is then without service for a long time it is only using its internal clock? Not the time from GPS?

---

<div class="post-metadata">

**Author:** ![seant](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@seant](https://discuss.blues.com/u/seant)\
**Post date:** [May 30, 2022, 2:58pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/10 "2022-05-30T14:58:03Z")

</div>

@gauteh The notecard can set its time from 3 sources

- Notehub - each time it connects to Notehub. I’m afraid I don’t know the guaranteed accuracy of the Notehub clock, but I can check if this is particularly important.
- From the cellular network
- From the GPS receiver (RMC NMEA sentence when the fix is valid).  
While the Notecard has power the time is maintained by the Notecard’s CPU’s RTC which uses a precision 32.768kHz crystal oscillator which has better than 250ppm over -40C to +85C.  
GPS is extremely power hungry, so the Notecard will never autonomously enable GPS in order to update the RTC.

---

<div class="post-metadata">

**Author:** ![gauteh](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/gauteh/32/269_2.png) [@gauteh](https://discuss.blues.com/u/gauteh)\
**Post date:** [May 30, 2022, 6:23pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/11 "2022-05-30T18:23:16Z")

</div>

Thank you. Does the accuracy of the time from the Notehub depend on connection latency? What is the overall accuracy of the system (maximum deviation). Do you use PPS from GPS? Maybe using time from a less accurate source after a recent fix + RTC deteriorate the quality of the time. I’ve seen a discrepancy of about 1 second over 4-5 hours, but I’ve so far attributed that to GPS getting a fix (which doesn’t quite make sense when I think about it, compared to an IMU sampling so there could be issues there as well).

---

<div class="post-metadata">

**Author:** ![seant](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@seant](https://discuss.blues.com/u/seant)\
**Post date:** [May 30, 2022, 11:32pm UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/12 "2022-05-30T23:32:02Z")

</div>

The current accuracy of the Notecard is around +/- 2 seconds. We do not use PPS- only the RMC sentence time. I would expect the drift of the time to be low due to the high accuracy / stability crystal we use for the CPU RTC, but the absolute accuracy is certainly not sub-second.  
I will review both our GPS receiver and the firmware to see if this could be improved in future firmware releases, but for the time being if your application requires 1s or better accuracy the quickest solution may be to use an external GPS receiver.

---

<div class="post-metadata">

**Author:** ![gauteh](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/gauteh/32/269_2.png) [@gauteh](https://discuss.blues.com/u/gauteh)\
**Post date:** [May 31, 2022, 8:57am UTC](https://discuss.blues.com/t/card-location-time-in-utc/565/13 "2022-05-31T08:57:08Z")

</div>

Thanks. Better timing would be very useful for me, especially when the GPS is working I would expect the time to be quite accurate. As you say the RTC drift between each fix is probably much less than the inaccuracy in the different timing sources. If GPS is active regularly it would maybe be best to just use the GPS time + RTC.
