1
1
/*
2
- Cosm sensor client with Strings
3
-
4
- This sketch connects an analog sensor to Cosm (http://www.cosm .com)
2
+ Xively sensor client with Strings
3
+
4
+ This sketch connects an analog sensor to Xively (http://www.xively .com)
5
5
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
6
6
the Adafruit Ethernet shield, either one will work, as long as it's got
7
7
a Wiznet Ethernet module on board.
8
-
9
- This example has been updated to use version 2.0 of the Cosm .com API.
8
+
9
+ This example has been updated to use version 2.0 of the xively .com API.
10
10
To make it work, create a feed with two datastreams, and give them the IDs
11
11
sensor1 and sensor2. Or change the code below to match your feed.
12
12
20
20
created 15 March 2010
21
21
modified 9 Apr 2012
22
22
by Tom Igoe with input from Usman Haque and Joe Saavedra
23
-
24
- http://arduino.cc/en/Tutorial/CosmClientString
23
+ modified 8 September 2012
24
+ by Scott Fitzgerald
25
+
26
+ http://arduino.cc/en/Tutorial/XivelyClientString
25
27
This code is in the public domain.
26
28
27
29
*/
30
32
#include < Ethernet.h>
31
33
32
34
33
- #define APIKEY " YOUR API KEY GOES HERE" // replace your Cosm api key here
35
+ #define APIKEY " YOUR API KEY GOES HERE" // replace your Xively api key here
34
36
#define FEEDID 00000 // replace your feed ID
35
37
#define USERAGENT " My Project" // user agent is the project name
36
38
@@ -50,12 +52,12 @@ EthernetClient client;
50
52
51
53
// if you don't want to use DNS (and reduce your sketch size)
52
54
// use the numeric IP instead of the name for the server:
53
- IPAddress server (216 , 52 , 233 , 121 ); // numeric IP for api.cosm .com
54
- // char server[] = "api.cosm .com"; // name address for Cosm API
55
+ IPAddress server (216 ,52 ,233 ,121 ); // numeric IP for api.xively .com
56
+ // char server[] = "api.xively .com"; // name address for xively API
55
57
56
58
unsigned long lastConnectionTime = 0 ; // last time you connected to the server, in milliseconds
57
59
boolean lastConnected = false ; // state of the connection last time through the main loop
58
- const unsigned long postingInterval = 10 * 1000 ; // delay between updates to Cosm .com
60
+ const unsigned long postingInterval = 10 * 1000 ; // delay between updates to xively .com
59
61
60
62
void setup () {
61
63
// Open serial communications and wait for port to open:
@@ -84,7 +86,7 @@ void loop() {
84
86
dataString += sensorReading;
85
87
86
88
// you can append multiple readings to this String if your
87
- // Cosm feed is set up to handle multiple values:
89
+ // xively feed is set up to handle multiple values:
88
90
int otherSensorReading = analogRead (A1);
89
91
dataString += " \n sensor2," ;
90
92
dataString += otherSensorReading;
@@ -124,8 +126,8 @@ void sendData(String thisData) {
124
126
client.print (" PUT /v2/feeds/" );
125
127
client.print (FEEDID);
126
128
client.println (" .csv HTTP/1.1" );
127
- client.println (" Host: api.cosm .com" );
128
- client.print (" X-CosmApiKey : " );
129
+ client.println (" Host: api.xively .com" );
130
+ client.print (" X-xivelyApiKey : " );
129
131
client.println (APIKEY);
130
132
client.print (" User-Agent: " );
131
133
client.println (USERAGENT);
0 commit comments