🛠 Contrôler la LED SYS du NanoPi R5S

NanoPi R5S (FriendlyElec) · debutant · Schéma : IMG-nanopi-r5s-debutant-1-nanopir5s-sys-led.svg — NanoPi R5S vu de dessus avec les quatre LED (SYS rouge, WAN, LAN1, LAN2 vertes) mises en évidence

Objectives

The NanoPi R5S has four GPIO-controlled LEDs in the device tree: SYS (red), WAN, LAN1, and LAN2 (green). This tutorial teaches you how to discover them via sysfs, switch from an automatic trigger (heartbeat, netdev) to manual mode, and turn the SYS LED on/off from the command line. You will understand how the Linux LED subsystem (/sys/class/leds) works, which is applicable to any SBC board.

Hardware

Complete code

#!/bin/bash
# decouvrir_leds.sh — lister et piloter les LED du NanoPi R5S
ls /sys/class/leds/            # noms : SYS, WAN, LAN-1, LAN-2 (mainline)
                               # ou sys_led/wan_led/lan1_led... (vendor)

SYS=$(ls /sys/class/leds | grep -iE 'sys' | head -1)
echo "LED système détectée : $SYS"

# Mode manuel puis clignotement manuel
echo none | sudo tee "/sys/class/leds/$SYS/trigger"
echo 1 | sudo tee "/sys/class/leds/$SYS/brightness"   # allumée
sleep 2
echo 0 | sudo tee "/sys/class/leds/$SYS/brightness"   # éteinte

# Trigger heartbeat du noyau
echo heartbeat | sudo tee "/sys/class/leds/$SYS/trigger"

# Retour au trigger par défaut (habituellement cpu ou none)
cat "/sys/class/leds/$SYS/trigger"   # la valeur active est entre crochets

Expected verification

After execution, ls /sys/class/leds/ displays at least four entries. The red SYS LED blinks in a heartbeat rhythm when the heartbeat trigger is active. In manual mode, the commands echo 1 / echo 0 on brightness visibly turn the LED on and off. Note: on recent mainline kernels (6.17+), netdev triggers have been removed from the device tree, and the default behavior of the LAN LEDs differs from vendor kernels 5.10/6.1.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials