HTTP-POST via SIM900 and AT+HTTPDATA

Hi,
I’m trying to send measured data every second by a HTTP-POST Message to a Server.
Establishing a TCP-Connetion by CIPSEND works OK, excepting the OutOfMemory errors.

I’ve read that the SIM900 module has a proper function to send HTTP-Post messages.
It is documented in “an_sim900_ip_application note_v1.00_draft.pdf” but without examples.

Until now I have tried very much without any success…
The conection is established well, every command gets an OK or positive answer.
How do I can debug a bit deeper?

Do anybody has a working code-snippet to help me?

Here some debug-console-text:


AT

Recieved : AT

OK

ATE1

Recieved : ATE1

OK

AT+CPIN=9257

Recieved : AT+CPIN=9257

OK

AT+CIPMUX=0

Recieved : AT+CIPMUX=0

OK

AT+CIPMODE=0

Recieved : AT+CIPMODE=0

OK

AT+CGDCONT=1,“IP”,“internet.t-mobile”,“0.0.0.0”,0,0

GC: 3msec 26556 bytes used, 37824 bytes available
Type 0F (STRING ): 288 bytes
Type 11 (CLASS ): 1212 bytes
Type 12 (VALUETYPE ): 816 bytes
Type 13 (SZARRAY ): 2268 bytes
Type 15 (FREEBLOCK ): 37824 bytes
Type 16 (CACHEDBLOCK ): 120 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1932 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : AT+CGDCONT=1,“IP”,“internet.t-mobile”,“0.0.0.0”,0,0

OK

AT+CSTT=“internet.t-mobile”

Recieved : AT+CSTT=“internet.t-mobile”

ERROR

AT+HTTPINIT=?

Recieved : AT+HTTPINIT=?

Recieved : OK

AT+HTTPINIT

Recieved : AT+HTTPINIT

OK

AT+HTTPPARA?

GC: 3msec 27384 bytes used, 36996 bytes available
Type 0F (STRING ): 252 bytes
Type 11 (CLASS ): 1212 bytes
Type 12 (VALUETYPE ): 1152 bytes
Type 13 (SZARRAY ): 2712 bytes
Type 15 (FREEBLOCK ): 36996 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 2136 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : AT+HTTPPARA?

+HTTPPARA:
CID: 1
URL:
UA: SIMCOM_MODULE
PROIP: 0.0.0.0
PROPORT: 0
REDIR: 0
BREAK: 0
BREAKEND: 0
TIMEOUT: 120
CONTENT:

OK

AT+HTTPPARA=“CID”,1

Recieved : AT+HTTPPARA=“CID”,1

OK

AT+HTTPPARA=“URL”,“http://www.myserver.de/janitza/j.php

GC: 3msec 27528 bytes used, 36852 bytes available
Type 0F (STRING ): 228 bytes
Type 11 (CLASS ): 1224 bytes
Type 12 (VALUETYPE ): 72 bytes
Type 13 (SZARRAY ): 4356 bytes
Type 15 (FREEBLOCK ): 36852 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1728 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : AT+HTTPPARA=“URL”,“http://www.myserver.de/janitza/j.php

OK

AT+HTTPDATA=5,20000

Recieved : AT+HTTPDATA=5,20000

DOWNLOAD

AT+HTTPACTION=1

Recieved :
OK

AT+HTTPDATA=69,20000

Recieved : AT+HTTPDATA=69,20000

DOWNLOAD

key=jts,1348000766;u1,230.1;u2,230.1;u3,230.1;i1,2221;i2,1222;i3,2221
GC: 3msec 26328 bytes used, 38052 bytes available
Type 0F (STRING ): 252 bytes
Type 11 (CLASS ): 1452 bytes
Type 12 (VALUETYPE ): 96 bytes
Type 13 (SZARRAY ): 4356 bytes
Type 15 (FREEBLOCK ): 38052 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 4164 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1932 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved :
OK

AT+HTTPACTION=1

Recieved : AT+HTTPACTION=1

OK

+HTTPACTION:1,601,0

Recieved :
+CREG: 2

