smarties
Posts: 2
Joined: Sat Sep 23, 2017 10:54 am

[SOLVED] Turning Off Zero ACT LED

Sat May 11, 2019 11:13 am

Hi,

Below used to work for me in order to turn the ACT LED off on a Zero. Not any longer. I'm at a loss to understand why.
There's a load of statements out there that say this works.

Code: Select all

echo 255 | sudo tee /sys/class/leds/led0/brightness

If I cat the file afterwards I still see a 0.

The LED turns off for a fraction of second and then back on again. It's like the kernel overrides what I've done.

It's not working on a Zero with Jessie. Also not working on a Zero with Stretch.

Any thoughts? I'm at a loss.

(please, no suggestions about using tape ;) )

Thanks.
Last edited by smarties on Sat May 11, 2019 2:28 pm, edited 1 time in total.

Andyroo
Posts: 3005
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Turning Off Zero ACT LED

Sat May 11, 2019 2:01 pm

I would NEVER suggest tape to cover an led - it may short it or burn up! Use a Sharpie when the power is off :lol:
Sorry - try:

Code: Select all

echo none | sudo tee /sys/class/leds/led0/trigger
echo 1 | sudo tee /sys/class/leds/led0/brightness
You have to force the system to have no triggers on the LED first, then turn it off but the main issue with the above is that it only lasts till you reboot, so you can either script it and run via Cron or Systemd at restart or add:

Code: Select all

dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
into config.txt

edit: Above is on a Pi Zero W connected via USB running the April 2019 version of Stretch and untested in any other config.
Need Pi spray - these things are breeding in my house...

smarties
Posts: 2
Joined: Sat Sep 23, 2017 10:54 am

Re: Turning Off Zero ACT LED

Sat May 11, 2019 2:20 pm

Thanks Andyroo.

I wasn't dealing with the trigger then! Do'h! :roll: :roll: :oops: :oops:
Appreciated. All good now.

I assume if the trigger is left active, on the next trigger the brightness is reset.

I have a systemd service - see below.
Need to do something with the USB WiFi dongle so went for a systemd rather than config.txt.
Assumption being I have no control of the USB WiFi from config.txt.
I also get to turn the LEDs back on if needed.

Thanks again. Appreciated.


Code: Select all

leds-off.service
—————————
[Unit]
Description=Turn Pi & WiFi LEDs Off
After=network.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo none | tee /sys/class/leds/led0/trigger && \
                        echo 255 | tee /sys/class/leds/led0/brightness && \
                        echo 0 | tee /sys/class/leds/rt2800usb-phy0::assoc/brightness"
RemainAfterExit=True
ExecStop=/bin/bash -c "echo mmc0 | tee /sys/class/leds/led0/trigger && \
                       echo 255 | tee /sys/class/leds/rt2800usb-phy0::assoc/brightness"

[Install]
WantedBy=multi-user.target

Return to “Advanced users”