I'm sending temperature information from my Arduino via the WiFly shield to a Google Spreadsheets like in this tutorial:
http://www.s2ptech.com/2012/04/send-data-from-arduino-to-google-docs.html#.T80OE45DuS1The problem is that after a few sends the actions simply stalls. Resetting helps but again after a few send actions (4-8) it stalls again. The LED at P104 blinks green.
The code are as follows:
#include "WiFly.h"
#include "Credentials.h"
char formkey[]="dHF2eFlCQjhYbnFmRjNLQWlnN29fUlE6MQ"; //Key for google spreadsheet
byte server[]={ 209,85,229,101}; //Google IP
Client client(server, 80);
//Server server(80);
//Store values for temp
int temp_in_kelvin;
int celsius;
void setup() {
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
while (1) {
// Hang on failure.
}
}
Serial.begin(9600);
Serial.print("IP: ");
Serial.println(WiFly.ip());
}
void loop() {
//reads the input and converts it to Kelvin degrees
temp_in_kelvin = analogRead(1) * 0.004882812 * 100;
//Converts Kelvin to Celsius minus 2.5 degrees error
celsius = temp_in_kelvin - 2.5 - 273.15;
String data;
data+="";
data+="entry.0.single=";
data+= celsius;
data+="&submit=Submit";
if (client.connect()) {
Serial.println("connected");
client.print("POST /formResponse?formkey=");
client.print(formkey);
client.println("&ifq HTTP/1.1");
client.println("Host: spreadsheets.google.com");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println();
Serial.print("POST /formResponse?formkey=");
Serial.print(formkey);
Serial.println("&ifq HTTP/1.1");
Serial.println("Host: spreadsheets.google.com");
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.print("Content-Length: ");
Serial.println(data.length());
Serial.println();
Serial.print(data);
Serial.println();
}
delay(1000);
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
//Serial.print("Temp: ");
//Serial.println(celsius);
Serial.flush();
delay(10000);
}
Any ideas what might be wrong?