+HTTPACTION:1,200,424

AT+HTTPREAD

Recieved : +HTTPACTION:1,200,424
AT+HTTPREAD

OK

Recieved :
+CREG: 1,“8905”,“B454”

GC: 3msec 23052 bytes used, 41328 bytes available
Type 0F (STRING ): 252 bytes
Type 11 (CLASS ): 1452 bytes
Type 12 (VALUETYPE ): 672 bytes
Type 13 (SZARRAY ): 4416 bytes
Type 15 (FREEBLOCK ): 41328 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 252 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1932 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved :
+CREG: 1,“8905”,“7C18”

1 Like

I don’t know anything about the SIM900 module. Just want you to know that before expecting me to be too much help :slight_smile:

AT+CSTT="internet.t-mobile"
 
Recieved : AT+CSTT="internet.t-mobile"
 
ERROR

That to me is the problem. Resolve that before assuming anything after it is at fault.

You mention OutOfMemory error. Where?

GC: 3msec 26556 bytes used, 37824 bytes available
 Type 0F (STRING ): 288 bytes
 Type 11 (CLASS ): 1212 bytes
 Type 12 (VALUETYPE ): 816 bytes
 Type 13 (SZARRAY ): 2268 bytes
 Type 15 (FREEBLOCK ): 37824 bytes
 Type 16 (CACHEDBLOCK ): 120 bytes
 Type 17 (ASSEMBLY ): 11748 bytes
 Type 18 (WEAKCLASS ): 48 bytes
 Type 1B (DELEGATE_HEAD ): 144 bytes
 Type 1D (OBJECT_TO_EVENT ): 72 bytes
 Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
 Type 1F (THREAD ): 768 bytes
 Type 20 (SUBTHREAD ): 96 bytes
 Type 21 (STACK_FRAME ): 1932 bytes
 Type 27 (FINALIZER_HEAD ): 96 bytes
 Type 31 (IO_PORT ): 108 bytes
 Type 34 (APPDOMAIN_HEAD ): 72 bytes
 Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes

Those are standard Garbage Collector debug output and don’t show any error and don’t show out of memory. In fact, “26556 bytes used, 37824 bytes available” is pretty healthy. If you look at a later one, the available bytes increases too.

Welcome to the community RJunghanns!

@ RJunghanns, How are you communicating with the cellular module? SPI, COM?

Thanks Brett and kurtnelle for your replies,
I’m still beginner in NETMF and apreciated for every advice of you.

I am using a FEZ Panda II board with an Seeedstudio GPRS shield with SIM900 chip.
To send data to a server via POST command I have tried two ways:

I. via AT+CIPSEND → http://netduino2seedgsm.codeplex.com/releases/view/82492
The memory errors appeared here in a stringbuilder-class http://www.tinyclr.com/codeshare/entry/203
II. via AT+HTTPDATA

The 2nd way seems easier with less code and finally I got it work.
There was missing the
AT+HTTPPARA="CONTENT,“application/x-www-form-urlencoded”
to interpret the key by the server.

If the string to send is too long, i have to separate it to two substrings and send it with a delay of 1000ms each.
Can you explain me why?

The execution of the code stops befor regulary ends. After the “AT+HTTPACTION=1” comes a “AT+HTTPREAD”, but it was executed only on or two times.
Sometimes the execution stops after AT+SAPBR=1,1. Sometimes not.

Thanks for you interest and your help.


Here the debug-code:

AT

Recieved : AT

OK

AT+CPIN?

Recieved : AT+CPIN?

+CPIN: READY

Recieved :
OK

AT+SAPBR=3,1,“CONTYPE”,“GPRS”

Recieved : AT+SAPBR=3,1,“CONTYPE”,“GPRS”

GC: 2msec 25572 bytes used, 38808 bytes available
Type 0F (STRING ): 204 bytes
Type 11 (CLASS ): 1152 bytes
Type 12 (VALUETYPE ): 144 bytes
Type 13 (SZARRAY ): 2112 bytes
Type 15 (FREEBLOCK ): 38808 bytes
Type 16 (CACHEDBLOCK ): 120 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 12 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1908 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : OK

