25
25
#define APIKEY "foo" // replace your pachube api key here
26
26
#define FEEDID 0000 // replace your feed ID
27
27
#define USERAGENT "my-project" // user agent is the project name
28
-
29
- char ssid[] = "networkname"; // your network SSID (name)
30
- char pass[] = "password"; // your network password
31
-
32
- */
28
+ */
33
29
34
30
35
31
// set up net client info:
@@ -44,12 +40,13 @@ void setup() {
44
40
Serial.begin (9600 );
45
41
Bridge.begin ();
46
42
delay (2000 );
47
-
43
+
48
44
while (!Serial); // wait for Serial Monitor to open
49
45
Serial.println (" Xively client" );
50
-
46
+
51
47
// reserve space for dataString:
52
48
dataString.reserve (100 );
49
+ sendData ();
53
50
}
54
51
55
52
void loop () {
@@ -64,9 +61,8 @@ void loop() {
64
61
dataString += random (5 ) + 100 ;
65
62
66
63
// if there's incoming data from the net connection,
67
- // send it out the serial port. This is for debugging
68
- // purposes only:
69
- while (xively.available ()>0 ) {
64
+ // send it out the serial port:
65
+ if (xively.available ()>0 ) {
70
66
char c = xively.read ();
71
67
Serial.write (c);
72
68
}
@@ -83,7 +79,6 @@ void loop() {
83
79
// this method makes a HTTP connection to the server:
84
80
void sendData () {
85
81
Serial.println (" Sending data" );
86
- xively.begin (" curl" );
87
82
dataString = " --data \' " + dataString;
88
83
dataString += " \' " ;
89
84
@@ -93,12 +88,13 @@ void sendData() {
93
88
apiString += " \" " ;
94
89
95
90
// form the string for the URL parameter:
96
- String url = " https://api.xively.com/v2/feeds/" ;
91
+ String url = " \" https://api.xively.com/v2/feeds/" ;
97
92
url += FEEDID;
98
- url += " .csv" ;
99
-
93
+ url += " .csv\" " ;
94
+
100
95
// send the HTTP PUT request:
101
- xively.addParameter (" -k" );
96
+ xively.begin (" curl" );
97
+ xively.addParameter (" -k" );
102
98
xively.addParameter (" --request PUT" );
103
99
xively.addParameter (dataString);
104
100
xively.addParameter (apiString);
@@ -108,3 +104,9 @@ void sendData() {
108
104
109
105
110
106
107
+
108
+
109
+
110
+
111
+
112
+
0 commit comments