Main Content

ThingSpeak Write

Publish data to Internet of Things using ThingSpeak

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

  • Raspberry Pi ThingSpeak Write icon

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

Description

The ThingSpeak Write block publishes input data from target hardware to the Internet of Things (IoT) using ThingSpeak™.

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

Input

expand all

The block publishes the data read from this port to the nth variable on the ThingSpeak channel at each time step. The number of data channels at the block input depends on the number of variables you select in the Number of variables to send parameter. For example, if you set the Number of variables to send parameter to 3, the block enables three input ports with names var1, var2, and var3.

Data Types: single

Specify location data as a three-element numeric vector of the form [latitude, longitude, altitude]. The block then publishes the location data to ThingSpeak.

Dependencies

To enable this port, on the Optional tab, select Send location information and set the Location source parameter to Input port.

Data Types: single | double

Parameters

expand all

Main

Enter the 16-digit write API key of the ThingSpeak channel.

Follow these steps to get the API key for your ThingSpeak channel:

  1. Sign in to ThingSpeak using your MATLAB account.

  2. Select Channels > My Channels.

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

  4. Click the API Keys tab and copy the key from the Write API Key parameter.

    Raspberry Pi ThingSpeak Write API Key

  5. Open the ThingSpeak Read block in your model and paste the copied API key in the Write API key parameter.

Select the number of ThingSpeak variables to publish data from the block.

Specify the time interval at which the input data is updated on the ThingSpeak channel.

Select this parameter to save the response from the ThingSpeak server to a log file for each write request. The name of the log file has the format <model_name>.log.

Optional

Select this parameter to send location information to the ThingSpeak channel.

Select the source of the location data as one of the following:

  • Block dialog — Specify the location using the Location (latitude, longitude, altitude) parameter.

  • Input port — Specify the location using the location input port.

Use decimal degrees notation to specify latitude and longitude and use meters to specify altitude. For example:

  • The lowest human-sized point underground, the TauTona Mine in Carletonville, South Africa, is [-26.416111,27.4275,-3900].

  • The highest point measured from sea level, the summit of Mount Everest in Nepal, is [27.988056,86.925278,8848].

Enter the location information as a three-element numeric vector of the form [latitude, longitude, altitude] to publish location information to the ThingSpeak channel.

Dependencies

To enable this parameter, set Coordinate source to Block dialog.

Version History

Introduced in R2014b