Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

AIO dashboard data lost on low-frequency posts
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

AIO dashboard data lost on low-frequency posts

by biod101 on Fri Oct 02, 2020 4:00 pm

Hello,

I've been playing with using Particle devices (both Boron and Argon) for posting data to Adafruit IO successfully over the past few months, but last night, I came across an issue.

I have a Particle Argon that is programmed to post the state of a float sensor to an Adafruit IO dashboard available here: https://io.adafruit.com/ADEQ_innovate/dashboards/alum . The post is taking place via this sketch uploaded to an Argon device via the Particle online IDE. The sketch references the Adafruit library "Adafruit_MQTT (1.6.1)". Everything works fine as long as I keep the posting interval at four minutes or less as per this code (keys hidden) per the delay at the top of the loop:

Code: Select all | TOGGLE FULL SIZE
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_MQTT_SPARK.h"
#include "Adafruit_MQTT.h"

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883                   // use 8883 for SSL
#define AIO_USERNAME    "XXXXXX"
#define AIO_KEY         "XXXXXX"

/************ Global State (you don't need to change this!) ******************/
TCPClient TheClient;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_SPARK mqtt(&TheClient,AIO_SERVER,AIO_SERVERPORT,AIO_USERNAME,AIO_KEY);

/****************************** Feeds ***************************************/

// Setup feeds for publishing data

Adafruit_MQTT_Publish alum_count    = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/adeq-field.alum-count");
Adafruit_MQTT_Publish alum_response = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/adeq-field.alum-response");
Adafruit_MQTT_Publish alum_flow     = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/adeq-field.alum-flow");

String body = "Alum Flowed: https://io.adafruit.com/ADEQ_innovate/dashboards/alum (Scroll down if on a phone.)";

/*************************** Variables ************************************/

int led2 = D7; // little blue LED on your board.

int x = 0; // loop counter, aka "alum_count" for tracking dropped data
int flowOn = 0;

int analogPin = 19; // pin 19 same as A0 on pinout diagram
int sensor = 0;

SYSTEM_THREAD(ENABLED);

void setup()
{
   
  pinMode(led2, OUTPUT);
   
    Serial.begin(115200);
    delay(10);
   
    Serial.println(F("Setup Complete"));
    delay(1000);
   
}

void loop() {

delay(240000); // if I bump this past 240000, posts to Adafruit IO start to fail via Argon
               // 30000  - (30 sec delay) no problem - posting as expected prior to 8:30 PM (10/1/20)
               // 600000 - (10 min delay) only one post at 8:30 pm - no posts every ten minutes as expected overnight (10/1/20)
               // 380000 - (6 min delay) only one post at 7:59 am - no posts every three minutes as expected
               //        - BUT Argon did send me a text 8:12 via Particle IO webhook when sensor was wetted (10/2/20)
               //        - Checked status of modem: Particle reports modem is "Healthy" with a "good signal", and "everything looks good"
               // 60000  - (1 min delay) no problem - posts starting at 8:17 working okay (10/2/20)
               // 120000 - (2 min delay) no problem - posts starting at 8:30 working okay (10/2/20)
               // 180000 - (3 min delay) no problem - posts starting at 8:57 working okay (10/2/20)
               // 240000 - (4 min delay) no problem - posts starting at 9:45 working okay (10/2/20)
               // 300000 - (5 min delay) - posts starting at 10:22 - two posts through 10:53 so missing four posts (10/2/20)
               // 600000 - (10 min delay) - flashed at 10:53 - posts starting at 11:04, but none thereafter through 12:42 pm.
               //                         - engaged switch at 11:44 and did receive a text
               //
               // *** Tests suggest there is some kind of synchronicity issue happening when posting intervals exceed four minutes.
               // *** The fact that I can text via the Particle IO webhook when the sensor is wetted when Adafruit IO
               //     is not picking up posts to my feeds suggests there might be somethign misaligned (timing wise?) on Adafruit IO's end (?)
               // *** It seems like I have to keep posts alive every four minutes or less to avoid losing data
               
               
sensor = analogRead(analogPin);
// sensor = 700;

 if(sensor > 600) {

    alum_count.publish(x++); //increments after publish
    digitalWrite(led2, HIGH);
    if (flowOn == 0) { // first detection of flow
     // Particle.publish("latzko", body, PRIVATE);
     Particle.publish("huth", body, PRIVATE); // this is my webhook; won't work because upon powering on, sets flowOn immediatley to 1. Set delay at beginning to test.
     flowOn = 1;   
    }
 }
 
  else {
    flowOn = 0; // sensor
    digitalWrite(led2, LOW);
  }
   if( mqtt.Update() )
    {
       if (!alum_count.publish(x++)) {
          Serial.println(F("Failed"));
       }
       else {
          Serial.println(F("OK!"));
       }
 
       if (!alum_response.publish(sensor)) {
          Serial.println(F("Failed"));
       }
       else {
          Serial.println(F("OK!"));
       }
       
       if (!alum_flow.publish(flowOn)) {
          Serial.println(F("Failed"));
       }
       else {
          Serial.println(F("OK!"));
       }
  // delay(60000); // don't break Adafruit's servers-- temper your feed or you will be banned!
   }
}   




