|
|
|
@ -25,6 +25,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// this int will hold the current count for our sketch
|
|
|
|
// this int will hold the current count for our sketch
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
bool aio_connected = false;
|
|
|
|
|
|
|
|
|
|
|
|
// set up the 'counter' feed
|
|
|
|
// set up the 'counter' feed
|
|
|
|
//AdafruitIO_Feed *counter = io.feed("counter");
|
|
|
|
//AdafruitIO_Feed *counter = io.feed("counter");
|
|
|
|
@ -46,7 +47,7 @@ void aio_setup() {
|
|
|
|
// connect to io.adafruit.com
|
|
|
|
// connect to io.adafruit.com
|
|
|
|
io.connect();
|
|
|
|
io.connect();
|
|
|
|
|
|
|
|
|
|
|
|
// wait for a connection
|
|
|
|
/* // wait for a connection
|
|
|
|
while(io.status() < AIO_CONNECTED) {
|
|
|
|
while(io.status() < AIO_CONNECTED) {
|
|
|
|
Serial.print(".");
|
|
|
|
Serial.print(".");
|
|
|
|
delay(500);
|
|
|
|
delay(500);
|
|
|
|
@ -55,40 +56,49 @@ void aio_setup() {
|
|
|
|
// we are connected
|
|
|
|
// we are connected
|
|
|
|
Serial.println();
|
|
|
|
Serial.println();
|
|
|
|
Serial.println(io.statusText());
|
|
|
|
Serial.println(io.statusText());
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void aio_loop(float tlm[]) {
|
|
|
|
void aio_loop(float tlm[]) {
|
|
|
|
|
|
|
|
|
|
|
|
// io.run(); is required for all sketches.
|
|
|
|
if (!aio_connected) {
|
|
|
|
// it should always be present at the top of your loop
|
|
|
|
if (io.status() < AIO_CONNECTED) {
|
|
|
|
// function. it keeps the client connected to
|
|
|
|
Serial.println("Connecting to Adafruit IO...");
|
|
|
|
// io.adafruit.com, and processes any incoming data.
|
|
|
|
} else {
|
|
|
|
io.run();
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
Serial.println(io.statusText());
|
|
|
|
// save count to the 'counter' feed on Adafruit IO
|
|
|
|
aio_connected = true;
|
|
|
|
Serial.print("\nsending to Adafruit IO -> ");
|
|
|
|
}
|
|
|
|
// Serial.println(count);
|
|
|
|
} else {
|
|
|
|
// counter->save(count);
|
|
|
|
// io.run(); is required for all sketches.
|
|
|
|
Serial.print(tlm[0]);
|
|
|
|
// it should always be present at the top of your loop
|
|
|
|
temperature->save(tlm[0]);
|
|
|
|
// function. it keeps the client connected to
|
|
|
|
Serial.print(" ");
|
|
|
|
// io.adafruit.com, and processes any incoming data.
|
|
|
|
Serial.print(tlm[1]);
|
|
|
|
io.run();
|
|
|
|
pressure->save(tlm[1]);
|
|
|
|
|
|
|
|
Serial.print(" ");
|
|
|
|
// save count to the 'counter' feed on Adafruit IO
|
|
|
|
Serial.print(tlm[2]);
|
|
|
|
Serial.print("\nSending to Adafruit IO -> ");
|
|
|
|
altitude->save(tlm[2]);
|
|
|
|
// Serial.println(count);
|
|
|
|
Serial.println(" ");
|
|
|
|
// counter->save(count);
|
|
|
|
Serial.print(" ");
|
|
|
|
Serial.print(tlm[0]);
|
|
|
|
Serial.print(tlm[3]);
|
|
|
|
temperature->save(tlm[0]);
|
|
|
|
humidity->save(tlm[3]);
|
|
|
|
Serial.print(" ");
|
|
|
|
|
|
|
|
Serial.print(tlm[1]);
|
|
|
|
// increment the count by 1
|
|
|
|
pressure->save(tlm[1]);
|
|
|
|
count++;
|
|
|
|
Serial.print(" ");
|
|
|
|
|
|
|
|
Serial.print(tlm[2]);
|
|
|
|
// Adafruit IO is rate limited for publishing, so a delay is required in
|
|
|
|
altitude->save(tlm[2]);
|
|
|
|
// between feed->save events. In this example, we will wait three seconds
|
|
|
|
Serial.println(" ");
|
|
|
|
// (1000 milliseconds == 1 second) during each loop.
|
|
|
|
Serial.print(" ");
|
|
|
|
delay(15000); // 3000
|
|
|
|
Serial.print(tlm[3]);
|
|
|
|
|
|
|
|
humidity->save(tlm[3]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// increment the count by 1
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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(3000); // 15000
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|