Read data stored in ThingSpeak channel
Simulink Coder Support Package for STMicroelectronics Nucleo Boards / STM32F7
Simulink Coder Support Package for STMicroelectronics Nucleo Boards / STM32H7
The ThingSpeak Read block reads data from the ThingSpeak™ channel on the ThingSpeak.com website.
ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. You can send data to ThingSpeak from your devices, create instant visualizations of live data, and send alerts using web services. With MATLAB® analytics inside ThingSpeak, you can write and execute MATLAB code to perform preprocessing, visualizations, and analyses.
The ThingSpeak Write and ThingSpeak Read blocks take a minimum of 700 ms for execution when you run the model in external mode. If the overall model execution time when you run the model in external mode exceeds 2 s, there can be sporadic disconnects. There is no such limitation if you run the model in the
Build, load and runmode.
Data — Data read from specified field of ThingSpeak channel
At each time step, the port outputs the data read from the field specified in the Field Number parameter.
Status — Status of each read request
The port outputs the status of each read request as mentioned in the following table:
Return status codes
|200||OK or Success|
|-301||Failed to connect to ThingSpeak|
|-303||Unable to parse response from ThingSpeak|
|-304||No response from server within timeout|
This port appears only when you select the Output Status parameter.
Channel ID — Channel ID from which block reads data
65531 (default) |
Specify the channel ID from which the block reads data.
If you do not know the channel ID of your channel:
Sign In to ThingSpeak using your MathWorks® Account.
Select Channels > My Channels.
Select the channel from which to read data.
Click the Channel Settings tab.
Copy the channel ID from the Channel ID parameter.
Open the ThingSpeak Read block in your model and paste the copied ID to the Channel ID parameter.
Channel access — Sharing settings of channel
Public (default) |
Specify if your channel is private or public.
If you do not know the sharing settings of your channel:
Sign In to ThingSpeak using your MathWorks Account.
Select Channels > My Channels.
Select the channel to get the sharing status.
Click the Sharing tab. Use the option selected in the tab to set Channel Access.
Keep channel view private: Set Channel Access to
Private. Only you can view the channel data.
Share channel view with everyone: Set Channel Access to
Public. Anyone browsing the ThingSpeak website can view the channel data.
Share channel view only with the following users: Set Channel Access to
Private. Users who have access to shared channels can see only the private view of a channel; they cannot add channels, see alerts, or see license information.
Field number — Field from which block reads data
1 (default) | integer between 1 and 8
Select a field of the ThingSpeak channel from which the block reads data.
Output Status — Enable output status
off (default) |
When you select the Output Status parameter, the block configures an output port, Status. The port outputs the status message.
Sample time — Interval at which block reads data
20 (default) |
Specify how often the block reads data from the ThingSpeak channel.
When you set this parameter to
-1, Simulink® determines the best sample time for the block based on the block
context within the model.
Introduced in R2021b