Search code examples
modulearduinogsmiotgprs

sim800L gprs post request


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://: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.

enter image description here

enter image description here


Solution

  • Did you set up your PDP context already? I think some main concepts are that you need to successfully attach and startup GPRS connection.

    Some things that need to be active before this will work:

    1) Network registration

    AT+CREG?     should return 0,1    if so, skip to 2)
    

    if it doesn't then you can start by turning on and off the modem by inputting AT+CFUN=0 and then AT+CFUN=1

    if you are still having problems registering make sure you have selected the correct network: AT+COPS? should see your service providers name in the results eg. AT+COPS: 1,0,"T-Mobile USA"

    If you don't, then make sure your band is set properly to your service provider. Look up your providers 2G band e.g. t-mobile uses PCS_MODE for their 2G service. set this via: AT+CBAND="PCS_MODE"

    Also, obviously you should make sure you have signal: AT+CSQ should return at at least a 5 or 6

    2) Network Activation

    AT+CIPSHUT   
    AT+CGATT=1      - this can take some time to get through. I have a 40 sec timeout
    

    Its important for this step to work. If it doesn't perhaps restart your modem. But this is a key part.

    3) setting PDP context and bringing up GPRS service

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

    set your APN: find out what your 2g APN is from your provider. e.g. for t-mobile: epc.tmobile.com define your APN:

    T+SAPBR=3,1,"APN","epc.tmobile.com"
    
    AT+SAPBR=1,1        This is the most important part to get through. Sometimes it takes a while to get through, I have a timeout on this part for 3 minutes to let it work.
    

    if this doesn't give you an error proceed:

    4) sending HTTP Basically proceed with what you have...

    an example of what I do:

    AT+HTTPTERM
    AT+HTTPINIT
    AT+HTTPPARA="CID",1
    AT+HTTPPARA="URL","www.google.com"
    AT+HTTPACTION = 0      This should return 200 if it is successful
    

    5 shut down GPRS

    AT+CIPSHUT    this may give you an error buts its not important
    AT+SAPBR=0,1     can take awhile 
    AT+CGATT=0       also can take a while
    

    anyways I wrote some pretty neat lightweight code for arduino to send data via HTTP. I also wrote one for SMS. let me if you want to take a look. I use a SIM800L -- one of the cheap breakout boards.