The next part of the code I am trying to bring in is to check the latest value of a different IO Feed controlled by a slider on the dashboard. I want to set the desired temperature using the slider and use that as a variable to check against later in the code. I am stuck on how to bring in the latest value of that feed titled "Temperature Setting"
I am by no means a programmer, but I've been able to piece together the code I have.
Sorry, I posted this in the arduino forum, not realizing there was an IO forum. I hope to find some help.
I thought I could list a second feed in the setup. The first by itself works.
Code: Select all
Adafruit_IO_Feed testFeed = aio.getFeed("temperature");
Adafruit_IO_Feed settingFeed = aio.getFeed("Temperature Setting");
Code: Select all
// Initialize the Adafruit IO client class (not strictly necessary with the
// client class, but good practice).
aio.begin();
// Get the latest value of the temperature setting feed.
FeedData setPoint = settingFeed.receive();
//print the value received from the feed
if (setPoint.isValid()) {
Serial.print(F("Received value from feed: ")); Serial.println(setPoint);
// By default the received feed data item has a string value, however you
// can use the following functions to attempt to convert it to a numeric
// value like an int or float. Each function returns a boolean that indicates
// if the conversion succeeded, and takes as a parameter by reference the
// output value.
int i;
if (setPoint.intValue(&i)) {
Serial.print(F("Value as an int: ")); Serial.println(i, DEC);
}
// Other functions that you can use include:
// latest.uintValue() (unsigned int)
// latest.longValue() (long)
// latest.ulongValue() (unsigned long)
// latest.floatValue() (float)
// latest.doubleValue() (double)
}
else {
Serial.print(F("Failed to receive the latest feed value!"));
}
//print the variable setPoint to confirm it exists.
Serial.println(F("Desired donness: ")); Serial.println(setPoint);
Serial.println(F("Ready!"));