1
1
/*
2
- Pachube sensor client with Strings
2
+ Cosm sensor client with Strings
3
3
4
- This sketch connects an analog sensor to Pachube (http://www.pachube .com)
4
+ This sketch connects an analog sensor to Cosm (http://www.cosm .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 Pachube .com API.
9
+ This example has been updated to use version 2.0 of the Cosm .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
21
21
updated 16 Mar 2012
22
22
by Tom Igoe with input from Usman Haque and Joe Saavedra
23
23
24
- http://arduino.cc/en/Tutorial/PachubeClientString
24
+ http://arduino.cc/en/Tutorial/CosmClientString
25
25
This code is in the public domain.
26
26
27
27
*/
30
30
#include < Ethernet.h>
31
31
32
32
33
- #define APIKEY " YOUR API KEY GOES HERE" // replace your pachube api key here
33
+ / #define APIKEY " YOUR API KEY GOES HERE" // replace your Cosm api key here
34
34
#define FEEDID 00000 // replace your feed ID
35
35
#define USERAGENT " My Project" // user agent is the project name
36
36
37
+
37
38
// assign a MAC address for the ethernet controller.
38
39
// fill in your address here:
39
40
byte mac[] = {
40
41
0xDE , 0xAD , 0xBE , 0xEF , 0xFE , 0xED };
42
+
41
43
// fill in an available IP address on your network here,
42
44
// for manual configuration:
43
45
IPAddress ip (10 ,0 ,1 ,20 );
@@ -47,12 +49,12 @@ EthernetClient client;
47
49
48
50
// if you don't want to use DNS (and reduce your sketch size)
49
51
// use the numeric IP instead of the name for the server:
50
- // IPAddress server(216,52,233,122 ); // numeric IP for api.pachube .com
51
- char server[] = " api.pachube .com" ; // name address for pachube API
52
+ IPAddress server (216 ,52 ,233 ,121 ); // numeric IP for api.cosm .com
53
+ // char server[] = "api.cosm .com"; // name address for Cosm API
52
54
53
55
unsigned long lastConnectionTime = 0 ; // last time you connected to the server, in milliseconds
54
56
boolean lastConnected = false ; // state of the connection last time through the main loop
55
- const unsigned long postingInterval = 10 *1000 ; // delay between updates to Pachube .com
57
+ const unsigned long postingInterval = 10 *1000 ; // delay between updates to Cosm .com
56
58
57
59
void setup () {
58
60
// start serial port:
@@ -76,7 +78,7 @@ void loop() {
76
78
dataString += sensorReading;
77
79
78
80
// you can append multiple readings to this String if your
79
- // pachube feed is set up to handle multiple values:
81
+ // Cosm feed is set up to handle multiple values:
80
82
int otherSensorReading = analogRead (A1);
81
83
dataString += " \n sensor2," ;
82
84
dataString += otherSensorReading;
@@ -116,8 +118,8 @@ void sendData(String thisData) {
116
118
client.print (" PUT /v2/feeds/" );
117
119
client.print (FEEDID);
118
120
client.println (" .csv HTTP/1.1" );
119
- client.println (" Host: api.pachube .com" );
120
- client.print (" X-PachubeApiKey : " );
121
+ client.println (" Host: api.cosm .com" );
122
+ client.print (" X-CosmApiKey : " );
121
123
client.println (APIKEY);
122
124
client.print (" User-Agent: " );
123
125
client.println (USERAGENT);
0 commit comments