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 , SIM800A, SIM800H, 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
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
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).
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
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,1and 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=1,1) and then your
HTTP*commands will start working again without having to set the
HTTPPARAsettings again and without having to restart with