Here are some notes I included in the comments of the code that summarize the issue:

Code: Select all | TOGGLE FULL SIZE
delay(240000); // if I bump this past 240000, posts to Adafruit IO start to fail on Argon
               // 30000  - (30 sec delay) no problem - posting as expected prior to 8:30 PM (10/1/20)
               // 600000 - (10 min delay) only one post at 8:30 pm - no posts every ten minutes as expected overnight (10/1/20)
               // 380000 - (6 min delay) only one post at 7:59 am - no posts every three minutes as expected
               //        - BUT Argon did send me a text 8:12 via Particle IO webhook when sensor was wetted (10/2/20)
               //        - Checked status of modem: Particle reports modem is "Healthy" with a "good signal", and "everything looks good"
               // 60000  - (1 min delay) no problem - posts starting at 8:17 working okay (10/2/20)
               // 120000 - (2 min delay) no problem - posts starting at 8:30 working okay (10/2/20)
               // 180000 - (3 min delay) no problem - posts starting at 8:57 working okay (10/2/20)
               // 240000 - (4 min delay) no problem - posts starting at 9:45 working okay (10/2/20)
               // 300000 - (5 min delay) - posts starting at 10:22 - two posts through 10:53 so missing four posts (10/2/20)
               // 600000 - (10 min delay) - flashed at 10:53 - posts starting at 11:04, but none thereafter through 12:42 pm.
               //                         - engaged switch at 11:44 and did receive a text
               //
               // *** Tests suggest there is some kind of synchronicity issue happening when posting intervals exceed four minutes.
               // *** The fact that I can text via the Particle IO webhook when the sensor is wetted when Adafruit IO
               //     is not picking up posts to my feeds suggests there might be somethign misaligned (timing wise?) on Adafruit IO's end (?)
               // *** It seems like I have to keep posts alive every four minutes or less to avoid losing data
               


Bottom line is the modem is operating properly during those periods when data is not being registered on Adafruit IO-- I can signal it; I can prompt it to send me texts; and its status and battery power is healthy. What would be causing Adafruit IO to stop receiving data from this modem if I increase the post interval past four minutes? This constraint is especially significant for Borons which rely on cellular data plans ($) and which will be remotely deployed (power demand).

Thanks!

biod101
 
Posts: 138
Joined: Sun Apr 19, 2015 4:21 pm

Re: AIO dashboard data lost on low-frequency posts

by brubell on Wed Oct 07, 2020 11:00 am

Continuing this over on this thread: viewtopic.php?f=56&t=170153

brubell
 
Posts: 1061
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.