SIM908 AT commands

1) Power On the SIM908 :

Here, I will be explaining what commands are used to connect SIM908 to the internet using GPRS and how to read and send GPS data from the SIM908 to the server.

First step when the system is powered on, module will be in power down state, so you need to power on the module by making the PWRKEY pin low for a second and high again. Here is the code i used to activate the PWRKEY.

GPIO_ResetBits(GPIOA, GPIO_Pin_0);    

DelayProc(250000);

GPIO_SetBits(GPIOA, GPIO_Pin_0);

DelayProc(250000); 


2) Set module to text mode : 

The module needs to be set to operate in text mode, necessary while reading and sending SMS. Do it by issuing the command,

AT+CMGF=1 followed by carriage return rn.

ex: Print(“AT+CMGF=1rn”); 


3) Power on and enable the GPS module :

The GPS part of the SIM908 module is in disabled state on powered up, so we need to enable the GPS module by issuing the command,

AT+CGPSPWR=1 followed by carriage return rn,

ex: Print(“AT+CGPSPWR=1rn”);


4) Reset GPS module in autonomy mode :

The GPS part of the module needs to be reset before it can start acquiring the location information, Do this by issuing the command,

AT+CGPSRST=1 followed by carriage return rn.

ex: Print(“AT+CGPSRST=1rn”); 

Now the GPS of the module will start acquiring location information and you must get a proper location in a minute.


5) Set module to full functionality (Optional) :

We need to set the SIM908 to fully GSM functionality mode by issuing the command,

AT+CFUN=1 followed by carriage return rn,

ex: Print(“AT+CFUN=1rn”);  


6) Shut Down GPRS before starting to connect (Optional) :

I just shut down the GPRS connection before I attempt to make a connection by issuing,

AT+CIPSHUT followed by carriage return rn,

ex: Print(“AT+CIPSHUTrn”);


7) Start up Single IP connection mode : 

We need to Start up single IP connection mode by issuing the command,

AT+CIPMUX=0 followed by carriage return rn,

ex: Print(“AT+CIPMUX=0rn”);


8) Check if modules IP status is in INITIAL mode :

Before we proceed, we need to check the IP status of the module and make sure that the module is in IP INITIAL mode by issuing,

AT+CIPSTATUS followed by carriage return rn,

ex: Print(“AT+CIPSTATUSrn”);   

The module should reply with STATE: IP INITIAL, if not then you need to restart with the whole process again.


9) Set the GPRS PDP context :

Now we need to set the PDP context by issuing the command,

AT+CGDCONT=1,”IP”,”www” followed by carriage return rn,

Here “www” is the APN for Vodafone but it can be omitted in some networks and still the module works with empty APN is my observation on DOCOMO and AIRTEL SIM cards.

ex: Print(“AT+CGDCONT=1,”IP”,rn”);


10) Activate PDP context :

Activate the PDP context set before by issuing the command,

AT+CGACT=1,1 followed by carriage return rn,

ex: Print(“AT+CGACT=1,1rn”); 

This command takes some time to respond, so wait for some time before you expect a response from the SIM908.

This command may not be successful in the first attempt and may return ERROR so keep sending this command until it returns OK


11) Attach to the GPRS service :

Now since everything is set, we need to attach to the GPRS service by issuing the command,

AT+CGATT=1 followed by carriage return rn,

ex: Print(“AT+CGATT=1rn”); 


12) Check if modules IP status is in INITIAL mode :

Before we proceed, we need to check the IP status of the module and make sure that the module is in IP INITIAL mode by issuing,

AT+CIPSTATUS  followed by carriage return rn,

ex: Print(“AT+CIPSTATUSrn”);   

The module should reply with STATE: IP INITIAL, if not then you need to restart with the whole process again.


13) Start task and set APN user name and password : 

Start the task and set the parameters by issuing,

AT+CSTT followed by carriage return rn,

ex: Print(“AT+CSTTrn”);


 14) Check if modules IP status is in START mode :

Before we proceed, we need to check the IP status of the module and make sure that the module is in IP START mode by issuing,

AT+CIPSTATUS  followed by carriage return rn,

ex: Print(“AT+CIPSTATUSrn”);   

The module should reply with STATE: IP START, if not then you need to restart with the whole process again.


15) Bring up wireless connection with GPRS or CSD : 

Do this by issuing the command,

AT+CIICR followed by carriage return rn,

ex: Print(“AT+CIICRrn”);

This command takes some time to respond, so wait for some time before you expect a response from SIM908.


16) Check if the module has been allocated an IP address by the network :

Check if everything was all right and an IP address has been allocated by issuing,

AT+CIFSR followed by carriage return rn,

ex: Print(“AT+CIFSRrn”);

Once you receive an IP address as a response for this command, we can proceed with connecting to server and sending packets. If the reply is ERROR then the the GPRS settings and connections were not successful, you need to start all over again. 


17) Read the GPRMC packet from the SIM908’s GPS :

We need to read the Location information in the form of Latitude and Longitude from the GPS of SIM908 in the form of GPRMC packet by issuing,

AT+CGPSINF=32 followed by carriage return rn,

ex: Print(“AT+CGPSINF=32rn”); 

This command will respond with the GPRMC packet something like,

32,143843.000,A,1737.227259,N,8700.614235,E,0.00,172.97,141014,,E,A


18) Read the IMEI number of your module (Optional) :

In my application i had to read the IMEI number of the module to be sent to the server so I did it by issuing the command,

AT+GSN followed by carriage return rn,

ex: Print(“AT+GSNrn”);

This will respond with the 15 digit IMEI number something like 761007003925730


19) Connect to the server using TCP protocol : 

Now we need to connect to the server using its IP address and port number by issuing the command,

AT+CIPSTART=”TCP”,”IP”,”PortNumber” followed by carriage return rn,

ex: Print(“AT+CIPSTART=”TCP”,”192.168.44.144″,”111″rn”); 

Replace the IP and PortNumber with your servers IP address and port number respectively.

This command should respond with CONNECT OK, if you receive ERROR or CONNECT FAIL then the port on the server is either closed or server is down! 


20) Send the TCP packet to the server :

Since we have now made the connection, we can send the data to the server in the form of a TCP packet by using,

AT+CIPSEND=DataLength followed by carriage return rn,

ex: Print(“AT+CIPSEND=100rn”); 

Replace DataLength with the length of the data you want to send.

After issuing this command you must receive a input prompt ” > ” indicating that you can send 100 bytes of data in now.


30) Close the TCP connection :

We need to close the TCP link opened by CIPSTART command so that the port is available for other devices to send data by issuing the command,

AT+CIPCLOSE followed by carriage return rn,

ex: Print(“AT+CIPCLOSErn”); 

This command should be followed by a reply of CLOSE OK  from the SIM908.


31) Reading an SMS from the module (Optional) :

To read an SMS from the module issue the command,

AT+CMGR=n followed by carriage return rn, where n is the index number of the message in the Inbox.

ex: Print(“AT+CMGR=3″rn); 

After issuing this command the module will respond with the content of the 3rd message in the Inbox.


Summarizing everything, Here is the series of commands you need to issue to log a packet to the server,

 ........ .AT+CGPSPWR=1 .OK 
.AT+CGPSRST=1 .OK
.AT+CFUN=1 .OK
.AT+CIPSHUT .SHUT OK
.AT+CIPMUX=0 .OK
.AT+CIPSTATUS .OK .STATE: IP INITIAL
.AT+CGDCONT=1,"IP", .OK
.AT+CGACT=1,1 .OK
.AT+CGATT=1 .OK
.AT+CIPSTATUS .OK .STATE: IP INITIAL
.AT+CSTT .OK
.AT+CIPSTATUS .OK .STATE: IP START
.AT+CIICR .OK

.AT+CIFSR .100.105.13.151
.AT+CGPSINF=32 .32,144114.000,A,1527.220080,N,7500.613057,E,0.00,0.00,141014,,E,A .OK

.AT+GSN .77100550392530 .OK
.AT+CIPSTART="TCP","192.168.44.100","747" .OK .CONNECT OK
.AT+CIPSEND=109 .> *77100550392530,1,0000,0,0,144101.000,A,1527.222891,N,7500.613869,E,0.00,0.00,141014,,E,A000000000000000000! .SEND OK
.AT+CIPCLOSE .CLOSE OK

 

Also see:

 

Leave a Comment

Your email address will not be published. Required fields are marked *