8 Replies Latest reply on Nov 16, 2016 4:48 AM by BigG

    GPRS module HTTP GET/POST

    alexmawashi

      Hello Everyone,

      I've been working on a LoNet mini GSM module (SIM800L), interfacing it with Arduino.

      I've inserted the SIM mobile card with Internet connection available.

      Through serial monitor I'm communicating with it with no problems, but when it comes to make a GET or a POST request to a webserver page it returns Network Error (601).

      Here it is:

       

      AT+SAPBR=3,1,"CONTYPE","GPRS"

      OK

       

      AT+HTTPINIT

      OK

       

      AT+HTTPPARA="CID",1

      OK

       

      AT+HTTPPARA="URL","http://<Public_Ip_Address>:8080/folder/savedata.php"

      OK

       

      AT+HTTPACTION=0

      OK

      +HTTPACTION: 0,601,0      //601: Network Error

       

      AT+HTTPREAD=1,100000

      OK

       

      And no response of the "echo" of the php page...

      Do you have any suggestion?

      Thanks in advance.

        • Re: GPRS module HTTP GET/POST
          BigG

          Usually after this command AT+SAPBR=3,1,"CONTYPE","GPRS" you  enter your "APN", "USR" & "PWD" details also using SAPBR=3,1 etc. These details must match the SIM card / mobile phone provider.

           

          Then it is recommended to check that your device has now received an IP address. Sometimes this is not straight away. Use AT+SAPBR=2,1 to query and this will return your IP address which you should check for confirmation.

           

          Once you have IP address you can enter AT+HTTPINIT, AT+HTTPPARA="CID",1 etc.

           

          Now to use GET you have to include a "?" after the URL to provide your php script with a key=value pairing.

           

          Thus in your case it is something like, AT+HTTPPARA="URL","http://<Public_Ip_Address>:8080/folder/savedata.php?A=1001" where A is the key and 1001 is the value.

           

          Now send the AT+HTTPACTION=0 and you should get a +HTTPACTION: 0,200,1000 response where 200 is the OK and 1000 is the payload size. AT+HTTPREAD will allow you to read the response if it is required.

            • Re: GPRS module HTTP GET/POST
              alexmawashi

              Hi BigG, thanks to your response, it is very useful to me...

              What I still don't understand is:

               

              why do I have to set APN (access point name), USR, PSW, if I don't connect to the Internet using an Access Point?

              I want to connect to the Internet using GPRS directly, without passing through a Lan or through a Router which I have to connet to.

              Thanks again.

              • Re: GPRS module HTTP GET/POST
                alexmawashi

                HiBigG,

                I got what you wanted to say. We talk about APN,USER,PSW of the Provider of the GPRS sim card.

                I've searched these pieces of information on the Internet and I've found: APN= "tre.it", USER=""; PSW=""

                then I wrote the following commands, but, as you can see, I cannot get a valid IP address to start the connection:

                 

                RDY

                +CFUN: 1

                +CPIN: READY

                 

                Call Ready

                 

                SMS Ready

                 

                AT

                OK

                 

                AT+CGATT? 

                +CGATT: 1

                OK

                 

                AT+CGATT=1

                OK

                 

                AT+SAPBR=3,1,"CONTYPE","GPRS"

                OK

                 

                AT+SAPBR=3,1,"APN","tre.it" 

                OK

                 

                AT+SAPBR=3,1,"USER","" 

                OK

                 

                AT+SAPBR=3,1,"PWD","" 

                OK

                 

                AT+SAPBR=2,1 

                +SAPBR: 1,3,"0.0.0.0"

                OK

                 

                ... What am I getting wrong? Thanks.

              • Re: GPRS module HTTP GET/POST
                BigG

                Hello, no you are not getting anything wrong as far as I can tell. Assuming you have credit on SIM card, are using the right settings and that you have reasonable cellular signal strength etc, then what is happening is that you are waiting for the tre.it AP to assign you an IP address. As noted in my original post, this does not always happen straight away. You could wait awhile (minutes) on some occasions and other times you can get one straight away. You just keep checking every few seconds using AT+SAPBR=2,1

                  • Re: GPRS module HTTP GET/POST
                    arun@819

                    HI BigG

                     

                    hello i am  also working in sim 800 and whenever i try to update to the http server i am facing these kind of errors mainly

                     

                    +HTTPACTION: 0,603,0 (Dns error)

                    +HTTPACTION: 0,601,0 (network error)

                    +HTTPACTION: 0,604,0 (stack Busy)

                     

                    i am not getting any idea how to solve it  tried whatever u were telling to  Alessandro Argentieri but i was not able to solve it is there any way to get to know what the problem is by using any other  at commands .

                     

                    1)how to overcome the stack busy error ?

                    2)  i got network error (+HTTPACTION: 0,601,0 ) but when i call it picks my call? at that moment.

                     

                    please help me to sought the error

                     

                    Thanks in advance

                  • Re: GPRS module HTTP GET/POST
                    BigG

                    Arun, if I recall from past experience this could have something to do with your server script rather than with device hardware/code. Are you trying to get a large amount of data in return via a server response. If it is stack related you may need to use a chunked data response. Sometime you need to buffer at server side before responding. Did you try a "hello world" test etc. to make sure a basic http request works.

                    • Re: GPRS module HTTP GET/POST
                      arun@819

                      HI BigG

                       

                      I am able to uplod data to the server but sometimes i get these type of errors which i mentioned earlier.Please look at the issues also.

                      I am trying to post the data to the server and my buff size will be around  150KB and with some delay i am posting one more data which will be around 30KB

                       

                      and some times i get this error +HTTPACTION 604 (stack error ) and after that i get one more error is +HTTPACTION 603(dns error) .

                      • Re: GPRS module HTTP GET/POST
                        BigG

                        Need to see your device and server code as well as know what microcontroller and server type is being used to rule in / rule out probable causes.

                         

                        Did you search stackoverflow, as a quick search revealed this link gsm - error +HTTPACTION:0,601,0 - Stack Overflow