Obtaining time from local cell tower

I am using the XBee Cellular Cat 1 dev kit and plan to move to the LTE-M module once it is available. I see the example in the User’s Guide for obtaining the local time using the Daytime server. However, I’m looking for a production-level solution to obtain the local time over the air, preferably as UTC time. I know NTP is a better solution, but I’m quite space-limited on my microcontroller and was hoping for a solution that took less code space.

Is there a way to ask the local cell tower what time it is? I’m assuming the Telit module knows how to get the time from the local cell tower, but is that exposed to me through the Digi interface?

1 Like

The XBee Cellular provides localtime in MicroPython via the time.time() method, but there isn’t an AT command (yet) to retrieve that information.

If there was an AT command, what format would you want the data? Textually I’d imagine an ISO8601 formatted timestamp including timezone information. As an integer value, probably the number of seconds since 1/1/2000 (seems to be a common epoch), but you might also want a way to retrieve the time zone.

Thanks for the additional information. To be clear, does this mean the XBee Cellular updates its local time from the local cell tower, or is this just an interface to its RTC which may or may not have been set?

Yes, an ISO8601 formatted timestamp with timezone information would be ideal for me since that’s the mode I’m running my RTC. I assume there are others that would prefer the integer number of seconds since the epoch, but as you stated they would also need a way to get the time zone. Maybe two separate AT commands: one for an ISO8601 formatted timestamp and one for integer number of seconds with timezone information?

Yes, the XBee Cellular receives local time from the cell tower. Thanks for your feedback; I’ve added it to an open issue tracking the desire for an AT command to access local time.

You wouldn’t happen to know how much data a MicroPython time.time() consumes? I have been having a problem tracking my data use and using the Remote Manager does not seem to provide accurate information. I have a 5MB/Mo plan and am doing hourly uploads of sensor data to Udibots and an over use of this command could really increase cost ($2/MB overage). If an AT command were included, a one time time.time() could be used to set a real time clock which could last until the next reset. I am doing this in MP.

Perhaps LTE is better than older 3G/HSPA, but cell towers don’t always give the right time - actually, time’s usually okay, but date might be many days off (so on Thursday, your data has Tuesday’s date). Or you might get a date/time like Jan-1-2003, etc. Apparently, cell towers giving time is an “optional feature”, so not all do it. Also be careful because you’ll get local-time, so make sure you parse & handle time-zone correctly.

NTP is probably overkill for a small cellular ‘sensor’.

If you are using HTTP/HTTPS, then the safest solution is to use the required (not optional) UTC DATE field in the server response, which will be like “Date: Mon, 21 Nov 2016 21:11:56 GMT”. I do this, plus have a ‘tolerance’ like 10 seconds, so don’t change my RTC unless the server UTC is more than 10 seconds off.

To ‘boot-strap’ my RTC, I embed the FW build UTC in the firmware, and upon boot, make sure the RTC is never ‘older’ than the FW build time.


I hadn’t thought of this option. I don’t need anything too exact; seconds of jitter will be fine for my case so this should work fine even on slow connections. I also like that I don’t need to talk to an extra server for time. I’ll give this a try.

I don’t think time.time() generates any cellular traffic that would count toward your 5MB/month plan.