Visual development in Sofia2 with Raspberry, Node-RED and Dashboards


We have already spoken in previous publications about Node-RED, a tool for visual editing and execution of flows.

In this post will be presented a set of nodes designed to interact with Sofia2 IoT Platform and will present a small demo using those nodes deployed on a Raspberry with a SenseHat sensor.

We will start presenting this set of nodes:


We have a configuration node that has a global reach, that is, its state will be shared between flows. This node represents a shared connection with a remote system, in this case the configuration node is responsible for creating the connection (REST or MQTT) and make it available to the other nodes.

As for the other nodes are the performers of the operations of insertion, update, deletion, queries and release of the connection.

The nodes are available in Sofia2’s Github, in the npm repository and in the official Node-RED page.

Next we will develop two flows using the Node-RED tool, one of them will be deployed in a Raspberry Pi and another in Sofia2 IoT Platform:


The flow of the Raspberry Pi will trigger the process:


  • A node controls the SenseHat sensor data that we have integrated with our Raspberry Pi, and triggers the flow every second with temperature, pressure and humidity data.
  • A function node performs a data processing to generate a JSON instance that matches the ontology that is registered in Sofia2.
  • One of the nodes previously presented, will be responsible for sending a message to Sofia2 IoT Platform with the data obtained from SenseHat to the ontology and will be stored in the Real Time Database, which will feed us later the Dashboard.

The flow in Sofia2 IoT Platform


We have a flow that consists of two parts:

  • On the one hand we have a node that retrieves from an Internet service the temperature of Madrid. This data is stored in the context at the flow level.
  • On the other hand we have a node listening the events received from the Raspberry to the ontology in which the data obtained from the SenseHat board are being inserted. In this flow a simple calculation will be made to obtain the difference of temperatures, in addition a rule will be created in which if that difference exceeds a certain threshold a tweet will be sent. Note that the temperature variation data will also be stored in another ontology in Sofia2, so that you can then feed the Dashboard.

Once the demo is in progress, we create a Dashboard on the Platform, which represents the data of temperature, pressure and humidity, collected from the SenseHat sensor, and also the data of the calculated temperature variation.


This Demo is available in a guide format at the following link:

Visual development in Sofia2 with Raspberry, Node-RED and Dashboards

Creating Dashboards with Node-RED


As we mentioned in previous posts, Node-RED is a tool with which you can create flows visually. In this post we will see a new use of Node-RED as a tool to create Dashboards.

To do this we will use the Freeboard node, it is available on GitHub, this node allows us to design our own dashboards.

For this demo, we used a Meshlium sensor concentrator, which inserts real-time data into two ontologies defined by a single ThinKP. To access this data, in our Node-RED flow we will use the following nodes:

  •  A SSAP-process-request node: listening to insert events on the ontologies defined.
  • A function node, whose function will be to parse the data recovered from the ontology. It must be taken into account that the freeboard node only represents the data provided by the message payload in JSON format.
  • A Freeboard node, this will allows us to design our dashboard.

Our flow would look like this:


We will create two different Dashboards, in one of them we will represent the monitoring data of the device as the battery, internal temperature … In the other one we will represent the measurements provided by the sensors: solar radiation, humidity …

The two dashboards are shown below:



Once we have created the Dashboard, we save it to be able to access it from other devices or at another time. There are two ways to open a dashboard that you have saved:

  • By copying the URL generated at the time of saving the dashboard, through this URL we can access it from another device or browser.
  • By selecting the option “LOAD FREEBOARD” in the upper left corner, where we will have to load the generated .json file when we save the dashboard.

In the following video you can see a video of the demo:

Creating Dashboards with Node-RED