I also wish to send data from the web server to the microcontroller/gprs-module.
Getting a web server to send a request to your SIM900 is a bit tricky and there are several obstacles you have to overcome to accomplish that:
- The SIM900 must be put into Server mode - this can be really tricky if you want to simultaneously support client mode
- Since the SIM900 will get it's IP address from the network, and is therefore not known in advance, you must have a means to tell your clients what the SIM900's IP address is - your service provider may give you a fixed IP address, but in most cases it won't
- Your service provider must allow incoming connections - for security purposes, most service providers block incoming requests
Assuming you can meet those 3 points, you can configure the SIM900 to be a server by following the instruction in this document:
http://www.svtehs.com/simcom/docs/SIM900_AN_TCPIP_V100.pdf
However, if you want to both send data to the server and get data from it there's another way...
In a network-based conversation between 2 devices one is considered the
client (the one that makes a request) and one is considered the
server (the one that replies to the request). When you open a browser and go to a web site, your browser (computer) is the client and the web site is the server. When you make a request to the server you can give it parameters that tell it to do something. And the web server can return just about anything as a response to your request. It can return a web page, picture, XML data, or text that means something to your application - all depends on how your server is configured.
Let's say you have a web site with a web page named "StoreData.php", and the purpose of the web page is to store data you send it in a database. To make the example simple lets send the data in a "GET" request. A request to this page may be something like "74.125.228.35/StoreData.php?Data=this_is_my_data". Once you've established a GPRS connection you could make this request by sending the following:
Code:
AT+CIPSTART='TCP','74.125.228.35','80' \n // Will return 'CONNECT OK' to indicate it's connected to the server
AT+CIPSEND\n // Issue Send Command (wait for module to return '>' to indicate it's ready to receive data
GET /StoreData.php?Data=this_is_my_data HTTP/1.1\n // Send request
Host: 74.125.228.35\n
Accept: */*\n
Accept-Language: en-us\n
\n
Ctrl-Z
Anything the server returns as a response will be sent out the SIM900's serial port after you send the Ctrl-z. For example, in this case it could return a status message or the ID of the data it just stored.
To get the data from the server you could have another page "GetData.php" that returns data to the SIM900. A request to this page may be something like "74.125.228.35/GetData.php?ID=1". The following commands would accomplish that:
Code:
AT+CIPSTART='TCP','74.125.228.35','80' \n // Will return 'CONNECT OK' to indicate it's connected to the server
AT+CIPSEND\n // Issue Send Command (wait for module to return '>' to indicate it's ready to receive data
GET /GetData.php?ID=1 HTTP/1.1\n // Send request
Host: 74.125.228.35\n
Accept: */*\n
Accept-Language: en-us\n
\n
Ctrl-Z
The server will return the data you requested - the SIM900 will send it out the serial port after you send the Ctrl-Z.