Node-Red Grafana en InfluxDB op Raspberry-pi 4 -2Gb

Marco Rudolph

Commandline commands:

Node_Red:http://192.168.1.54:1880/

node-red-stop

node-red-start

node-red-log

Autostart on boot:

sudo systemctl enable nodered.service

sudo systemctl disable nodered.service

InfluxDB:

Poort: 8086

Configuratiefile: /etc/influxdb/influxdb.conf
sudo nano /etc/influxdb/influxdb.conf

Grafana:http://192.168.1.54:3000/

sudo systemctl daemon-reload
sudo systemctl enable grafana.service
sudo systemctl start grafana-server

Mosquitto:

\\192.168.1.54: 1883

sudo service mosquitto stop

sudo service mosquitto start

Chronograf:http://192.168.1.54:8888/

23-sept. 2019

https://sourceforge.net/projects/win32diskimager/
  • Download puTTY (64B Windows)

putty-64bit-0.73-installer.msi

  • Unzip het <datum>-raspian-buser Lite. Zip.torrent bestand en schrijf,  met het programma Win32DiskImager, het bestand naar een SD card (16G).
  • Open het image bestand op de sdcard met de Windows  verkenner en zet een lege tekst file  met de naam ‘ssh’ (zonder quotes en zonder .txt extensie) in de root van het image op de sdcard.
  • Plaats de sdcard in Raspberry Pi, sluit deze met  een netwerkkabel aan op je router.
  • Zoek  in de management tool van je router naar Ipaddress van de Raspberry Pi
  • SSH  via puTTY naar je Raspberry Pi , log in met :
    • Username: pi
    • Password: raspberry
  •   Start Raspi-config voor enkele aanpassingen  zoals:
    •  Veranderen van standaard admin wachtwoord > passwd
    • TimeZone Europe –Amsterdam > raspi-config
    • Expand Filesystem…etc.

Installatie Node-Red

Source info:https://nodered.org/docs/getting-started/raspberrypi#running-as-a-service

Start puTTY, open een SSH sessie met pi en gebruik het volgende commando:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Running Node-RED install for user pi at /home/pi on raspbian\n

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

  Stop Node-RED                       ✔

  Remove old version of Node-RED      ✔

  Remove old version of Node.js       ✔

  Install Node.js for Armv6           ✔

  Clean npm cache

  Install Node-RED core

  Move global nodes to local

  Install extra Pi nodes

  Npm rebuild existing nodes

  Add shortcut commands

  Update systemd script

Any errors will be logged to   /var/log/nodered-install.log

Commando:

node-red-start

Commando:

sudo systemctl enable nodered.service

Installatie npm package manager

(kan zijn dat die al geinstalleerd is)

Attentie! Belangrijk om regelmatig even te checken of er geen verouderde of onveilige paketten geinstalleerd zijn:

Source info:https://docs.npmjs.com/cli/audit

Commando:

npm audit

 en dan zie je bijvoorbeeld:

Moderate      │ Denial of Service                                            │

├───────────────┼──────────────────────────────────────────────────────────────┤

│ Package       │ axios                                                        │

├───────────────┼──────────────────────────────────────────────────────────────┤

│ Patched in    │ >=0.18.1                                                     │

├───────────────┼──────────────────────────────────────────────────────────────┤

│ Dependency of │ node-red-contrib-ibm-watson-iot                              │

├───────────────┼──────────────────────────────────────────────────────────────┤

│ Path          │ node-red-contrib-ibm-watson-iot > ibmiotf > axios            │

├───────────────┼──────────────────────────────────────────────────────────────┤

│ More info     │ https://npmjs.com/advisories/880                             │

└───────────────┴──────────────────────────────────────

 Vervolgens heb ik node-red-contrib-ibm-watson-iot verwijderd via node-red (Mange Pallet > Node > remove)

Installatie InfluxDB (Time-Series Data Storage)

Source info:https://gist.github.com/boseji/bb71910d43283a1b84ab200bcce43c26

Commando:

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add

Check je OS version

Commando:

lsb_release -a

pi@raspi-dev-wired:/etc $ lsb_release -a

No LSB modules are available.

Distributor ID: Raspbian

Description:    Raspbian GNU/Linux 10 (buster)

Release:        10

Codename:       buster

Commando:

sudo apt install apt-transport-https
Zoek de juiste InfluxDB repository:
Commando:
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
Commando:
sudo apt update

Installeer InfulxDB:

