3 #include <HttpClient.h>
6 char ssid[] = "YourNetwork"; // your network SSID (name)
7 char pass[] = "password"; // your network password (use for WPA, or use as key for WEP)
8 int keyIndex = 0; // your network key Index number (needed only for WEP)
10 int status = WL_IDLE_STATUS;
12 // Your Xively key to let you upload data
13 char xivelyKey[] = "YOUR_API_KEY";
15 // Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
18 // Define the strings for our datastream IDs
19 char sensorId[] = "sensor_reading";
20 XivelyDatastream datastreams[] = {
21 XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
23 // Finally, wrap the datastreams into a feed
24 XivelyFeed feed(15552, datastreams, 1 /* number of datastreams */);
27 XivelyClient xivelyclient(client);
29 void printWifiStatus() {
30 // print the SSID of the network you're attached to:
31 Serial.print("SSID: ");
32 Serial.println(WiFi.SSID());
34 // print your WiFi shield's IP address:
35 IPAddress ip = WiFi.localIP();
36 Serial.print("IP Address: ");
39 // print the received signal strength:
40 long rssi = WiFi.RSSI();
41 Serial.print("signal strength (RSSI):");
43 Serial.println(" dBm");
46 // put your setup code here, to run once:
49 Serial.println("Starting single datastream upload to Xively...");
52 // attempt to connect to Wifi network:
53 while ( status != WL_CONNECTED) {
54 Serial.print("Attempting to connect to SSID: ");
56 status = WiFi.begin(ssid, pass);
57 // wait 10 seconds for connection:
60 Serial.println("Connected to wifi");
65 int sensorValue = analogRead(sensorPin);
66 datastreams[0].setFloat(sensorValue);
68 Serial.print("Read sensor value ");
69 Serial.println(datastreams[0].getFloat());
71 Serial.println("Uploading it to Xively");
72 int ret = xivelyclient.put(feed, xivelyKey);
73 Serial.print("xivelyclient.put returned ");