Main Content

Subscribe to a Channel Feed

Subscribe to updates from channel feed with MQTT

ThingSpeak™ MQTT supports only QoS 0. For more information,see Server Response for Connections.

Description

channels/<channelID>/subscribe subscribes to updates to a channel feed. Replace <channelID> with the channel ID and <format> with the format of the return message.

Input Arguments

expand all

Channel ID for the subscription target, specified as a positive integer.

Limitations

  • Each ThingSpeak license type allows a different number of concurrent 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.

Examples

Configure MQTT X to subscribe to channel updates from your channel 33301 using mqtt-v2.thingspeak.com and port 1883.

In the New Connection dialog, use the following connection settings, along with client ID, username, and password derived when the MQTT device was created in ThingSpeak:

Name: MyChanName
Client ID: ENTER_MQTT_DEVICE_CLIENT_ID
Host: mqtt://    mqtt-v2.thingspeak.com
Port: 1883
Username: ENTER_MQTT_DEVICE_USERNAME
Password: ENTER_MQTT_DEVICE_PASSWORD

In the New Subscription dialog, use the subscribe topic syntax and settings:

Topic: channels/33301/subscribe
QoS: 0

Now when data is written to the channel, you can observe the messages in the MQTT X client display.

Introduced in R2017b