3

I see there are quite a few posts about this already but none seem to work for me.

I am running a pihole server on my RPi 3 and I would like to turn off the external power and LAN LEDs (green and orange) as they can be quite bright at night. I am running a Raspberry Pi 3 Model B Rev 1.2

I know it is possible to do as I managed to achieve this once before but it was a few years ago and I can't remember the steps I took. Also not sure if anything changed in the later versions of Raspbian.

I have tried methods mentioned in this thread: https://www.raspberrypi.org/forums/viewtopic.php?t=149126 as well as https://www.jeffgeerling.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi and Turning off LEDs on Raspberry Pi 3 and quite a few others but nothing seems to work for me.

One of the methods /boot/config.txt

# Disable Ethernet LEDs
dtparam=eth_led0=14
dtparam=eth_led1=14

# 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

Has anyone achieved this on a Pi 3 Model B and could share the method?

EDIT

$ cat /sys/class/leds/led0/trigger
[none] rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer oneshot heartbeat backlight gpio cpu cpu0 cpu1 cpu2 cpu3 default-on input panic actpwr mmc1 mmc0 rfkill-any rfkill-none rfkill0 rfkill1
3
  • 1
    I know it's not helping, but overlay LED settings do work on a Pi 4. Do you have anything in /sys/class/leds? Oct 15, 2020 at 14:28
  • 1
    Are you using a 3 or 3B+? The documentation states "N.B. For Pi 3B, 3B+, 3A+ and 4B, use the act-led overlay"
    – Milliways
    Oct 15, 2020 at 23:11
  • @DmitryGrigoryev the following is in /sys/class/leds default-on led0 led1 mmc0 @Milliways it is a 3B
    – GiarcTNA
    Oct 16, 2020 at 12:47

6 Answers 6

3

You control the green activity led with /sys/class/leds/led0/trigger and the red power led with /sys/class/leds/led1/trigger. First look at its standard settings with:

rpi ~$ cat /sys/class/leds/led0/trigger
none rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer oneshot heartbeat backlight gpio cpu cpu0 cpu1 cpu2 cpu3 default-on input panic actpwr [mmc0]

rpi ~$ cat /sys/class/leds/led1/trigger
none rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer oneshot heartbeat backlight gpio cpu cpu0 cpu1 cpu2 cpu3 default-on [input] panic actpwr mmc0

The settings within square brackets are set on boot up: [mmc0] for the green activity led and [input] for the red power led on my Raspberry Pi 3B. Don't forget them if you want to reset to these trigger without booting.

To turn the leds permanent on just use trigger default-on, to turn them off use none with:

rpi ~$ sudo bash -c 'echo none > /sys/class/leds/led0/trigger'
rpi ~$ sudo bash -c 'echo none > /sys/class/leds/led1/trigger'
6
  • Thanks for the reply. It seems both LEDs are already set to none, I have updated my original post with the output of led0
    – GiarcTNA
    Oct 16, 2020 at 12:53
  • @GiarcTNA What Raspberry Pi version exactly do you use? RPi 3B or RPi 3B+? Have you tried to switch the LEDs on and off?
    – Ingo
    Oct 16, 2020 at 18:04
  • It is the RPi 3B running the latest Raspbian. I don't seem to be able to switch them off. I have managed to do this before so I am not sure why it is not working now.
    – GiarcTNA
    Oct 18, 2020 at 11:39
  • I saw in another post that someone wasn't able to do it with the latest Raspbian version (Buster). I suppose I can try another OS to see. raspberrypi.stackexchange.com/questions/70593/…
    – GiarcTNA
    Oct 18, 2020 at 11:51
  • @GiarcTNA Maybe it is active low? Try to switch ON with trigger none.
    – Ingo
    Oct 18, 2020 at 23:45
3

I created a gist to show how to disable power+activity+ethernet LEDs on Raspberry Pi 3, here's: https://gist.github.com/andrewssobral/840c5be9aff3347d358a43bb5deb1a9e

Check model

cat /sys/firmware/devicetree/base/model
# Raspberry Pi 3 Model B Rev 1.2

Disable Power (red) and Activity (yellow) LEDs

sudo nano /etc/rc.local

Add the following lines before exit 0:

sudo sh -c 'echo none > /sys/class/leds/led0/trigger'
sudo sh -c 'echo none > /sys/class/leds/led1/trigger'
sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'
sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'

