Skip to content

Node-RED

Node-Red

Node-RED is a programming tool that provides a browser-based flow editor that makes it easy to wire together flows using nodes in the Node-RED palette. This example shows how you can use Edge Xpert to deliver the data to Node-RED. Once the data is in Node-RED you can create rules and analytics to handle the data or send commands back to Edge Xpert.

The following example demonstrates how to set up and use Node-RED. In this example we are going to use the Virtual Device Service to send data to Edge Xpert. The data is exported to an MQTT broker using the Application Service which will publish it to Node-RED. Finally, a subscription is set up in Node-Red to subscribe to the data from Edge Xpert.

These are the steps:

  1. Start the Edge Xpert services
  2. Export events to a MQTT-broker using the Application Service
  3. Set up a Subscription in Node-Red

Start the Edge Xpert Services

In this example, we are using Node-RED, the MQTT broker and the Virtual Device Service. We are also going to use the Xpert Manager to set up the Application Service to export events to the mqtt-broker. Start Edge Xpert using the command:

    edgexpert up nodered mqtt-broker device-virtual --secret sys-mgmt xpert-manager

Export Events to a MQTT-Broker Using the Xpert Manager

We are going to export events to a MQTT broker via the Application Service. For more information on using the Application Service see Application Service To make things easy we are going to use the Application Service Onboarding Wizard in the Xpert Manager.

To bring up the Xpert Manager navigate to localhost:9090 in a web browser. Enter the user name and password (the default user name and password is admin). See Edge XPert Manager UI for more information about using the Xpert Manager.

Go to the App Services tab and click the Add App Service (+) button.

Application Service window

Enter the following information

Field Value
Name NodeRed
Destination MQTT
Broker Address tcp://mqtt-broker:1883
Topic MyTopic

Click the save button to save the application service setup.

Set Up a Subscription in Node-RED

To set up Node-RED to subscribe to the data from Edge Xpert complete the following steps:

  1. Open a browser and enter localhost:1880 in the Address Bar to start the Node-RED user interface.
  2. Drag mqtt-in from the network options to the flow, as shown below:

    Node Red MQTT in

  3. Double-click the mqtt input node to edit the node properties.
  4. Select the Edit (pencil) icon beside the Server field, as illustrated below:

    Node Red Edit Server

  5. In the Name text box, enter mqtt
  6. In the Server text box, enter mqtt-broker

    Node Red Edit Server

  7. Click the Add button
  8. In the Topic text box, enter MyTopic

    Node Red Add Topic

  9. Select the Done button.

  10. Drag json from the parser to flow, as illustrated below:

    Node Red Add JSON

  11. Drag debug from the common options to flow, as illustrated below:

    Node Red Add Debug

  12. Drag the connector box on the right of the mqtt node to the json node. Then drag the connector box on the json node to the debug node as shown below:

    Node Red Add Connector

  13. Select the Deploy button.
  14. Select the debug node, then select Debug Messages (bug) icon, as illustrated below. You can see the data from Edge Xpert in the Debug Messages panel.



Node Red Debug Messages

Back to top