[英]Check from Python script Raspberry´s power status
Is there an equivalent to the yellow lightning on screen, or the red PWR LED blinking, that can be used from a Python script to know if there are power issues with a Raspberry?是否有与屏幕上的黄色闪电或红色 PWR LED 闪烁的等效项,可以从 Python 脚本中使用它来了解 Raspberry 是否存在电源问题?
Thanks!谢谢!
With help from @MarkSetchell (thanks!), this works.在@MarkSetchell 的帮助下(谢谢!),这是有效的。 I´ve tested it on a RPI 3B+ with some power supply issues:
我已经在 RPI 3B+ 上对其进行了测试,但存在一些电源问题:
import subprocess
pt = subprocess.Popen(['/opt/vc/bin/vcgencmd', 'get_throttled'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
(res,err) = pt.communicate()
res = res.decode().split("=")[1]
res = res.rstrip("\n")
print ("Current Power Issues? = ",(int(res,0) & 0x01) == 0x01)
print ("Any Power issues before? = ",(int(res,0) & 0x50000) == 0x50000)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.