Publishing messages to an MQTT topic
- Open Node-RED.
- Add an mqtt node from the output category to the workspace.
- Connect the input of the mqtt node to the output of the node whose output you want to publish.
- 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.
NOTICE


You can set topic, QoS and retain dynamically via message properties by leaving the corresponding fields blank.
- In the text box Topic, enter the topic you want the node to publish to.
- In the drop-down list QoS, select the Quality of Service level. Choose from:
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.
- In the drop-down list Retain, select whether messages shall be retained on the broker.
- Click Done to apply your changes.