I’m presently doing the following with my Ethernet shield and now I want to do the same with GPRS facility from GSM shield, Please guide me for the same.
(In the following code I want to write the code in BOLD for my seeedstudio GPRS shield!)
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 2 };
byte gw[] = {192,168,1,1};
byte server[] = { XXX, XX, XXX, XXX }; // My webpage IP
byte subnet[] = { 255, 255, 255, 0 };
int watt = 0;
int tempPin = 2;
int ledPin = 10;
void setup()
{
pinMode(tempPin, INPUT);
}
void loop()
{
delay(3000);
senddata();
}
void senddata()
{
watt = analogRead(tempPin); //Read analogue value
watt = (5.0 * watt * 100.0)/1024.0; //convertera analog data to temperature
[b]Ethernet.begin(mac, ip, gw, subnet);
Client client(server, 80);
Serial.println();
Serial.println(“Initiates connection…”);
Serial.println(“Connecting…”);
delay(1000); //This one keeps it from hanging
if (client.connect()) {
Serial.println(“Connected!”);
client.print(“GET hjeng.se/PHPFile.php?watt=”);
client.print(watt);
client.println(" HTTP/1.1");
client.println(“Host: hjeng.se”);
client.println();[/b]
}
else
{
Serial.println(“Connection failed”);
}
//}
//stop client
client.stop();
while(client.status() != 0)
{
delay(5);
}
}