Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

One of two feeds not handled on initializing get()
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.

One of two feeds not handled on initializing get()

by cavemanlawyer on Wed Dec 23, 2020 1:32 pm

I have 2 feeds that I've set up to contain threshold values used in the sketch. During execution, when updated through io.adafruit.com, they are each handled properly. However, during setup, when I attempt to get() each of these values, only one triggers the retrieval of the latest value. The other does nothing - regardless of order. Code excerpts:

Code: Select all | TOGGLE FULL SIZE
 
  AdafruitIO_Feed *photoresistorthreshold = io.feed("Photoresistor Threshold");     // allows management of photoresistor threshold (can be finicky)
  AdafruitIO_Feed *temperaturethreshold = io.feed("TemperatureThreshold");          // allows management of temperature threshold


Code: Select all | TOGGLE FULL SIZE
void setup(){
 
  Serial.begin(115200);       // start serial port for debug
  while(! Serial);            // wait for serial monitor to open
//
// Adafruit IO handshake
//
  long unsigned int startConnect = millis();
  Serial.print("Connecting to Adafruit IO");
  io.connect();                                     // connect to io.adafruit.com
  while((io.status() < AIO_CONNECTED) && (millis() < (startConnect + connectTimeout))){   // wait for a connection or until timeout
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println(io.statusText());
 
  photoresistorthreshold->onMessage(handlePRThreshold);    // set up handle to catch any changes to the light threshold from Adafruit IO
  temperaturethreshold->onMessage(handleTempThreshold);    // set up handle to catch any changes to the temperature threshold from Adafruit IO   
 
  temperaturethreshold->get();                             // force retrieval of most recent threshold data
  photoresistorthreshold->get();                           // force retrieval of most recent threshold data
 
  sensors.begin();


Code: Select all | TOGGLE FULL SIZE
void handlePRThreshold(AdafruitIO_Data *data) {
  int prThreshold = data->toInt();                  // convert the data to integer
  alertLightR = prThreshold;                        // set the new reference threshold
  Serial.print("<-photo threshold: ");
  Serial.println(alertLightR);
}
//
void handleTempThreshold(AdafruitIO_Data *data) {
  float tempThreshold = data->toFloat();                  // convert the data to integer
  alertTempC = tempThreshold;                        // set the new reference threshold
  Serial.print("<-temp threshold: ");
  Serial.println(alertTempC);
}


The "temperaturethreshold" get() call does NOT trigger during setup (only once executing). The photoresistor feed triggers at setup and during execution.

At this point, it's mostly just a PITA for testing as I have to always immediately update through the web when I restart the sketch, but it is curious behaviour.

If relevant, I'm using an ESP8266 (NodeMCU) on the Arduino library, with everything up to date.

I've attached the JSON (as TXT) construct for the feed in question.
tempthreshold.txt
temperature threshold adafruit io feed json
(2.5 KiB) Downloaded 1 time


Any ideas?

Thanks.

cavemanlawyer
 
Posts: 4
Joined: Sat May 12, 2018 1:18 pm

Re: One of two feeds not handled on initializing get()

by brubell on Thu Dec 24, 2020 10:21 am

I haven't experience this before, but I also don't typically try to get() > 1 feed during initialization..

Could you please file this as an issue on the Adafruit IO Arduino repository?
https://github.com/adafruit/Adafruit_IO_Arduino/issues

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

Re: One of two feeds not handled on initializing get()

by cavemanlawyer on Thu Dec 24, 2020 12:20 pm

UPDATE: I don't believe there is a connection between having multiple initializations during setup and this issue. I removed the working get() from the code, leaving the problematic call in place, and I still don't get the current feed value. A CURL request behaves as expected with the funky feed key. I will still go ahead and log this as an issue, with the amended symptoms.

cavemanlawyer
 
Posts: 4
Joined: Sat May 12, 2018 1:18 pm

Re: One of two feeds not handled on initializing get()

by brubell on Mon Dec 28, 2020 10:37 am

Thanks for filing an amendment. I'm going to take a look into this when I have some free time.

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

Re: One of two feeds not handled on initializing get()

by cavemanlawyer on Mon Dec 28, 2020 12:24 pm

If it helps, I believe the IO feed itself may be corrupted or malformed in some way. When I created a new feed and replaced it in the code, it worked fine. The old feed (ID: 1523053) still exists in my profile. Thanks!

cavemanlawyer
 
Posts: 4
Joined: Sat May 12, 2018 1:18 pm

Re: One of two feeds not handled on initializing get()

by brubell on Wed Dec 30, 2020 11:21 am

cavemanlawyer wrote:If it helps, I believe the IO feed itself may be corrupted or malformed in some way. When I created a new feed and replaced it in the code, it worked fine. The old feed (ID: 1523053) still exists in my profile. Thanks!

Ok - well - If you'd like us to attempt to rebuild the feed, please visit io.adafruit.com/feedback and link to this post.

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

Please be positive and constructive with your questions and comments.