[PLUGIN] GPIO Power Button with LED State Plugin for Volumio 4

Weekend Concept: GPIO Power Button with LED State

The Idea

Some of us use Audiophonics boards with their power management MCU (ATtiny85). But what if you want similar functionality without the MCU? Just a simple button and LED connected directly to GPIO pins?

This weekend I put together a concept plugin that mimics Audiophonics on/off behavior using only the Raspberry Pi GPIO - no external microcontroller needed.

What It Does

  • Power button triggers clean shutdown (and wakes Pi from halt state!)
  • LED shows system status with blink patterns
  • All GPIO pins configurable via UI
  • Supports both NO (Normally Open) and NC (Normally Closed) buttons
  • LED polarity configurable (in case you wire it backwards)

How It Works

Button: Uses kernel-level gpio-shutdown overlay. The plugin manages /boot/userconfig.txt automatically. Because it’s kernel-level, the button works even before Volumio starts and can wake the Pi from halt state - just like the Audiophonics MCU.

LED: Software-controlled blinking. LED is wired between two GPIO pins (not GPIO to GND), giving us full control over on/off/blink states.

LED Patterns

State Pattern
Booting Slow blink (500ms)
Running Solid ON
Shutdown Fast blink (100ms)
Halted OFF

Default Wiring (4-pin header)

    4-Pin Header              Pi Physical Pins
    +---------+               
    | 1  LED- |-------------> Pin 7  (GPIO 4)
    | 2  GND  |-------------> Pin 9  (GND)
    | 3  BTN  |-------------> Pin 11 (GPIO 17)
    | 4  LED+ |-------------> Pin 15 (GPIO 22)
    +---------+               

IMPORTANT: LED Current Limiting Resistor

YOU MUST USE A RESISTOR IN SERIES WITH THE LED!

Recommended value: 330-470 ohm

    GPIO 22 ----[330R]-----(+)LED(-)---- GPIO 4

What happens without a resistor:

  1. Burn out the LED - LEDs have very low internal resistance. Without current limiting, excessive current flows and the LED dies (sometimes spectacularly).

  2. Damage GPIO pins - Raspberry Pi GPIO pins can source/sink about 16mA safely (absolute max 50mA per pin, 100mA total for all pins). A LED without resistor can try to draw 100mA+ which will damage or destroy the GPIO driver on the Pi’s SoC. This damage is permanent and not repairable.

  3. Damage the Pi - In worst case, excessive current can damage the SoC beyond just the GPIO pin, potentially killing your Pi.

The math:

  • Pi GPIO voltage: 3.3V
  • Typical LED forward voltage: 2V (red) to 3V (blue/white)
  • Desired current: 10-20mA for good brightness
  • Resistor needed: (3.3V - 2V) / 0.015A = 87 ohm minimum
  • Use 330-470 ohm for safety margin and longer LED life

TL;DR: No resistor = dead LED + possibly dead Pi. Always use 330-470 ohm resistor.

Button Wiring

Most momentary buttons have 3 terminals: C (Common), NO (Normally Open), NC (Normally Closed).

Standard wiring (NO - most common):

    Button C  ----> GND (Pin 9)
    Button NO ----> GPIO 17 (Pin 11)
    Button NC ----> not connected

Internal pull-up is enabled by the kernel overlay. Button press pulls GPIO low.

Configuration UI

The plugin has two configuration sections:

Button Settings (require reboot):

  • Button GPIO pin (0 to disable)
  • Button type: NO or NC

LED Settings (apply immediately):

  • LED+ GPIO pin
  • LED- GPIO pin
  • Polarity: Normal or Reversed

Limitations vs Audiophonics MCU

  • LED doesn’t work when Pi has no power (obviously)
  • No true “power off” - Pi stays in halt state consuming ~0.5W
  • Button only wakes from halt, cannot power on from completely off

What You Need

  • Any momentary push button (C/NO/NC type preferred)
  • Any standard LED
  • One 330-470 ohm resistor (REQUIRED!)
  • 4 wires

Compatibility

  • Volumio 4 (Bookworm)
  • 32-bit armhf only (current Volumio 4 limitation)
  • All Raspberry Pi models including Pi 5, CM5, Pi 500

Feedback Welcome

This is a weekend concept - looking for feedback before polishing for submission:

  1. Does the wiring make sense?
  2. Any GPIO conflicts with common DAC HATs?
  3. Would you use this?
  4. What’s missing?

Kind regards,


Credits: Inspired by Audiophonics power management. Built using @iiot2k/gpiox library.