Node-RED
Cómo instalar Node-RED en Rapberry Pi OS
Install Node-RED on Raspberry Pi OS
Browser-based flow editing
Node-RED proporciona un editor de flujo basado en navegador que facilita la interconexión de flujos utilizando la amplia gama de nodos de la paleta. Luego, los flujos se pueden implementar en el tiempo de ejecución con un solo clic.
Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range of nodes in the palette. Flows can be then deployed to the runtime in a single-click.
Las funciones de JavaScript se pueden crear dentro del editor utilizando un editor de texto enriquecido.
JavaScript functions can be created within the editor using a rich text editor.
Una biblioteca integrada le permite guardar funciones, plantillas o flujos útiles para su reutilización.
A built-in library allows you to save useful functions, templates or flows for re-use.
Built on Node.js
El entorno de ejecución ligero se basa en Node.js y aprovecha al máximo su modelo sin bloqueo basado en eventos. Esto lo hace ideal para ejecutarse en el borde de la red en hardware de bajo costo como Raspberry Pi, así como en la nube.
The light-weight runtime is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi as well as in the cloud.
Con más de 225 000 módulos en el repositorio de paquetes de Node, es fácil ampliar el rango de nodos de paleta para agregar nuevas capacidades.
With over 225,000 modules in Node's package repository, it is easy to extend the range of palette nodes to add new capabilities.
Social Development
Los flujos creados en Node-RED se almacenan mediante JSON, que se puede importar y exportar fácilmente para compartir con otros.
The flows created in Node-RED are stored using JSON which can be easily imported and exported for sharing with others.
Una biblioteca de flujos en línea le permite compartir sus mejores flujos con el mundo.
An online flow library allows you to share your best flows with the world.
Node RED's Official Web Page:
Docs:
Crea tu primer flow -- Create your first flow:
Como asegurarlo -- How to secure Node-RED:
Agregando nodos -- Adding nodes:
Abrimos la Terminal (Ctrl+Alt+T) y escribimos--Open Terminal and type:
sudo apt install -y build-essential git curl
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
Respondemos con Y a todas las consultas que nos realice.Una vez ejecutado al finalizar veremos lo siguiente--Answer Y to all Questions, Once finished you see:
Al finalizar nos consultara si queremos personalizar la configuración, At the end ask for customize settings:
Settings file.
User security.
Projects.
Editor settings(theme, text editor)
Node settings
Running locally
As with running Node-RED locally, you can use the node-red command to run Node-RED in a terminal. It can then be stopped by pressing Ctrl-C or by closing the terminal window.
Due to the limited memory of the Raspberry Pi, you will need to start Node-RED with an additional argument to tell the underlying Node.js process to free up unused memory sooner than it would otherwise.
To do this, you should use the alternative node-red-pi command and pass in the max-old-space-size argument.
node-red-pi --max-old-space-size=256
Como podemos observar, nos indica el comando para iniciarlo--And the message for start it:
node-red-start
O podemos hacer clic en el icono de la barra de tareas, así como también buscarlo en--Or Start from menu: Raspberry -> Programming-> Node-Red
Una vez iniciado minimizamos la ventana de consola--Minimize the window:
Y procedemos a abrir la interfaz que se encuentra en el navegador o en cualquier navegador que este en nuestra red local de cualquier dispositivo(Raspberry Pi, PC, Smartphone, tablet, Smart TV), introduciendo la IP y el puerto 1880--We can see Node-red on the browser with the IP and Port 1880:
IP:1880
192.168.0.25:1880
Si no sabemos nuestra IP, basta con abrir una Terminal Ctrl+Alt+T y escribir--We can know our IP with:
hostname -I
Running as a service
The install script for the Pi also sets it up to run as a service. This means it can run in the background and be enabled to automatically start on boot.
The following commands are provided to work with the service:
node-red-start - this starts the Node-RED service and displays its log output. Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the background
node-red-stop - this stops the Node-RED service
node-red-restart - this stops and restarts the Node-RED service
node-red-log - this displays the log output of the service
You can also start the Node-RED service on the Raspberry Pi OS Desktop by selecting the Menu --> Programming --> Node-RED menu option.
Autostart on boot
If you want Node-RED to run when the Pi is turned on, or re-booted, you can enable the service to autostart by running the command:
sudo systemctl enable nodered.service
To disable the service, run the command:
sudo systemctl disable nodered.service
Interfaz Node-Red