Disable LAN/Ethernet LEDs by using lan951x-led-ctl

sudo apt-get install libusb-1.0-0-dev
git clone https://github.com/dumpsite/lan951x-led-ctl.git
cd lan951x-led-ctl/
make

Disable LAN LEDs

$ sudo ./lan951x-led-ctl --fdx=0 --lnk=0 --spd=0

# Setting FDX LED to status 0
# Setting LNK LED to status 0
# Setting SPD LED to status 0

Enable LAN LEDs

$ sudo ./lan951x-led-ctl --fdx=1 --lnk=1 --spd=1

# Setting FDX LED to status 1
# Setting LNK LED to status 1
# Setting SPD LED to status 1

Let's put all of this together in the rc.local file to start-up without LEDs (dark mode), see my code below:

$ sudo cat /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

sudo sh -c 'echo none > /sys/class/leds/led0/trigger'
sudo sh -c 'echo none > /sys/class/leds/led1/trigger'
sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'
sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'
sudo sh -c 'sudo /home/pi/Projects/lan951x-led-ctl/lan951x-led-ctl --fdx=0 --lnk=0 --spd=0'

exit 0
2

The existing two answers only handle the power LEDs and say nothing about the LAN LEDs. I tried this often linked tool: https://www.raspberrypi.org/forums/viewtopic.php?t=72070
…and also this one using /boot/config.txt: https://www.raspberrypi.org/forums/viewtopic.php?p=1445502&sid=f0624b638874faf337f71c23b969e326#p1445502
Neither worked for me. What did work was this tool (which for some reason only exists as a proof of concept in a pull request for a Linux distribution): https://github.com/LibreELEC/LibreELEC.tv/pull/1653
To be safe, I archived it on web.archive.org: http://web.archive.org/web/20210118022304/http://lrusak.libreelec.tv/public/lan951x-led-ctl

Usage: Make executable (e.g. with sudo chmod -R 777 lan951x-led-ctl), then:

sudo ./lan951x-led-ctl --fdx=0 --lnk=0 --spd=0

1 instead of 0 to enable LEDs, s to check status, order and completion doesn't matter. I don't know what these three abbreviations mean, I only have two LAN LEDs, but it also doesn't seem to hurt to use all three arguments. Calling the program without arguments outputs help.

This only applies in the moment, so it needs to be redone after every reboot, preferably with some kind of autostart method.

0

Rather than use the device tree I've had success using the "tmpfiles.d" hook provided by systemd.

For example, create a new file leds.conf at /etc/tmpfiles.d/:

w    /sys/class/leds/led0/trigger    - - - - timer
w    /sys/class/leds/led0/delay_off  - - - - 5000
w    /sys/class/leds/led0/delay_on   - - - - 1

That should give you a very short blink every 5 seconds on the green LED after a reboot. Adjust and expand to suit...

1
  • Unfortunately this didn't seem to work. Even using your settings unchanged it didn't blink the green LED
    – GiarcTNA
    Oct 28, 2020 at 16:03
0

Since most keyboards (if you even have one connected) don't have an AltGr key, the following worked for me to successfully switch off the power LED by assigning it to light up when ALtGr is engaged:

echo kbd-altgrlock >/sys/class/leds/led1/trigger
0

Update 2023:

for the latest version of the OS PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)" the names of the LED has changed

/sys/class/leds $ ls
ACT  default-on  mmc0  PWR

So the new command is:

sudo bash -c 'echo none > /sys/class/leds/PWR/trigger'
sudo bash -c 'echo none > /sys/class/leds/ACT/trigger'

For reference here's the PI information, including OS & model.

pi@hostname:~ $ raspinfo
System Information
------------------

Raspberry Pi 3 Model B Rev 1.2
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"

Raspberry Pi reference 2023-05-03
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 47eee1f0ddcf8811559d51eea1c1bb48335e3e88, stage2

Linux beta2 6.1.37-v7+ #1660 SMP Mon Jul  3 12:49:28 BST 2023 armv7l GNU/Linuxpi@beta2:~ $ raspinfo
System Information
------------------

Raspberry Pi 3 Model B Rev 1.2
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"

Raspberry Pi reference 2023-05-03
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 47eee1f0ddcf8811559d51eea1c1bb48335e3e88, stage2

Linux beta2 6.1.37-v7+ #1660 SMP Mon Jul  3 12:49:28 BST 2023 armv7l GNU/Linux
New contributor
PathToLife is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.