Learn How to Use MQTT.fx with ThingSpeak

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.

ThingSpeak MQTT Broker

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

  • MQTT Basics – Learn about the publish/subscribe architecture for connecting bandwidth and power-constrained devices over wireless networks
  • MQTT Client Configuration – Learn how to set up an MQTT client to communicate with the ThingSpeak MQTT broker
  • Choose Between REST and MQTT – Learn when to use REST and MQTT to update a channel

Leave a Reply

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