🛠 Allumer une LED via le GPIO 40 broches (libgpiod)
Objectives
Turn an LED on and off from the 40-pin GPIO connector of the Orange Pi 5 Plus using libgpiod, the modern Linux GPIO interface (the old sysfs /sys/class/gpio is no longer used). Understand the mapping: physical pin 7 of the connector is GPIO1_D6 (wPi 2), which corresponds to gpiochip1, line 30 (bank 1, group D = 3 → 3×8+6 = 30). All 28 GPIOs on the connector are 3.3 V.
Hardware
- Orange Pi 5 Plus running Armbian (or Orange Pi OS image), powered by 5 V / 4 A via the Type-C port located next to the Ethernet ports — the other Type-C port does NOT provide power!
- 1 red LED + 330 Ω resistor + 2 jumper wires
- Terminal access (screen/keyboard or SSH)
Complete code
# 1. Installer les outils libgpiod (gpiodetect, gpioset, gpiomon)
sudo apt update && sudo apt install -y gpiod
# 2. Lister les contrôleurs GPIO : gpiochip0..3 = gpio0..gpio3 (RK3588)
gpiodetect
# 3. Faire clignoter la LED 5 fois (broche 7 = gpiochip1, ligne 30)
sudo gpioset -c gpio1 --repeat 5 --hold-period=200ms --period=400ms 30=1
Expected verification
gpiodetect displays gpiochip0 to gpiochip3. The gpioset command makes the LED blink 5 times (200 ms on, 200 ms off) and then exits. On an official Orange Pi image, wiringOP is preinstalled and the same pin is written as sudo gpio mode 2 out then sudo gpio write 2 1 / 0; sudo blink_all_gpio tests the 28 GPIOs on the connector.
Common errors
- Wrong Type-C port: only the socket next to the Ethernet ports powers the board; plugging the power supply into the data port = board off.
- Numbering confusion: physical pin 7 = GPIO1_D6 = line 30 of gpiochip1, not “GPIO 7”.
- Forgetting the resistor or inserting the LED backwards (cathode, short leg, ground side).
- >
Other tutorials for this board
- Lire un bouton poussoir et afficher dans la console
- Premier script Python : fiche signalétique de la carte et LED
- Variation d'intensité d'une LED avec PWM (sysfs pwm)
- Lire un capteur I2C (BMP280) depuis le bus du connecteur
- Exploiter le double Ethernet 2,5 GbE et sécuriser le SSH
- Booter sur NVMe (M.2 PCIe 3.0 x4) et récupérer une carte brique via MaskROM
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash