Although SIM300 GSM/GPRS modems
are out-dated now, with the coming of its successors, I thought it is a good
idea to post the AT commands for GPRS access. AT commands are string commands
used to communicate with gsm/gprs modems.If you have a modem, that can be interfaced with PC through COM port,
then you will be able to test these commands using some terminal softwares
(Hyperterminal in Windows Xp, Putty for Windows 7, Minicom in linux, …). SIM
300 has an inbuilt TCP/IP stack, which will be helpful when it is connected to
a microcontroller for gprs data transfer.
Here is the sequence of AT commands for various purposes. All commands should be followed by Carriage return(\r) and Line feed(\n) at the end (if you are using terminal in PC, you can simply hit ENTER). If the commands are correct, the modem will return OK otherwise ERROR.
Here is the sequence of AT commands for various purposes. All commands should be followed by Carriage return(\r) and Line feed(\n) at the end (if you are using terminal in PC, you can simply hit ENTER). If the commands are correct, the modem will return OK otherwise ERROR.
To send an SMS:
AT+CMGF=1 //This command select the text message format
AT+CMGS=”<mob num>” //Hit ENTER and the modem will return a prompt (>), then type the message and press Ctrl-Z (0x0A in hex)
Here is an example,
AT+CMGS=”123456789”
>how are you?
Press Ctrl-Z.
Modem won’t send message until Ctrl-Z is pressed.
To receive an SMS:
AT+CNMI=2,2,0,0,0 //Setting this command will set the modem to receive text messages instantly on reception.You can give different parameters by referring to the datasheet.
Here,with these parameters, it is stated that the modem buffers
unsolicited result codes (including text messages) in the TA when TA-TE link is
reserved (e.g. in on-line data mode) and flush them to the TE after
reservation. Otherwise forward them directly to the TE. (TA is the modem and TE
is PC or microcontroller). The message will be received starting with +CMT.
Configuring as Client:
Note:If one of the below commands (those changing status of modem) fails, then you
have to issue AT+CIPSHUT and start from the beginning.
Before configuring the modem as client, we should check the status
of modem.
AT+CIPSTATUS //Query current connection status
IP INITIAL //This should be the initial status
IP START //After issuing AT+CSTT command
IP CONFIG //After issuing AT+CIICR command
IP IND //After issuing AT+CIICR, if the module accepts the command.
IP GPRSACT //After issuing AT+CIICR, if activated successfully
IP STATUS //After issuing AT+CIFSR command
TCP/UDP CONNECTING //After AT+CIPSTART command, modem is trying to connect
IP CLOSE //After AT+CIPCLOSE, when the current client-server
connection closed.
CONNECT OK //After AT+CIPSTART, when a connection is established.
CONNECT FAIL //After AT+CIPSTART, when a connection fails.
Start configuring on the status of IP INITIAL.
AT+CGATT=1 //Attaching to GPRS service
AT+CIPCSGP=1,”<apn>” //Selecting GPRS mode and providing access point name. For example, <apn> for Airtel is airtelgprs.com or airtelgprs.
AT+CSTT //Starts the task. After this command, status should change to IP START.
AT+CREG? //Query network registration status (optional). If the returned value is 1 or 5, sim card is registered home/roaming network. For all other values, you cannot proceed.
AT+CIICR //On the status of IP START. It will bring up a GPRS connection. This command will takes a seconds/minutes to return OK/ERROR.
AT+CIFSR //Returns the IP address of the modem.
AT+CDNSORIP=1 //0 if server IP address and 1 if server domain name in AT+CIPSTART command.
AT+CIPSPRT=1 //Set prompt ‘>’ and SEND OK when data is sent successfully.
AT+CIPHEAD=1 //Add an IP header while receiving data from server (Received data starts with +IPD) (optional)
Connecting to server:
After configuring as client, you will be getting the status as IP STATUS and so proceed to connect to remote server.
After configuring as client, you will be getting the status as IP STATUS and so proceed to connect to remote server.
AT+CIPSTART=”TCP”,”www.google.com",”80” //On status of IP STATUS. This command connects to the server. Returns CONNECT OK on success.
AT+CIPSEND=<len><Hit ENTER><type data after prompt> //To send known length of data
OR
AT+CIPSEND<Hit ENTER> //To send unknown length of data.
><type data after prompt><press Ctrl-Z to send>
Example:
AT+CIPSEND //wait for module to return'>' to indicate it's ready to receive data
GET / HTTP/1.1 //This an HTTP request for the default page
Host: "www.google.com"
Connection: Keep-Alive
Accept: */*
Accept-Language: en-us
<Hit ENTER>
<press Ctrl-Z to send>
AT+CIPCLOSE //Closes the current client server connection
AT+CIPSHUT //Closes entire GPRS context and returns to initial state.
Configuring as Server:
Proceed with the same steps for Configuring as client. After getting the status as IP STATUS, you have to issue the following commands.
Some useful commands:
Here are some of the basic commands which may help you in diagnosis of modem.
Proceed with the same steps for Configuring as client. After getting the status as IP STATUS, you have to issue the following commands.
AT+CLPORT="TCP",<portnum> //Set port
AT+CIPSERVER=1 //Returns SERVER OK if running successfully
Now, you can access this server port from anywhere. You may try it using Telnet for raw data transfer.Some useful commands:
Here are some of the basic commands which may help you in diagnosis of modem.
AT+CSQ //Returns signal strength and bit error rate. Maximum of signal strength is 31, which means you have a very good coverage.
ATE0 //Turns Echo OFF
AT+CUSD=1,”<ussd code>” //Such as to check balance
AT+CLTS //To get local time stamp
AT+CCLK? //Query current date and time.
Keep in mind that SIM300 acts as a server or a client at a time, it cannot be configured as both client and server simultaneously.
I hope this is it. Now you can try it. And thank you for reading this.
Nice , Its Very Useful
ReplyDeletesathees,
ReplyDeleteI got error while AT+CIPSTART = "TCP","www.google.com","80"
it returns
ok
ERROR 6
STATUS: IP STATUS
I got error while AT+CIPSTART = "TCP","www.google.com","80"
ReplyDeleteit returns
ok
ERROR 6
STATUS: IP STATUS
Hai,
DeleteCan you obtain the IP address of your SIM300 modem.
If it is a local IP, such as 10.x.x.x, it may be the reason for this error.
Can you explain this?
DeleteMy GSM300 has such a local IP and i am trying to work out a IOT using GPRS.
Also please do explain how to rectify this.
Getting a local ip means you are not connected to internet. it might be an issue with the APN address
Deleteat+cifsr
ReplyDelete100.113.204.38
im trying on tata dcomo
at+cgdcont=1,"IP","TATA.DOCOMO.INTERNET"
OK
at+cstt?
+CSTT: "TATA.DOCOMO.DIVE.IN","",""
at+cgdcont?
+CGDCONT: 1,"IP","TATA.DOCOMO.INTERNET","100.113.204.038",0,0
Did you configure the commands I've used in my post?
ReplyDeleteWhat about the signal?
I too experienced some issues while using TATA DOCOMO.
Try some other operator such as Airtel...
satheesh sir
ReplyDeletei have made my gsm 300 as a client and it connect all the server but if we make my laptop as a server using socket test software it will not connect to it .
means my laptop has not became a sever
so how we can make pc as a server that i can chat with my gsm module using gprs. one more thing is that to make my pc as a server i need an static ip is there any other mathod to make pc as server without static ip
For the modem to connect to your server, it should've a global ip. So, if your PC is part of LAN, you can use port forwarding from router.
ReplyDeleteOtherwise you can obtain global ip by connecting a Dongle.
But for a static ip, you have to purchase it from your provider
Hi, how to send data to web server in sim300. My requirment is I need to send gps data to we server. AT+CIPSTART i sdone after that In AT+CIPSEND how to post data? please help
ReplyDeletehow to post our temperature data on wave page through SIM300
ReplyDeleteCommand:
AT+CIPSTART="TCP","www.google.com","80" //Start up TCP connection (mode, IP address/name, port)
i got error.