14

I have an RPI 4 in my room. When I sleep the red light fills a big part of the room. I don't want to turn the pi off as I want 24/7 availability. Its ability to be quiet and always available is why I find it appealing to use.

I thought about ducktaping it, but I find hardware solutions to be brutal (+ I can always do it if I get too fed up with it).

Is there a script I can write to turn it off?

Melvin Roest
  • 243
  • 1
  • 2
  • 5

8 Answers8

20

Should work by writing the appropriate value to /sys/class/leds/led1/trigger on older OS.
Use /sys/devices/platform/leds/leds/PWR/trigger on kernel6 which replaced the confusing led1 with explicit PWR (ACT is used for activity LED).

cat /sys/devices/platform/leds/leds/PWR/trigger will show all supported values; the value in […] is the current value.

To permanently change use the dtparam=pwr_led_trigger=none in config.txt

To switch it off use none, e.g.:

sudo su
echo none > /sys/class/leds/led1/trigger
#OR: 
echo none | sudo tee /sys/class/leds/led1/trigger 

Use default-on to reverse it.

Milliways
  • 59,890
  • 31
  • 101
  • 209
Dirk
  • 3,541
  • 3
  • 18
  • 25
6

There's a bunch of controls you can use in /boot/config.txt

    act_led_trigger         Choose which activity the LED tracks.
                            Use "heartbeat" for a nice load indicator.
                            (default "mmc")
act_led_activelow       Set to "on" to invert the sense of the LED
                        (default "off")
                        N.B. For Pi 3B, 3B+, 3A+ and 4B, use the act-led
                        overlay.

act_led_gpio            Set which GPIO to use for the activity LED
                        (in case you want to connect it to an external
                        device)
                        (default "16" on a non-Plus board, "47" on a
                        Plus or Pi 2)
                        N.B. For Pi 3B, 3B+, 3A+ and 4B, use the act-led
                        overlay.

pwr_led_trigger
pwr_led_activelow
pwr_led_gpio
                        As for act_led_*, but using the PWR LED.
                        Not available on Model A/B boards.

And

Name:   act-led
Info:   Pi 3B, 3B+, 3A+ and 4B use a GPIO expander to drive the LEDs which can
    only be accessed from the VPU. There is a special driver for this with a
    separate DT node, which has the unfortunate consequence of breaking the
    act_led_gpio and act_led_activelow dtparams.
    This overlay changes the GPIO controller back to the standard one and
    restores the dtparams.
Load:   dtoverlay=act-led,<param>=<val>
Params: activelow               Set to "on" to invert the sense of the LED
                            (default "off")
gpio                    Set which GPIO to use for the activity LED
                        (in case you want to connect it to an external
                        device)
                        REQUIRED

For example my Zero has

dtparam=act_led_activelow=on

so that the LED isn't a power LED, but works like a activity LED (on other RPis)

Take a look at /boot/overlays/README for details.

You probably want

dtparam=pwr_led_activelow=on

to turn your RED LED off. I don't have a RPi4B, so I can't test that and confirm it does what you want. This does the same thing as @Dirk's answer but without needing a script run at boot time.

Seamus
  • 21,900
  • 3
  • 33
  • 70
Dougie
  • 5,301
  • 10
  • 19
  • 28
  • I've tried your answer, but it does not seem to work on my RPi 4B. I've tried from the command line (as you seem to suggest), and in /boot/config.txt using a dtparam line, and the dtoverlay as it suggests in /boot/overlays/README. It also seems that there is no dtoverlay for pwr-led as there is for act-led. It's fairly confusing in there - perhaps I've made a bodge of it? – Seamus Jun 12 '21 at 06:31
3

I wanted to confirm and abbreviate Dougie's answer in that putting these lines in /boot/config.txt worked for me in accomplishing this goal:

dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=on

Note that act_led_trigger/pwr_led_triger can be set to "none." There are various other options for these parameters, including "heartbeat." When you change this file, you will need to reboot the Pi in order to see the changes take effect; there might be a shortcut to avoid having to reboot that I'm not aware of.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
ajaayc
  • 31
  • 1
  • Although it is derived from Dougie's answer, this is different enough to stand on it's own with a little editing. – goldilocks Sep 28 '21 at 15:06
  • The runtime shortcut is echo gpio | sudo tee /sys/class/leds/led0/trigger. Take a look at /sys/class/leds for proper names of your leds. Then you can blink them with echo 1 | sudo tee /sys/class/leds/led0/brightness and echo 0 consecutively. – user3603546 Feb 21 '24 at 10:55
2

If you (like me) are using Ubuntu 20.04 server 64 bit, the file to edit is:

/boot/firmware/syscfg.txt

By adding the line:

dtparam=pwr_led_activelow=off

In order to deactivate the LED permanently

clriis
  • 21
  • 2
1

On Ubuntu 22.04 server-lts it is the: /boot/firmware/config.txt

# Disable Power LED (Red)
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off

Disable Activity LED (Green)

dtparam=act_led_trigger=none dtparam=act_led_activelow=off

Disable ethernet RJ45 cable LEDs

dtparam=eth_led0=4 dtparam=eth_led1=4

Sparkofska
  • 103
  • 4
creeser
  • 111
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Jul 02 '22 at 17:11
0

With my Raspberry Pi 4 Model B and a fresh install of Raspberry Pi OS 2023-02-21 (Bullseye ARM64), Seamus' answer works, however, after updating the operating system, these paths have now changed and one must use:

echo none | sudo tee /sys/class/leds/PWR/trigger
AusMatt
  • 1
  • 1
0

My first post here but maybe this will help someone else.

I have had a bash alias commands to turn the light on my pi 4 on or off for a while.

Apparently, they changed the directory, and my bash alias commands of the past no longer worked on the latest version of pi buster / debain 11. It was not just a matter of changing the directory of where the bash alias command was pointed. I need an entirely new bash alias to turn the light on or off.

With the help of this post, I was able to make new bash alias commands to turn the light on my pi 4 on or off.

alias lightsoff='echo none | sudo tee /sys/class/leds/PWR/trigger'

alias lightson='echo default-on | sudo tee /sys/class/leds/PWR/trigger'

I hope this can help someone else trying to accomplish turning the lights on and off on their pi 4 with buster / debain 11

George
  • 1
  • 1
-1

[pi4 /boot/firmware/syscfg.txt]

Disable the PWR LED

dtparam=pwr_led_trigger=none

dtparam=pwr_led_activelow=off

Disable the Activity LED

dtparam=act_led_trigger=none

dtparam=act_led_activelow=off

Disable ethernet port LEDs

dtparam=eth_led0=4

dtparam=eth_led1=4