TCP Connection over GPRS using SIM900 and AT Commands

This is one of those projects I always wanted to do. How do you use modem AT commands and make a TCP connection using a GPRS board? After struggling for a while and reading lot of documents from various places, I was able to do this. There are many blogs on the net covering this topic, but most of them either do not provide full details, or in many places specific answers have been provided to queries but not full details. I’m not claiming that this is the only blog that has the full details, just that I was not able to find a good one.

What do you need

To start this project, you will need the following:

  1. A GSM-GPRS board. I bought one from This board can be interfaced with RS-232 DB9 connector. The rest of the required items assume that the board you have, also interface using a RS-232 connector
  2. A laptop with spare USB port (I’m assuming your laptop does not have RS-232 port. I have not seen a laptop with RS-232 port in over last 10 years)
  3. A USB to RS-232 board. Please note, this should not be a USB-to-RS232 (TTL), but a full USB-to-RS232. The output should be RS232 voltage ranges (around +/-12V). This is due to the fact that the board I had, allowed interfacing with RS-232. If your board has TTL interfaces, please get a US-to-RS232 (TTL) interface. The one I have was bought from Nex-Robotics
  4. A RS-232 cable (please ensure you get the right combination of male/female). My USB-to-RS232 adapter had male output and GPRS board had female input. Thus, I got one RS232 cable with male/female combination.
  5. A SIM card that has data plan
  6. A power supply for your GPRS board. Generally, the GPRS boards require 2 Amp supply. So please read the board specifications and get the power supply accordingly. I made the mistake of not reading the specs right and got a 1 Amp supply. I had trouble exchanging data.
  7. A terminal program like Terminal.exe. You can download this from the Sunrom website. Look at the bottom right of this page.

How to setup

  1. First of all you need to install the driver and setup your USB-to-RS232 adapter. This is dependent upon the adapter you have. Please contact your seller for the installation driver and details.
  2. Once you install, there should be a virtual COM port available on your machine. I have a windows laptop and it shows under “Devices and Printers”.
  3. Next, insert the SIM card in your GPRS board and power on. These boards generally come with some sort of indicator LEDs that will tell you when the registration is successful. The one I have, has a green LED that blinks at 3 sec period to indicate the board is ready. So again, read the board specification.
  4. Connect the RS232 cable between the adapter and the board.
  5. Bring up the terminal.exe. It should show available COM ports. Select the COM port that represents your USB-to-RS232 adapter. Now comes the tricky part. You need to know what is the Baud rate. After many attempts and multiple blog site visits, I found that perhaps (I’m still not sure) 19200 is the default setting for Sim 900. I have been using that and it works like a charm.
Terminal.exe Tool

Terminal.exe Tool

In Terminal.exe tool, you have a text box at the bottom. You enter AT commands in that text box. Please ensure, you have the checkbox labeled “+CR” (to the right of the textbox) checked. Every AT command needs to be terminated by \r\n (CR + LF) combination. You enter the command and click the “Send” button. The response is visible in the area above the textbox.

The command sequence

Now comes the interesting part. Given below is a list of AT commands that you must fire in the exact given sequence to connect to a webserver using TCP over GPRS. The symbol => indicates the command you need to enter, <= indicates the response received from the SIM900. Text within /** **/ are my comments for further explanation. The response may contains additional information than what is shown here. I have listed down only the important part of the response that you need to be aware of.

Also, please note, send the commands in uppercase only.

Here is the sequence:

/** First test if everything is okay **/

=> AT

<= AT /** This should come back. SIM900 default is to echo back commands you enter **/

<= OK /** This string should tell you all is well**/

=>AT+CPIN? /**This is to check if SIM is unlocked. This sample assumes unlocked SIMs**/

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

=>AT+CREG? /**This checks if SIM is registered or not**/

<=+CREG: 0,1 /**This string in the response indicates SIM is registered**/

=>AT+CGATT? /**Check if GPRS is attached or not**/

<=+CGATT: 1 /**A response containing this string indicates GPRS is attached**/

=>AT+CIPSHUT /**Reset the IP session if any**/

<=SHUT OK /**This string in the response represents all IP sessions shutdown.**/

=>AT+CIPSTATUS /**Check if the IP stack is initialized**/

<=STATE: IP INITIAL /**This string in the response indicates IP stack is initialized**/

=>AT+CIPMUX=0 /**To keep things simple, I’m setting up a single connection mode**/

<=OK /**This string indicates single connection mode set successfully at SIM 900**/

=>AT+CSTT= “APN”, “UNAME”, “PWD” /**Start the task, based on the SIM card you are using, you need to know the APN, username and password for your service provider**/

<= OK /**This response indicates task started successfully**/

=> AT+CIICR /**Now bring up the wireless. Please note, the response to this might take some time**/

<=OK /**This text in response string indicates wireless is up**/

=>AT+CIFSR /**Get the local IP address. Some people say that this step is not required, but if I do not issue this, it was not working for my case. So I made this mandatory, no harm.**/

<= /**If previous command is successful, you should see an IP address in the response**/

=>AT+CIPSTART= “TCP” , “”, “80” /**Start the connection, TCP, domain name, port**/

<= CONNECT OK /**This string in the response indicates TCP connection established**/

=>AT+CIPSEND /**Request initiation of data sending (the request)**/

<= > /**The response should be the string “>” to indicate, type your data to send**/

=> xxxxxx /**Just type anything for now**/

=>#026 /**Now type the sequence #026. This tells the terminal.exe to send the hex code 0x1a (which is Ctrl+Z) to indicate end of data sending**/

<= xxxxxxxxxx /**You should get some response back from the server…it would generally be a complain that the request string was not valid…but that is a different subject…you have established the connection**/

/**To close the connection**/

=>AT+CIPSHUT /**Request shutting down of the current connections**/

<=SHUT OK /**Indicates shutdown successful**/


You can get many errors during this exercise and I cannot possibly think of all of them. A few key ones are given below:

  1. You get junk characters – It can either be due to baud rate mismatch or because of lose connections. Initially, I used hookup wires to connect the two DB9 connectors but I got junk. I replaced the wires with a DB9 cable and the problem was gone.
  2. You get an error when you issue the command – Either your command sequence is wrong, or you have entered an invalid command. Sometimes, you need to power cycle your SIM900 board and start again.

