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.
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,
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
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
Enable the GPRS
Query if the connection is setup properly, if we get back a IP address then we can proceed
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, which is a simple web page that puts out some dummy text as shown below. You can retrieve any webpage you want.
We were allocated a IP address and now we can proceed by enabling the HTTP mode
Start by setting up the HTTP bearer profile identifier
Set the url to the address of the webpage you want to access
Start the HTTP GET session, by giving this command
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
The below command tells the module that we want to read the received data
The below is the data read from the webpage
Logged Meter Readings:<br>Date Time: Current Voltage Temp.<br>
<br>Mon May 19 23:56:12 2014 :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>
The contents above are the contents of the webpage shown before.
See next page for the HTTP post request >>
- Next >>