Académique Documents
Professionnel Documents
Culture Documents
ravi@valetron.com (mailto:ravi@valetron.com)
(/)
Page 2 of 2
We will upload a file to the server using HTTP POST multipart/form-data method. You can
search in google for more information on multipart/form-data method of sending data in
HTTP POST. In this method the POST variables are sent between demarcation strings called
boundary.
The server will be told before what boundary will demarcate our data in the HTTP header. In
our case below our Boundary string is ----WebKitFormBoundaryvZ0ZHShNAcBABWFy.
Here we are using the Henry's HTTP POST Dumping server available at the
url http://www.posttestserver.com/ (http://www.posttestserver.com/) .
Lets get started and when we are already allocated a IP address, now we can proceed
by enabling the HTTP mode
AT+HTTPINIT
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 1/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
OK
OPTIONAL, ONLY IF URL is HTTPS or SSL enabled: Also Remove the http:// part in the
HTTPPARA="URL",xxxx command
AT+HTTPSSL=1
OK
Start by setting up the HTTP bearer profile identifier
AT+HTTPPARA="CID",1
OK
Set the url to the address of the webpage you want to post to
AT+HTTPPARA="URL","http://posttestserver.com/post.php"
OK
Set the Content as multipart/form-data type of HTTP POST and also set the boundary value
AT+HTTPPARA="CONTENT","multipart/form-data; boundary=----
WebKitFormBoundaryvZ0ZHShNAcBABWFy"
OK
Tell the module that you will be sending 192 bytes of data and it can timeout after 10 seconds of inactivity. 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 Hello Ravi
AT+HTTPDATA=192,10000
OK
DOWNLOAD
------WebKitFormBoundaryvZ0ZHShNAcBABWFy
Content-Disposition: form-data; name="fileToUpload"; filename="data.txt"
Content-Type: text/plain
Hello Ravi
------WebKitFormBoundaryvZ0ZHShNAcBABWFy
OK
Execute the HTTP POST command so that the buffer contents are POST to the server
AT+HTTPACTION=1
OK
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 2/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
This URC means that the data was successfully posted to the server and a received a data of 141 bytes which is the server
response to your HTTP POST
+HTTPACTION:1,200,141
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
After this you can see the uploaded file at the above URL. Note: The data length to be
uploaded is very strict here and needs to be carefully calculated. So i wrote the below script
which can be RUN on Windows and Linux using GCC. Also make sure you set the correct
COM port in Windows and right tty/USBx device in Linux You can modify according to your
use. Watch the video above to get more idea. This code also needs the RS232.c Library which
you can find here >> Serial Port programming in Linux using C - Working code
(/embedded/189-serial-port-programming-in-linux-using-c-working-code)
demo_tx.c
(https://www.raviyp.com/plugins/content/highlight_code/highlight/vista_p
#include <stdlib.h> #include <stdio.h> #ifdef _WIN32 #include <Windows.h> #else #inclu
Watch this video if you want to see the live demo (https://youtu.be/QsNcfxc8YSA),
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 3/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
(https://youtu.be/QsNcfxc8YSA)
Also see:
ztex.de OPEN
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 4/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
Sort by Best
Recommend ⤤ Share
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
Hi Venkat,
Thank you :)
By default it will be in text or ascii format unless you
encode it.
I dont understand where the data is getting converted to
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 6/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
binary. Could you please explain more?
△ ▽ • Reply • Share ›
sprintf(_buffer, "#;%s;%d-%d-
%d;%d:%d;%f;%f",imei,(uint16_t)rtc.year,
(uint16_t)rtc.month,(uint16_t)rtc.date,
(uint16_t)rtc.hour,(uint16_t)rtc.min,temp,humid);
HTTP_Post(_buffer, responseLength);
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere";
filename="nogithub.txt"
Content-Type: text/plain
QWERTY
---------------------------acebdf13572468--
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 7/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
Hi Naresh,
Please post your tech queries here.
http://www.embeddedadvice.com/
We can discuss
△ ▽ • Reply • Share ›
Hi Daniel,
Please post tech queries here,
http://www.embeddedadvice.com/
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 9/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
We can discuss.
△ ▽ • Reply • Share ›
Hi Venkat,
Regards,
Ravi
△ ▽ • Reply • Share ›
#define pinPowerSIM900 9
TinyGPS gps;
SoftwareSerial sGPS(10,9);
void setup() {
pinMode(pinPowerSIM900, OUTPUT);
digitalWrite(pinPowerSIM900,LOW);
see more
△ ▽ • Reply • Share ›
see more
△ ▽ • Reply • Share ›
Thanks in advance.
△ ▽ • Reply • Share ›
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","mtnirancell"
AT+SAPBR=1,1
AT+SAPBR=2,1
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 13/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
AT+SAPBR=0,1
//get
AT+HTTPINIT
AT+HTTPPARA = "CID",1
AT+HTTPPARA="URL","www.sim.com"
AT+HTTPACTION=0
AT+HTTPREAD
AT+HTTPTERM
△ ▽ • Reply • Share ›
_______________________________________________
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+SAPBR=3,1,"APN","internet.com"
see more
△ ▽ • Reply • Share ›
△ ▽ • Reply • Share ›
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","http://posttestserver.com/p..."
OK
AT+HTTPPARA="CONTENT","multipart/form-data; boundary=---
-WebKitFormBoundaryvZ0ZH
ShNAcBABWFy"
OK
AT+HTTPDATA=192,10000
DOWNLOAD
ERROR
△ ▽ • Reply • Share ›
Set the url to the address of the webpage you want to post to
AT+HTTPPARA="URL","http://posttestserver.com/p..."
ERROR
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 15/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
△ ▽ • Reply • Share ›
AT+CGATT=1
OK
AT+SAPBR=3,1,"Contype","GPRS"
OK
AT+SAPBR=3,1,"APN","airtelgprs.com"
OK
AT+SAPBR=1,1
OK
AT+SAPBR=2,1
+SAPBR: 1,1,"100.100.97.117"
see more
△ ▽ • Reply • Share ›
back to top
Facebook (http://www.facebook.com/sharer.php?u=https://www.raviyp.com/embedded/194-
sim900-gprs-http-at-commands)
Twitter (http://twitter.com/share?url=https://www.raviyp.com/embedded/194-sim900-gprs-http-
at-commands&text=SIM900%20GPRS%20HTTP%20AT%20Commands%20-
%20Jump%20to%20SIM900/SIM800%20HTTP%20POST%20request)
(https://plus.google.com/share?url=https://www.raviyp.com/embedded/194-sim900-gprs-http-at-
commands)
(http://www.linkedin.com/shareArticle?mini=true&url=https://www.raviyp.com/embedded/194-
sim900-gprs-http-at-commands)
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 16/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
(https://plus.google.com/102969188306424582103)
Email:ravi@valetron.com
(mailto:ravi@valetron.com)
Find us on Google+
(https://plus.google.com/104907583360502363516)
HIRE ME FOR YOUR PROJECT AS A
FREELANCER
Ravi Pujar
YouTube 2K
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 17/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
Subscribe
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 18/19
9/2/2018 Jump to SIM900/SIM800 HTTP POST request - Page 2
Embedded World
7.1K likes
Like Page
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands?showall=&start=1 19/19