IoTFlows
  • Welcome to IoTFlows Docs
  • IoTFlows
  • Console
  • REST API
  • Device Management & Secure Remote Access
    • 1. Connect a device to the cloud or create a virtual device
    • 2. SSH to your device over the internet
    • 3. Transfer files to your device over the internet
    • 4. Remotely access Node-RED on your device
    • 5. Create public links for local web-apps
  • Real-Time Data Streams, Alerts, and Actions
    • Create a Device API Key
    • Publish and subscribe to real-time messages with Node-RED
    • Creating an Alert Channel
    • Publish an Alert with Node-RED
    • Define and execute an Action in Node-RED
    • Python real-time SDK
    • Javascript real-time SDK
  • Cloud Node-RED Servers
    • Create a secure Cloud Node-RED Server in five minutes
    • Subscribe to data streams with a Cloud Node-RED Server
    • Integrate data streams to Node-RED dashboard
    • Integrate data streams to Slack
  • IOTFLOWS OVERVIEW
    • IoTFlows Roles and Permissions
    • Adding Team Members
  • Example Projects
    • Raspberry Pi as Gateway
      • Arduino to Raspberry Pi Serial Communication for Ultrasonic Sensor
    • Getting Started with Node-Red Dashboard
      • Installing Node-Red Dashboard
      • Accessing Node-Red Dashboard
      • 1. Creating a Page
      • 2. Adding Gauge Nodes
      • 3. Changing Dashboard Themes
      • 4. Adding Data to Gauge Nodes
      • 5. Adding a Chart Node
      • 6. Adding Data to Chart Node
      • 7. Adding a Template Node
      • 8. Adding Data to Template Node
      • 9. Adding Switch Node
      • 10. Adding Logic to Switch Node
      • 11. Adding a Slider Node
      • 12. Adding a Color Picker Node
      • 13. Adding a Numeric Node
      • 14. Adding a Button Node
      • 15. Adding Logic to a Button Node
      • Node-Red Dashboard Code
    • Publishing Data Streams from Python
    • Ultrasonic Sensor on Raspberry Pi Node-Red
  • General
    • Downloading IoTFlows Node-Red Nodes
    • Publishing Alert from Node-Red Manual
    • Publishing Data Stream from Node-Red Manual
Powered by GitBook
On this page
  • Prerequisites
  • Create a Data Stream
  • Connect to Node-RED
  • Configure the Data Stream connection
  • Publish a message to the cloud
  • Subscribe to the Data Stream

Was this helpful?

  1. Real-Time Data Streams, Alerts, and Actions

Publish and subscribe to real-time messages with Node-RED

In this page, you will see how to publish and subscribe to real-time Data Streams with Node-Red.

PreviousCreate a Device API KeyNextCreating an Alert Channel

Last updated 3 years ago

Was this helpful?

Prerequisites

For this section, you'll first need to , , and .

In case you have a Node-RED already installed manually and only need to exchange real-time data without managing your device, you can add manually to your Node-RED. .

Alternatively, you can publish and subscribe to real-time data streams with , and .

Create a Data Stream

From the side navigation tab of the device page, click on Create Data Stream. Set the name, description, and units to the type of data that you will be receiving.

Connect to Node-RED

Ensure your device is connected to the cloud by checking if you see the green light on the device page, Enable the Node-RED connection in the Remote Connections tab, and hit Connect.

Configure the Data Stream connection

From the nodes in the left navigation bar, drag and drop the datastream out node.

Double-click on the datastream out node and click on the edit button for the server

Here we will add the Device API Key information that will be used to publish data into our table.

If you have previously configured any nodes with your Device API KEY username and password, your nodes should already be configured.

Next, we will click the refresh button in the Topic row and select our Data Stream and hit Done.

Publish a message to the cloud

Any message payloads sent to the data streams out node will be published to the cloud through our data stream. You can connect any sensor that is receiving data into the data streams out node and click Deploy.

For the purpose of simplicity, we will use an inject node and trigger it to publish a datapoint when it is clicked. Drag and drop an inject node to and connect it the data streams out.

Double-click on the inject node and configure it to publish a value of 10 with a 5 seconds intervals and click Done.

Click Deploy to deploy your code. Now, the inject node generates a message with msg.payload = 10 every 5 seconds and the data stream out node publishes the data to the cloud through our data stream. You can see real-time data coming shown in the console.

Subscribe to the Data Stream

You can subscribe to your data streams and receive the messages published by other apps/clients in real-time. For the purpose of demonstration only, we can subscribe to the Temperature data stream and verify that we can get the same data.

Drag and drop a datastream in node, double click on it, and select the Temperature data stream in the Topic list.

Connect the output of the datastream in node to a debug node and hit Deploy.

You should see that we receive a message with the payload of "10" from the cloud every 5 seconds.

Congratulations! You have successfully published and subscribed to secured real-time data streams over the internet.

IMPORTANT: We strongly recommend that you change the default username and password for NodeRED (admin, password). .

connect your device to the cloud
create a remote connection for Node-RED
create a Device API Key
IoTFlows Node-RED Nodes
Learn how to add nodes to Node-RED
Python
Javascript
Learn how to change the Node-RED credentials