Update adafruitio_00_publish_modified.cpp use millis instead of delay

beta-mqtt
Alan Johnston 2 years ago committed by GitHub
parent f74e958227
commit 200868b6fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -28,6 +28,7 @@
// this int will hold the current count for our sketch
int count = 0;
bool aio_connected = false;
unsigned long delay;
// set up the 'counter' feed
//AdafruitIO_Feed *counter = io.feed("counter");
@ -59,6 +60,7 @@ void aio_setup() {
Serial.println();
Serial.println(io.statusText());
*/
delay = millis();
}
void aio_loop(float tlm[]) {
@ -79,6 +81,8 @@ void aio_loop(float tlm[]) {
// io.adafruit.com, and processes any incoming data.
io.run();
if ((millis() - delay) > 8000) { // Only send if 8 seconds have passed
delay = millis();
// save count to the 'counter' feed on Adafruit IO
Serial.print("\nSending to Adafruit IO -> ");
// Serial.println(count);
@ -103,6 +107,7 @@ void aio_loop(float tlm[]) {
// Adafruit IO is rate limited for publishing, so a delay is required in
// between feed->save events. In this example, we will wait three seconds
// (1000 milliseconds == 1 second) during each loop.
delay(10000); // 1000
// delay(10000); // 1000
}
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.