You are on page 1of 18

9/2/2018 SIM900 GPRS HTTP AT Commands

 ravi@valetron.com (mailto:ravi@valetron.com)
(/)  

SIM900 GPRS HTTP AT Commands


 Ravi Pujar  28 January 2018

SIM900 GPRS HTTP AT Commands (/embedded/194-sim900-gprs-http-at-commands?


showall=&start=0)

Jump to SIM900/SIM800 HTTP POST request (/embedded/194-sim900-gprs-http-at-


commands?showall=&start=1)

All Pages (/embedded/194-sim900-gprs-http-at-commands?showall=1&start=0)

Page 1 of 2
This article is about showing you how to get the contents of a web page from and upload a
file to a web server using HTTP GET and POST methods. SIM900 GSM module provides a set
of AT commands which can be used for getting the contents of a web page and posting
variables and files to the web server through a GPRS connection.

LTE-M & NB-IoT Dev Board


ESP32 based Cellular IoT
MicroPython programmable Sequans Monarch based global cellular IoT
development

pycom.io OPEN

Before you begin make sure your SIM900 GSM module has acquired the network and it is
ringing when you make a call to it. Then test the basic AT commands and then proceed
further.


Once you are ready, you can start by first setting up the GPRS connection as follows, 

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 1/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Text in RED is typed by me and text in GREEN is the response from SIM900 module.

 Setting up GPRS connection

Set the connection type to GPRS


AT+SAPBR=3,1,"Contype","GPRS"
OK
 
Set the APN to to "www" since i am using a Vodafone SIM card, It might be different for you, and depends on the network
AT+SAPBR=3,1,"APN","www"
OK
 
Enable the GPRS
AT+SAPBR =1,1
OK
 
Query if the connection is setup properly, if we get back a IP address then we can proceed
AT+SAPBR=2,1
+SAPBR: 1,1,"100.120.204.132"
OK
 

Getting the contents of a webpage from the server

We will get the content of the webpage from my old website at the url
http://www.marsinnovations.in/testout.php,
(http://www.marsinnovations.in/testout.php,) which is a simple web page that puts out some
dummy text as shown below. You can retrieve any webpage you want. 

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands
 2/18
9/2/2018 SIM900 GPRS HTTP AT Commands

We were allocated a IP address and now we can proceed by enabling the HTTP mode

AT+HTTPINIT

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 access
AT+HTTPPARA="URL","http://marsinnovations.in/testout.php"
OK
 
Start the HTTP GET session, by giving this command
AT+HTTPACTION=0
OK
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 3/18
9/2/2018 SIM900 GPRS HTTP AT Commands

 
The below output from module indicates it  has read 654 bytes of data and the response of the HTTP GET request is 200,
which means success
+HTTPACTION:0,200,654
 
The below command tells the module that we want to read the received data
AT+HTTPREAD
The below is the data read from the webpage
+HTTPREAD:654
Logged Meter Readings:<br>Date Time: Current Voltage Temp.<br>
<br>Mon May 19 23:56:12 2014 :485683465429634
<br> :485683465429634
<br>Tue May 20 00:00:13 2014 :948598437599980
<br>Tue May 20 00:04:41 2014 :948598437599980
<br>Tue May 20 00:24:39 2014 :9485
<br>Tue May 20 00:25:37 2014 :9485
<br>Tue May 20 00:40:50 2014 :23423
<br>Wed May 21 00:07:19 2014 :948598437599980
<br>Wed May 21 00:43:20 2014 :34234324
<br>Wed May 21 00:47:15 2014 :34234324
<br>Wed May 21 11:12:10 2014 :34234324
<br>Wed May 21 15:23:22 2014 :34234324
<br>Wed May 21 15:28:07 2014 :564575676
<br>Wed May 21 15:38:06 2014 :564575676
<br>Wed May 21 15:43:53 2014 :564575676<br>
OK 
The contents above are the contents of the webpage shown before. 
 

See next page for the HTTP post request >>

Prev Next >> (/embedded/194-sim900-gprs-http-at-commands?showall=&start=1)

67 Comments Embedded World 


1 Login

Sort by Best
 Recommend ⤤ Share

Join the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 4/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Name

divum • 2 years ago


Hi Ravi ,

How can i check the Device flash size.

I am using SIM900A ,HTTP commands are working fine But


HTTPS is not working..My device flash size is 32MB...Please
kindly let me know the solution....
19 △ ▽ • Reply • Share ›

Muzzamil Shahid • 2 years ago


hi ravi!
kindly guide me how to read (GET) and upload values (POST)
using HTTP AT commands in JSON format?
kindly mention it in proper sequence?
4△ ▽ • Reply • Share ›

Udita Dua > Muzzamil Shahid • 7 months ago


hey, even i have the same question. could you find how
to do that ?
△ ▽ • Reply • Share ›

Ravi Pujar Mod > Udita Dua • 6 months ago


Hi Udit,
Please post your tech queries here.
http://www.embeddedadvice.com/
We can discuss
△ ▽ • Reply • Share ›

nada shata > Ravi Pujar • 2 months ago


i have the same question too,is there a
post explaining that sequence?
△ ▽ • Reply • Share ›

Bunny • a year ago


Hello Ravi,

Am sending the data to the URL from my logger using SIM900


module with POST method. But as on the server side, the data
is receiving in binary format.

How can i send data in text fomat? so on the server side no


need to encode the data.

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 5/18
9/2/2018 SIM900 GPRS HTTP AT Commands

And thanks for your blog. Very helpful.


2△ ▽ • Reply • Share ›

Ravi Pujar Mod > Bunny • a year ago

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
binary. Could you please explain more?
△ ▽ • Reply • Share ›

Bunny > Ravi Pujar • a year ago


Thanks for your reply.

I have using sprintf to make buffer with the


variables i have to send. An d those buffer is
posted to server. As sever part located in some
other location. The person handling the server,
reverted me as the data receiving in binary
format.

Please find the below code.

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);

