GSM Network time synchronization for RTC using AT+CLTS command

Since i had started designing the VALTRACK GPS trackers, I have always had trouble with maintaining the correct time on the tracking device because once i remove the battery, the STM32 RTC lost its synchronization. I didnt have the space or luxury to maintain a separate backup battery for the STM32 RTC. 

So, i was only using the server time for the incoming packets where the time field was auto populated by the server side script. 
This method was ok for certain applications but we didnt have the method to know the delayed packets time (Which get re-sent later on failure). This is when i was looking for a method to calibrate and sync the MCU RTC to the right time on power on reset. 
I considered a few options, 

  1. Sync/set RTC clock with a  SMS command
  2. Sync RTC by bluetooth
  3. Sync RTC using a network time server
  4. Sync using network time. 

Sync/set RTC clock with a  SMS command : 

We implemented a command to set the RTC date and time by SMS. Its working fine. But this has to be done everytime the power is removed. 

Sync RTC by bluetooth : 

We implemented a command on the VALTRACK-V2 setup application and added a field to set date and time. This can be only done when you have physical access to the device and are nearby it.

Sync RTC using a network time server: 

We tried using a Network Time server using NTP protocol but this method is a waste of data and time and not reliable. We cannot send packets until there is a response from server.

Sync using network time : 

We then implemented this method where in the GSM module synchronizes its internal RTC and then we take the clock value of the GSM module and set the clock of our STM32 RTC. 

This method has been working fine so far as it doesn’t need any manual intervention for calibrating the time.  

Here are the commands i used: 

Command to read the GSM RTC clock : 


Command to enable GSM RTC network time sync : 

Command to save the command settings to memory so that the time is synchronized on every boot up automatically. 

Procedure : 

Read current time (You can see that the time is not right): 


+CCLK: “04/01/01,00:14:12+22”


Enable auto network time sync : 



Check if value is set : 


+CLTS: 1


Save the setting to permanent memory so that module enables sync on restart also  : 



Restart the module and check time  : 


+CCLK: “18/06/21,12:00:21+22”


As you can see the RTC of the GSM module is always set to network time using this method and you have to do this only once. 
For live demo watch the video below,



5 thoughts on “GSM Network time synchronization for RTC using AT+CLTS command”

    1. AT+CLTS? will says what value is already set.
      AT+CLTS=? will give what values can be set.

      It shouldn’t give any error, its a basic command and is available on all firmware’s. If you have doubt, you could try updating to latest available GSM module firmware.

Leave a Comment