AT+SAPBR=3,1,“APN”, “internet.t-mobile”

Recieved : AT+SAPBR=3,1,“APN”, “internet.t-mobile”

OK

AT+SAPBR=1,1

Recieved : AT+SAPBR=1,1

ERROR

AT+HTTPINIT

Recieved : AT+HTTPINIT

ERROR

AT+HTTPPARA=“CID”,1

Recieved : AT+HTTPPARA=“CID”,1

OK

AT+HTTPPARA=“URL”,“www.myserver.de/janitza/j.php

GC: 3msec 26580 bytes used, 37800 bytes available
Type 0F (STRING ): 192 bytes
Type 11 (CLASS ): 1212 bytes
Type 12 (VALUETYPE ): 984 bytes
Type 13 (SZARRAY ): 2544 bytes
Type 15 (FREEBLOCK ): 37800 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 5868 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 1728 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : AT+HTTPPARA=“URL”,“www.myserver.de/janitza/j.php

OK

AT+HTTPPARA=“CONTENT”,“application/x-www-form-urlencoded”

Recieved : AT+HTTPPARA=“CONTENT”,“application/x-www-form-urlencoded”

OK

AT+HTTPDATA=5,10000

Recieved : AT+HTTPDATA=5,10000

DOWNLOAD

AT+HTTPACTION=1

Recieved :
OK

AT+HTTPDATA=177,20000

GC: 3msec 23580 bytes used, 40800 bytes available
Type 0F (STRING ): 264 bytes
Type 11 (CLASS ): 1452 bytes
Type 12 (VALUETYPE ): 360 bytes
Type 13 (SZARRAY ): 2868 bytes
Type 15 (FREEBLOCK ): 40800 bytes
Type 17 (ASSEMBLY ): 11748 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 144 bytes
Type 1D (OBJECT_TO_EVENT ): 72 bytes
Type 1E (BINARY_BLOB_HEAD ): 2424 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 2136 bytes
Type 27 (FINALIZER_HEAD ): 96 bytes
Type 31 (IO_PORT ): 108 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 900 bytes
Recieved : AT+HTTPDATA=177,20000

DOWNLOAD

key=jts,1348000766;u1,230.1;u2,230.1;u3,230.1;i1,2221;i2,1222;i3,2221;p1,2220;p2,2113;p3,4113;
q1,1120;q2,2113;q3,4113;s1,3320;s2,2113;s3,4223;cp1,2000;cp2,2123;cp3,4113;f,50.001
Recieved :
OK

AT+HTTPACTION=1

Recieved : AT+HTTPACTION=1

OK

Several times you are getting ERROR reported. There’s some comms issue going on, either the code is trying to send those strings too quickly or they’re mis-formed. I’d be trying to delve into that.

Hi RJunghanns,

the specified APN looks a bit unusual. There is the country code missing. Looking at your profile, I assume you are in Germany, so for T-Mobile the APN normally is “internet.t-mobile.de

Regards
Daniel

hi,
this might be too late but it may help you or someone else. When you call
AT+SAPBR=1,1
you instruct the module to find the IP Address and then start the connection (Command Manual says open bearer). The reason it is failing is most likely because you have not set the IP Address. In fact this command should then give you the IP address found. To set the IP Address use

AT+CGDCONT=1,“IP”,“apn”,“172.030.008.050”,0,0

As you realize the latter command sets the apn, so am not sure if whether to use AT+SAPBR or AT+CGDCONT for setting the APN.

Hope that helps

Hi everybody
I managed to send data with AT + DATA HTTP to my server, but I do not know the proper script code of my site to read these data, can someone plz help myself?

We’re going to need a lot more information before anyone can help, and even then, you are asking a server-side question on a client-side set of forums.

But, on the off chance we can help out, how are you hosting your site? That is, hosting company? OS? web server? site scripting environment (php, asp.net)?

At best, you will probably get general pointers to some recommendations for a better place to ask your server-centric question.

EDIT: Also, it would be best to start a completely new topic rather than asking off-topic questions on this thread.