FYI, am using my embedded device as a logger


and posting the data.
Format is
#;<imei>;<date>;<time>;<temp>;<humid>
△ ▽ • Reply • Share ›

Amarendra Ranade • 15 days ago


Hello..
I am trying to post using same method as you have mentioned.
After HTTPACTION=1 command, I am getting error 500 (internal
Server Error). What can be the issue ?

Below is the Request Body. Is there any issue in this part ?

---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere";
filename="nogithub.txt"
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 6/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Content-Type: text/plain

QWERTY

---------------------------acebdf13572468--

Awaiting your reply. Thanks in Advance.


△ ▽ • Reply • Share ›

Gayatri Vedula • 4 months ago


i m getting this while working on http requests using gsm 900a
AT+HTTPINIT
ERROR
can you suggest me in resolving the error
△ ▽ • Reply • Share ›

Shreevatsa Acharya > Gayatri Vedula • a month ago


hey , even i am getting the same error, did you find a
solution or why the error?
△ ▽ • Reply • Share ›

mohammad • 4 months ago


Hi Ravi
topic is very useful for me .
I have a problem with URL length , my URL is too long . when i
use "AT+HTTPPARA" it respond with ERROR .
the URL length is about 1000 chars .
How can i fix this problem ?
△ ▽ • Reply • Share ›

usmanhaider • 5 months ago


it gives 401 error
△ ▽ • Reply • Share ›

usmanhaider • 5 months ago


i gives 401 error
△ ▽ • Reply • Share ›

naresh puli • 6 months ago


Hello,
how we write data to the server using http commands using GET
Method

after connection establish, please suggest me


△ ▽ • Reply • Share ›

Ravi Pujar Mod > naresh puli • 6 months ago


https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 7/18
9/2/2018 SIM900 GPRS HTTP AT Commands
a uja a es pu 6 o t s ago

Hi Naresh,
Please post your tech queries here.
http://www.embeddedadvice.com/
We can discuss
△ ▽ • Reply • Share ›

bhaskar ch • 6 months ago


hi Ravi, i am new to WEB server application. need to send data
to web server through GSM(SIM808). i dont have any url(web
service) for testing get/post method. how can i get URL for
sending data
△ ▽ • Reply • Share ›

Ravi Pujar Mod > bhaskar ch • 6 months ago


Hi Bhaskar,
Please post your tech queries here.
http://www.embeddedadvice.com/
We can discuss
△ ▽ • Reply • Share ›

manisrinivas srungavarapu • 7 months ago


hi ravi ,
your blogs very good and helpful.we are getting response like
0,200,677 something like this from httpaction ,but how can i
store the value 200 in some variable ,200 means http connection
is fine.thank you
△ ▽ • Reply • Share ›

Ravi Pujar Mod > manisrinivas srungavarapu


• 7 months ago
Hi, Please post tech queries here.
http://www.embeddedadvice.com/
We can discuss
△ ▽ • Reply • Share ›

Egauss Egauss • 8 months ago


