TC2.12 - Creating IOT Applications

×

Warning message

You can't delete this newsletter because it has not been sent to all its subscribers.

Test Case Title

TC2.12 - Creating IOT Applications

Goal

Create an IOT application by using/exploiting  heterogeneous data and communication protocols, exploiting a large number of nodes/blocks implementing microservices. Each IOT Application may include several flows for data transformation, each flow can be saved and loaded.

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

Prerequisites

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.

Steps

 

According to Snap4City, an IOT applications may have connected multiple Dashboards, as well as a single  Dashboard can be connected to multiple IOT Applications. The IOT Applications are created by compositing Blocks/nodes and connecting them. Each block/node has input on left and output on right. The Output of a block/node can be monitored by using a DEBUG Block, and the IOT Application editor has a view of  the DEBUG data on the right panel.  Snap4City has created a large set of MicroServices / Blocks / nodes allowing from IOT Applications to access at all the Smart City data and services. They can be donwloaded frome the Node-RED kibrary, in two formats, basic and advnaced. If one would like to have the advanced suite, both library of Snap4City nodes/microservices have to be installed. The IOT Applications, which can be requested into the Snap4City environment already have them installed. 

The lists Snap4City nodes/microservices are

 

  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);

msg.payload=val_conv;

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

 

WHAT IS NEXT: