You might be closing the client connection before all the data has been sent. You are sending a lot of packets. I would increase the delay() time before closing the connection, or check the transmit buffer to insure it is empty.
Here is a thread that covers checking the transmit buffer free space. When client.free() returns 2048, all the data has been sent.
http://arduino.cc/forum/index.php/topic,72027.0.htmlEdit: If you increase the delay time and it works, you are lucky. If you check the transmit buffer and it works, you are good.
FYI: Every call to client.print(), client.println(), and client.write() creates another packet. Count the packets you are sending just for the date.
There are write functions that are not covered in the docs. These are available (from Client.h):
virtual void write(uint8_t);
virtual void write(const char *str);
virtual void write(const uint8_t *buf, size_t size);
I use the last one. I build a "packet" in a local byte array (outBuffer of size packetSize), then send it in one call.
client.write(outBuffer,packetSize);
Check the transmit buffer free space before writing this tho. If there is not enough space in the transmit buffer, it will cause errors.
I use something like this:
while(client.free() < packetSize) {
// don't write yet
delay(5);
}
and this to determine when all is sent:
while(client.free() < 2048) {
// don't stop yet
delay(5)
}
client.stop();