如何使用Python读取Raspberry pi3上的PowerLED的状态

2024-05-15 06:05:05 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在python脚本中读取Raspberry pi3上的电源指示灯(或者彩虹方块,如果您更喜欢的话)的状态来检测低电压情况?自从Raspberry Pi 2以来,电源LED的接线已经改变,看来GPIO 35不能再用于此目的了。在


更新:

因为在Raspberry Pi3上检测代码中的低功耗情况似乎很重要,所以我用一个快速的硬件黑客解决了这个问题。我在APX803(pi3上使用的电源监控设备)的输出端和GPIO26之间焊接了一根电线,这样我就可以简单地读取GPIO26来获得电源状态。很有魅力。在


Tags: 目的脚本ledgpio状态pi情况raspberry
2条回答

由于Pi3的BT/wifi支持,电源LED通过GPIO扩展器直接从GPU控制。在

我相信没有办法做你想做的事

我已经深入探讨了这个话题。找到了一个很好的discussion。在RPi 3中,GPIO的电源LED控制已被移除,如OP所述。在

可能的原因:

The power LED is different on Pi3. It is controlled from GPU through a GPIO expander which is configured as an input. It may not be possible to drive it from the arm (certainly it is not currently). Pi3's BT/wifi support required a number of additional GPIOs compared to Pi2. So, the ACT and PWR leds had to move to make that possible.

同时:

Since the B+ the functionality of PWR LED has doubled, power indicator and as well as an under-voltage indicator. Since GPIOs are in short supply, as well as being an indicator it is also the under-voltage detector - there is some external circuitry that can detect the GPIO direction so that it is either an input with an automatic LED or an output. This circuitry is only present on the red LED. The ability to change the "PWR" LED pin to an output, bypasses the under-voltage detection, which is permitted but not recommended.

These GPIOs may never be available as fully featured GPIOs because they are too slow to use in many circumstances. There is a simple GPIO driver that can efficiently control the ACT LED, but more effort is needed to make it work with the PWR LED and change its direction to an output. This is something we may address, but it isn't high on the list of priorities at the moment.


可能的出路:没有找到任何使用Python访问GPU的方法,但是发现了一些关于访问GPU配置的讨论-共享GPU配置可以帮助您复制Python中的等效功能。在

There is also the mailbox service that would allow userspace to fiddle with the outputs on the expander, but not set direction - see https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=109137&start=100#p990152 and https://github.com/6by9/rpi3-gpiovirtbuf

Also

For the complete list of GPIO allocations, look at the dt-blob.dts that configures the GPU side - https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts#L1175 Documentation is at https://www.raspberrypi.org/documentation/configuration/pin-configuration.md

如果我有什么有用的东西,我会把它作为更新2发布。在

相关问题 更多 >

    热门问题