Main Content

ThingSpeak Read

Read data stored in ThingSpeak channel

Add-On Required: This feature requires the Simulink Support Package for Raspberry Pi Hardware add-on.

  • Raspberry Pi ThingSpeak Read icon

Libraries:
Simulink Support Package for Raspberry Pi Hardware / Internet Of Things

Description

The ThingSpeak Read block reads data from the ThingSpeak™ channel on ThingSpeak.com website.

ThingSpeak is an open IoT platform with MATLAB® analytics that allows you to collect and store the sensor data in the cloud and develop IoT applications. The ThingSpeak IoT platform provides applications that allow you to analyze and visualize your data in MATLAB and then act on the data. For more information on how to use ThingSpeak, see ThingSpeak Apps, Plugins, and Tutorials.

Ports

Output

expand all

At each time step, the port outputs the data read from the field specified in the Field Number parameter.

Data Types: single

The port outputs the ThingSpeak server response for the read request at each time step. The response is received as an HTTP status code. An HTTP status code of 200 indicates that the read request is successfully completed. For more information on HTTP status codes, see matlab.net.http.StatusCode.

Data Types: single

Parameters

expand all

Specify the channel ID from which the block reads data.

If you do not know the channel ID of your channel:

  1. Sign In to ThingSpeak using your MathWorks® Account.

  2. Select Channels > My Channels.

  3. Select the channel from which to read data.

  4. Click the Channel Settings tab.

  5. Copy the channel ID from the Channel ID parameter.

    ThingSpeak Channel Settings

  6. Open the ThingSpeak Read block in your model and paste the copied ID to the Channel ID parameter.

Specify if your channel is private or public.

If you do not know the sharing settings of your channel:

  1. Sign In to ThingSpeak using your MathWorks Account.

  2. Select Channels > My Channels.

  3. Select the channel to get the sharing status.

  4. 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.

    ThingSpeak Sharing Settings

When you read data from your channel using the ThingSpeak API or MATLAB code, you need an appropriate read permission. The 16-digit API key allows you to read data from a private or a shared channel. You do not need an API key to read from a public ThingSpeak channel.

If you do not know the read API key of your channel:

  1. Sign In to ThingSpeak using your The MathWorks® Account.

  2. Select Channels > My Channels.

  3. Select the channel to get the read API key.

  4. Click the API Keys tab.

  5. Copy the key from the Read API Keys parameter.

    ThingSpeak Read API Key

  6. Open the ThingSpeak Read block in your model and paste the copied API key into the Read API Key parameter.

Dependencies

The Read API Key parameter appears only when you set the Channel Access parameter to Private.

Select a field of the ThingSpeak channel from which the block reads data.

Select this option to save the response from the ThingSpeak server to a log file for each read request. The name of the log file is the model name followed by .log.

Specify how often this 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.

Version History

Introduced in R2018a