(Rapsberry|Orange|..) Pi UPS
More info will follow shortly.
@see www.ibisek.com
TODO
-
Install package dependencies:
sudo apt-get install python3-smbus
-
Enable I2C
sudo raspi-config
Go to "5 Interfacing Options" -> "I2C" -> select Yes
and reboot.
-
Get the control script from https://github.com/ibisek/piups
git clone https://github.com/ibisek/piups.git cd piups
or
cd /opt mkdir piups cd piups wget https://raw.githubusercontent.com/ibisek/piups/master/autoShutdown.py wget https://raw.githubusercontent.com/ibisek/piups/master/autoShutdown.sh wget https://raw.githubusercontent.com/ibisek/piups/master/piups.py
-
Test the UPS is connected and works fine:
python3 piups.py status
You should see some information like HW & SW versions, batery voltage and possibly others at this stage
-
Add a user under which this script will run to sudoers to be able to shutdown the machine:
sudo vim /etc/sudoers
and add at the end of the file
<your username> ALL=(ALL) NOPASSWD: /sbin/shutdown
-
Configure your crontab
crontab -e
and append
@reboot /usr/bin/python3 /path/to/piups.py start & >/ dev/null
Shutting down your pi correctly means executing
python3 piups.py halt
Calling halt/shutdown/poweroff/whateverelse will just shutdown your pi but not turn off the UPS. In such case the UPS will turn off after configured limits without power - either timeout or battery level - whichever comes first.