I hooked up the ethernet shield to gather data and post to a mysql database. The strange thing is that it works about a 1/3 of the time and I can't figure out where to troubleshoot it.
I programmed it to send data every 10 seconds, and it would end up sending data randomly, usually about twice a minute. Sometimes it would be 40 seconds separation, sometimes 20. It appears to be in 10 second intervals, which makes me think that sometimes the POST is just not going through, other times it is.
Any ideas why this could be? Is this common?
Here's the pertinent part of the code just in case there is something in there:
String data = "temp=" + stempF + "&bright=" + slight;
// Serial.println(data);
if (client.connect("www.SERVER.com", 80)) {
Serial.println("Connected");
client.println("POST /data/add.php HTTP/1.1");
client.println("Host: www.SERVER.com");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println("Connection: close");
client.println();
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}
delay(10000);