TC9.5 - Creating IOT Applications coping with heterogeneous data

Test Case Title

TC9.5 - Creating IOT Applications coping with heterogeneous data


Create an IOT application by using heterogeneous data and communication protocols

Create IOT applications discovery IOT devices relying on their properties

Extract sensor observations from heterogeneous sensors (belonging to different context brokers and using different formats and units of measure) and conduct an analysis

Show the obtained results in the debug section


Using a PC with a web browser. You need credentials to access to the Node-Red application.

The following functionalities are available only for specific Snap4city users with specific privileges.

Expected successful result

Generation of a flow that gather temperature observations from two thermometers that collect values in Celsius and Fahrenheit compute the average temperature each 20 seconds and show the result in the debug section.




  1. In this test case we start with a node-RED flow that is partially instantiated and you have to complete it.
  2. Open a Flow in your cloud (TC2.1a) or local (TC2.1b) IotApplication
  3. Import for testing the flow  "TC9.5 - Creating IOT App coping with hetero.json" with the steps described in TC2.13 (on cloud) or import it from the file (if you have not an IOT Application on cloud)
  4. Once imported the flow, you can find the following two flows that simulate the generation of temperature values from two distinct sensors that adopt two different units of measure (Celsius the first one, Fahrenheit the second one). Also, the formats of the generated values are different (JSON the first one, single value the second one). The first flow produces observations every 5 seconds that are sent to the Orion Context Broker. The second one produces observations every 7 seconds and they are sent to a MQTT Context Broker.  This is thus an example in which data produced in different formats, unit of measures, frequencies and transmitted according to different protocols need to be integrated.
  5. You can select from the list of blocks in the left panel, the Orion block and the MQTT input and configure them as specified in the following figure (the red rectangles contain the information that you need to digit). We remark that the other parameters are already set because of the presence of the two flows described above.

  1.  Now you have to introduce a function for reading the JSON value from the Orion Context Broker and extract the temperature value. The following code should be written in the form of the function node

var temp= Number(msg.payload.temperature.value);

msg.payload= temp;

return msg;

The code extracts the temperature value from the JSON and returns it in the payload of the message. Moreover, you need to create another function for the transformation of the Fahrenheit values in Celsius.

var temp = msg.payload;

var val_conv=(temp-32)/(1.8);


return msg;

At this point you need to insert in the canvas an aggregator node that is able to collect values arriving in input for a given interval of time and calculate the average value every 20 seconds (this is just for demo purpose). This component can be downloaded from the community of node-red developers.


  1. We have completed the creation of the nodes and we can wire them as reported in the following figure:
  2. Now you can deploy it and see the average temperature in the debug section. You can check your flow with the one that we have developed and made available (TC2.13 on cloud) in the resource manager "TC9.5 (Completed) - Creating IOT App coping with hetero.json" or import it from the file (if you have not an IOT Application on cloud).