Skip to content

Commit a181cf7

Browse files
committed
Updates to Xively client
1 parent 5cb2550 commit a181cf7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/XivelyClient.ino

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
// set up net client info:
3636
boolean lastConnected = false; // state of the connection last time through the main loop
3737
const unsigned long postingInterval = 60000; //delay between updates to Pachube.com
38+
unsigned long lastRequest = 0; // when you last made a request
3839
String dataString = "";
3940
Process xively;
4041

@@ -43,7 +44,10 @@ void setup() {
4344
Serial.begin(9600);
4445
Bridge.begin();
4546
delay(2000);
46-
47+
48+
while(!Serial); // wait for Serial Monitor to open
49+
Serial.println("Xively client");
50+
4751
// reserve space for dataString:
4852
dataString.reserve(100);
4953
}
@@ -70,8 +74,9 @@ void loop() {
7074

7175
// if you're not connected, and the sending interval has passed since
7276
// your last connection, then connect again and send data:
73-
if(now % postingInterval < 5) {
77+
if(now - lastRequest >= postingInterval) {
7478
sendData();
79+
lastRequest = now;
7580
}
7681
}
7782

0 commit comments

Comments
 (0)