GET request using AT commands SIM800 SIM900

In this post I am writing how to send a GET request using GSM Module with AT commands. It should work with any module and has been tested to work with Sim800 series  (SIM800C-DS , SIM800ASIM800H, SIM800L, SIM800C, SIM800 etc) and Sim900 series (SIM900, SIM900A, SIM900D, SIM900B) of modules from simcom.

You have to bring up GPRS connection before this obviously , which is not covered here in this post.

 

HERE ARE THE STEPS TO MAKE GET REQUEST

Initiate the HTTP service

AT+HTTPINIT
> OK

Set the HTTP session.

AT+HTTPPARA=”CID”,1
> OK

Set the HTPP URL

at+httppara=”URL”,”google.com”

Start the session<

AT+HTTPACTION=0
> OK

> +HTTPACTION:0,601,0

The above AT response code (601) for HTTP session start indicates that there is a network error. Then make sure that the PDP context is setup properly.

IF the HTTP session is successful, it should return code of ’200′,

AT+HTTPACTION=0
> OK
> +HTTPACTION:0,200,4

Above HTTP GET request is sucessful and it returned 4 bytes.
To read the data of the HTTP server,

AT+HTTPREAD
> +HTTPREAD:4
> test
> OK

To terminate the HTTP service,

AT+HTTPTERM
> OK

UPDATE:

Sometimes a 601 Error code is received in response. @Bruno Lewin shared a link to a StackOverFlow Answer about the issue and I feel that I should include it here as well

 

Here are the minimum setup commands that have worked for me (based on trial/error and searching around on the internet).

AT+SAPBR=3,1,"APN","wap.cingular"
AT+SAPBR=1,1

The correct value for the APN may be different for you, depending on your network and service provider.

Status codes above 600 (and some in the 500 range) are unassigned in the HTTP standard. In the AT command manual for the SIM908, status meanings are given in the notes on the HTTPACTIONcommand:

600 Not HTTP PDU
601 Network Error
602 No memory
603 DNS Error
604 Stack Busy

You can query the bearer connection status of CID 1 with AT+SAPBR=2,1 and the related parameters with AT+SAPBR=4,1. You can also check that you’re attached to the GPRS network with AT+CGATT?. If everything indicates that you are connected and you are still getting a 601 status code, then check that your service plan has data and that it hasn’t run out. I have found that even when my account has a few hundred k of data showing on the balance that I start to get a 601 status until I add more data to my prepaid phone plan. If the SIM module has been on the whole time and you add more data, you’ll need to close and re-open your connection (AT+SAPBR=0,1 followed by AT+SAPBR=1,1) and then your HTTP* commands will start working again without having to set the HTTPPARA settings again and without having to restart with HTTPINIT.

 
Dost Muhammad Shah

Dost Muhammad Shah

Dost Muhammad specializing in Embedded Design, Firmware development, PCB designing , testing and prototyping. He enjoys sharing his experience with others .Get in touch with Dost on Twitter or via Contact form

 

18 thoughts on “GET request using AT commands SIM800 SIM900

  1. i need to upload temperature and some other sensors data to a domain at 000webhost.com i tried to use both httpget and httppost commands with sim900 connected to rpi3 but i always get error 603 that error had appeared once for me previously and was solved by restarting the module ,now it does not want to disappear what may be the problem ? putting in consider that the sim credit and Internet data both are recharged

    1. Hi,
      600 series of http error codes are not assigned in the standard.

      Status codes above 600 (and some in the 500 range) are unassigned in the HTTP standard.

      In the AT command manual for the SIM900, status meanings are given in the notes on the HTTPACTION command:

      600 Not HTTP PDU
      601 Network Error
      602 No memory
      603 DNS Error
      604 Stack Busy

      If you still haven’t solved the issue can you please share the part of your code that is responsible for the connection to the host? Also please share the url of the server where you are connecting to. In case you have solved please do share the reason /fix.

  2. hello i am using sim900 i am getting the information from the scanner but i do not know how to use it please help me.

  3. Hello Muhammad Shah, Nice Post, I am getting At response Code 603, how to fix the issue. please help. thank you. Dileep

  4. Thank you Mr Muhammad for sharing your expertize, I’m just starting to take CScience course and this blog is goinf to help a lot to understand some practical things, as I am starting to play around with some arduinos and SIMs, server, clients and so on.

      1. Thank you for your quick replies. But I am new to using gprs using gsm board. How to set up the PDP context and get the entire GET request successfully using the module.

    1. Sir,

      I am trying to send the data using gprs sim 800a,i am getting network error,before executing the AT+SAPBR=1,1 Signal strength will be good but as soon as AT+SAPBR=1,1 is executed led starts blinking continuously and returns response code 601.can you please help me how to resolve this issue? here is the AT commands used and the responses i got

      AT
      OK
      AT+CGATT=1
      OK
      AT+SAPBR=3,1,"Contype","GPRS"
      OK
      AT+SAPBR=3,1,"APN","airtelgprs.com"
      OK
      AT+SAPBR=1,1
      OK
      AT+HTTPINIT
      OK
      AT+HTTPPARA="CID",1
      OK
      
      AT+HTTPPARA="URL","URL:PORT"
      OK
      AT+HTTPPARA="CONTENT","application/json"
      OK
      AT+HTTPPARA="USERDATA","KEY1:VAL1, KEY2:VAL2,..."
      OK
      AT+HTTPDATA=40,80000
      DOWNLOAD
      {\r\n
      "m2m:cin" :{\\r\n
      "con" : "FIRE"}\r\n
      }
      ok
      AT+HTTPACTION=1
      ok
      +HTTPACTION:1,601,0
      1. 601 is some custom implemented Error code.

        Here is the list of standard HTTP Status codes

        +HTTPACTION:0,601,0

        The above AT response code (601) for HTTP session start indicates that there is a network error. Then make sure that the PDP context is setup properly.

        source

Leave a Reply to sgthoppaCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.