Controling Raspberry Pi Power and Status Light
One thing that has been irritating me for a while on the Pi serving the bedroom television is the red glow cast on the wall emitted by the power light. During the day it is unnoticeable but at night the flickering of the SD card activity LED and the glow of the power light can prove to be quite annoying.
Instead of resorting to taping over the lights to block them out, it is possible to disable them using software as they are connected to GPIO pins.
The green LED (ACT) is accessible via /sys/class/leds/led0/ and is normally tied to activity on the SD card.
This link to activity is established by something called a trigger and can be modified by altering the contents of the trigger file associated with the LED. It can be disabled by changing its value to “none” ( echo none >/sys/class/leds/led0/trigger) and restored by echoing the memory card to the file ( echo mmc0 >/sys/class/leds/led0/trigger).
The LED can be turned off ( echo 0 >/sys/class/leds/led0/brightness) or on ( echo 1 >/sys/class/leds/led0/brightness) by altering the value stored in the brightness file. Strictly speaking the brightness can be a value between 0 and 255, however the LEDs are on digital pins, so a value of 1 or higher is interpreted as on.
Power LED (Excludes RPi3)
The red LED (PWR) is accessible via /sys/class/leds/led1/ .
Similarly this can be turned on and off by modifying the brightness value stored in the brightness file.
echo 0 >/sys/class/leds/led1/brightness and echo 1 >/sys/class/leds/led1/brightness
Adding the below lines to the autostart file ( /storage/.config/autostart.sh) on OpenELEC will automatically disable to two LEDs on startup
echo 0 > /sys/class/leds/led0/brightness
echo 0 > /sys/class/leds/led1/brightness
As mentioned above, it’s possible to do a few fancy bits using triggers. Two examples are the “heartbeat” and “timer” based triggers.
Interchange led0 and led1 as desired in the following examples.
Heartbeat Trigger – The higher the system load the faster the LED blinks
The heartbeat module first needs to be loaded using modprobe ledtrig-heartbeat . It can now be added to the LED’s trigger file echo heartbeat >/sys/class/leds/led0/trigger .
Timer Trigger – Control the blink rate of the LED
Load the timer kernel module using modprobe ledtrig-timer and add it to the LED’s trigger file echo timer > /sys/class/leds/led0/trigger .
In this example to turn the LED on for 1 second and then off for 3 seconds:
echo 1000 > /sys/class/leds/led0/delay_on
echo 3000 > /sys/class/leds/led0/delay_off
For completeness it is also possible to disable or modify the actions of the Ethernet port’s LED’s. This topic on the Raspberry Pi forums contains the instructions on how to do just that.