Disable ACT LED on Pi Zero


5 posts
by geerlingguy » Sun Nov 29, 2015 3:46 am
I've tried controlling led0 and led1 on the Pi Zero (using the OS install of the official Raspbian Jessie Lite image, Nov/2015), and it seems none of the controls do anything for the single LED (labeled ACT) on the Pi Zero. I was using the instructions, basically, from this post: http://www.midwesternmac.com/blogs/jeff ... wr-and-act

Does anyone know if it will be possible to control that LED and either switch what it's set to indicate (it seems to indicate disk access by default) or disable it by setting 'brightness' to '0'?
My personal site: http://jeffgeerling.com/
User avatar
Posts: 31
Joined: Sun Feb 15, 2015 3:43 am
Location: St. Louis, MO, USA
by rpdom » Sun Nov 29, 2015 9:13 am
I haven't got a zero, so I can't test this, but it might be possible to redefine the ACT LED function using device tree parameters in config.txt
Code: Select all
dtparam=act_led_trigger=none

Or perhaps, as the LED seems to be inverted like the original Pi A/B (fewer components required), either
Code: Select all
dtparam=act_led_trigger=default-on

or
Code: Select all
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
User avatar
Posts: 10579
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by geerlingguy » Mon Nov 30, 2015 2:24 am
rpdom wrote:
Code: Select all
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on


This worked perfectly! I've updated the blog post linked in the first comment, and here are the commands to temporarily disable the LED (it's opposite, as you predicted):

Code: Select all
# Set the Pi Zero ACT LED trigger to 'none'.
echo none | sudo tee /sys/class/leds/led0/trigger

# Turn off the Pi Zero ACT LED.
echo 1 | sudo tee /sys/class/leds/led0/brightness
My personal site: http://jeffgeerling.com/
User avatar
Posts: 31
Joined: Sun Feb 15, 2015 3:43 am
Location: St. Louis, MO, USA
by pitchlynn » Tue Nov 08, 2016 12:13 am
I am using this is in my python script to control the act LED but I'm finding it takes too long to execute so I'm missing input signals.

Both of these lines of code takes 0.12 seconds to execute.
Turn ACT LED on:
Code: Select all
echo 1 | sudo tee /sys/class/leds/led0/brightness
 

Trun Act LED off:
Code: Select all
echo 0 | sudo tee /sys/class/leds/led0/brightness
 

Am I using this wrong by placing it directly in my script?

Maybe it would help if I understood it more if someone could break down that one line of code.
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm
by simon3270 » Tue Jan 10, 2017 12:21 pm
The problem is that you are loading up a shell, and a sudo command, and a tee command, just to write a single character to a file.

You can do this directly from your Python script, but you do need to be root to do it. If you are happy to run your entire script as root, just do something like this to turn it off (and write '0\n' to turn it on):
Code: Select all
with open("/sys/class/leds/led0/brightness","w") as f:
     f.write('1\n')
Posts: 2
Joined: Mon Jan 09, 2017 3:34 pm