Getting Time And Date from GSM Modem.

We can configure the GSM Modem to keep time. So there is no need for a separate RTC to keep time. These AT commands are supported  by the SIMCOM SIM900 and SIM800 series.

So the first step is to connect the modem to the computer. Then open a terminal using GtkTerm or PUTTY.

Send the following AT command.

AT+CLTS?

screenshot-from-2016-12-28-15-57-52

So if not configured the MODEM will reply +CLTS: 0. If the value returned is 0 it means network time updating is disabled.

Getting Time And Date from GSM Modem.

So let us make that value 1. Then we should write it permanently to the modem. &W is used to write the state permanently to Modem. So even if the modem is restarted CLTS will be enabled.

Send the following AT command

AT+CLTS=1;&W

Getting Time And Date from GSM Modem.

Now restart the modem using Software Restart command AT+CFUN=1,1 or you can hardware restart it.

AT+CFUN=1,1

Getting Time And Date from GSM Modem.

Now you can see after Call Ready there is a new line *PSUTTZ: which won’t be there during normal startup. It shows the date and UTC time. Year – 2016. Month – 12. Date – 28. Hour – 10. Minute – 30. Second – 7. +22 indicates the time zone expressed in quarters of an hour, between the local time and UTC; range -47 to +48. Here in India the IST is UTC + 5:30. In 5 hours and 30 minutes there are 22 quarters of an hour.

You can confirm whether the modem is in CLTS mode by sending AT+CLTS?

AT+CLTS?

Getting Time And Date from GSM Modem.

If the modem responds with 1, then CLTS mode is activated.

And finally to get the current time send AT+CCLK?

AT+CCLK?

Getting Time And Date from GSM Modem.

Modem will return the current local time in “yy/mm/dd,hh:mm:ss+/-zz” format.

If the GSM Modem is connected to an embedded board like arduino then you must send these AT commands via UART.

You can buy it from our store here.

Leave comment if  you found this helpful.

Advertisements

2 thoughts on “Getting Time And Date from GSM Modem.

  1. Hi!
    thank you for your article !
    The NITZ time update can also be done with “AT+CLTS=1” + “AT+COPS=2” + “AT+COPS=0” to get the local time from the provider.
    With this method you deregister from network (COPS=2) and switch back to automatic registration mode(+COPS=0), which forces a new connection and requires the NITZ packets.
    With this method the module does not need to be reset.

    My devices need the local time, because the device functionality is linked to the day/night behaviour of the user and their animals.
    Up to now, I have no interface to ask the user for the timezone.

    My problem is, that not all providers supply NITZ functionality and therefore this is not an option I can rely on for worldwide used mobile devices.

    As alternative there are the commands AT+CIPGSMLOC and AT+CLBS to get time information:
    Both location methods “AT+CIPGSMLOC=1,1” and “AT+CLBS=4,1” return usually the UTC time with the location.
    strangely “AT+CLBS=4,1” sometimes gives local time or UTC – which makes it obsolete for me as long as it can not be configured

    The third method is the connection to a time server via “AT+CNTP”, but for this i need to know the timezone in advance. So no option for me either.

    Do you know a way to get the local time instead of the UTC time based on the location of the device?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s