電力不足を検知する方法
hfu opened this issue · comments
Hidenori commented
電力不足があった時、Raspberry Pi OS では syslog にイベントが出るようなので、それを検知して例えばシャットダウンすることを考えてみます。
Hidenori commented
/var/log/syslog には、このような記録が残っています。
May 8 12:55:19 m330 kernel: [359795.525832] hwmon hwmon1: Undervoltage detected!
May 8 12:55:23 m330 kernel: [359799.557252] hwmon hwmon1: Voltage normalised
Hidenori commented
vcgencmd get_throttled
で情報が取れるようです。man vcgencmd
によれば、次の通り。
get_throttled
Returns the throttled state of the system. This is a bit pattern - a bit being set indicates the following meanings:
Bit Meaning
──── ────────────────────────────────────
0 Under-voltage detected
1 Arm frequency capped
2 Currently throttled
3 Soft temperature limit active
16 Under-voltage has occurred
17 Arm frequency capping has occurred
18 Throttling has occurred
19 Soft temperature limit has occurred
A value of zero indicates that none of the above conditions is true.
To find if one of these bits has been set, convert the value returned to binary, then number each bit along the top. You can then see which
bits are set. For example:
0x50000 = 0101 0000 0000 0000 0000
Adding the bit numbers along the top we get:
19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
From this we can see that bits 18 and 16 are set, indicating that the Pi has previously been throttled due to under-voltage, but is not cur‐
rently throttled for any reason.
Hidenori commented
unvt/kagero でツール化を進めます。
Hidenori commented
unvt/kagero#1 で実験を進めています。