Here are the steps that I took to get a
LiFePO4wered UPS battery module working on Pi B+ with Slackware 14.2 arm.
It's a rough slackification of the supplied install script but might save somebody a minute or two. Instructions based on the LiFePO4wered/Pi unit, but other versions are available for later hardware and the process might be similar.
The task is to build the supplied library, daemon, and CLI tool, for power management, UPS functionality, user-definable boot behaviour, low-voltage clean shutdown, wake-timer, &c.
Get and build supplied software
Code:
git clone https://github.com/xorbit/LiFePO4wered*Pi.git
cd LiFePO4wered-Pi
python ./build.py
Install library, daemon, and CLI util
Code:
su
install -p build/SO/liblifepo4wered.so /usr/lib
install -s -p build/CLI/lifepo4wered-cli /usr/bin
install -s -p build/DAEMON/lifepo4wered-daemon /usr/sbin
Set up an init script for the daemon
Put the following into an init script called /etc/rc.d/rc.lifepo4wered:
Code:
#!/bin/sh
# Start/stop/restart lifepo4wered daemon.
# Start lifepo4wered daemon:
lifepo4wered_start() {
if pidof lifepo4wered-daemon $2 > /dev/null; then
killall lifepo4wered-daemon
fi
if [ -x /usr/sbin/lifepo4wered-daemon ]; then
/usr/sbin/lifepo4wered-daemon $2 > /dev/null &
fi
}
# Stop lifepo4wered daemon:
lifepo4wered_stop() {
if pidof lifepo4wered-daemon $2 > /dev/null; then
killall lifepo4wered-daemon
fi
}
# Restart lifepo4wered:
lifepo4wered_restart() {
lifepo4wered_stop
sleep 2
lifepo4wered_start
}
case "$1" in
'start')
lifepo4wered_start
;;
'stop')
lifepo4wered_stop
;;
'restart')
lifepo4wered_restart
;;
*)
echo "usage $0 start|stop|restart"
esac
Make the script executable!
Code:
chmod +x /etc/rc.d/rc.lifepo4wered
Add the following lines to /etc/rc.d/rc.local to start the daemon on boot:
Code:
# start lifepo4wered daemon
if [ -x /etc/rc.d/rc.lifepo4wered ]; then
/bin/sh /etc/rc.d/rc.lifepo4wered start
fi
Enable I2C and UART in boot config
This assumes that you're using device tree. Check that the following lines are somewhere in /boot/config.txt and uncommented:
Code:
dtparam=i2c1=on
dtparam=i2c_arm=on
enable_uart=1
Done, reboot!
When you reboot you should be able to read and set various variables with the lifepo4wered-cli tool, shut down cleanly by touching and holding the touch switch on the module, enjoy sane UPS-type behaviour (with automatic shutdowns on low battery) or whatever else you set up the module to do.
Sorry that these steps assume you are familiar with things like /etc/rc.d, I'd be happy to answer questions about anything I haven't made explicit.
As for the battery module itself, it seems pretty cool so far. It's performed well as a UPS with DC supply permanently connected. I am hoping it'll give a useable runtime with a pitft and some peripherals connected for a holiday computer for (very!) light use. One cool thing is that I've had the UPS module lollygagging around unused for a couple of years, and the battery behaves fine---a function of the LiFePO4 chemistry I guess.