Learn How to Use MQTT.fx with ThingSpeak

Update, November 2026: ThingSpeak’s MQTT has changed since I wrote this in 2017, so the steps below don’t work as written anymore. The broker is now mqtt3.thingspeak.com (port 1883, or 8883 for TLS), and your write API key doesn’t go in the topic anymore. Instead, create an MQTT device in ThingSpeak (Devices, MQTT, Add a new device), add your channel to it, and download its credentials: a client ID, a username, and a password. Then publish to channels/<channelID>/publish with a payload like field1=45&field2=60&status=MQTTPUBLISH, or to channels/<channelID>/publish/fields/field1 with just the value. MQTT.fx’s old download pages are gone too. MathWorks’ current walkthrough uses MQTTX, a free, open-source desktop client: Publish and Subscribe to a Channel Using Desktop MQTT Client.

ThingSpeak just announced that they added MQTT as a way to send data to a ThingSpeak channel. This is great news since a lot of devices support MQTT. If you don’t have a device, but want to try out the MQTT protocol with ThingSpeak, you can use a desktop application called MQTT.fx. In this example, I am going to explain how to use MQTT.fx to send data to a ThingSpeak channel.

Your device or MQTTX logs in to the ThingSpeak broker mqtt3.thingspeak.com, publishes to channels/<channelID>/publish, and subscribes

Setup ThingSpeak

  • Sign up for ThingSpeak (or log in if you have an account)
  • Create a new channel
  • Note the Channel ID and Write API Key

Setup MQTT.fx

  • Download and install MQTT.fx.
  • Configure the connection profile for the desktop MQTT client.
    • Broker Address: mqtt.thingspeak.com
    • Broker Port: 1883

MQTT.fx Screenshot

  • Click Connect to connect to the ThingSpeak MQTT broker.

mqttdesktop02

  • Enter the topic channels/<channelID>/publish/<apikey> to publish data to a channel feed. Replace <channelID> with the channel ID and <apikey> with the write API key of the channel. Enter the message to publish to the channel feed. This PUBLISH message publishes a value of 45 to field 1 and 60 to field 2 of the specified channel, along with a status message MQTTPUBLISH.

mqttdesktop03

  • Alternatively, you can enter the topic channels/<channelID>/publish/fields/field<fieldnumber>/<apikey> to publish to a channel field. Replace <channelID> with the channel ID, <fieldnumber> with field number that want to update, and <apikey> with the write API key of the channel. Enter the message to publish to the channel field. This PUBLISH message publishes a value of 45 to field 1 of the specified channel.

mqttdesktop04

Additional Resources

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.