MQTT - Example with MQTT.fx

MQTT - Example with MQTT.fx

This is a tutorial on how to connect to Tago MQTT, subscribe to topics using wildcards and publish to a topic. For this tutorial we will use the software Mqttfx. To download and learn more about Mqttfx go to their website https://softblade.de/en/welcome/.

To connect to the Tago MQTT and publish to any topic, first, we need to add a device. Go to the Device section and create a device. Then, go to the section tokens and copy your device-token.

Open Mqttfx, and click on the gear icon

On the Connection Profile window, set the following information:

  • Profile Name: “Any name”
  • Broker Address: mqtt.tago.io
  • Broker Port: 8883
  • Client ID: “Any value”

On the section User credentials, set the following information:

  • User Name: “Any value” Tago validates your user by the token only
  • Password: “Your device token”

On the SSL/TLS section, check the option Enable SSL/TLS, and click OK

Now, you can connect to Tago using the configuration you just set up. Select the connection profile that you just created, and click Connect

When you are connected, the connection indicator will become green


Single level wildcard

As Tago MQTT broker supports single level wildcard represented by the + sign, On this section, you will learn how to work with this wildcard.

Go to the section subscribe and subscribe to the following topics:

  • home
  • home/+
  • home/+/temperature

As we subscribed to the topic home, let’s publish some data to this topic.

Go to the section Publish, type the topic home, then the payload ‘ac=on’ and click publish

Now going to the section Subscribe, we can see that the topic home received one message with the payload ‘ac=on’

Go back to the publish section and publish the same message to the topic home/bedroom

If we go back to the subscribe section, we can see that we received a message on the topic home/+and on the topic home there is the previous message.

Now go back to the publish section and publish the message ‘25’ to the topic home/bedroom/temperature

If we go back to the subscribe section, we can see that we received a message on the topic home/+/temperature and on the other topics there are the previous messages.

Now we will publish three more values to three different topics, so publish the value ‘26’ to the topic home/livingroom/temperature, the value ‘28’ to the topic home/kitchen/temperature and the value ‘23’ to the topic home/office/temperature

If we go back to the subscribe section we can see that the topic home/+/temperature received the three new messages we have just sent.


Multi level wildcard

Tago MQTT broker also supports multi level wildcard represented by the # sign, on this section you will learn how to use this wildcard.

Go to the section subscribe and subscribe to the following topics:

  • home
  • home/#

Now go to the section publish and publish the value ‘ac=on’ to the topic home

If we go to the section subscribe, we can see that both topics received the message.

Now go to the section publish and publish three more values to three different topics, so publish the value ‘1’ to the topic home/kitchen, the value ‘1’ to the topic home/kitchen/ac and the value ‘22’ to the topic home/livingroom/ac/temperature

If we go to the section subscribe we can see that the topic home/# received the three new messages that we have just sent.


    • Related Articles

    • MQTT

      MQTT stands for MQ Telemetry Transport; it's an extremely simple and lightweight publish-subscribe messaging protocol. It was designed for constrained devices and low-bandwidth, high-latency or unreliable networks. TagoIO has its own MQTT broker that ...
    • MQTT with Sensor Tag

      This is an example using the SensorTag Bluetooth module from Texas Instruments to send data to TagoIO. There is no code modification needed in the SensorTag side, and as it uses the MQTT protocol, only a configuration setup is needed. For the ...
    • MQTT - Publishing and Subscribing

      You can publish to your MQTT topics by coding a script that will run from an Analysis. When the analysis runs, your script can publish a topic that can be received by any device that has subscribed to that specific topic. There are different ways to ...
    • Trigger by MQTT Topic

      The trigger type, Trigger by Variable, allows you to execute your Action when data is sent to an MQTT topic. TagoIO has its own MQTT broker that is responsible for pushing data to clients in case something new is published in the specific topics they ...
    • MQTT - Process data, Publish it and Subscribe to a topic

      In this tutorial you are going to learn how to process some data, publish to a topic and subscribe to it. To subscribe to a topic we will use Mqttfx. To download and learn more about Mqttfx go to their website https://softblade.de/en/welcome/. ...