Ir al contenido

← Servicios systemd para un seguidor solar en un Raspberry PLC

Seguidores solares de dos ejesRaspberry PLC 21systemdInfraestructura

Servicios systemd para un seguidor solar en un Raspberry PLC — ejemplo completo

Ejecuta el control de un seguidor solar y un hotspot WiFi como servicios systemd en un Raspberry PLC 21, con auto-reinicio, logs en journald y HMI Node-RED.

Programa completo y ejecutable para el Raspberry PLC 21 (solar-tracker.service): 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.

# -----------------------------------------------------------------------------
# COMPLETE EXAMPLE — Tracker systemd services (control + button-activated AP)
#
# Device:    Raspberry PLC 21 (Industrial Shields)
# Based on:  dual-axis solar tracker project
#
# Service architecture on the PLC:
#   solar-tracker.service   main control process (this file):
#                           PyEphem + CANopen + TCP socket with Node-RED.
#   tracker-ap.service      watches the I0.5 button and brings up the WiFi
#                           hotspot (same scheme: change ExecStart to
#                           manage_ap.py).
#   Node-RED serves the dashboard (control, calibration, inverter and
#   configuration tabs) behind Authelia as the authentication layer.
#
# Installation (as root):
#   1. cp solar-tracker.service /etc/systemd/system/
#   2. systemctl daemon-reload
#   3. systemctl enable --now solar-tracker.service
#   4. Verify:  systemctl status solar-tracker.service
#               journalctl -u solar-tracker.service -f
#
# For the second service, copy this file as tracker-ap.service, change
# Description and ExecStart (/home/pi/tracker/access-point/manage_ap.py)
# and repeat steps 2-4.
# -----------------------------------------------------------------------------

[Unit]
Description=Solar tracker control (PyEphem + CANopen + TCP Node-RED)
# Starts once the network is up and the CAN bus is already configured
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
# Main tracker control script
ExecStart=/usr/bin/python3 /home/pi/tracker/main.py
WorkingDirectory=/home/pi/tracker
# Needs root for socketcan and GPIO
User=root

# Automatic restart if the process dies (CAN bus failure, exception, etc.)
Restart=always
RestartSec=10

# Logs to journald (check with journalctl -u solar-tracker.service)
StandardOutput=journal
StandardError=journal

# Avoid aggressive restart loops if something is truly broken
StartLimitIntervalSec=300
StartLimitBurst=10

[Install]
WantedBy=multi-user.target
Descarga el pack completo del proyecto — gratisEste ejemplo + los relacionados + lista de materiales