Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Telit Cinterion IoT Developer Community

Use EHSx Time Zone Reporting function to update RTC

Tutorial, March 14, 2016 - 9:09am, 7183 views

Sometimes we would like to query current time from EHSx module, via AT+CCLK? command; however in most cases the return timestamp is not what we expect to see. 

This is because by default the EHSx start it's RTC from 04/01/01,00:00:00 during every boot, we have to set it once to current time so that it can report right time in the subsequent query.

Here are steps one can follow to setup EHSx RTC via the AT+CTZR=1 Time Zone Report command: 

1. Make sure a valid SIM card is inserted to your device so that EHSx can use it.

2. Use AT+CTZR=1 to turn on time zone reporting; the two URCs

+CTZV: <timezone>, <time> and +NITZINFO: <timezone_variance>, <time> will report current timestamp <time> once the EHSx is camping on a mobile network.

3. Use AT+COPS=2, follow-by AT+COPS=0 to get the +CTZV / +NITZINFO URCs, and extract the <time> for setting up RTC.

4. use "AT+CCLK=<time>" to store current timestamp.

Ex.

During EHS6 boot-up,

 [Wed Mar 09 10:29:10.870 2016] ^SYSLOADING

[Wed Mar 09 10:29:11.087 2016] 

[Wed Mar 09 10:29:11.087 2016] ^SYSSTART

[Wed Mar 09 10:29:11.997 2016] 

[Wed Mar 09 10:29:11.997 2016] +PBREADY

[Wed Mar 09 10:36:51.761 2016] AT+CPIN?

[Wed Mar 09 10:36:54.569 2016] +CPIN: READY

[Wed Mar 09 10:36:54.578 2016] 

[Wed Mar 09 10:36:54.578 2016] OK

[Wed Mar 09 10:36:55.024 2016] AT+COPS=2

[Wed Mar 09 10:36:58.057 2016] OK

[Wed Mar 09 10:36:59.257 2016] AT+CTZR=1

[Wed Mar 09 10:37:04.479 2016] OK

[Wed Mar 09 10:37:06.129 2016] AT+COPS=0

[Wed Mar 09 10:37:19.270 2016] OK

[Wed Mar 09 10:37:19.401 2016] 

[Wed Mar 09 10:37:19.401 2016] +CTZV: +32,"16/03/09,10:37:19"

[Wed Mar 09 10:37:19.427 2016] 

[Wed Mar 09 10:37:19.427 2016] +NITZINFO: "GMT+08:00","16/03/09,10:37:19"

[Wed Mar 09 10:37:23.816 2016] AT+CCLK="16/03/09,10:37:19"

[Wed Mar 09 10:37:26.459 2016] OK

[Wed Mar 09 10:38:18.983 2016] AT+CCLK?

[Wed Mar 09 10:38:21.225 2016] +CCLK: "16/03/09,10:38:13" 

Based on the knowledge, we can wrap the used AT commands inside a Java MIDlet so that a Java module can setup it's RTC automatically once it has camped on one network.

The attached zip file is a Java MIDlet project shows this flow in Java form, Java user can use this project to extend applications that has to access wall clock time.

To use this demo MIDlet, one has to

1. Unpack the file into some folder, then Import the project file into Eclipse IDE.

2. Open and expand the project to find the Application Descriptor of this project, click to open it.

3. Modify the PIN code you'll use in the User Defined tab, under the key AutoRtcUpdate-SIMPIN

4. Prepare the EHSx HW, maybe a Concept board or an EHS6T terminal, connect to Eclipse IDE.

5. Run and see the output of the MIDlet from Eclipse Console.

Feel free to discuss and contribute your version of RTC update algorithm here.

Download File AutoRtcUpd.zip (zip | 101.61 KB)

Hello,

It is a good idea to synchronize the RTC with the network time or NTP on application start, especially when the accurate time is critical.

But the RTC should not reset with every boot, only when the power is cut off. After setting AT+CTZU=1 the RTC can be updated automatically after receiving +NITZINFO update.

Regards,

Bartłomiej

Is it also required to first deregister from network? Or is it also possible to save these settings with AT&F and with next startup the timezone information will also be retrieved from the network?

Hi,

This AT Command uses the network feature called "NITZ". It is not available on all network operators worldwide.

Where it is available you tend to get the NITZ (time) information when you do a "Location Update" this happens (i) when you boot the module or (ii) when you toggle Airplane Mode with AT+CFUN=4 then AT+CFUN=1.

You need to issue AT+CTZU=1 before the module tries to register or before you toggle airplane mode.

Author

antonyshen's picture
antonyshen