Changes

Jump to: navigation, search
Created page with "{{InfoBoxTop}} {{AppliesToSBCSPG}} {{InfoBoxBottom}} {{WarningMessage|text=This technical note was validated against specific versions of hardware and software. It may not wor..."
{{InfoBoxTop}}
{{AppliesToSBCSPG}}
{{InfoBoxBottom}}
{{WarningMessage|text=This technical note was validated against specific versions of hardware and software. It may not work with other versions.}}
[[Category:MISC-AN-TN]]
[[Category:MISC-TN]]

__FORCETOC__
== History ==
{| class="wikitable" border="1"
!Version
!Date
!Notes
|-
|1.0.0
|October 2019
|First public release
|-
|}

==Introduction==

==Installing Node-RED==
Installing Node-RED is quite strightforward. 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:
<pre class="board-terminal">
root@sbcspg:~# apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.3).
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
</pre>


Then, invoke the script <code>update-nodejs-and-nodered</code>:
<pre class="board-terminal">
armbian@sbcspg:~$ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
q

This script will remove versions of Node.js prior to version 7.x, and Node-RED and
if necessary replace them with Node.js 10.x LTS (dubnium) and the latest Node-RED from Npm.

It also moves any Node-RED nodes that are globally installed into your user
~/.node-red/node_modules directory, and adds them to your package.json, so that
you can manage them with the palette manager.

It also tries to run 'npm rebuild' to refresh any extra nodes you have installed
that may have a native binary component. While this normally works ok, you need
to check that it succeeds for your combination of installed nodes.

To do all this it runs commands as root - please satisfy yourself that this will
not damage your Pi, or otherwise compromise your configuration.
If in doubt please backup your SD card first.

Are you really sure you want to do this ? [y/N] ? y

Would you like to install the Pi-specific nodes ? [y/N] ? N

Running Node-RED update for user armbian at /home/armbian on debian


We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for armbian:

This can take 20-30 minutes on the slower Pi versions - please wait.

Stop Node-RED \u2714
Remove old version of Node-RED \u2714
Remove old version of Node.js \u2714
Install Node.js LTS \u2714 Node v10.16.3 Npm 6.12.0
Clean npm cache \u2714
Install Node-RED core \u2714 1.0.1
Move global nodes to local -
Install extra Pi nodes -
Npm rebuild existing nodes -
Add shortcut commands \u2714
Update systemd script \u2714


Any errors will be logged to /var/log/nodered-install.log
All done.
You can now start Node-RED with the command node-red-start
or using the icon under Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started Mon Oct 14 10:56:44 CEST 2019 - Finished Mon Oct 14 11:15:09 CEST 2019
</pre>


After a while, Node-Red is ready to be started:
<pre class="board-terminal">
armbian@sbcspg:~$ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.0.81:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
Started Node-RED graphical event wiring tool.
14 Oct 11:27:55 - [info]
Welcome to Node-RED
===================
14 Oct 11:27:55 - [info] Node-RED version: v1.0.1
14 Oct 11:27:55 - [info] Node.js version: v10.16.3
14 Oct 11:27:55 - [info] Linux 4.1.15-rialto-1.1.3 arm LE
14 Oct 11:27:59 - [info] Loading palette nodes
14 Oct 11:28:10 - [info] Settings file : /home/armbian/.node-red/settings.js
14 Oct 11:28:10 - [info] Context store : 'default' [module=memory]
14 Oct 11:28:10 - [info] User directory : /home/armbian/.node-red
14 Oct 11:28:10 - [warn] Projects disabled : editorTheme.projects.enabled=false
14 Oct 11:28:10 - [info] Flows file : /home/armbian/.node-red/flows_sbcspg.json
14 Oct 11:28:10 - [info] Creating new flow file
14 Oct 11:28:10 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
14 Oct 11:28:10 - [info] Starting flows
14 Oct 11:28:10 - [info] Started flows
14 Oct 11:28:10 - [info] Server now running at http://127.0.0.1:1880/
</pre>

==Implementing a simple application==
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:
*It logs in the local debugger a message containing the timestamp associated with the timer that reiggers the execution of the flow at regular intervals
*It saves the timestamp on a local file
*
4,650
edits

Navigation menu