I am unable to find what's the problem in the code. I want to upload my Arduino data online. By directly operating GSM900 with Hyperterminal I was able to send the data. Code is as follows
{
"method": "put",
"resource": "/feeds/1820378806",
"params": {},
"headers": {"X-ApiKey":"**********"},
"body": {
"version" : "1.0.0",
"datastreams": [
{
"id": "Humidity",
"current_value": "12"
}
]
}
}
But when I try to write it in Arduino IDE, it is not working. Please help !
void setup()
{Serial.begin(9600);
upload();
}
void loop()
{
}
void upload()
{
Serial.println("AT+CGATT?");
delay(1000);
Serial.println("AT+CSTT=\"airtelgprs.com\"");//start task and setting the APN,
delay(1000);
Serial.println("AT+CIICR");//bring up wireless connection
delay(3000);
Serial.println("AT+CIFSR");//get local IP adress
delay(2000);
Serial.println("AT+CIPSPRT=0");
delay(3000);
Serial.println("AT+CIPSTART=\"tcp\",\"api.xively.com\",\"8081\"");//start up the connection
delay(2000);
Serial.println("AT+CIPSEND");//begin send data to remote server
delay(4000);
Serial.print("{\"method\": \"put\",\"resource\": \"/feeds/1820378806/\",\"params\"");//here is the feed you apply from pachube
delay(500);
Serial.print(": {},\"headers\": {\"X-ApiKey\":\"**********"},");//in here, you should replace your pachubeapikey
delay(500);
Serial.print("\"body\":");
delay(500);
Serial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");
delay(500);
Serial.println("[{\"id\": \"Humidity\",\"current_value\": \"12\"}]}}");
delay(500);
delay(500);
Serial.println((char)26);//sending
delay(5000);//waitting for reply, important! the time is base on the condition of internet
Serial.println();
Serial.println("AT+CIPCLOSE");//close the connection
delay(100);
}