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


Use / as hierarchy separator. You can use MQTT wildcards: + for one level, # for multiple levels.
- In the drop-down list QoS, select the Quality of Service level.
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.
- Click Done to apply your changes.
- Add more nodes to the workspace and connect them to a flow with the mqtt node being the first node.
- Once you deploy the flow, the mqtt node injects messages of the selected topic into the flow.