General Raspberry Pi

DFR0494 poweroff and powering up RPi automatically

userHead dolphs 2025-10-28 13:57:00 24 Views1 Replies

Hi,

 

 

I am using the DFR0494 Raspberry Pi UPS HAT on my RPi3.

 

The Pi needs to be shut off when the electricity percentage is between 10-15%, however as it seems a simple “poweroff” is not sufficient and similar signal needs to be send to the UPS HAT to get things powered off fully. 

Can this be achieved and also default behaviour would be the HAT powers the Rpi, so the function keys do not need to be pressed for 3 seconds once power will be back?

 

The provided python script “Check UPS Battery Percentage” ups.py I use in conjunction with a “do while” bash script which starts booting up the RPi, but .

 

 

while true
do
  output=($(python3 /usr/local/bin/ups.py))
  if echo "${output[2]}" | grep -q "percentage=1[0-5]"
  then
     systemctl poweroff
     exit
  fi
  sleep 60
done
 

Hopefully I can achieve my goal with little help from you guys.

Thanks!

2025-10-29 17:48:47

OK it seems using another batterry things work out for me.

So I do not have to do anything when battery is exhausted ( +/- 7% ) and once power came back the RPi comes back quickly when elec. is around 9%. 

Though would be nice these values can be altered

userHeadPic dolphs