Raspberry Pi External Status Lights

Wiring up "online" and cpu activity lights via GPIO.
, Updated: 2 min read

For one of my projects, I wanted some external LED indicators of my Raspberry Pi’s status as they are not always easily visible when embedded in projects.

I wired up a pair of LEDs with a resistor attached to each to limit the current. (The resistance used value here depends on the forward voltage of the LED1. For my red status LED, I used a 220Ω resistor). I then plugged them into GPIO pins2 #13/#21 and to the ground pins.

Impotant Note: In this post, the pin numbers I reference are “GPIO pin” numbers and not physical pin numbers. See for example, GPIO pin 21 is physical pin #40: https://pinout.xyz/pinout/pin40_gpio21. You will need to make sure you are using the correct GPIO pin numbers in your setup.

Device Tree Setup

This is what actually controls the LEDs we attached. These device tree overlay configurations instruct the kernel to use each of the GPIO pins we set as activity or other indicator LEDs.

I altered the config file at /boot/config.txt and appended the following lines:

# activity LED on gpio 21 (physical pin 40)
dtoverlay=act-led,gpio=21

# "online" indicator LED on GPIO 13 (physical pin 33)
# this one's set to blink in a heartbeat pattern, but could
# be changed trigger on disk activity or stay on.
dtoverlay=gpio-led,gpio=13,trigger=heartbeat,label=statusled0

Other trigger types for gpio-led can be found in this stack overflow post

Full documentation for the device tree overlay setup can be found here: https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/README

Some approaches for a status led (ab)use the gpio-poweroff overlay which causes kernel panics during system shutdown. Using gpio-led does not have these issues.

Pin Naming

The device tree uses GPIO pin numbers, not physical pin numbers. I attached + programmed my leds to use GPIO 21 and GPIO 13 since they had close proximity to the ground pins needed for the LEDs.

Mounting

I 3d-printed a custom faceplate that I could mount inside a standard keystone-sized hole: /3d-prints/keystone-led-indicators. After some leds and some soldering, it looks pretty nice!

Profit

On the next reboot, the LED on GPIO 21 will perform the functions of the onboard status LED, and the LED on GPIO 13 will activate based on its configured “heartbeat” trigger.

Footnotes

  1. I use the “single LED” calculator on this site for doing calculations on which resistance values I need: http://ledcalc.com/#calc

  2. Impotant Note: In this post, the pin numbers I reference are “GPIO pin” numbers and not physical pin numbers. See for example, GPIO pin 21 is physical pin #40: https://pinout.xyz/pinout/pin40_gpio21

Subscribe to my Newsletter

Like this post? Subscribe to get notified for future posts like this.

Change Log

  • 8/11/2021 - Initial Revision
  • 9/10/2021 - Added links to 3d-printed keystone plate with slots for a pair of leds
  • 2/23/2023 - Added additional notes about wiring and setup
  • 4/24/2024 - Added a more prominent note about the physical pin vs GPIO pin numbering

Found a typo or technical problem? file an issue!