Obtain Time From GSM netwok using SIM900

Instead of using a Realtime Clock if the Project is already using a SIM 900 module then you can obtain correct Date and Time from the NTP Server GSM Network using the following commands.

AT

OK If your response contains this, This string should tell you all is well

AT+CMGF=1

OK If your response contains this, This string should tell you all is well(Set SMS Text Mode )

AT+CENG=3

OK If your response contains this, This string should tell you all is well(command is used to turn on the engineering mode to get detailed network information)

AT+CCLK?

+CCLK: “16/01/12,07:33:42+00”
If the response is OK then you will get date and time in above format.
Date – YY/MM/DD format

 

SIM 900 Network Time

GPRS using SIM900 and AT Commands

sim900-gprs-gsm-module-arduino-compatible

Powerup the Sim900 module
connect it to the system through serial to USB or through FTDI cable.The TTl pins for FTDI is available near to the DB9 connector.

Open any serial Terminal porogram. In Linux i use GtkTerm. Select the correct port and set
Baudrate = 9600
parity = None
Bits = 8
Stop bits = 1
Flow Control = None

Screenshot from 2015-11-26 12:49:46

 

Screenshot from 2015-11-25 20:00:44

 

The AT Commands

I am posting the commands and its reply for better understanding. I am using an Airtel postpaid sim card.
Make sure you have enough balance on Sim card.

First Command

AT

OK If your response contains this, This string should tell you all is well

This is to check if SIM is unlocked.

AT+CPIN?

+CPIN: READY If your response contains this, then it means SIM is unlocked and ready

This checks if SIM is registered or not

AT+CREG?

+CREG: 0,1 This string in the response indicates SIM is registered

Check if GPRS is attached or not

AT+CGATT?

+CGATT: 1 A response containing this string indicates GPRS is attached

Reset the IP session if any

AT+CIPSHUT

SHUT OK This string in the response represents all IP sessions shutdown.

Check if the IP stack is initialized

AT+CIPSTATUS

STATE: IP INITIAL This string in the response indicates IP stack is initialized

single connection mode,if AT+CIPMUX=1 multi connection mode

AT+CIPMUX=0

OK This string indicates single connection mode set successfully at SIM 900

This sets the PDP context parameters such as PDP type (IP, IPV6, PPP, X.25 etc), APN, data compression, header compression etc.

AT+CGDCONT=1,"IP","airtelgprs.com"

OK If your response contains this, This string should tell you all is well

you need to know the APN, username and password for your service provider
AT+CSTT= “APN”, “UNAME”, “PWD”
For Airtel

AT+CSTT="airtelgprs.com"

OK If your response contains this, This string should tell you all is well

Bring up the wireless. The response to this might take some time

AT+CIICR

OK indicates wireless is up

Get the local IP address

AT+CIFSR

aa.bb.xx.yy If previous command is successful, you should an IP address in the response

comamnd returns the current connection status

AT+CIPSTATUS

STATE:IP STATUS if not this, some thing is wrong

Start the connection, TCP, domain name, port

AT+CIPSTART= "TCP","flaskprint.herokuapp.com","80"

CONNECT OK This string in the response indicates TCP connection established

Request initiation of data sending

AT+CIPSEND

The response should be the string “>” to indicate, type your data to send
Type anything after the prompt
>This is the Test Data
Now use Ctrl+Z key combination to indicate end of data sending

You should get some response back from the server. Normally some error message. But you have established the connection

To close the connection

AT+CIPSHUT

SHUT OK Indicates shutdown successful

Screenshot from 2015-11-25 20:12:47Screenshot from 2015-11-25 21:53:44Screenshot from 2015-11-25 20:51:29

 

For the ease of Copy Pasting retyping AT commands in sequence

AT
AT+CPIN?
AT+CREG? 
AT+CGATT?
AT+CIPSHUT
AT+CIPSTATUS
AT+CIPMUX=0 
AT+CGDCONT=1,"IP","airtelgprs.com"
AT+CSTT="airtelgprs.com"
AT+CIICR
AT+CIFSR
AT+CIPSTATUS
AT+CIPSTART= "TCP","flaskprint.herokuapp.com","80"
AT+CIPSEND

Happy Hacking 🙂