From AGILE IoT Wiki
Revision as of 13:30, 9 October 2017 by Roman.sosa (talk | contribs) (Add github repo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


AGILE provides a Node-RED node to connect to a FIWARE IDAS IoT agent using the UL protocol. The code is hosted here:

The node uses a config node where to specify the address of the IoT agent and the apikey to connect to.

In order to use the node, you need a FIWARE infrastructure with the Orion Context Broker GE and the IDAS Backend Device Management GE running, a service created and an IoT device registered in the service. You can get more details about this at How to read measures captured from IoT devices, which summarizing, are:

  1. create a service
  2. register an IoT device in the service
  3. send observations



First of all, we prepare the needed FIWARE services. You can use this docker-compose file to setup Orion and IDAS.

docker-compose up

Now you have Orion at port 1026, and IDAS at ports 4041 (control) and 7896 (measures reception).

The next step is creating a service (check [1]).


This creates a service, which will "contain" the different IoT devices. The service has a Fiware-Service = "OpenIoT" and a Fiware-ServicePath = "/agile".

Now, we have to register a device ([check]).


This register an IoT device into the previously created service. The script registers a kind of temperature sensor in the Fiware-Service and Fiware-ServicePath from the previous created service.

The registration declares the translation between the NGSI model (used on Orion) and the IDAS domain (used on the IDAS service).

The current specification of FIWARE-NGSI is v2 and can be found at [2]. The main elements of the NGSI data model (see Figure 13) are context entities, attributes and metadata, while the IDAS elements are devices and attributes.

The workflow

Now that we have the needed FIWARE services running, we create the workflow. To simplify it, we will not use security nodes.

The FIWARE node and the FIWARE config node have to be configured like below. NOTE: the DeviceId and Attribute parameters are the IDAS names for the device, as defined when it was created; if the names coming from AGILE (i.e, DeviceId and ComponentId) match the IDAS names, you can leave these parameters empty.

Fiware-node-params.png Fiware-config-node-params.png

The final workflow is shown below (you can import it with the menu item Import-> from Clipboard)


[{"id":"1fff7493.f83abb","type":"tab","label":"Flow 1"},{"id":"8c0aa56.05c9258","type":"fiware-send-data","z":"1fff7493.f83abb","name":"fiware-send","server":"71b72dd6.549854","deviceid":"temp","attribute":"t","x":309.5,"y":1235,"wires":[[]]},{"id":"68c74239.79053c","type":"agile-device-read","z":"1fff7493.f83abb","server":"283731de.1a608e","name":"dummy","deviceId":"dummy001122334455","componentId":"DummyData","interval":"10","x":132.5,"y":1235,"wires":"8c0aa56.05c9258"},{"id":"71b72dd6.549854","type":"fiware-config","z":"","idas_server_url":"","service":"OpenIoT","servicepath":"/agile","apikey":"4jggokgpepnvsb2uv4s40d59ov"},{"id":"283731de.1a608e","type":"agile-config-server","z":"","host":"agile","port":"8080"}]

Once it is deployed, it starts sending data to the IoT agent. Now the data can be observed registering to the Orion Context Broker, as shown below.


The workflow used to receive the data from Orion is very simple, composed of stock nodes, as shown below.


[{"id":"cc2fbca6.d5ac9","type":"tab","label":"Flow 2"},{"id":"43743295.3b379c","type":"inject","z":"cc2fbca6.d5ac9","name":"trigger","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":120.5,"y":106,"wires":"a45c7dda.ac064"},{"id":"a45c7dda.ac064","type":"function","z":"cc2fbca6.d5ac9","name":"prepare-request","func":"msg.headers = {\n    \"Fiware-Service\": \"OpenIoT\",\n    \"Fiware-ServicePath\": \"/agile\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":295.5,"y":106,"wires":"700e9e54.c461a"},{"id":"700e9e54.c461a","type":"http request","z":"cc2fbca6.d5ac9","name":"request-orion","method":"GET","ret":"obj","url":"","tls":"","x":480.5,"y":106,"wires":"a1012e5e.14a9a"},{"id":"a1012e5e.14a9a","type":"ui_chart","z":"cc2fbca6.d5ac9","name":"","group":"690bfc28.21d374","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":634.5,"y":106,"wires":[[],[]]},{"id":"690bfc28.21d374","type":"ui_group","z":"","name":"Default","tab":"7fa84b6d.78d4a4","disp":true,"width":"6"},{"id":"7fa84b6d.78d4a4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

The prepare-request node is a function node needed just to add the headers to the request:

 msg.headers = {
   "Fiware-Service": "OpenIoT",
   "Fiware-ServicePath": "/agile"
 return msg;

The request-orion node is an http request node with the following parameters: