1
1
/*
2
- Cosm sensor client with Strings
2
+ Pachube sensor client with Strings
3
3
4
- This sketch connects an analog sensor to Cosm (http://www.cosm .com)
4
+ This sketch connects an analog sensor to Pachube (http://www.pachube .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
8
9
- This example has been updated to use version 2.0 of the Cosm .com API.
9
+ This example has been updated to use version 2.0 of the pachube .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
+ modified 8 September 2012
24
+ by Scott Fitzgerald
23
25
24
- http://arduino.cc/en/Tutorial/CosmClientString
26
+ http://arduino.cc/en/Tutorial/PachubeClientString
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 Pachube 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
@@ -49,12 +51,12 @@ EthernetClient client;
49
51
50
52
// if you don't want to use DNS (and reduce your sketch size)
51
53
// use the numeric IP instead of the name for the server:
52
- IPAddress server (216 ,52 ,233 ,121 ); // numeric IP for api.cosm .com
53
- // char server[] = "api.cosm .com"; // name address for Cosm API
54
+ IPAddress server (216 ,52 ,233 ,121 ); // numeric IP for api.pachube .com
55
+ // char server[] = "api.pachube .com"; // name address for pachube API
54
56
55
57
unsigned long lastConnectionTime = 0 ; // last time you connected to the server, in milliseconds
56
58
boolean lastConnected = false ; // state of the connection last time through the main loop
57
- const unsigned long postingInterval = 10 *1000 ; // delay between updates to Cosm .com
59
+ const unsigned long postingInterval = 10 *1000 ; // delay between updates to pachube .com
58
60
59
61
void setup () {
60
62
// Open serial communications and wait for port to open:
@@ -83,7 +85,7 @@ void loop() {
83
85
dataString += sensorReading;
84
86
85
87
// you can append multiple readings to this String if your
86
- // Cosm feed is set up to handle multiple values:
88
+ // pachube feed is set up to handle multiple values:
87
89
int otherSensorReading = analogRead (A1);
88
90
dataString += " \n sensor2," ;
89
91
dataString += otherSensorReading;
@@ -123,8 +125,8 @@ void sendData(String thisData) {
123
125
client.print (" PUT /v2/feeds/" );
124
126
client.print (FEEDID);
125
127
client.println (" .csv HTTP/1.1" );
126
- client.println (" Host: api.cosm .com" );
127
- client.print (" X-CosmApiKey : " );
128
+ client.println (" Host: api.pachube .com" );
129
+ client.print (" X-pachubeApiKey : " );
128
130
client.println (APIKEY);
129
131
client.print (" User-Agent: " );
130
132
client.println (USERAGENT);
0 commit comments