Generate Random Measurement

generate measurement flow

Introduction

This flow is part of our Input flows collection. Input flows are used for importing data inside Node-RED environment for further processing.

Generating Random Line flow can be used in various scenarios, where we dont yet have stream of data comming to Node-RED, but we want to test if our other flows work.

Prerequisites

This flow with other data generating nodes and flows is available for user in the following package:

@senlab/node-red-generate-random-senlab

To learn more about Verdaccio and how to install packages, please refer to this documentation: Verdaccio

Setting Up The Inject Node

We initiate our flow with the Inject Node, which is a basic node and already preinstalled inside Node-RED. It can be found under the common tab.

The Inject Node can function as a button or a signal generator. Users need to specify which property and value the node will inject into the flow. For the purposes of this flow, the specific configuration of the property and value is not critical, as the primary goal is to activate other nodes within the flow. In the configuration panel, users have the option to set the Inject Node to either inject the value just once or to do so repeatedly at a specified interval.

step1 inject

Setting up the Generate Random Object Node

This custom node is designed for generating random data objects that can be used for further analysis. For guidance on creating custom nodes, refer to this documentation:

TODO: make documentation on how to create custom nodes

Generate Random Object Node is a simple node which generates random object which can be then used for further analysis.

The Generate Random Object Node is straightforward to configure. Within the node’s UI, user can select the type of object to generate—options include JSON, XML, and CSV, all available from a dropdown menu. Additionally, checkboxes allow you to specify which data elements to include in the object, such as ID, timestamp, and measurement.

While this node offers limited functionality on its own, it is intended for use in conjunction with other nodes to enhance its capabilities and enrich the data object with additional properties.

senlab rand obj node

Debug Node

The Debug Node enables users to inspect properties of the msg object. Users can choose to view the entire msg object or only a selected property. This node is crucial for development within Node-RED and should be utilized frequently to ensure optimal function and debugging.

Setting up Generate Random Data Subflow

This subflow extends the capabilities of the Generate Random Object Node by adding additional measurements to the previously generated object. Users can configure this subflow through environmental variables. Before implementing this subflow, it is advisable to consult our detailed documentation to ensure optimal setup and integration. The documentation can be found here: Generate Random Data Subflow

Sending The Data Through MQTT

MQTT is our protocol of choice inside our Node-RED examples and you will see it being used many times. To find out what MQTT is and how to use it in the scope of Node-RED, please refer to this documentation: MQTT

MQTT Node uses outMSG variable to be sent out as message body, in this case previously created object needs to be assigned to the outMSG variable.