Using Thingspeak React with "dynamic" channels

5 views (last 30 days)
Ben Alimansky
Ben Alimansky on 17 Sep 2020
Answered: Vinod on 17 Sep 2020
Hi Vinod - you helped me a few minutes ago with a question about how to work with multiple devices which were all updating Thingspeak concurrently. Your suggestion of dynamically creating a dynamic, for each respective device, makes sense.
However, I have a related issue. I have a React app (in Thingspeak) that triggers a Matlab Analysis script on data insertion to the single channel that I'm using today. As I go to implement a multi-channel approach, do you have any thoughts on how I can use React across channels that I am creating "dynamically"? The React parameters (via the Thingspeak website) seem to specify the channel that you're monitoring - and I'm not sure how to do this in a more dynamic way.
Thank you!
Ben

Answers (1)

Vinod
Vinod on 17 Sep 2020
My recommendation would be to set up a TimeControl that triggers MATLAB code that reads data across all your channels. Your MATLAB code can use the same REST APIs as your devices to find all the channels and their API keys and then read the last 10 minutes of data across all of the channels and do the operations you need. With MATLAB code you can get much more control over the conditions under which you want something to happen, and a much wider range of actions that you can have the MATLAB code perform for you.
The one downside with this approach is that it is not instantaneous, unlike a react which monitors the data as it is inserted into the channel. Then again, this approach is a lot more flexible. I guess that is the sort of tradeoff that engineers have to consider all the time :)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on Read Data from Channel in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!