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:
On the section User credentials, set the following information:
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
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.
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.