Setting Up MQTT

This article will guide users on how to configure a MQTT Publisher and Subscriber using a public broker. It is divided into two parts; Part 1 and Part 2.

 

Part 1: Configuring the Publisher

  • First of all, user need to enable the MQTT Publisher driver. Select IO Server on the left pane and enable the MQTT Publisher and save.
  • To configure a broker, select MQTT Publisher under IO Server. Create an entry and under MQTT server, type in the address of the public broker and save. If user wishes to use a local broker, type “localhost” under MQTT server.

  • To add a publisher tag, first user must create a virtual tag. Select Virtual under Tag and create a string type tag called “Publisher“. Save.
  • Finally, to assign the tag as a MQTT publisher tag, right-click the tag, select Add to IO Server, select MQTT Publisher, Select Broker and select Tag.
  • Under Topic, type in “/ecava/MQTT/test” and save.

  • User can now start to publish messages to the topic.

 

Part 2: Configuring the Subscriber

  • Firstly, user need to create a subscriber tag. To do that, under Tag, select IO Driver. Create an entry named “MQTT” and type in “iot.eclipse.org” or “iot.eclipse.org:1883” under Address. Save.

  • On the left pane, select MQTT under IO Driver. Create an entry with a suitable name and select the desired Timer. Under Driver, select the MQTT driver. Save.

  • Select the entry created from the step above on the left pane and create an entry.This entry will be the subscriber tag. Give a suitable name and type in “/ecava/MQTT/test” under Path.

  • User can now subscribe to the topic. Any messages published to the topic will be retrieve by the subscriber tag.

Check out this great article on how to troubleshoot your project using MQTT Spy software.