Mạch Siêu tụ tham khảo
root@robot:~# cat power_monitor
#!/bin/bash
set -euo pipefail
r="$(vcgencmd get_throttled)"
throttle="$(echo "$r" | sed 's/throttled=//')"
#echo "throttle is $throttle"
if [ $(($throttle & 0x1)) -eq 1 ];
then
logger "undervoltage detected - shutting down"
shutdown +1 "undervoltage detected - shutting down in 1 minute."
fi
root@robot:~# chmod 755 power_monitor
root@robot:~# tail -2 /etc/crontab
* * * * * root /root/power_monitor
root@robot:~# grep "undervoltage" /var/log/messages
Apr 30 05:26:01 robot pi: undervoltage detected - shutting down
Vì ShoutDown mềm nên Pi sẽ không tự khởi động sau khi có điện lại nếu nguồn vào chưa ngắt hoàn toàn (đang tắt nguồn thì có điện lại). Nên cần tạo trường hợp ngắt hoàn toàn điện vào Pi (cho dù xả hết điện Pin/Siêu Tụ hay chưa hết thì có điện lại) để Pi có thể tự khởi động sau khi có điện lại.
Tạo như nào thì chưa biết :v