Getting Position Information using MQTT and Node-Red
Prerequisites
Node-Red must be installed on your system as well as an active MQTT broker.
Setup
Ensure your MQTT broker is running and accessible. Read this article for instructions on setting up an MQTT broker on Windows using Mosquitto.
Open Node-Red in your browser and navigate to your Node-Red instance.
Configuring Node-Red Nodes
Drag an MQTT IN node from the palette located on the left to the flow.
Double-click the MQTT IN node to configure its settings.
Click the pencil icon next to the server to add a new MQTT broker configuration.
Enter the MQTT broker’s IP address (e.g. 10.22.74.163) and port (1883). This IP address is the same as your previous MQTT broker’s IP address.
Click the Add button.
Set the topic of your choice.
Click Done.
Note: Ensure that the MQTT V5 protocol is selected and that the Keep Alive value is set to 60.
Adding a Debug Node
Drag a Debug node from the palette to the flow.
Connect to the output of the MQTT IN node to the Debug node.
Ensure that the Debug node is set to show the complete message object or the payload.
Deploying the Flow
Click the Deploy button in the top right corner to save and deploy all changes made.
Click the button on the Debug node to start receiving the position data.
Verifying Data Flow
Navigate to the debug pane on the right side of the Node-Red editor.
You should see the positioning data being received in the debug pane, indicating that the messages are successfully being received via the MQTT broker.
The image below is an example of the data that is received in Node-Red.