Hi Ravi, i have sim808 and looking for advice how to GET http
headers have you got any solution?
△ ▽ • Reply • Share ›

Daniel • 9 months ago


Hello Ravi,
Is it also possible to upload a csv file to webserver as you did
with txt file?
What is the maximum size of csv file that can be sent using
HTTP Post with sim900? I think there is a limitation caused the
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 8/18
9/2/2018 SIM900 GPRS HTTP AT Commands
HTTP Post with sim900? I think there is a limitation caused the
buffer of the sim900, right?

Best regards, Daniel


△ ▽ • Reply • Share ›

Ravi Pujar Mod > Daniel • 9 months ago

Hi Daniel,
Please post tech queries here,
http://www.embeddedadvice.com/
We can discuss.
△ ▽ • Reply • Share ›

Bunny • 9 months ago


Hi Ravi,

How to get a timestamp fro a server? Is there HTTP command


request to get the time and date?
△ ▽ • Reply • Share ›

Ravi Pujar Mod > Bunny • 9 months ago

Hi Venkat,

Could you please post your query here.


http://www.embeddedadvice.com/
We can discuss further.

Regards,
Ravi
△ ▽ • Reply • Share ›

Sayajin_Slayer • 9 months ago


hello, can you help me? i just can't figure this out
check my code
#include <softwareserial.h>
#include <tinygps.h>
#include <wire.h>
#include <ds1307new.h>

#define pinPowerSIM900 9

TinyGPS gps;
SoftwareSerial sGPS(10,9);

float flat, flon;


float previousFLat = 0.0;
float previousFLon = 0.0;

void setup() {
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 9/18
9/2/2018 SIM900 GPRS HTTP AT Commands
void setup() {
pinMode(pinPowerSIM900, OUTPUT);
digitalWrite(pinPowerSIM900,LOW);
see more

△ ▽ • Reply • Share ›

Tejas Arlimatti • a year ago


Thank you, very helpful
△ ▽ • Reply • Share ›

Tumza • a year ago


Can you send instead of reading?
△ ▽ • Reply • Share ›

sameer ahamad • a year ago


Dear Ravi,
my self Sameer ,
i was connecting gsm/gprs sim 900a module to raspberry pi2 but
iam unable to post the data from Raspberrypi2 using HTTP AT
commands but the data posting in the server as emty ,how we
have to send the data as variables in python by Using HTTP
commands could you please provide me with more details,
△ ▽ • Reply • Share ›

Ravi Pujar Mod > sameer ahamad • a year ago


Hi Sameer,
I have not used Raspberry pi and python so far. I cant
help much on that. But if you are getting OK responses
from SIM900A then communication should be just fine.
You should enter correct data length for proper packet
delivery in HTTPDATA command.
△ ▽ • Reply • Share ›

sameer ahamad > Ravi Pujar • a year ago


Dear Ravi,
i was connecting gsm/gprs sim 900a module to
raspberry pi2 but iam post the data from
Raspberrypi2 using HTTP AT commands but the
data posting in the server as emty ,
1)how we have to send the data as variables in
python by Using HTTP commands ,can you send
the exact syntax of URL HTTP Post in variable
2)in here HTTPget and post method was can be
work simultaneously when we establish the
connection of GPRS is that necessary to run the
hole commands are simply use HTTPPARA to
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 10/18
9/2/2018 SIM900 GPRS HTTP AT Commands
hole commands are simply use HTTPPARA to
transfer the data 3)how to get the imei number
sim900 in a variable
can u send the arduino coding
could you please provide me with more details,
△ ▽ • Reply • Share ›

Ravi Pujar Mod > sameer ahamad


• a year ago
Dear Sameer,
As i said i have no idea on python. Never
used it.
The only code i have is as shown above. It
works on Linux.
You can modify it to python or arduino as it
is simple c program.
You can get IMEI number using the
command AT+CGSN
HTTPPARA is only used to set the
parameters and HTTPDATA is used to set
the data part. The data is sent only when
you execute AT+HTTPACTION command.
Hope it helps.
△ ▽ • Reply • Share ›

sameer ahamad > Ravi Pujar


• a year ago
Dear Ravi,
i have trying to post data using coolterm
win software but iam getting error in that
can u tell me what means of this
1.AT+HTTPPARA="CONTENT","multipart/fo
data; boundary=----
WebKitFormBoundaryvZ0ZHShNAcBABWF
2.AT+HTTPDATA=192,10000 i was totally
struck in this issue

see more

△ ▽ • Reply • Share ›
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 11/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Ravi Pujar Mod > sameer ahamad


