Subscribing to an MQTT topic

  1. Open Node-RED.
  2. Add an mqtt node from the input category to the workspace.
  3. Double-click the mqtt node to open the Edit node dialogue.
  4. In the Server drop-down list, select a server to connect to or add a new MQTT broker.
  5. In the Topic text box, enter the topic you want the node to subscribe to.
  6. notice

    Use / as hierarchy separator. You can use MQTT wildcards: + for one level, # for multiple levels.

  7. In the QoS drop-down lists, select the Quality of Service level of the respective message. Choose from:
  8. 0 (fire and forget): Arrival of the message solely relies on the underlying Internet Protocol network. Message loss may occur.
  9. 1 (at least once): The message is assured to arrive, but may arrive more than once.
  10. Click Done to apply your changes.
  11. Add more nodes to the workspace and connect them to a flow with the mqtt node being the first node.
  1. Once you deploy the flow, the mqtt node injects messages of the selected topic into the flow.

Adding an MQTT broker