336 thoughts on “TCP Connection over GPRS using SIM900 and AT Commands

    • I looked at dropbox API briefly. I’m afraid, this is too complicated a task using an ATMega16. Dropbox needs HTTPS, therefore, your first task is to find out an HTTPS (SSL) implementation for ATMega16. AT first, you might want to check PolarSSL and see if they support what you need. Once you have SSL support, you can then go on to use HTTPS. But a tough one indeed. Good Luck 🙂

  1. Hello Sir, I I have to send data to a server. But I am not getting how to make a server on my computer or where I am sending data, how to collect it on a server. Can you provide me some tutorial link or some help. Thanks in advance.

    • You need to first create a basic website, using either ASP.NET, PHP or Java. Whatever is your choice of programming language. Let me explain this using ASP.NET.
      Create a simple page in ASP.NET called sim900.aspx. You can host this page in an IIS website. Let’s assume that the IIS website is hosted on IP address. Therefore, the URL you need to call would be
      To start simple, you can pass values in the URL. For example, if your sensor is measuring temperature, you can pass the value as

      In the ASPX page, you can write code to read the querystring parameter “temp”. How to do this is available at

      Remember, you need to issue a GET request from SIM 900 for this to work.
      Once you succeed in this, you should ideally try to move to POST request.
      Hope this helps.

      • Sir,

        I didn’t understand
        “Remember, you need to issue a GET request from SIM 900 for this to work.
        Once you succeed in this, you should ideally try to move to POST request.”

        GET is to check the reply from Server. Why is it important for transmitting data. Can you please explain. Thanks.

      • In order to work with a web server, you need to issue a request to it. There are various types of requests, like GET, PUT, POST etc. When you issue a request, you must specify what is the request type. A GET request type is the simplest. Thus start with the GET request type. The syntax for GET request will be available online, but basically, you need to type something like GET / HTTP/1.1 to tell the server that the request type is GET.

      • Hello sir. In what format should I send GET data from SIM900A (AT commands),so that a php file on server end can insert it into a database.

      • You can decide what is your format. If you know PHP, then you can extract and parse the data. But generally, I woulud suggest JSON, if possible, else plain/text.

  2. Hi Vishnu,
    I am trying to transfer data to HTTPS webpage using SIM900, but HTTPS AT commands returns error. On contacting simcom they told a new firmware build supporting HTTPS, SSL stack is required, but didn’t get any further information from them.
    Have you tried HTTPS data transfer, could you please help me proceed further.

  3. Hi Vishnu,
    the default Baud rate for SIM900 is “auto-baunding”, according to the SIM900_AT_Commands Manual V1.06 page 43 (AT+IPR=0).
    Nice application you have presented.
    Best Regards

  4. I am using th following sequence of commands on the hyper-terminal and I’m receiving data at the terminal. But when I create a dial up connection using this modem I get error 692. It would be kind of you to explain it to me…

    >GET HTTP/1.1(ctrl+m)(ctrl+j)(ctrl+m)(ctrl+j)(ctrl+z)
    Data comes here

  5. Hello Vishnu,
    I am having trouble trying to get HTTP POST method to work. The recorded log is below. This has been bothering me for days. Please let me know as to where i am making the error.


    +HTTPREAD:226Not Acceptable!Not Acceptable!
    An appropriate representation of the requested resource could not be found on this server.
    This error was generated by Mod_Security.OK

    • Vinay,
      I have not tried this level of details yet. I read the V 1.03 of Sim900 module and it looks like your commands for HTTP are incorrect. Please read the HTTP commands from page # 196 of the v 1.03 manual. The response returned contains the HTTP status code 406 (+HTTPACTION = , , )
      Status code 406 means not acceptable. This can happen for multiple reasons (including invalid params and data length). Your param part does not look correct. Please revisit that part.

  6. Hello!
    I´m trying to send a https GET request but I don´t find the way. Any one know how to do this after a https connect??
    Thanks for all

  7. Hi,

    I was being told by someone that the module has size limit. And I have to split data into pieces before sending them to remote server via gprs, then assemble it back on the server side.

    However, I have searched through the SIM900 manual and the only thing I found is this:

    “Flow control is very important for correct communication between the GSM engine and DTE. For in the case such as a data or fax call, the sending device is transferring data faster than the receiving side is ready to accept. When the receiving buffer reaches its capacity, the receiving device should be capable to cause the sending device to pause until it catches up.”

    I am not quite sure if the above is anything related to my question..

    What’s your thoughts?

    • James,
      You are mixing multiple things. I know for sure that SIM900 has a buffer size, but I cannot find what is that size. Given the fact that you will control Sim900 via some other device (an Arduino, PC etc.), you may also be limited by the controlling device buffer size(for example, Arduino buffer is 64 bytes if I’m not wrong). Thus, the right way to look at it is as follows:
      1. What is the buffer size of my microcontroller. That buffer must be less than or equal to Sim900. A 64 byte buffer is safe to use.
      2. Once I send data to the Sim900 module, how long should I wait before sending next set of data to allow Sim900 to process it.
      3. Should I use RTS/CTS pins for flow control.

      My best bet at answering these questions are:
      1. The buffer size is indeed important. But I have not found Sim900 buffer size information. When I use Arduino, I use 64 bytes and when I use Netduino, I have used up to 128 bytes. Both have worked.
      2. I generally use the send, wait, send method as this keeps my program simple. When you are using AT command set, you know when the send has ended (as the control will return only after that). Post that, I wait for a few seconds (about 2-5) and then send again. Not the best strategy, but it works in my case.
      3. RTS/CTS is something I do not use as this complicates the H/W design and programming. In some cases, you may not even get these pins (e.g. US to RS 232 TTL converters)

      Hope this clarifies

      • Thanks for your explanation.

        If I understand correctly, I can send the stream of data (image in my case) within the buffer limit to sim900 module with delay in between.

        Should I worry about data assembling on the server side? Or the TCP/IP protocol will take care that part?

      • Since you are splitting the data in the application layer, you need to have a way to re-assemble the data on the server side. You need to know that the data that arrived on the server side is partial and there is more to come. You also need to know when you receive the last chunk after which, you can assemble all the bytes and save the image in a repository. This, you have to take care on the server side.

  8. Hi Friends,
    I am using this sim900A module and trying to interface directly with Arduino Uno with by connecting GSM_TX –>Rx of arduino and GSM_RX –> TX of arduino.but when i send AT commands from Hyperterminal it works fine and while sending commands from Arduino microcontroller via Code i am not getting reply from GSM Sim900A module.
    Does i need external MAX232 circuit to interface with Arduino board ?
    What is the voltage level of onboard DB9 of sim900A?

    • Please check the shield/breakout board datasheet. If it has a DB9 connector, then most probably it needs a level converter. Check the datasheet of the board. Arduinos are 5V compatible and some shield work on 3.3 or can tolerate 5V (not all, check the datasheet again).

    • Raji,
      The question is not very clear. If you are referring to the port number 80, then here is the answer…The port number has got nothing to do with the GSM module. It is the port number on which the web server is listening. By default, any HTTP website is hosted on port number 80. Similarly, any HTTPS website is hosted on port 443. If your administrator has hosted the website on a different port, then check with your administrator (sometimes, they are hosted on port 8080. Not very common for public sites though.)

    • Sorry I do not have Sim900 firmware. The only way to do this is to get from Simcom. Another alternative is to select a different model. I know that Sim5360 is one such model that supports SSL. Check with Simcom directly or from resellers about this model.

  9. sir , i am using sim 900 . i have already sent some data to a sever from it by using tcpip i want to send the data repeatedly to that remote server . So please tell me which AT commands are required to repeat to send the data again and again to that server from gsm module by using tcpip connection

    • Naresh,
      I’m not aware of any Sim900 command that can repeat the last command. Also, I’m not sure why you want to do this (as this could be considered spam).
      You should have a loop in your code to repeatedly call the Sim900 functions to send data

    • Austin,
      I do not have access to a TM4C1294NCPDT. I did look at the datasheet of this IC. Given that you control Sim900 over a UART, all you need in your controller is a UART port. The datasheet of this IC states that this has 8 UARTs. So this should not be a problem. You should simply use the UART of the TI chip and issue the commands in the sequence outlined in this blog.

      • Hello Sir ,

        can you please help me out regarding apn setting .

        I am working on a project , on which I have to change APN of my device according to service provider without using any external hardware , So please can you mail me some AT commands (flow) by which I can get the APN of any sim card.

        Thanks & Regards

        Gaurav Saraswat

      • Gaurav,
        You can create various profiles and specify one profile during connection. What I have not understood is how you want to change the APN without external H/W? Your question is not clear.

  10. Dear Sir,
    Can you help me with the time taken from start of the modem to sending 20 bytes data to shutdown of the module. What to do if the module is hanged. Please tell best case execution time and worst case execution time. regards

    • If I assume start means starting with power on then configuration and then finally send data, then it could be about 2 to 3 mins. Of this, 90% would be initialization (as my experience shows you need to give about 2 secs delay during initialization between each init sequence command).
      If the module hangs, you may try soft reset. In my case, soft reset was not working, so I (bad solution but works everytime) put a relay form which the Sim900 module was being powered. If the module hangs, I simply switch the relay to power off the module and then power it on again (a hard reset)

  11. Sir, i am using Sim900A for GET / HTTP1.1 request and sending a sensor data; when i sent the sequence of AT commands using Terminal the response was “SEND OK HTTP/1.1 200 OK “and data was send properly, but when i am using same with arduino uno i get “SEND OK HTTP/1.1 404 Not Found”.Please help !!!

  12. Hi vishnu,
    thank u for your valuable post.

    i have two doubts here.
    1.why should we use #026 at the end of the data , instead can we send direct hex code ?? can u please inform me, whats that exactly means?

    2.if we try to send AT+CIICR command SIM900A module ,its respond with error: +PDP Deact, why?

    • Answer 1 : You need to send the hex code 0x26 to instruct Sim900 that data has ended. To send hex using Terminal program, you need to use the syntax #026
      Answer 2 : Difficult question. There could be many reasons, but to start with, use a local sim that has good reception. Sometimes I have seen this with roamin SIM.

      • Thank u vishnu,
        AT+CIPMUX={0 for single mode , 1 for multimode connection}, here i bit confused, 1.whats that means?
        2.i am not getting how data transfer occurs in both cases?

        3. How it works exactly?


  13. RAVI:
    Hello sir,
    i am using sim900 gsm and i can usig UDP protocol, i sent data but i can,t view that data sir so what i do, please help me because now going BE final year project sir

  14. AT

    +CSQ: 31,0

    +CREG: 0,1

    +CGATT: 1



    > SIM900 UDP TEST

  15. –> =>AT+CIPSTART= “TCP” , “”, “80” /**Start the connection, TCP, domain name, port**/

    Can I use raw TCP socket and port other than standard HTTP, 80?
    If it is HTTP request (GET/POST) then it will send unnecessary HTTP headers. Will it not be redundant where GPRS data charges are high?
    I’m confused between choosing raw TCP socket or HTTP.

    Please help.

    • I have used UDP packets successfully. You should be able to do raw TCP. It’s upto you to decide what is your requirement.
      You decide what is the trade-off you want to take. If operational costs (e.g. GPRS data plan cost) is important to you, then use raw TCP.
      If simplicity is important to you then use HTTP…etc.

  16. Hello,iam using airtel sim,i’ve trying to connect the modem to n/w witjh the command at+cstt=”,””,”””but it is showing error,any solution pls..

  17. Sir, I am having trouble making a server for this. I have installed IIS as you stated in a comment above. Now I am creating a website to put on this server on ASP.NET. Now, I am stuck on how to put code in the server that can handle UDP packets.

    Secondly, your code is for TCP, can you tell what changed do I have to do for UDP. I am using SIM900D with Arduino Mega 2560. Thanks in advance.

    • If you want UDP packets, you need to create a UDP server. For that, you do not need IIS. I’m not sure which comment you picked up. But for UDP, you can create a UDP listener on a port and accept packets. There are numerous examples on the internet to use UDP listeners.

      • Thanks for your kind reply. It is the third comment from the top, by divyansh. Okay, I didn’t know that we don’t need IIS for this, actually I am a beginner and working on my final year project that is why a bit confused. Okay, I am now searching for UDP listner as you said. I will be needing your help on how to send UDP packets from SIM900D, after I create a UDP listener. Regards.

      • I have realized that using UDP would not be suitable because I cannot take riskt to reverse the sequence of data as I am building a tracker application. So I am now focussing on TCP. I am searching for TCP listener on internet and trying to create a TCP listner and then send TCP data to it from my SIM900D.

  18. Thanks. What is HTTP endpoint? How can I create it with IIS? I have installed IIS but I don’t know what to do further. Can you guide a little?

    • Well, unfortunately, the answer to this question will not fit this little reply box 🙂
      My suggestion is that you talk to a web developer who can help you on this.
      You can get in touch with any web developer (Java, PHP, .NET etc.)

      • Unfortunately, I am not getting anyone to help, thats why I asked here. If you could give me a link to a tutorial or something, I would be really thankful

      • I have searched on internet and manged to send data to my web server using HTTP GET request. But I am facing the problem that, when I turn on my Arduino and GSM module, the data is sent through GET request on the server only the first time. Afterwards, the data is not shown up on the server. I am trying to send the data every 10 seconds, so I initiate HTTP GET request in a loop after every 10 seconds. SIM900 replies with +HTTPACTION:0,200 that means there is no error, then why the data is not received on web server after the first attempt?

      • Interesting. Have you checked on the sending side how many bytes were transferred (I think you can use AT+CIPSEND)
        Also, what do you see on the server logs? Do you see the entry for subsequent GET requests

      • No, I have figured out that the problem is with the response of the GET request. When I use AT+HTTPREAD (just to check), the code hangs there and reading the response never ends and it stays in the while loop that is reading the response, and thats why I am unable to initiate second GET request. I am wondering whether the problem is from the server side? Is it sending the correct response after receiving a GET request? How to check that?

      • As per the documentation, you need to issue a write command AT+HTTPREAD=
        The response is +HTTPREAD:
        You can issue an HTTPREAD only when AT+HTTPACTION=0 or AT+HTTPDATA is executed.
        For a get, you do not need to issue an HTTPREAD. Simply CIPSEND response will give you the results.

      • I am using AT+HTTPACTION=0 to send the get request, thats why I am using AT+HTTPREAD. Can I use AT+CIPSEND after AT+HTTPACTION=0?

      • Hey, I got successful with AT+CIPSEND. my issue is resolved. Now, the problem is, TCP connection is automatically closed, I don’t know how. I have written the code for TCP connection in the setup function, so that it should establish connection in the start, then in the loop function, I have used CIPSEND. But CIPSEND failes after sending two or three times, that means TCP connection was closed. How to keep a check that if a connection is there or not? any AT COMMAND for that? Thanks in advance

    • Is port 80 the default port for TCP? I have made a free php server on and I have my php file there. I have assigned port 80 in code, but I only receive data sometimes. The same code works and if I check it again after sometime, it doesn’t work. I mean, it is successful from the device but not always received on the server. Can it be a port issue? or something else?

  19. I learned much from this forum… got a pretty uncommon data task to prove, and should be quite an unorthodox method to enhance mission scope via GPRS data call, as opposed to the status quo of point-to-point telemetry radio links, and their inherent limitations of range and propagation.
    I won’t bug you now, as Im hacking with what ive learned here 1st…better for my development you know…But want to thank you in advance in the event I have a query for something. I will keep any such requests light, and carry my burdens stubbornly, as it will make me stronger.
    Thank you for the unexpected perspective in my quest, as I just grazed this place in a cluster search for something else….It really had a huge effect on where and how Im taking the solution!

  20. Hi Vishnu,GPRS connectivity works perfectly. I am able to send data from SIM900A modem to computer. But the issue is if I keep the SIM900A and PC ON for 1 day and next day I come, I will not be able to send data from SIM900A modem to PC. For this to happen, I need to physically switch OFF and ON the SIM900A modem. I want this should work perfectly without a power cycle. Please let me know, how to achieve this? Your quick help will be highly appreciated. Regards, Kishore

    • Some boards come with a “RESET” pin. Rather than doing a full power cycle, you can simply pull the reset pin low for a few seconds, and then switch it back again. Only as a last resort, you will need to do a power cycle. To automate that, I power the Sim900 via a relay. To power cycle I simply switch on the relay from my microcontroller. That will energize the relay and cut-off power supply. Then after few seconds, the microcontroller de-energizes the relay

      A board with reset pin can be found here

  21. hello sir,
    I used your explantions to open a connection with GPRS, it works well. thanks

    But now I need to send data (like small picture) which can have 0x1A somewhere as value.

    But the “AT+CIPSEND” command will stop to read/send the bytes after this 0x1A …

    How can I solve that ?

    Thanks for your help

    • You can either do an HTTP post (which is the right thing to do if I understand your requirement) or you can first convert the image bytes into a Base64 array and then send it across.

  22. Hi Vishnu,
    thanks for the information. am very new to gsm/gprs and need your help in this.
    I need to communicate between two gprs modems. how can I establish a link between them for data exchange. please help.

    • Well, the solution depends on many things. Without know what you are trying to do, I can only make a guess.
      You can either simply send SMS from one module to another or you can make one module as HTTP server and another module as HTTP client.

      • Dear Vishnu, I have same question. What I want to do this to control radio control toy over GPRS. I need to generate different PWM signal at toy, by sending command from control side. SMS will be very slow and not reliable. Can we setup direct connection between 2 GSM/GPRS module? Or can HTTP server/client thing work?

      • Thanks Vishnu, However, I would like to figure how can I send command over HTTP server/client connections. By the way, is there anyway to setup like VPN between 2 connections and control like in LAN environment?

        Thanks in advance. 🙂

  23. Myself R.lakshmikanth,. i much interested to the knowing the concept of gprs. I try to store the data from temperature and humidity which is interface to controller 8051 by using GPRS modem. I follow the steps as you mention in site .I got error at command AT+CIPSEND . if i enter the command then i did’nt get response from terminal . I did’nt understand what to do. can you please guide me. if i spell any wrong don’t mind. Hope am waiting for reply.

  24. Hi Vishnu..Thanks a lot for this blog. I would like to know about AT+CIPRXGET. With above reference, I could send data on server. Now I want to receive data through TCP. Can you please suggest me related to this matter?

  25. after sending http header using “AT+CIPSEND” command, I am not able to receive anything through GSM/GPRS modem. why? server must response something to this.
    can you please help me with this?

    • I’m not sure if I understood the question correctly. But once you do CIPSEND, you should wait for sometime to get the > prompt. Only after that, you can send / receive data

  26. How can we know whether GSM modem have GPRS settings ? Is their any specific AT commands to recognize the GPRS data.

  27. I tried to send strings to a socket server program (sockettest 3.0) from the gprs module but when enter the command AT+CIPSTART=”TCP”,”my public IP”,”port number for server”. it shows connection fail, all the previous commands get executed without any error and my module gets a Ip address by AT+CIFSR.
    Is their a problem from the module side or server side?

    • This is a difficult question to answer. There are too many things that could go wrong. For starters, assuming all the previous steps really succeed (you should recheck), check if the IP address and port are reachable.

  28. While configuring sim900 as server using AT+CIPSERVER=1,”port” command,how server (sim 900) knows if client cannot establish the connection to server and should restart the module?

    • Arduino is based on 8-bit controller. If I understand you right, you want to open a websocket on arduino and connect with a remote server. If that is the case, what you are trying to do is a little too much for Arduino. I’m not sure if you can do this easily. If you are still interested, I found a link about Arduino and WebSocket – (I have not read this to see applicability to your case. Just a simple web search)

  29. Hello Mr Vishnu Sharma,
    I read all your posts and replies. I am very proud of you and the way you reply to different peoples. If every one on the web was simple and humble as you are, I am sure this whole would have moved us to another dimension of the love of one another. Keep on with good work!! I pray that GOD bless you more in your live. Honestly I have not try or tested your code yet but will test it latter. Have a fantastic day and stayed blessed.

    Alain St Etienne

  30. hello sir , I want to access the google maps using sim900 and arduino , how its possible guide me in this ?

  31. Hi Mr. Vishnu,

    Your blog post was very informative. My application requires a full duplex connection at all times, I managed to get my SIM900 to transmit data to my server via TCP/IP, however I ran into problems when i tried to transmit data from server to SIM900 as the sim card i used has a dynamic ip, is there a way around this. It would be really helpful.

    Thanks Again

    • Your Sim900 will get assigned a dynamic IP address everytime it connects. You can get a static IP address but that is a very involved process.
      The way around this is to try out the following options:
      1. Respond back only when the client sends a request
      2. If you want your server to call the client, then do the following:
      a. Everytime client establishes a internet connection, send the client IP address to the server
      b. Use the IP address available at the server side to send messages to the client.
      The option #2 can be either custom built, or you can check with a service like

  32. Hi vishnu,
    Thanks for your details about the SIM 900 modem ,i have one doubt..
    How to send a get command from SIM900 modem?
    i’ve followed the sequence as follows but it does’nt yield any results










    After the connect ok it does not gives any info about it has sent the command or not
    please suggest some tonic for this…

    • There is clearly an ERROR response that I can see after AT+CIPSEND . Have you checked if all parameters are correct. Also, you are issuing HTTPS command and not an HTTP command. You need to read the Sim900 document on how to work with HTTPS as that requires TLS support along with certificate exchanges.

  33. Hi Vishnu, maybe you can help me.
    I’m trying to use SIM900 as a server. After the AT+CIPSERVER=1,80 command, the module returns STATE: SERVER LISTENING. The local IP is in range.
    Previously I’ve got the module Internet IP using NO-IP.COM and it is in the range.
    Trying to connect to the IP from my computer always result in TIMEOUT.
    SIM900 continues to show STATE: SERVER LISTENING.
    Tryed other port numbers but the result is the same.
    Is there something I can do to make this work?
    Thanks for your help!

    • Mark,
      I also struggled to get the AT+CIPSERVER command working for us on the Sim900 module. I could get to “SERVER LISTENING” (both single, as well as multiple connection mode). Using the AT+CIFSR command, I was able to check that the module was getting a public IP. However, I could never connect to it 😦
      After a lot of search, I remember reading a forum, where some field testing engineers stated that the firmware had an issue. If I can recollect it right (about 2 yrs ago), the firmware version was “B10” (I’m not sure though).

      One way to test this, could be to use another module and see if AT+CIPSERVER works (as I know that module supports this command). It it does, then your Sim900 is bad. (Worst possible case, you can try out ESP8266, if it is for learning)

      • Thanks for your prompt answer.
        Today I updated the SIM900 firmware to “B13” version, the last I could find.
        Unfortunately, it didn’t change anything. Maybe the cell operator is blocking inbound connections. Next test will be with different Simcards.
        Thanks again!

      • Mark,
        I think your guess is right. The cell operator might be clocking such inbound connections. If you are able to get this working, I would love to hear from you (that will help me add to my learning)

      • Got it working, finally!
        Tried using simcards from other operators and found one that works. That one shows me an external IP address, the same reported by NO-IP service.
        So the conclusion is: it depends on the operator’s simcard permissions.
        If the AT+CIFSR command gives you a local IP address, chances are that inbound connections will be blocked.

      • hi ,

        using SIM800 and facing same issue. i am using SIM card with Public static IP . always getting CISFR response with static Public IP only.

      • I’m not sure if I understood your question. Do you mean to say, that you have a SIM card that is enabled for static public IP? If yes, then CIFSR will always give you the same value. Alternatively, if you meant that you are trying to connect to a public static IP (the remote IP) and then AT+CIFSR is still giving you the same value for IP, then this is fine. Sometimes, the cell tower will not recycle the IP address assigned to your SIM card very quickly.

  34. Hello!
    I am using SIM900A module. I have finished working of SMS send/receive, TCP communication for bidirectional way (Client/receive) and UDP for sending data from client to server. I am getting error while doing UDP as a server. Can anyone suggest me steps for running UDP as server?
    Thanks in advance!

    • The problem with server is that you need an IP address where incoming data is allowed. I know that a large number of data service providers do not allow that. Recently, when I had to do this, the network provider asked for a separate connection where incoming (or server mode) is allowed.
      If I understand your context right, you have not tried running a TCP server (e.g. HTTP web server on port 80). Can you please confirm if my understanding is correct.

      • Hello Vishnu,
        Thanks for a reply.
        Actually I have successfully run TCP server. In fact, I have successfully done TCP Client/server module. But the only problem is that of UDP server. I have also followed steps mentioned on your blog by Mr Mark Jordan but the same issue.
        Thanks in advance!

      • I see the same here. Only TCP connections pass to the SIM900 server. UDP seems to be blocked somewhere.

  35. Hi Vishnu,
    Thanks for the article, I am using sim900a gprs to send and get data from server, I am able to send and get data from server properly.
    But when I am reading HTTP response from server using AT+HTTPREAD, it is able to read upto 20min after that my controller is hanging.

    Can you suggest any solutions for this.

    i am using this below commands

  36. hi vishnu, i m using MOXA oncell G2110,
    i have executed AT+CGDCONT=1,”IP”,”rcomnet” command with OK
    but m getting error for this command AT+CIPSHUT which is shutting the previous ip which have been establised..

    • AT+CIPSHUT is designed to shutdown the current IP session (if any). The command is doing exactly what it is supposed to do. Check your command sequence. You should reconnect after shutdown (cleanup)

      • Hi Vishnu, about this data connection status, I think SIM900 has a firmware bug. Several times a TCP connection stops passing data without notice, both on server side and client side. The SIM900 in client mode reports (CIPSTATUS) CONNECTED but doesn’t receive any data sent by the server. The server also reports connected. SIM900 can be stuck in this state for hours. If I tell SIM900 to close the TCP connection and connect again, it resumes receiving data. It seems there is some inactivity timeout somewhere that breaks the link but doesn’t disconnect the TCP link when there is no data flowing for some time. Have you seen this behavior?

      • I have not seen this behavior specifically on Sim900, but on other connectivity modules, I have indeed experienced this. Everything succeeds but data returned is null. I still do not know the reason clearly, but I also do think it has to do with timeouts and how it is internally managed (along with socket timeouts internally). All my applications take the approach of CONNECT -> SEND -> RECEIVE (if any) -> DISCONNECT in an infinite loop. This works all the time.

    • APN is dependent on your data provider. For example, in India, if I use a SIM card from the company named “Airtel”, then generally, the APN is For the specific provider in your country, please check with the company.
      The UNAME and PWD are also provided by your data connection provider. Please call the SIM card company and get the details.

  37. Hey Vishnu, I’m the person who contacted you via Twitter.
    I’m working with a Telit GT864 PY module and I’m trying to get it to send POST requests. I’ve been trying to follow your guide, but the module won’t accept the CIPSHUT or the CIPSTATUS commands, it says “Command unrecognized”. Are these steps important in order to get the module to send the requests? Are there other commands that I could use that get me the same results? Help is greatly appreciated.

  38. hello Vishnu
    I have some questions:
    1 / I read all the reviews but I did not find a complete example to read data via HTTP, plz give us a complete example, and if you can with two method
    2 / I want to send data (coordinates of a mobile (from a GPS)) to the PC for display on Google maps, plz can you advise me what is the most effective methodological
    Best regards

  39. Hi Vishnu,
    I am using Arduino and GSM module. The GSM/ GPRS modem is connected via 12V/ 1A adapter. I uploaded a code for SMS/ Voice call on Arduino. It works fine. But when I try to make a data call, it does not work. Shows up ERROR. Or simply does not connect. I tried via Arduino, Terminal Software (Error connecting port.) and even online AT command tester (Error connecting port). I got a USB-to-RS232 (DB9) connector too. No use. Can you suggest something to get me out of here?

    • This is a difficult one. There could be many things that can go wrong. A few of them could be:
      1. Can the module operate at 1A. I know Sim 900 can take upto 2A. Check voltage/current requirements of the module
      2. Does the module support GPRS in the given band
      3. Does your data plan support GPRS
      4. Does the module firmware need any update
      5. Are you issuing the right command set and in the right sequence

      • Hi Vishnu,
        Thanks for the prompt reply. The invaluable advice you gave was all that I was looking for. I have been looking for the answers to the pointers you gave. Here they are:
        1. I am not able to get any information about this module. Though I have been doing some hit-and-trials. As shared before, I connected via 12V/1A adapter. It shows ERROR. I changed the adapter to 12V/1.5A. Any AT commands (even simple AT) returns nothing. So, I have concluded that the module does not support >1A. But I don’t have an adapter < 1A. 😦
        2. Module's support on GPRS band is as good as SIM900A's support on GPRS band. So, it does support 900/1800 MHz band. (Ref.
        3. The SIM I am using support GPRS, and the same band. I checked.
        4. There have been several updates from the firmware version (Rev. 1137) my module has. Though I am not so sure if they are exactly what is blocking me, but I will still give it a shot. (Will post an update on this.)
        5. I am issuing commands in the same sequence as in this tutorial. Though for test purposes, I have done them one by one.

        Coming back to 12v/1A, I reduced my code to
        1. AT
        2. AT+GSV (version inquiry about firmware)
        3. AT+CGATT?

        for this, I get the response as below:
        [I have reduced newline here.]

        So, apparently, I am not getting any response for "AT+CGATT?". I did further HnT, I am able to find that if I issue single command, it will respond. But not so when I issue 2 commands. I suspect there is something wrong with the serial communication as well. Even though I am flushing the stream after every response, I get the same reply from the modem, again.

      • The command and response pattern does not seem right. If I understood the response pattern right, I’m not sure why the response is repeated thrice.
        You should send one command, then read the response, then the next and so on. Between every command, keep a gap of 2 seconds and see if it works

  40. hi Vishnu
    i want to send data with AT+HTTPDATA (sim800) and post, can u give me an exemple for site script php wich can receive data with request GET

  41. Sir,
    I am trying to connect to my website “”
    It shows connect ok
    But I wrote a html script and tried to connect to “www.xxxxxx/my.html”
    It shows error CONNECT FAIL

    What is the reason?

    • 1. From your comment, the path you have provided is “www.xxxxxx/my.html”. This looks wrong, unless it is a typing mistake. The path should have been “”
      2. Are you able to access the page when you type “” in the browser
      3. In your HTTP GET, you need to provide the relative path “/my.html”. Are you sure your command is right

      • Hi i want to make arduino + Gsm module a webserver and want get request on that gsm server so that m able to control appliances to on off. So plz tell me is it possible ? And how?

      • Hi m using SIM 900 and arduino. And i want to make arduino+gsm module a webserver so through http get request m able to switch on off my appliance. Plz help

      • For a GSM module to be able to listen to a port, you need a static IP (alternatively, the complex method of DNS updates for name resolution). Getting a static IP on a SIM card, is not an easy process even for businesses. The easier way, is to create a GSM client, that will poll the server and check whether to switch on/off the device. There are more ways, like using CoAP with an edge router etc.,but then, you will have to start from scratch I guess.

      • Thanks for the reply
        is there any other solution like 3G shields etc for acting as a web-server ?
        but i think same case is there because m using a Sim there or is it not?

      • To act as a server, your device needs to listen on an IP address and a port number. The IP address and port must be searchable by the routers and DNS system. Additionally, your network provider must allow for incoming connections. This has nothing to do with 2G or 3G.

      • Thanks for the reply again
        so how is it possible to control appliances from web using the controller and gsm shiled ?

      • Mahesh, this is a difficult question to answer in this tiny reply box! It requires considering a lot of different variable, legal aspects and design. Something, that needs great amount of discussion and time. As an alternative, have a polling system, that keeps checking for next command from server. That could get you started much faster, although, not the most efficient and will bring in longer lag.
        You are perhaps trying to do something similar to what is given here But then, it uses ethernet.

  42. Hai Vishnu,

    Am Using SIM908 quad band GSM/GPRS which combines GPS technology.For initial setup same procedure to be followed for this devise? and how to get latitude and longitude?

  43. Hi Vishnu,

    Can you let me know how to read this values in webserver ? what configuration can be done in website.

    Thanks in advance

    • Well, this would need a very long answer. In short, have a HTTP server run on your device, ensure it is accessible from your PC and then simply send GET/POST commands to the device from your PC browser. Not sure what is the question

  44. Hi Vishnu,

    Thanks for your contribution to this comumunity.

    I want to ask you, I’m having trouble getting the ‘SEND OK’ during a TCP connection. I do get the CONNECT OK.

    Let me detail you my steps:
    1. After I issue the AT+CIPSEND I get the ‘>’ char.
    2. Later I send my data for example ‘V1=234’ and add the CTR+Z ascii with NO 0x0A new line.
    3. I wait for the SEND OK reply but the module does not reply with this.

    What I think is :
    1. Is it enought only printing the CTR+Z as for example serial.write(0x1A)
    2. am I missing an 0x0A character?

    Thanks !

  45. Good afternoon,
    the AT + CREG command?
    I’m getting an answer + CREG: 0.2
    that seems to be rather not registered, right?

    What should I do?

    • If response to AT+CREG comes back as :0,2 then it means not registered and the module is not searching for a provider to register. This generally means the network operator, whose SIM card you are using, does not have coverage in that area. To double check, put the SIM in a phone and see if the phone is able to register to network

  46. sir
    i am using sim 900a gprs module
    by using your commands below







    upto now it was cleared…
    but failed to upload data to the speaking things channel..
    i am using the AT+CIPSEND but it was not responding to my commands to send temperature value “which is 5 characters like 30.23 “to channel…
    i have to send my data to channel 1 using this api key…

    please suggest me the commands to send data

  47. Hi Vishnu,
    Did you note that sometimes SIM900 TCP connections seems to get “suspended” forever?
    The server gets TCP CLOSED but the SIM900 does not!
    It seem the operator doesn’t inform SIM900 that the TCP connection closed.
    I had to implement some ACK/NACK protocol between SIM900 and the remote server to get more reliability in the connection.
    In other cases I had to make SIM900 connect, send the info, receive some info and disconnect.
    It seems a firmware bug, but I’m using the latest B15 version.

    • Hi Mark,
      I never use Sim900 over TCP (HTTP) and I do not use it in a way where it is connected to the network for long term. So I have not noticed this (or I may have missed noticing this problem). I use Constrained Application Protocol (CoAP) over UDP. My code almost always opens a connection, sends data, optionally waits for an acknowledgement (based on exchange type, CON or NON) and then disconnects. If connection/send fails multiple times, I reset the entire Sim900 module (using PWRKEY) and start the whole process again.

  48. Hi All,
    I have been working on sim 800L but no any result some AT commands do work but if i try to call or send sms error comes up my location is Nigeria where we have MTN-nigeria, Airtel, Glo Nigeria so I need help.

    • Abu,
      You need to check if you have network. If I’m correct, Nigeria GSM band is 900/1800. First check if network is available, then try to issue commands. Also check the UART settings.

  49. Hi Good morning All,
    I am tested SIM800 with help of minicom , everything happening proper.

    We have written serial program(with same baud , parity ,data , stop and parity) to send same AT commands, whatever message we have sent , same AT command replying(if we write “AT\r\n” message to serial port ,read message also AT, if we write “AT+CPIN?” message to serial port ,real message also same as send message”)

    please do needful at earliest.


    • Have you disabled echo. When echo is enabled, any command you send, the same command will also come back in response. To disable echo, you can issue the command ATE0 .

  50. hey mr.sharma
    i am using the sim900a for gprs connection
    here i sent all AT commandS successfully and i have create my website through
    now when i send AT+CIPSEND than it gives responce > and after i send the massage with cntrl+z and it gives the response ur massage is sent but when i open the webpage on browzer i didnt see my massage than how can i see the massage i have no idea about that wht happen next?

    • That is not how websites work Mahesh. When you send your data from the Sim900 to the webserver, you need to have a program on the webserver that will accept your request and then, store it in some kind of database. Then, you need to have another program written on the server that you can execute by calling a URL. For example, let’s say your website is at You can write a program on the server side that will be called when you visit the URL , which in turn will instruct the web server to excute your code which in turn will read the data from the database and then return the result as an HTML.

  51. hello sir,
    i have a sim900a module, its work properly 2-3 months ago, but now it is not going to connect to network. if connection be establish in any how then modules power off automatically and connection being lost.
    please suggest whats a problem.

    • I have never come across this problem, but a quick search on google tells me, that this could be a power supply issue. Please check if during bursts, if the voltage dips too much (I guess below 3V). If that is the case, then the module will automatically shut down

  52. HELLO SIR ,
    I m trying to send the data to ip address but I can’t send data
    I using this cmt at+cipstart=”tcp”,”″,”8080″
    <<ok .please replay for solution

    • From your post, it is not clear as to what error you are getting. You need to first check that a TCP port 8080 is indeed open at the IP
      Additionally, you also need to ensure that the TCP listener is designed to return you data.

  53. Hello Sir, Your blog is interesting and educative, please keep it up.
    Am working on internet based based wireless electronics notce board and am experiences some challenges. Please I have two questions Sir;

    1. How do I create a web server on a microcontroller so that I can use my internet
    enabled mobile phone and log into the server through the address and update
    messages to the board through internet.

    2. How do I achieve the system using SIM 900 and a Microcontroller without
    connecting the system to a PC. The SIM 900 will serve as internet service
    provider and the microcontroller will perform the required operation. Please I
    appreciate any help and advice you will render to me in other to achieve this.


    • 1. Creating a web server on the microcontroller is not a trivila task. You should include existing implementations (e.g. wolfSSL or simpler Tuxgraphics)
      2. I think you are confusing…when you say Sim900 will serve as “Internet Service Provider”. All you want to do perhaps, is when you device switches on, the Sim900 acts like a web server and you can type in the URL in your PC/mobile phone and configure. This requires that whenever Sim900 connects to the network, it is given a pre-defined (static) IP address by the mobile tower. This is generally not granted by any network operator and is a complex procedure to obtain one.

      With a cellular device, you should design your system around a process where your device is a client and connects to a remote server. That is much easier to achieve.

      • Thank you so much Sir for your Prompt reply. I think I have used the wrong terms. I mean that the SIM 900 will provide internet access to the system while the microcontroller acts as the main server. Also is there any other way I can go about this task with only the SIM 900 and the microcontroller without having to connect to a PC remote server. Any suggestions will be of great help. Thank you Sir in advance for your reply.

      • Generally, what people do, is to have another WiFi chip in the system. The Wifi chip opens up as an access point. You can have your webserver implemented, and people can connect to your device using WiFi. Any query to internet can be routed through the Sim900. Look at a good WiFi chip called AMW006 from Zentri Corp.

  54. I am trying to test TCP connection on SIM900.
    1. I have created a GPRS connection and got the IP address for my idea sim.
    2. I got the IP address of my laptop from myipaddress
    3. I run the socket test version 3 program and created a socket with port no 555
    4. I tried to connect the TCP connection with a command
    AT+CIPSTART=”TCP”,”XXX.XXX.XXX.XXX”,”555″ (where XXX.XXX.XXX.XXX was ip address of my laptop)
    5. I get response as OK but never get “CONNECT OK” why?
    Always I get CONNECT FAIL (TCP CLOSES) after some time. BUT I Never get “CONNECT OK” response.
    Please help

    • You will never get to connect like this.. If your laptop a part of internal network (e.g. IP address is of type then its internal. The Sim900 cannot reach unless you have network translation. The only way is to have your machine exposed to internet (generally via a static IP and no firewall on the ip/port).

  55. Hi Vishnu…

    My project uses GPRS communication. How can we assign the APN parameter if I don’t know the service provider previously. I mean, the network going to be used is unknown, only the client knows it (whether AIRTEL,BSNL,Vodafone or any other). How can it be handled via same firmware??

    • The way I do it is as follows:
      1. I always build my device with a USB/COM port provision
      2. I write a PC application.
      3. User connects the device to the PC
      4. User enters all the required configuration parameters in the PC application
      5. The PC application sends the data to the device (connected via USB/COM port)
      6. The device stores the data in the EEPROM
      After this, the device can read from EEPROM and work.
      Your case is “field configuration” for which, what I described above is the most common method.

  56. I’m trying to connect a SIM800 module to a server using a VPN between them.
    At the moment, I communicate them using http get request from the SIM800 to the server (i want to update to https to improve security, it doesnt seem to much complicate with the AT commands manual).
    The thing is, i dont know if its posible to connect to the VPN using this GPRS module. Does anyone tried it before?
    When we achieved the VPN connection, Will we be able to continue doing the same https GET request ? or Do you advise any other method to improve the security and amount of data traffic?

    BTW, very good blog.

    • You are mixing multiple things. Using HTTPS is not the same as having a VPN. Having a VPN is something that the private network owner creates. When you use the public network of the cellular service provider, you do no get a VPN. You need to talk to the cellular service provide if you want VPN between your device and the server (because the carrier is your cellular network owner). In most cases, this will be denied.
      The best you can do, is to have some form of authentication and use HTTPS. That way, the authentication process will ensure server is talking to the right device and with HTTPS, you will have secure communication.

  57. hi guys,
    i am planning to make my dynamic IP static by giving a domain name. I made it possible using duckdns. But since my IP is dynamic i have to update my IP to duckdns website which is also possible. But i have an issue, i am not always getting +PDP: DEACT when the IP expires. Is there any way to notify me about the IP expiring. I am not preferring CIPSTATUS command. I prefer notification instead

    • Hi Alex,
      I have never tried this on my own. But theoretically, +PDP:DEACT is an unsolicited result code. You should be getting this. One command to control the URC is AT+CGEREP . Have you tried tinkering around with this. Additionally, I would also suggest that you should have both approaches in the code – depend on URC and periodically, also check for the PDP activation status. Only then, this will be fool-proof.

  58. Assalamualaikum, It is great that you release good informative videos which help many over the internet. Actually I would like to know how I can implement FOTA (Firmware update over the Air) for Pic micro controller with GSM kit. please advise.

    • I have never done this on my own, but here is a possible solution:
      1. Setup a webserver with a webpage that can be called by the GSM module. Let’s call it
      2. The webpage named firmware.aspx, when called, will return the bytes of the new firmware to the caller in the response
      3. On your device side, using the GSM module, make an HTTP call to the page
      4. This page will return the firmware bytes which you can temporarily store on your device (may be a local RAM)
      5. Now, perform firmware upgrade of your PIC microcontroller. I do not use PIC microcontroller, so this you should check in the datasheet. You already have the new firmware locally available to you (either in a separate RAM or in the PIC memory itself)

      Hope this helps.

  59. Hi Vishue Sharma!

    please help me and say me how to can read the answer from my serial (sim9oo) after command AT in special the command AT+CIPSTART, this one conect me to my server. i want to turn on some led with this condition and know if my sim900 is conect with my server … if the sim 900 is conect the answer will be “CONECT OK” after i can send my information to server … how can i put this condition? thanks por you help !

    • Fernando,
      If I understood you right, you want to turn on an LED after you receive CONNECT OK response after issuing AT+CIPSTART command. You should be simply able to read the UART response after sending the AT+CIPSTART command and check in the returned string, if CONNECT OK string is present or not.
      Alternatively, if you want to check continuously whether your Sim900 is connected to the server or not, you can issue the command AT+CIPSTATUS command and know the status of the current IP connection.
      Hope I understood your problem correctly.

  60. Hey vishnu sir! I am doing the same project using sim 808 module .Can u tell me about the baud rate to be set in that case?Thanks in advance

  61. Hi Vishnu,

    First of all, thank you very much for all the support that you provide in the blog. I have learned many things after reading the logs.

    I am a new bee with the GPRS. I am using SIM900 module. I can call a phone number and send a SMS message now. But I can not get an access to the internet yet. I have checked some AT commands as follows:









    However I don’t know clearly username and password. Could you please send me your suggestions how to connect to the internet. (Not: Simcard is registered and connected to the internet. However using a GPRS module, I can not. Why?

    Waiting for your valuable suggestions.


  62. Hi Vishnu, maybe you can help me to solve a problem I’m having on a SIM340 based device I made years ago. Those devices were working ok until last year. Now some of them are not connecting anymore to the TCP server. I send the CIPSTART command and the SIM340 responds OK as usual. A couple seconds later the module send “ERROR: 1” and “STATE: IP STATUS”. Have tried SIM cards from different operators but no luck, same error. Googled for a solution but found nothing.
    Any ideas?

    • Hi Mark,
      This is a difficult one to solve ! I can only make a best case guess. If all of them were working and now some of them are no longer connecting, then my best guess is that something in the external environment has changed (Very rare that the module is past its life and not good anymore, but a possibility). Sim900 was a replacement of Sim300/340. Now, even Sim900 has reached end-of-life. The two most common factors, that I can guess (from experience) is the carrier properties. Sim340 is a 2G module, check the following – Do you have 2G network in your area for the given provider. If all modules are using data from same network provider, then this may not be the case. Did you run out of data limit for the device. Almost all these modules require PTCRB and carrier approval. I found an old datasheet for Sim340, and it states that this module has PTCRB approval. In addition, you still need carrier approval. If the module is not approved by the carrier, after a while, they might reject connection requests. Check if this is the case.

      I once had a similar problem, where a device working for two years suddenly stopped and CIPSTART was failing. I spent a lot of time debugging without any luck. I realized only a few days later, that the phone company that provided me the SIM card had closed 2G operation in my area. I solved it by using another SIM card from a different company which still supported 2G.

      See if you can find out such environmental factors .Good luck.

      • Hi Vishnu, I have made some more tests and found the culprit seems to be the server. The SIM340D connects to other computers flawless. The “ERROR: 1” only shows when connecting to the server it used to connect.

        It is interesting that several SIM900 based devices continue to connect to the same server!

        Will ask the server admin for a solution.

        Thanks for your comment.

  63. Hi. I need your help. I bought sim900 module. I’m trying to send an email with attachment (jpg and bmp) through SMTP. I receive email, but file is corrupted. After opening corrupted file with HEX editor, I found out that sim900 automatically adds CR(carriage return) and LF(line feed) to the file. That causes corruption of file. I also updated firmware to the latest one. How I may fix this problem? Is there any AT command to stop this?

  64. I am trying to test TCP connection on SIM800L.
    1. I have created a GPRS connection.
    2. I tried to connect the TCP connection with a command
    3. I get response as OK but never get “CONNECT OK” why?
    Always I get Reboot on SIM800L. BUT I Never get “CONNECT OK” response.
    Please help

    • I looked at the AT command datasheet for Sim800 ( On page #183, the documentation for AT+CIPSTART is given. Here, it is clearly written that you will get OK if the argument format is correct. You get CONNECT OK, only when connection is successful. It seems, that the AT+CIPSTART command parameters are correct, but the connection is failing because the domain/port is wrong. Also, the connection might fail if the DNS resolution fails. To check this, you can try out with an IP address first and see if you get CONNECT OK

  65. Hi, I have been trying to connect the GSM module and for some reason I have been getting error in at+cipstart command while the rest of the commands have given expected output.

    • What is the error you are getting? If the CIFSR command is giving you the IP address, you need to check the DNS and port number. Do you really have a server listening on it. You may try to use the IP address instead of the DNS.

  66. It’s very helpful
    My project is to send some data from gsm sim900 arduino shield to the out platform orome other website
    Can I get the code and guide lines from you
    My project is on arduino 🙂

  67. Hi Vishnu,

    Thanks for the amazing post.. It’s so helpful..

    I’m trying to post data from the Arduino to a server using your method.. But i can’t..

    This is the response..

    Please help me to fix this..

    Chitraveer Akhil









    POST h

    The request is not being completed..It is not printing the other commands such as


    Help me to fix this..

    • 1. In AT+CSTT, you are only passing the APN name. If there is no userid and password, pass blanks. I have seen some subsequent commands fail if we do pass blanks (I dont know why). So,in your case it should be AT+CSTT=”www”,,
      2. STATE: TCP CLOSED indicates that the server is not listening on port 8080. You should first use IP address and port number. Then, if that works, then use the domain name and the port number. Additionally, check if server is listening on port 8080, and even if it is, check for any firewall settings that might block incoming connections

      • Thanks for the reply Vishnu.. But still the same error is happening..







        CONNECT OK



        The server is not blocked.. The port number is 80(not 8080).. Thanks for that..

        POST h

        The request is not being completed..It is not printing the other commands such as


        The comments are been stopped.
        It is not completing the other commands such as

        “{ \”testId\” : 1, \”testval\” : 1, \”valTest\” : 12.983027, \”dataTest\” : 80.2594\” }}”;

        Chitraveer Akhil

  68. T




    +CREG: 0,1







    +CREG: 0,1










    POST /obdListener/obdreceiver/insert HTTP/1.1


    SIM900A R11.0

    { “ve180


    This is the complete result I got..
    The port is in open state..







    POST /Listener/receiver/insert HTTP/1.1


    SIM900A R11.0

    { “ve180


    The TCP port number is 80..
    The server is in open state..
    Help me to fix this Vishnu..

    Chitraveer Akhil

    • CIPSEND is low level command generally used for raw TCP/UDP socket. You can use this for HTTP requests also. HTTP POST is specifically designed for HTTP exchange only. It is nothing bur a wrapper over CIPSEND. Just makes it easier to do HTTP exchange over TCP sockets by hiding all low level stuff.

  69. Hello, first of all thank you for the really helpful article, I’ve been searching for something like this for a long time. I’d like to ask two questions on this topic, I’d really appreciate if you’d some time to reply.

    First, we’d like to use the GPRS modem in a way where we don’t use AT+CIPSEND commands, but setup a kind of *trabsoarebt* mode, where we just send the raw data via serial connection and the modem will transparently forward it via it’s set up TCP connection. This mode could be ended with the +++ sequence. Somewhere I’ve read about it being possible, but I’m unsure about it’s wide support.

    Secondly, I’d like to ask how could one setup a modem as a server, so it would start to listen on a given TCP port and transparently send the received data via serial.

    We’d use this setup in an embedded system to communicate between devices, each having a GPRS modem installed in it.

    • Answer to Q1: Zoltan, you can always use the transparent mode and send/receive raw bytes over TCP/UDP. For all my IoT projects, I use the CoAPSharp library. I create a CoAP request, convert that into bytes and then, send it over the UDP connection using Sim900. To do this, you need to set the transparent mode (use AT+CIPMODE=1). After you get the IP address, you can start the task (use AT+CIPSTART) and wait for CONNECT in the response. From this point onwards, you can send the raw bytes. To read the response, keep polling the serial port (or setup serial port for interrupt mode). Once done, to close the data mode, you can write +++ to the serial port and wait for about 500 milliseconds. The module will come back to command mode. I have done this multiple times (using Sim900, Sim800) and this works.

      Answer to Q2: If you want to create a server in your module, then tough luck. You need a data plan that allows you to open an incoming port. In my country, this is nearly impossible (unless you work for the government perhaps). However, if you do get a SIM card that supports incoming connections, then I guess you can simply read from the serial port (polling or interrupt) after setting it into transparent mode.

      • Thank you for the quick and detailed answers, it was really helpful. We have all the SIM cards in a private APN network, and all of them have their own static IP address, I should’ve mentioned that, sorry. Could you please help in two more follow-up questions?

        1. How to configure the modem to have static IP address?

        2. Is it possible to store all the configuration in the modem, like APN name, username, password and the static IP address? Or do I have to feed it from upper level every time the modem starts up?

        3. Sorry your answer about the modem acting as server wasn’t completely clear to me. How exactly can I make the modem start listening to a given port and put it into transparent mode afterwards? I know that after this I can simply poll the serial port, the question is about the modem side.

        Thank you in advance.

      • 1. To configure the modem to have static IP address, can you please check AT+CGDCONT. Such things can perhaps be controlled using PDP context (I have not used this, so if you try this out, please let me know)
        2. Some AT commands do store the parameter values in NV RAM. I always use an EEPROM in my design which allows me to store all such values in a single place.
        3. To configure the modem to act as a server, check the command AT+CIPSERVER. An excellent application note on TCP server can be found at

  70. Hello bro,
    I have made a project which is arduino and GSM900 based which is displaying some data(numerical) on lcd,so now i want to see that data on my laptop on a webpage or on single page software so would you plz tell me any way through which i can do so?

    • Most simplistic approach:
      1. Create a website with at-least one page to view and one page to accept data
      2. Let’s assume that page that accepts data has a URL
      3. Using the concepts presented here, send data to the page in point #2. For simplicity, if you are using HTTP GET, then sending the temperature could look like
      4. When the URL in point #3 is called, extract the querystring named “temperature” and store the value (25.00) in your database.
      5. Now, to view the stored value, create the viewer page and lets say the URL is
      6. When the URL in point #5 is typed in the browser, the code of the page, queries the database and renders the data on the page.

      • Thanks for your response,
        Bro, do you think changing of a value is also possible through that webpage for suppose there is a formula which i am using for calculation just like “a+b” and want to change value of “a” occasionally through that webpage is it possible? to do so?
        again i do really appreciate your quick reply

      • If I understand your question right, on your micro, you have a formula like a+b=c, where “a” could be a constant and current value is lets say 30. Now, on the webpage, you can store the value of “a”. Your micro can do a HTTP “GET” to retrieve that value.
        All this is already available via the IoT platform CoAPWorks ( If instead of HTTP, you use CoAP then each fo the things people ask for (e.g. storing a value on webpage, getting configuration values etc) are all available via this platform via CoAP protocol.

  71. Hi Sir,
    I am created the TCP connection and proceed for data sending.. but how to send a message from Android app.. that’s how to access that GSM modem like via IP address or port or what?? .. please help me

  72. Hello Sir, am trying to implement the SIM900 to send data as sms using Atmega32 USART. The problem is, am having much difficulty getting the module to communicate with the microcontoller. Is there any help you can render sir?

  73. hello sir…good afternoon..

    im using same steps as you mention.and i aslo successful to send data to thingspeak for some duration
    .but now i get this error–HTTP/1.1 400 Bad Request
    Server: nginx/1.9.3
    after SEND OK reply on serial monitor ..why this error occures …is their any range problems.

    • HTTP/1.1 400 Bad Request means that your syntax (and/or input data) is malformed. It is not following the rules specified by thingspeak. I would suggest that you read the documentation of thingspeak and make adjustments as required.

  74. hello, My project is energy meter monitoring over IOT, in this i am have to send the data on webpage using gsm sim900, i’ve to make a webpage where the data is constantly changing, but i am not sure how to do this. Please help

    • 1. Select a programming language (PHP,Java, .NET)
      2. Select an appropriate hosting provider (PHP hosting, Java hosting, .NET hosting)
      3. Create a webpage that accepts HTTP POST
      4. In that page, extract posted data
      5. Create a database (Oracle, SQL , MySQL)
      6. Ensure hosting provider also gives you the required database
      7. In your webpage, after extracting the POST’ed data, save in the database
      8. Create another webpage
      9. In that webpage, select the data from the database
      10. Write code in the webpage to show the data in appropriate manner

  75. Hello, Sir I want to sent data from my gsm module to a website which keeps on changing every 30sec.
    What should i do to display the data in the textbox in .net, And i don’t want to use database

  76. Hi! This is a brilliant blog and comments make it even better. I am using SIM808 for a vehicle tracking system. I am faced by 2 constraints.

    First, I cannot upload a packet of more than 255 bytes.

    Second, the port is automatically Closed after a successful CIPSEND. So I have to do CIPSTART every cycle.

    These 2 constraints induce a very tough situation in which I can only send small packets to server, that also not continuously but a gap of 30-40 seconds! What could be the possible solutions?

  77. At+cipstart=”TCP”,””, “80”

    Connect ok

    Get https://………..Key…Value

    Send ok

    But data not shown on thingspeak

  78. Hi sir,
    I am working on tracking system and I am using SIM808. I have hosted my websocket server on heroku and trying to connect that using Sim808 and I tried to console id of socket clients connect to server but when i try to connect to server from sim808 I get CONNECT OK response but connection gets closed after sometime and server does not console any socket id





    +CMTI: “SM”,5

    • The +CMTI:”SM”,5 indicates that there is a message waiting in the buffer. Have you checked your code on the server side. Most common mistake programmers do, while writing socket code, is to not handle the incoming socket properly after an “accept”, thereby, leaving the handle as orphan. Check your server side code first and then come back to this code if server side is fine.




    .+QIACT: 1,1,1,”″


    .HTTP/1.1 400 Bad Request
    .Content-Type: text/html; charset=utf-8
    .Date: Fri, 21 Apr 2017 08:43:16 GMT
    .Connection: close
    .Content-Length: 2959
    … . Facebook | Error. . . . . . . . . html, body {. color: #141823;. background-color: #e9eaed;. font-family: Helvetica, Lucida Grande, Arial,. Tahoma, Verdana, sans-serif;. margin: 0;. padding: 0;. text-align: center;. }.. #header {. height: 30px;. padding-bottom: 10px;. padding-top: 10px;. text-align: center;. }.. #icon {. width: 30px;. }.. h1 {. font-size: 18px;. }.. p {. font-size: 13px;. }.. #footer {. border-top: 1px solid #ddd;. color: #9197a3;. font-size: 12px;. padding: 5px 8px 6px 0;. }. . . . . . . . . . Sorry, something went wrong.. . We’re working on it and we’ll get it fixed as soon as we can.. . . Go Back. . . Facebook. . © 2017. . . ·. Help Center. . . . . document.getElementById(‘back’).onclick = function() {. if (history.length > 1) {. history.back();. return false;. }. };.. // Adjust the display based on the window size. if (window.innerHeight < 80 || window.innerWidth < 80) {. // Blank if window is too small. = 'none';. };. if (window.innerWidth < 200 || window.innerHeight < 150) {. document.getElementById('back-link').style.display = 'none';. document.getElementById('help-link').style.display = 'none';. };. if (window.innerWidth < 200) {. document.getElementById('sorry').style.fontSize = '16px';. };. if (window.innerWidth < 150) {. document.getElementById('promise').style.display = 'none';. };. if (window.innerHeight < 150) {. document.getElementById('sorry').style.margin = '4px 0 0 0';. document.getElementById('sorry').style.fontSize = '14px';. document.getElementById('promise').style.display = 'none';. };. . ..

    • In fact, you have received a response from the facebook website. The response indicates you have successfully made a request, but one or more mandatory parameters in the request is missing. To test, try calling a more simple page, something that simply returns very small data and has no dependency. Perhaps a blank HTML page.
      The “NO CARRIER” that you receive, even after a successful response from facebook, perhaps means there could be some syntax error in the commands you are issuing. Check with the datasheet once again.

  80. Hi sir i checked my arduino and gsm sim808 code everything works fine with socket test application and I am able to send gnss data but my server hosted on heroku does not recognize my device

    ///index.html inside script tag in body

    socket.on(‘new message’,function(data){
    var html=”;
    var users_id=$('#users');
    html += '’+data[i]+”;

    socket.emit(‘new message’,client);

    Please help me

    Thanks in advance

  81. hi Vishnu ,

    i have created TCP server in SIM800H to receive Command from Cloud getway while using HTTP for sending Data to Cloud. i have two issue :

    1) cloud getway expecting acknowledge as 200,OK for each request generated to SIMCOM device , but SIMCOM not generating ACK. (getway is LWM2M and getway awaiting ACK for OBSERVE command)

    2) TCP server, which created for receiving Command , is suddenly stopped getting Command from cloud . it again receiving after GPRS Init only.

    • Satish,
      There is not enough technical details for me to clearly outline what is the problem. Therefore, as a first attempt, here are some generic reasons:
      1. Are you running Sim800H as a TCP server? If yes, then please understand, across the world, generic SIM cards do not support incoming connections. You need special permission to have a SIM card that allows incoming connections. Did you get that permission? (or are you a part of a testing / certification team simulating the tower in your lab)
      2. When you say ACK is expected for OBSERVE, this is a CoAP concept. Are you using CoAP protocol (since I’m aware that LWM2M uses it). If yes, then your SIM800H should have opened a UDP server on port 5683 and not TCP or HTTP.
      3. As stated in point #1, incoming connections are not allowed in a SIM card, so any incoming request will be dropped.

      Your setup and use of protocol at different levels is not very clear for a 100% accurate resolution to the problem. Check the above and let me know if it help, otherwise, send more details.

      • Hi Vishnu ,
        Thanks for Reply , find my point to point to response:

        1) yes ,we got Special Permission from SIM operator , and they provided with static public IP. after permission we are able to receive Command generated from Cloud getaway.
        2) this is OMA LwM2M and we are using JSON script . UDP is not preferable due to security concern.
        3) we are receiving command from Cloud getway as below log but cloud not receiving HTTP ACK ( 200,OK) from our Device ( SIMCOM)

        in below LOG first device sending “details” to cloud successfully and then Cloud sending “OBSERVE” on TCP server




        {“adaptLayerId”:”862877030295321″,”details”:{“device/0/endPointClientName”:”862877030295321″,”connectivity/0/network bearer”:”0″,”connectivity/0/radio signal strength”:”0″,”connectivity/0/IP address”:”″,”connectivity/0/IP address type”:”IPv4″,”connectivity/0/APN”:”PRIVATEAPN”,”connectivity/0/periodic data interval”:”300″,”connectivity/0/ICCID number”:”00″,”connectivity/0/phone number”:”0″,}}



        REMOTE IP:

        +IPD,277:POST /devices HTTP/1.1
        Content-Length: 97
        Connection: Keep-Alive
        User-Agent: Apache-HttpClient/4.5.2 (Java/1.7.0_97)
        Accept-Encoding: gzip,deflate



      • In order for your device to be able to send the HTTP Status code 200 (OK), the device must be either configured to run as an HTTP server, or you need to manually set that response code. When I look at the AT command manual at I do not see any HTTP command to set the response code. Also, when I read it, it seems the commands AT+HTTPXXXX are for HTTP client and not server. To set the module as a server, you perhaps need to use AT+CIPSERVER. Have you done that? If not, the try checking with some application not on how to run the module as a server.

      • Is there any GSM/GSPR Module available which can be configured as HTTP server ? kindly confirm .

        I am doing AT+ CIPSERVER but I believe it is TCP server not HTTP server so Module is not responding as 200,OK.

      • HTTP server is a higher level protocol (Application layer in OSI layer). It works on top of TCP/IP (lower layers). I’m not aware if any module implements HTTP server. You need a separate library for that.

    • Sim808 should be very similar to Sim900. Just look at the Sim808 AT command manual. Follow the commands in this blog and if there are any minor changes, make them as per the AT command manual. In fact, if you visit the manufacturers website, on Sim808, they have given the link to Sim800 datasheet. Its all the same.

      • yes i followed that but i want to share the connection with arduino wanted to do the same thing as ethernet does.

      • For that, you need to implement the networking stack. For example, you can write ‘BSD style’ socket API and underneath you can provide a simplistic imlpementation (e.g. SLIP protocol). This is a huge task and not something that you can do with ATMEGA328p kind of controllers.

  82. Not a good option, but given your restrictions, here is what you can do:
    1. Create a page to which the module will post data. Let’s say, the URL is
    2. Once data is received by the page above, it can parse and extract the data and forward to a page with URL
    3. The page in step 2 can then show the data in a text box and it will get refreshed everytime new data is received from the module

    You gave me this ans to my solution on April 5th post as Prashant!

    I have following query:

    I created a web page!!
    But how will the gsm900 will send data on the website?
    And i also want to know how will the data be parsed and extracted ?

  83. AT+CIPSTART=”TCP”,””,”80″

    GET HTTP/1.1

    HTTP/1.1 400 Bad Request
    Connection: close
    Server: Cowboy
    Date: Wed, 03 May 2017 10:19:44 GMT
    Content-Length: 0


    What could be an issue

    • HTTP 400 – Bad Request means that the request sent to the server is missing something or is corrupted. When I type the URL (GET request), I see a webpage. If you indeed wanted webpage HTML content to be returned, check what other parameters the GET request needs. Alternatively, you should first test with a basic HTML page (perhaps a blank page).

      • ok sir thanks and which parameter is missing please let me know because i tried all possibilities

      • Akshay,
        I apologize, I do not use the website. It seems you already have an account with them. So please check their documentation.

  84. Hello Mr Vishnu Sharma , i’m using STM32F4discovery and i want to send a picture(76Kbytes) to a webserver using SIM900, can you tell me how can i send these enormous quantity of data using SIM900? And thank you

    • First take the picture and store it locally (in an external RAM or SD card).
      Then use one of these two methods:
      1. Open a TCP connection and perform byte transfer. Create a simple protocol that could be; always send 32 bytes. First byte is start indicator, second byte is sequence number, followed by data bytes. Second last byte is true/false to indicate if more data is coming in. Last byte is a CRC.So 28 bytes of data and 4 bytes of metadata
      2. Open an HTTP connection. Post 32 bytes as per the scheme given above. To make it easier, convert the bytes to Base64 string and then simply post them as a string value or a parameter.

  85. Hi

    when I use this code then I got the error
    the line code is

    AT+CIPSTART= “TCP” , “”, “80”

  86. Sir I have to access internet from SIM800L module using Airtel sim card and transmit that internet data over wifi through ESP8266 wifi module so that I can access internet in my smart phone through wifi.please tell me how this can be made

  87. hi sir,
    u r article is really interesting,i need help from u sir
    how to send image data to server using lpc1768 or any controller via GSM/GPRS.
    actually this is possible or not?

    im using below code but always respond with error after sending the data using CIPSEND

    PUT /Thingworx/Things/etiajmp_mohamedkhalil1711/Properties/mykidname?appKey=58b3eb57-36ef-4f59-aa45-79b60099b052 HTTP/1.1
    Accept: application/json, */*
    Accept-Encoding: gzip,deflate
    Connection: keep-alive
    Content-Length: 21
    Content-Type: application/json
    {“mykidname” : “Amr”}

    below is the response i always get after enabling the tcp and sending the data



    TCP connection success


    > PUT /Thingworx/Things/etiajmp_mohamedkhalil1711/Properties/mykidname?appKey=58b3eb57-36ef-4f59-aa45-79b60099b052 HTTP/1.1

    Accept: application/json, */*

    Accept-Encoding: gzip,deflate

    Connection: keep-alive

    Content-Length: 21

    Content-Type: application/json


    {“mykidname” : “Amr”}



    TCP connection is closed by remote server

    • There could be many reasons for this:
      1. Incorrect IP address
      2. Incorrect port
      3. Port and service mismatch (e.g. asking for SSL on port 80)
      4. Incorrect input data format (the data you supply after CIPSEND)

      First, send a simple request and check connectivity, before starting to add headers and data. One step at a time.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s