• a year ago
+SAPBR DEACT means your network
internet got disconnected. Use good
network SIM like Airtel or Vodafone. Idea
and Docomo and others wont work
properly.
You need to enter data within 10 seconds
there or it will get timeout
△ ▽ • Reply • Share ›

sameer ahamad > Ravi Pujar


• a year ago
Dear Ravi sir,
i have doubt about is that any sim 900
gsm/gprs module to setup the GPRS
connection time gap need between one AT
Commands other in Ardunio , is that really
required are not, clarify to me for this issue
△ ▽ • Reply • Share ›

sameer ahamad > Ravi Pujar


• a year ago
Dear Ravi sir,
which HTTP AT commands pass the
variable data of particular column
database in My Sql server
is that HTTPPARA are HTTPDATA,
AT+HTTPPARA="CONTENT","vr=1234" i
was unable send data to the database
△ ▽ • Reply • Share ›

ashok • a year ago


Hi Ravi,
I am Using maestro 100 lite gsm/gprs device in my project.
In hyper terminal AT+SAPBR=3,1,"CONTYPE","GPRS" it's
giving error response.
Please help me about the problem.

Thanks in advance.
△ ▽ • Reply • Share ›

amin • a year ago


hi ravi.
i get ok for all command but not for AT+HTTPACTION=0
it returns +HTTPACTION: 0,601,0
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 12/18
9/2/2018 SIM900 GPRS HTTP AT Commands

how should i fix it?

this is all my code :

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

AT+SAPBR=3,1,"APN","mtnirancell"

AT+SAPBR=1,1

AT+SAPBR=2,1

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 ›

Amin Hajihosseinlu • a year ago


Hi Ravi,

Thank you in advanced for your great tutorial.


After a week of troubleshooting I am going to ask for your help. I
am pretty newbie in wireless networks and gsm modules.

I follow the instructions; everything works very well and I get a


valid IP address.
After sending the command "AT+HTTPACTION=0" to read
random string from a website (e.g. https://www.google.ca), either
I receive the 601 error or the module restarts. (See the code
below)

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

OK
AT+SAPBR=3,1,"APN","internet.com"
see more

△ ▽ • Reply • Share ›
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 13/18
9/2/2018 SIM900 GPRS HTTP AT Commands
py

Ankit Kekre • a year ago


Hii Ravi!
Your post has been a great help. although I have ran into some
trouble while using this method for posting some data to the
above mentioned site using Arduino.
The problem is that i don't exactly have a text file to post. Just
some text and values. Can you please tell me some method to
do that? Thanx in advance.
△ ▽ • Reply • Share ›

Ankit Kekre > Ankit Kekre • a year ago


Ok I got it. After a lot of searching, I used the
application/x-www-form-urlencoded to send the data as
URL parameters
△ ▽ • Reply • Share ›

gowtham bieber • a year ago


Hi I,m gowtham and i'm getting error while using the above post
commands
AT+SAPBR=3,1,"APN","aircelgprs.pr"
OK
AT+SAPBR=1,1
OK
AT+SAPBR=1,1
ERROR
AT+SAPBR=2,1
+SAPBR: 1,1,"100.68.229.191"

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 ›

D h Bi i
https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 14/18
9/2/2018 SIM900 GPRS HTTP AT Commands
Deepanshu Biyani • a year ago
i am getting error in these commands,

Start by setting up the HTTP bearer profile identifier


AT+HTTPPARA="CID",1
ERROR

Set the url to the address of the webpage you want to post to
AT+HTTPPARA="URL","http://posttestserver.com/p..."
ERROR
△ ▽ • Reply • Share ›

Chitraveer Akhil • 2 years ago


Hi, I'm trying to post data from Arduino to the server using AT
commands.. I used HTTP connections.. But the data is not send
to the server.. Please check my code..

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)

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 15/18
9/2/2018 SIM900 GPRS HTTP AT Commands

 (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)

 

About the Author


Ravi Pujar
(https://plus.google.com/102969188306424582103)
is the author of this blog and is an
Embedded systems design engineer by
profession & Founder @ Valetron
Systems Pvt Ltd
(http://www.valetron.com)

(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 16/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Enter your Email Address

Subscribe

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 17/18
9/2/2018 SIM900 GPRS HTTP AT Commands

Embedded World
7.1K likes

Like Page

Be the first of your friends to like this

© 2017 Valetron Systems Pvt Ltd. All Rights Reserved.

https://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands 18/18

You might also like