Getting time from cellular network before Particle Cloud connection on Boron

I’m working with a Particle Boron gen 3 and I want to know if it’s possible to get the current time from the cellular tower in this situation:

  • Can I run the AT command AT+CCLK on the Boron before it ever connects to the Particle Cloud?

  • Will this return the correct current time from the carrier even if the Boron has never synced with Particle Cloud yet?

  • Are there any limitations or caveats I should be aware of when relying on network-provided time for scheduling events immediately after boot?

The goal is to keep a relay schedule running accurately even if the Boron hasn’t connected to the cloud yet but was powered on in a location that has cellular service.

It's very unlikely that the device will connect to cellular, but not to the cloud, that is to say it's stuck at blinking cyan, not blinking green. Once connected to the cloud the second thing that's done is the time is synchronized. At boot the cellular modem does not know the time.

It's theoretically possible to use the AT command to get the tower time, but you'd have to manage it manually because the built-in functions will use it. You could set the Device OS Time functions from the cellular clock, but it will be reset after connecting to the cloud.

If you really need accurate time all the time, I'd use an external I2C RTC. One option is the AB1805/AM1805, which is the RTC/Watchdog used on the Tracker, but there are others that also work well. Using the AB1805 with the Boron is well documented.

Hey @oraclerouter ,

if you decide to go with an RTC like the AB1805, there’s this fantastic carrier spearheaded by @chipmc that can help you:

Best,

As always, I really appreciate the quick response and recommendations. I’ll take them into consideration. Thanks guys!

@rickkas7 One more question how often does the LocalTimeRK library sync time with the cloud during normal operation

Particle devices in general synchronize time to the cloud automatically on cloud connection. This includes boot, restart, and wake from sleep modes where network is off or cloud disconnected during sleep.

Once connected, the time is not synchronized unless you call Particle.syncTime.

When using AB1805_RK, at startup it can set the Device OS time from the hardware RTC. It also detects when the device has synchronized time to the Particle cloud, and then updates the hardware RTC to match cloud time.

The Tracker does the same time synchronization as AB1805_RK.

LocalTimeRK just uses the underlying Device OS Time class, which can come from the cloud or be set manually based on an RTC.

You can counter the drift on the Boron’s local clock by forcing a time sync every 24hs or so:

https://docs.particle.io/reference/device-os/api/cloud-functions/particle-synctime

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.