File tree 1 file changed +7
-2
lines changed
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 35
35
// set up net client info:
36
36
boolean lastConnected = false ; // state of the connection last time through the main loop
37
37
const unsigned long postingInterval = 60000 ; // delay between updates to Pachube.com
38
+ unsigned long lastRequest = 0 ; // when you last made a request
38
39
String dataString = " " ;
39
40
Process xively;
40
41
@@ -43,7 +44,10 @@ void setup() {
43
44
Serial.begin (9600 );
44
45
Bridge.begin ();
45
46
delay (2000 );
46
-
47
+
48
+ while (!Serial); // wait for Serial Monitor to open
49
+ Serial.println (" Xively client" );
50
+
47
51
// reserve space for dataString:
48
52
dataString.reserve (100 );
49
53
}
@@ -70,8 +74,9 @@ void loop() {
70
74
71
75
// if you're not connected, and the sending interval has passed since
72
76
// your last connection, then connect again and send data:
73
- if (now % postingInterval < 5 ) {
77
+ if (now - lastRequest >= postingInterval ) {
74
78
sendData ();
79
+ lastRequest = now;
75
80
}
76
81
}
77
82
You can’t perform that action at this time.
0 commit comments