PeterH:
parker21:
All,I downloaded and slightly modified a Pachube Client sketch. It works fine, but when I add in another sensor, it starts printing the "client.print" sections of the code 1 character at a time in the serial window. It's like it only stays in the sendData subfunction to print 1 character, then it jumps back into the loop.
If I'm looking at the right bit of code, the client output should appear on the serial output at all. Have you tried putting another Serial.println at the end of sendData() to confirm that you've left that function?
So I added the serial.print and this is what I got. I think pachube might be sending the arduino a serial stream back. This is what I got in the terminal:
disconnecting.
connecting...
Testing....................
HTTP/1.1 200 OK
Date: Fri, 05 Oct 2012 11:03:08 GMT
Content-Type: text/plain; charset=utf-8
Connection: close
X-PachubePurgeCache: t:feeds/48961,web:feed:48961
X-Runtime: 212
Content-Length: 1
X-Pachube-Logging-Key: logging.dcsUN2sofumFGHfurn1n
X-PachubeRequestId: 3ba70f54de845bcba009fba24cfcf4af2bfac35f
Set-Cookie: _pachcore_app_session=BAh7BjoPc2Vzc2lvbl9pZCIlZTlmNzJhNDc5ZmExMGZiMmNjY2E3YmQ5ZTBhNWNkYjU%3D--a3220a61208086635fe78b68a041074d145df1fc; domain=.cosm.com; path=/; expires=Fri, 19-Oct-2012 11:03:08 GMT; HttpOnly
Cache-Control: max-age=0
Vary: Accept-Encoding
void sendData(int thisData, char* dataName) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.pachube.com");
client.print("X-PachubeApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
// calculate the length of the sensor reading in bytes:
// 8 bytes for "sensor1," + number of digits of the data:
int thisLength = 8 + getLength(thisData);
client.println(thisLength);
// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();
// here's the actual content of the PUT request:
client.print(dataName);
client.println(thisData);
Serial.println("Testing....................");
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// note the time that the connection was made or attempted:
lastConnectionTime = millis();
}