3 #include <HttpClient.h>
6 // MAC address for your Ethernet shield
7 byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
9 // Your Xively key to let you upload data
10 char xivelyKey[] = "YOUR_XIVELY_API_KEY";
12 // Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
15 // Define the strings for our datastream IDs
16 char sensorId[] = "sensor_reading";
17 XivelyDatastream datastreams[] = {
18 XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
20 // Finally, wrap the datastreams into a feed
21 XivelyFeed feed(15552, datastreams, 1 /* number of datastreams */);
23 EthernetClient client;
24 XivelyClient xivelyclient(client);
27 // put your setup code here, to run once:
30 Serial.println("Starting single datastream upload to Xively...");
33 while (Ethernet.begin(mac) != 1)
35 Serial.println("Error getting IP address via DHCP, trying again...");
41 int sensorValue = analogRead(sensorPin);
42 datastreams[0].setFloat(sensorValue);
44 Serial.print("Read sensor value ");
45 Serial.println(datastreams[0].getFloat());
47 Serial.println("Uploading it to Xively");
48 int ret = xivelyclient.put(feed, xivelyKey);
49 Serial.print("xivelyclient.put returned ");