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 drop-down list Server, select a server to connect to or add a new MQTT broker.
  5. In the text box Topic, enter the topic you want the node to subscribe to.
  6. NOTICE

    notice

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

  7. In the drop-down list QoS, select the Quality of Service level.
  8. NOTICE

    notice

    0 (fire and forget): Arrival of the message solely relies on the underlying Internet Protocol network. Message loss may occur.

    1 (at least once): The message is assured to arrive, but may arrive more than once.

    2 (once and once only): The message is assured to arrive once and only once.

  9. Click Done to apply your changes.
  10. 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.