mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Updates to Xively client
This commit is contained in:
parent
5cb25503d7
commit
a181cf715a
@ -35,6 +35,7 @@
|
|||||||
// set up net client info:
|
// set up net client info:
|
||||||
boolean lastConnected = false; // state of the connection last time through the main loop
|
boolean lastConnected = false; // state of the connection last time through the main loop
|
||||||
const unsigned long postingInterval = 60000; //delay between updates to Pachube.com
|
const unsigned long postingInterval = 60000; //delay between updates to Pachube.com
|
||||||
|
unsigned long lastRequest = 0; // when you last made a request
|
||||||
String dataString = "";
|
String dataString = "";
|
||||||
Process xively;
|
Process xively;
|
||||||
|
|
||||||
@ -44,6 +45,9 @@ void setup() {
|
|||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
||||||
|
while(!Serial); // wait for Serial Monitor to open
|
||||||
|
Serial.println("Xively client");
|
||||||
|
|
||||||
// reserve space for dataString:
|
// reserve space for dataString:
|
||||||
dataString.reserve(100);
|
dataString.reserve(100);
|
||||||
}
|
}
|
||||||
@ -70,8 +74,9 @@ void loop() {
|
|||||||
|
|
||||||
// if you're not connected, and the sending interval has passed since
|
// if you're not connected, and the sending interval has passed since
|
||||||
// your last connection, then connect again and send data:
|
// your last connection, then connect again and send data:
|
||||||
if(now % postingInterval < 5) {
|
if(now - lastRequest >= postingInterval) {
|
||||||
sendData();
|
sendData();
|
||||||
|
lastRequest = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user