Ir al contenido

← Modo kiosk en Raspberry Pi para un HMI de Node-RED

Riego agrícola automatizadoRaspberry Pi (Docker)HTTPHMI / Dashboard

Modo kiosk en Raspberry Pi para un HMI de Node-RED — ejemplo completo

Convierte una Raspberry Pi con pantalla táctil en un HMI de planta dedicado: Chromium en modo kiosk sobre Wayfire arranca directo al dashboard de Node-RED.

Programa completo y ejecutable para el Raspberry Pi (Docker) (kiosk-wayfire-chromium.sh): incluye cabecera de conexionado, requisitos y notas de integración.

Descarga el pack completo del proyecto — gratisEste ejemplo + los relacionados + lista de materiales

Vista de solo lectura.

#!/bin/bash
# =============================================================================
# COMPLETE EXAMPLE — On-screen kiosk mode (Wayfire + Chromium)
#
# Hardware:  Raspberry Pi (Docker) with touchscreen — Raspberry Pi OS Bookworm
# Based on:  automated agricultural irrigation project
#
# Requirements:
#   - Raspberry Pi OS Desktop (Bookworm) with a Wayland/Wayfire session,
#     which is the default compositor on Pi 4 / Pi 5.
#   - Autologin of the plant-floor user enabled (raspi-config -> System
#     Options -> Boot / Auto Login -> Desktop Autologin).
#   - The Docker stack running: the Node-RED dashboard must respond
#     at http://127.0.0.1:1880/dashboard before Chromium opens.
#
# What it does:
#   1. Adds the [autostart] section to ~/.config/wayfire.ini to launch
#      Chromium in kiosk mode pointing at the Node-RED dashboard.
#   2. Hides the mouse cursor (dedicated touch HMI).
#   3. Disables screen blanking (DPMS) for an always-visible HMI.
#
# Usage:
#   chmod +x kiosk-wayfire-chromium.sh && ./kiosk-wayfire-chromium.sh
#   sudo reboot   # the kiosk starts on its own after the reboot
# =============================================================================

set -euo pipefail

DASHBOARD_URL="http://127.0.0.1:1880/dashboard"   # URL of the Node-RED HMI
WAYFIRE_INI="$HOME/.config/wayfire.ini"

mkdir -p "$HOME/.config"
touch "$WAYFIRE_INI"

# --- Backup before touching anything ------------------------------------------
cp "$WAYFIRE_INI" "$WAYFIRE_INI.bak.$(date +%Y%m%d%H%M%S)"
echo "Backup created: $WAYFIRE_INI.bak.*"

# --- Avoid duplicates if the script runs twice ---------------------------------
if grep -q "^\[autostart\]" "$WAYFIRE_INI"; then
    echo "WARNING: an [autostart] section already exists in $WAYFIRE_INI."
    echo "Review it manually and merge the lines below if needed."
fi

# --- Kiosk autostart section ---------------------------------------------------
# chromium-browser in kiosk mode:
#   --kiosk                  full screen without toolbar or buttons
#   --noerrdialogs           no "Chromium closed unexpectedly" dialogs
#   --disable-infobars       no automation notices
#   --check-for-update-interval  do not nag about updates
cat >> "$WAYFIRE_INI" <> "$WAYFIRE_INI" <
Descarga el pack completo del proyecto — gratisEste ejemplo + los relacionados + lista de materiales