sudo apt-get install influxdb
Configuratiefile: /etc/influxdb.conf
Commando:
sudo nano /etc/influxdb/influxdb.conf

[http]D

enable = true

bind-address = “:8086”

Commando:

sudo service influxdb start

Create admin user:

Commando:

Influx

Commando:

> CREATE USER “pi” WITH PASSWORD ‘password’ WITH ALL PRIVILEGES

<enter>

Commando:

>show users

user admin

—- —–

pi   true

Commando:

>exit

Installatie Grafana:

Let op! Grafana installeren op armv6/armv7 geeft problemen/gaat niet werken.https://community.grafana.com/t/grafana-does-not-run-on-raspberry-pi-model-b-rev-2/5232https://www.raspberrypi.org/forums/viewtopic.php?t=246117

Commando:

sudo apt-get purge grafana
sudo apt-get autoclean

echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apt-transport-https
sudo apt-get install grafana
to configure grafana to start automatically using systemd
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server

Installatie git:

Commando:

sudo apt-get install git

Installatie node-red-contrib-ttn:

Let op, deze node kan installatie fouten geven en is soms niet stabiel (zie TTN forum)

Heb eerst git geinstalleerd daarna was het mogelijk om de node te  installleren.

Commando:

sudo apt-get install git

Commando:

npm install node-red-contrib-ttn

Installatie node node-red-contrib-tuya-smart 1.2.0

Installatie uitgevoerd via Manage palette in Node-Red

Installatie Telegraf (Time-Series Data Collector):

$ sudo apt-get install telegraf

$ sudo service telegraf start

Installatie Mosquitto Broker (no client)

Commando:

sudo apt-get update

Commando:

sudo ap-get  install mosquito

Installatie Chronograf  (Time-Series Data Visualization):

Commando:

apt-get install chronograf

Commando:

point your browser to http://<pi-address>:8888/ to get to Chronograf.

########################################################################

Nog niet uitgevoerd op Rpi4:

Installatie Node-Red/security –

Security (uncomment adminAuth part in settings.js replacing username and password)

cd ~/.node-red

sudo npm install -g node-red-admin

node-red-admin hash-pw

vi settings.js

Using PM2 to monitor the service (recommended, notice the messages):

sudo systemctl disable nodered.service

sudo npm install -g pm2

pm2 start node-red

pm2 save

pm2 startup

Commando:

sudo apt-get install libfontconfig1
Commando:
sudo apt --fix-broken install
Setting up libfontconfig1:armhf (2.13.1-2) ...
Setting up grafana (6.2.2) ...
Adding system user `grafana' (UID 109) ...
Adding new user `grafana' (UID 109) with group `grafana' ...
Not creating home directory `/usr/share/grafana'.
### NOT starting on installation, please execute the following statements 
sudo update-rc.d grafana defaults 

sudo systemctl daemon-reload
sudo systemctl enable grafana.service
sudo systemctl start grafana-server

Links:

Fixing npm permissions:

CORRECTLY REMOVE SYMBOLIC LINKS

Grafana

https://github.com/fg2it/grafana-on-raspberry/blob/master/old-versions/wheezy-https://grafana.com/docs/installation/configuration/#http-por jessie/README.md

Andreas Spiess: #255 Node-Red, InfluxDB, and Grafana Tutorial on a Raspberry Pi

Peter Scargill: The Script (Let op, lijkt verouderd, ik kreeg veel foutmeldingen, bovenfdie zie ik allerlei vulnarabilitys)

node-red-contrib-tuya-smart 1.2.0:https://flows.nodered.org/node/node-red-contrib-tuya-smarthttps://docs.npmjs.com/creating-a-package-json-file

Specifications :

  • Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
  • 1GB, 2GB or 4GB LPDDR4-3200 SDRAM (depending on model)
  • 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 USB 3.0 ports; 2 USB 2.0 ports.
  • Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with previous boards)
  • 2 × micro-HDMI ports (up to 4kp60 supported)
  • 2-lane MIPI DSI display port
  • 2-lane MIPI CSI camera port
  • 4-pole stereo audio and composite video port
  • H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
  • OpenGL ES 3.0 graphics
  • Micro-SD card slot for loading operating system and data storage
  • 5V DC via USB-C connector (minimum 3A*)
  • 5V DC via GPIO header (minimum 3A*)
  • Power over Ethernet (PoE) enabled (requires separate PoE HAT)
  • Operating temperature: 0 – 50 degrees C ambient

TAGSGRAFANANODEREDPI