title
Best-practices & guides for Node-RED

Using the IoT-Simulator in Node-RED

Learn the basics of data contextualization with Node-RED to process simulated sensor data and fit it into the United Manufacturing Hub datamodel.

Using the IoT-Simulator in Node-RED

In this guide you will learn the basics of data contextualisation with Node-RED. You will learn how to process sensor data, in this case simulated data, and how to process it to fit the United Manufacturing Hub data model.

Before you start, take a look at our data model by checking out the documentation. In short, any data type, e.g. a shift, sensor data or other acquired data can be formatted into the UMH data model. Why is this important? First, it is important to structure the data to keep track of it. Secondly, the UMH can automatically calculate KPIS and OEE if you follow the data model.

ℹ️
Instead of Kafka, you can also connect via the MQTT broker. It does not matter in the UMH.

Prerequisites

  • Node-RED opened in your browser
  • node-red-contrib-kafkajs plugin installed.

Instructions

  1. Drag the following nodes into your Node-RED flow:
    kafkajsonfunction

  2. Open the kafka consumer node

  3. Create a new client by clicking on the pen.

  4. Give the client a Name, configure the Brokers field with
    united-manufacturing-hub-kafka:9092 and choose a unique Client ID.

    clientproperties

  5. Click on the top right on Update.

  6. Configure the Name and Group ID field with a fitting name and enter in the Topic field ia.raw.development.ioTSensors.Temperature. Finally click Done.

    kafkaproducer

  7. Open the function node and paste in the follwing:

    msg.payload = {
     "timestamp_ms": Date.now(),
     "Temperature": parseFloat(JSON.parse(msg.payload)["value"])
    } 
    return msg;
    
  8. Next, open the kafka producer node and select your previously created client.

  9. Configure the Topic field with ia.factoryinsight.aachen.test.processValue and tick Advanced Options.

  10. Tick the box Allow Auto Topic Creation and click on Done.

autotopiccreatino
12. Finally click on Deploy located on the top right.
13. Now your flow is active and you have successfuly contextualized the temperature data.

Stay up-to-date

Subscribe to the UMH Learning Hub Newsletter to receive the latest updates and gain early access to our blog posts.

Subscribe