This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Subscribe to a Channel Field Feed

Subscribe to channel updates from a particular field of a channel with MQTT

ThingSpeak™ MQTT requires an MQTT API Key to subscribe to channel updates for both private and public channels. Supply any unique user name and your MQTT API Key as a password parameter to the ThingSpeak MQTT broker when connecting. Choose Account > My Profile to see your MQTT API key. ThingSpeak MQTT supports only QoS 0.




channels/<channelID>/subscribe/fields/field<fieldnumber> subscribes to updates from a single field of a channel feed. Replace <channelID> with the channel ID and <fieldnumber> with the target field number. Subscribing to a channel feed automatically returns the last entry in the channel to your subscription. Invalid subscription details such as API Key, channel number, or MQTT User API Key result in the client being disconnected.

channels/<channelID>/subscribe/fields/field<fieldnumber>/<apikey> subscribes to updates to a channel field from a private channel. Replace <apikey> with the Read API Key of the channel.

channels/<channelID>/subscribe/fields/+ subscribes to updates to all fields of a channel feed from a public channel.

channels/<channelID>/subscribe/fields/+/<apikey> subscribes to updates to all fields of a channel feed from a private channel. Replace <apikey> with the Read API Key of the channel.

Input Arguments

expand all

Channel ID for the subscription target, specified as a numeric.

Data Types: uint16 | int16 | int8 | uint8

Field number of the subscription target, specified as a positive integer.

Data Types: uint16 | int16 | int8 | uint8

Channel Read API Key, required to subscribe to a private channel. This value is different from the MQTT API Key used for connection and different from the Write API Key.

Data Types: char


If a connection is successful, the server responds with the last value in the subscribed channel field.


  • Each ThingSpeak license type allows different number of MQTT subscriptions and has different restrictions on the number of messages delivered. For more information, see How to Buy and Frequently Asked Questions.

  • MQTT subscriptions do not report updates to the channel from Bulk Write JSON Data or Bulk Write CSV Data.

  • ThingSpeak MQTT honors all MQTT disconnect and unsubscribe messages. If you disconnect from the MQTT server, you are automatically unsubscribed from channel updates.


Configure MQTT.fx to subscribe to channel field updates from the MathWorks® weather station. Field 2 provides the current wind speed. Use and port 1883. Enter a unique user name and your MQTT API Key as the password.

Use the subscribe format channels/12397/subscribe/fields/field2. Since the MathWorks weather station is public, the /<apikey> is not needed. This example is shown with the API key included.

Now update the channel, and observe the messages in your client.

To unsubscribe from channel updates, click the Unsubscribe or Disconnect buttons.