how to pull latest value from an IO feed

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.
Locked
User avatar
ecodad
 
Posts: 18
Joined: Wed Jun 05, 2013 2:18 pm

how to pull latest value from an IO feed

Post by ecodad »

I am trying to write some code for the SGP30 that will store and retrieve the baseline data with an Adafruit IO feed.

I have no problem writing the value to the feed, but what I haven't figured out is how to read the latest value from the same feed, store that in a variable so I can use that to re-establish the baseline after a reset.
something like:

Code: Select all

AdafruitIO_Feed *baseline1Feed = io.feed("sgp30.baseline1");
AdafruitIO_Feed *baseline2Feed = io.feed("sgp30.baseline2");
void setup() {
  baseline1 = baseline1Feed->get;
  baseline2 = baseline2Feed->get;
  setupSGP30(baseline1,baseline2);
    // where this is a modified version from SGP30test.h to take two variables and set the baselines on setup

I cannot find anything on getting the value out. I can print it to Serial with a handleMessage function, but how would I store that to a variable?
****Baseline values: eCO2: 0x8BE4 & TVOC: 0x8DCC
received <- 35814
received <- 35812

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: how to pull latest value from an IO feed

Post by jwcooper »

Here is an example of a handleMessage that sets a variable, converting the value to an int:
https://github.com/adafruit/Adafruit_IO ... vo.ino#L90

User avatar
teempade04
 
Posts: 2
Joined: Tue Jan 31, 2023 7:07 am

Re: how to pull latest value from an IO feed

Post by teempade04 »

The get() function wil ask the Adafruit servers to resend the last value of the feed to this client only. When the value is received,

User avatar
teempade04
 
Posts: 2
Joined: Tue Jan 31, 2023 7:07 am

Re: how to pull latest value from an IO feed

Post by teempade04 »

Thanks and regards.. BANNED.one

BANNED

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”