Subscribe to Channel Updates Using Desktop MQTT Client

This example shows how to use a desktop MQTT client to subscribe to a channel. The example uses MQTT.fx, which is a JavaFX based MQTT client.

Set Up Software

1) Obtain the channel information. For a public channel, you need only the channel ID. For a private channel, you additionally need the read API key. The channel ID is available at the upper left of the main landing page for your channel.

2) Download and install MQTT.fx. This example was tested with MQTT.fx version 1.3.1.

Configure MQTT Connection

Configure the connection profile for the desktop MQTT client.

1) Click the gear icon to the right of the profile name, and then click the plus button on the lower left.

2) In the Connection Profile dialog box, enter the mqtt.thingspeak.com for Broker Address and 1883 for Port. Click the Generate button to generate a unique client ID.

3) On the User Credentials tab, enter any user name and your MQTT API key from your ThingSpeak™ Account > MyProfile page.

4) Subscribe to the channel. Using the topic formats described in MQTT Basics, enter the channel of interest. For this example, subscribe to the MathWorks® weather station and receive posts in JSON format.

channels/12397/subscribe/json

For a private channel, add /<Read API Key> to the end of the topic name. Make sure to select QoS 0.

You are now set up to receive messages in the client each time the weather station data is updated.

See Also

| | |

Related Examples

More About

External Websites