1

How can I read the status of the on board red led in raspberry 3.0 model B? Thank you

hmmy92
  • 13
  • 4

2 Answers2

0

Current kernels have the board LEDs in /sys/device/platform/leds/leds. There are two; in each subdirectory you will find a uevent node with some information. led0 is evidently the green ACT light:

OF_NAME=act
OF_FULLNAME=/leds/act
OF_COMPATIBLE_N=0

And led1 is the red PWR light:

OF_NAME=pwr
OF_FULLNAME=/leds/pwr
OF_COMPATIBLE_N=0

Note these names correspond to another sysfs directory, /sys/firmware/devicetree/leds -- but the information there does not look pertinent. However, in the same directory as uevent there is brightness, which apparently has a range of 0-255; normally when running it's 255. Although that node is writable, trying to change the value has no effect. But reading its state is obviously possible.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
0

Your question is ambiguous.

If you want to determine the low voltage state, you can do this by reading the state through a mailbox interface. I have used the following c code:-

https://raspberrypi.stackexchange.com/a/54328/8697

Other code described in https://raspberrypi.stackexchange.com/a/44177/8697 may also make it possible, but untested.

If you just want to read LED status /sys/devices/platform/leds/leds/led1 seems to work; whether this also reflects the low voltage state is unknown (and AFAIK) undocumented. It is certainly possible to extinguish the LED by writing 0 to brightness.

Examination of the Pi3 circuitry (which differs from earlier models) seems to indicate that if the voltage is Low the LED will ALWAYS be off.

I have not explored what the impact of writing to /sys/devices/platform/leds/leds/led1 is on the rpi3-gpiovirtbuf. GPIO can be input OR output (but who knows about the expander), so they may be incompatible functions.

Testing low voltage is a non-trivial task.

Milliways
  • 62,573
  • 32
  • 113
  • 225