0

my issue is around knowing when the raspberry pi is turned off so I can disconnect it from the power supply.

H.W - Rev 1 B+

Details on LEDs:

  • PWR LED - ALWAYS ON if POWER SUPPLY IS CONNECTED
  • ACT(ACTIVITY) LED - NEVER ON

I assume led1 is ACT in this case and isn't on!

$ 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 default-on input panic actpwr mmc0 rfkill-any rfkill-none

turning it on by:

$ modprobe ledtrig_heartbeat
$ sudo sh -c 'echo heartbeat >/sys/class/leds/led0/trigger'

this turned the ACR LED.

Finally, on shutting down the raspberry pi the ACR led is turned off.

  1. is it safe to immediately plug off the raspberry pi after the ACR LED turned off ?
  2. Is that a good aproach to know when the rapsberry pi turned off ? If so, how to make the ACT LED turned on at boot?

If not, please advise a solution

BadSugar
  • 11
  • 2

1 Answers1

0

You can use the gpio-poweroff. See https://raspberrypi.stackexchange.com/a/100125/8697

This is really intended to control external power and has some issues with timing.

If all you want is a visual indication dtparam=act_led_trigger=heartbeat provides an indication that the Pi is running, and stops when shutdown (although the actual state ON or OFF depends on model).

The final step on shutdown is to flash the ACT LED 10 times at 1 second intervals.

NOTE Don't modprobe or poke at /sys/class/leds/ - this is UNRELIABLE and will be superseded by kernel code.
Set LED properly through Device Tree commands in config.txt

Setting GPIO state when running is futile - the GPIO keeps its state when shutdown (unless modified by the kernel).

Milliways
  • 59,890
  • 31
  • 101
  • 209