Act On Data in ThingSpeak | IoT from Data to Action, Part 4 - MATLAB
Video Player is loading.
Current Time 0:00
Duration 3:46
Loaded: 4.37%
Stream Type LIVE
Remaining Time 3:46
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 3:46

    Act On Data in ThingSpeak | IoT from Data to Action, Part 4

    From the series: IoT from Data to Action

    ThingSpeak™ is a cloud data service that lets you collect and store data from your devices and then analyze and display the data using MATLAB. Learn ways to schedule actions based on your insights using the React and TimeControl apps in ThingSpeak. For example, using the data from our environmental monitor in the previous videos, we can generate alerts, control mechanical devices, or interface with external services.

    React works with ThingHTTP, ThingTweet, and MATLAB Analysis apps to perform actions when channel data meets a certain condition.

    Similarly, the TimeControl app can perform these actions at a specific time or on a regular schedule. Finally, share all your IoT data, insights, and custom visualizations with specific ThingSpeak and MATLAB users or with anyone who has the channel URL.

    Published: 13 Dec 2021

    ThingSpeak and MATLAB let you act on the insights from your IoT data. You can turn on alarms, activate sensors, start or stop motors, and send alerts. Also, you can share your data and visualizations with others to keep them informed.

    We started by setting up this ThingSpeak account to be able to write and read data from the environmental monitor into channels.

    One of our sensors measures the carbon dioxide concentration in the air. Now, we will add a control device that is connected to an exhaust fan. The control device could be an Arduino, Raspberry Pi, or any other Wi-Fi connected thing. When the CO2 sensor reports a high concentration, we can use ThingSpeak to trigger the exhaust fan to remotely kill the air.

    We'll use the React app to set up a trigger that is based on the detected CO2 concentration. The React will call MATLAB code that turns the fan on or off, based on a threshold value. The code writes to the control channel, which is read by the fan's device.

    The test frequency determines how often the React runs. It can be done at regular intervals, or every time data is written to the channel. Select On Data Insertion for Test Frequency and then choose the MATLAB analysis that controls the fan. Now, when the value exceeds the threshold, ThingSpeak updates the control channel and the fan turns on.

    ThingSpeak can also be used to perform more complex actions, like generating a daily report of average CO2 values. This code reads the data and calculates the daily average, then sends the values in an email alert. Note that we can make our code easier to read by using functions.

    We code the criteria into a MATLAB script and then schedule it to run every day with the time controller. In the ThingSpeak menu, select Apps, Time Control. We give it a name, specifying Recurring as the frequency, choose a time, and then select the MATLAB code that we just wrote. After saving the time control, we get daily email reports of the environmental condition.

    We can bridge devices and apps together using external services, like IFTTT and Google. For example, using the webwrite function in the MATLAB analysis app, we can write files to a Dropbox account.

    Another way to act on your data is to share your insights with others. ThingSpeak makes sharing especially easy. There are ways to share with other ThingSpeak users and with non-users.

    To share data with everyone, make the channel public. You can use the Sharing tab on the Channel view to change a private channel to public. Anyone with the channel URL can see the channel's public view. To share with specific ThingSpeak users, use the Sharing tab to add their MathWorks account. This lets them see the private view of the channel when they sign in.

    We can share visualizations created in ThingSpeak with a similar process. On the editing tab for the visualization, check Create URL, and then provide this URL to your audience.

    In summary, ThingSpeak in MATLAB enable us to act on the insights from IoT data. We can react to changes in the data by triggering remote actions, like altering the state of a mechanical device. We can also schedule regular analysis to generate alerts and easily share our data and insights with others.

    Related Information

    View more related videos