Open main menu

DAVE Developer's Wiki β

Changes

no edit summary
{{InfoBoxTop}}
{{AppliesToSBCSPG}}
{{AppliesTo SBC Lynx TN}}
{{AppliesToIoT}}
{{AppliesTo IoT TN}}
{{InfoBoxBottom}}
{{WarningMessage|text=This technical note was validated against specific versions of hardware and software. It may not work with other versions.}}
==Introduction==
In a typical Industrial IoT (IIoT) scenario, the edge devices like the [[MISC-TN-004:_Running_Debian_(armbian)_on_SBCSPG#The_hardware_platform|SBCSBP gateway]] are installed and used by personnel who have limited or no programming skills at all. Nevertheless, these operators are required to implement simple automation processes with edge devices. To address this situation, no-code visual development tools can be used. [https://nodered.org/ Node-RED] is an example of such tools.
 
According to the official home page of the project, it is defined as:
 
 
''... a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.''
 
 
This Technical Note (TN) shows how Node-RED can be installed and used on the SBCSBP gateway.
 
The procedure was tested on a SBCSPG gateway running ''armbian'' GNU/Linux distribution. For more details about this configuration, please refer to [[MISC-TN-004:_Running_Debian_(armbian)_on_SBCSPG|this TN]].
==Installing Node-RED==
Installing Node-RED is quite strightforwardstraightforward. Essentially, you need to follow the procedure described [[https://nodered.org/docs/getting-started/raspberrypi here]].
First, make sure that the <code>build-essential</code> package is installed:
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
</pre>
 
 After a while, Node-Red RED is ready to be started:
<pre class="board-terminal">
armbian@sbcspg:~$ node-red-start
</pre>
==Implementing a simple application(flow)==Many tutorials are available on the Internet showing how to develop, test, and deploy Node-RED based applications. Here, a simple example is shown. It consists of one flow that performs the following operations every 5 seconds(please note that the execution of the flow is triggered by a 5-second periodic timer):*It logs logging in the local debugger window a message containing the timestamp associated with the timer that reiggers the execution of the flow at regular intervals*It saves saving the timestamp on a local file*sending a message to a remote MQTT server.  Before creating this simple flow, the connection with the remote MQTT server can be tested (<code>test.mosquitto.org</code>):<pre class="board-terminal">root@sbcspg:~# apt install mosquitto-clients...armbian@sbcspg:~$ mosquitto_sub -h test.mosquitto.org -t "#" -v...</pre>   The test flow looks like this:[[File:SBCSPG-Node-RED-1.png|thumb|center|600px|Test flow diagram]]   The following pictures show how the individual nodes were configured:[[File:SBCSPG-Node-RED-debug-logger.png|thumb|center|600px|''Debug'' node configuration]][[File:SBCSPG-Node-RED-MQTT-out.png|thumb|center|600px|''MQTT out'' node configuration]][[File:SBCSPG-Node-RED-file-out.png|thumb|center|600px|''File'' node configuration]][[File:SBCSPG-Node-RED-timer.png|thumb|center|600px|''Timer'' node configuration]]   Once deployed, to verify that the flow is working correctly, it is possible to read the local file where the timestamps are stored ...<pre class="board-terminal">armbian@sbcspg:~$ tail -f nr-flow1-test 157114596345715711459684611571145973478...</pre> and receive the test messages from the remote broker, by subscribing to the test topic:<pre class="board-terminal">armbian@sbcspg:~$ mosquitto_sub -h test.mosquitto.org -t "dave-am-test/#" -vdave-am-test 1571146144165dave-am-test 1571146149185dave-am-test 1571146154204...</pre> == Video ==Watch our dedicated video were is possible to see this demo in action:{{#ev:youtube|mTkk8YTldpM|600|center|Using Node-RED on SBCSPG to develop zero code applications|frame}}
dave_user, Administrators
5,190
edits