Skip to content

Node-RED

Node-Red Overview

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. We use the Virtual Device Service to send data to Edge Xpert. The data is exported to the MQTT broker by using the Application Service and then publish to Node-RED. Finally, a subscription is set up in Node-Red to subscribe to the data from Edge Xpert.

Steps are as follows:

  1. Start the Edge Xpert
  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 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.

In the following example, we use the Application Service Onboarding Wizard with the Xpert Manager.

  1. 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.

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

  3. Enter the following information and click the save button to complete the process.

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

Application Service window

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 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. Now you can see the data from Edge Xpert in the Debug Messages panel.



Node Red Debug Messages