5

How to read the status of the Power-LED (or the rainbow square - if you like that better) on Raspberry Pi 3 to detect an low-voltage-condition in a python script? Since the wiring of the Power-LED has changed since Raspberry Pi 2, it seems that GPIO 35 cannot longer be used for that purpose.


Update:

Since it seems to be non-trivial to detect a low-power-condition in code on Raspberry Pi 3, i solved it with a quick hardware hack. I soldered a wire between the Output of the APX803 (the power-monitoring device used on Pi 3) and GPIO26 and that way I can simply read GPIO26 to get the power status. Works like a charm.

6

On the B+ (and presumably Pi2) the "PWR" LED was connected to a GPIO pin as was the APX803 voltage monitor chip. This let the LED be controlled, and (presumably) let the Pi detect under-voltage.

The Pi3 "PWR" LED is directly connected to the APX803 but the APX803 is still connected to PWR_LOW_N. Unfortunately this is not documented and the schematic is incomplete, but is reputed to be on a port extender. Obviously the kernel can detect this, but again there appears to be no documentation. The only option seems to be exploring kernel sources.

How can I control the red LED again shows some info about the output status.

EDIT


I did a bit of digging, and was directed to https://github.com/6by9/rpi3-gpiovirtbuf/ I have tested on my Pi3, and it works. rpi3-gpiovirtbuf g 135 produces output

Get state of 135 as 1
get_config dir input, active low (inverted), not terminated

which is active low and indicates Voltage is OK.

Admittedly this is not Python, but is very simple c and it would be possible to replicate.

Incidentally testing proved to be a challenge. For all the reports on this site of inadequate power supplies, I could not find one which was reliably low, and had to make a variable regulator.

The APX803 is open drain, so it should be possible to pull it low (and turn the LED off) with a program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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