I have a sim908 shield and I'm trying to send some data periodically to a server using AT commands. For every command, I wait for the response to check if everything is working. Actually the sketch works but, often, I noticed errors during http request.

State of the art:

Here it is the sequence of AT commands (not the entire code) into the loop:

1) Check the Network Registration and, if necessary, wait


2) Set params for GPRS connection (no user or password required)


3) Get current bearer


4) If bearer == 0,0,0,0 (not assigned) get a new bearer


5) Init HTTP


6) Set CID and URL


7) Execute the HTTP command (POST)


8) Close HTTP connection



Why HTTP init (step 5) or HTTP posting (step 7) often fails? What is wrong in this procedure? I'm missing something? There is a way to make the procedure more stable?

Thank you in advance :)

Important update:

If occurs an error during sending data via HTTP, is a great idea to renew the bearer (step 4)

Answers to the comments:

a) Shield has an antenna and it works. If I try to disconnect the antenna, code still search the network (step 1) untill I reconnect the antenna.

b) Some times I have this error initializing HTTP (step 5):



Some times I have only "OK" as response posting data (step 7) instead of:


Or this response:


c) I have error at step 4 (AT+SAPBR=1,1) only if I execute the command when I have yet a bearer. The error in this case is:



For this reason I do a check (step 3)

  • Does it have an antenna? And what particular error do you get back? Post messages should get an http+error back with a nummer.
    – aaa
    May 4, 2016 at 21:01
  • Did you get the results of the new bearer settings returned by AT+SAPBR=1,1? Post the exact +CMEE error code you're seeing. May 5, 2016 at 0:15
  • I edited the original post
    – Lipsyor
    May 5, 2016 at 16:22
  • CME ERROR: 3 is "operation not allowed". And HTTP response code 600 isn't officially something, try reading the message header and body, but it may be "invalid request".
    – aaa
    May 7, 2016 at 17:27
  • Thank you Paul. From documentation (waveshare.com/w/upload/4/4e/SIM908_AT-Command-Manual.pdf) 600 is "Not HTTP PDU". This error doesn't appear every time. For what you know, my procedure is correct?
    – Lipsyor
    May 7, 2016 at 17:31

1 Answer 1


You mention two different error messages.


You get +CME ERROR 3. Which means "operation not allowed".

This can be due to an improperly closed HTTP setup. If you get this error (or just always do before setting up), call AT+HTTPTERM to be sure that it's closed.


I notice you're trying to do a POSTmessage, while your variables are in the URL (which is GET style afaik).

I've found a source that states you need to call AT+HTTPDATA with apropriate values.

Tell the module that you will be sending 192 bytes of data and it can timeout after 10 seconds of inactivity.

After that, the device will say DOWNLOAD, and you can send the POST body.

After this command you get the DOWNLOAD URC then you can type in 192 bytes of data within 10 seconds. The typed data is filled in a local buffer of the module and is not yet posted to the server. In the post body is the multi part form data which contains the necessary headers and data to post a file with name data.txt with 10 bytes of data. AT+HTTPDATA=192,10000

And after that you can send the POST message.

Execute the HTTP POST command so that the buffer contents are POST to the server AT+HTTPACTION=1 OK

You will get a return message that states the HTTP code (200 'OK') and the amount of bytes received in the return message.

+HTTPACTION:1,200,141 This URC means that the data was successfully posted to the server and received 141 bytes of data. which is the server response to your HTTP POST

You can use AT+HTTPREAD to receive these bytes.

The below command tells the module that we want to read the received data AT+HTTPREAD The below is the data received from the server +HTTPREAD:141 Successfully dumped 0 post variables. View it at http://www.posttestserver.com/data/2015/10/07/07.41.291690063480 Post body was 0 chars long. OK

(Scroll a fair bit down in the source, the first part is on HTTP GET: http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands)

You could also omit this by using HTTP GET since it's somewhat easier.

If all else fails, you can set up a TCP IP connection with the GSM module and manually set up the HTTP GET/POST message.

  • Thank you for answer. About HTTPINIT fail, note that (step 8) I use HTTPTERM for each loop. I'll try what you suggest about GET and POST. However I don't understand why sometimes my code works and other times no.
    – Lipsyor
    May 7, 2016 at 18:38
  • I tried but without results. Now I'll try to wait more time for responses.
    – Lipsyor
    May 7, 2016 at 22:59
  • 1
    @Lipsyor which option did you try? I suggest trying to make a GET request working before you try the POST requests.
    – aaa
    May 9, 2016 at 13:24
  • 1
    I tried to wait more time for response: now GET and POST works. I have some problems with HTTPINIT: when it fails I can't recover with HTTPTERM and I had to try more times. I'm considering to reset shield if more than two or three errors occurs consecutively.
    – Lipsyor
    May 9, 2016 at 17:16
  • Hmm, atleast we're making progres here ;) have you checked how other libraries handle errors? If http init fails, you could check all the above again, at+creg?, at+sapbr and whatnot. Having to reset it is a bit crude (if it happens often). But it's good to have such a feature built in anyway.
    – aaa
    May 9, 2016 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.