Subscribe to updates from a channel feed 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. For more information,see Server Response for Connections.
channels/
subscribes to updates to a channel feed. Replace
<channelID>
/subscribe/<format>
<channelID>
with the channel ID and
<format>
with the format of the return message.
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/<format>/
subscribes to updates to a channel feed from a private channel. Replace
<apiKey>
<apikey>
with the Read API key of the channel.
If a connection is successful, the server responds with the last value in the
subscribed channel. The <format>
used in your
topic subscription determines the format of the response.
Each ThingSpeak license type allows 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.
Configure MQTT.fx to subscribe to
channel updates from the MathWorks® weather station. Use mqtt.thingspeak.com
and port
1883
. Enter your MQTT API Key as the password.
Use the subscribe topic format channels/12397/subscribe/json
.
Since the MathWorks weather station is public, you do not need to include
/<apikey>
.
Now update the channel, and observe the messages in your client.
To unsubscribe from channel updates, click the Unsubscribe or Disconnect buttons.
Publish to a Channel Feed | Publish to a Channel Field Feed | Subscribe to a Channel Field Feed