Sunday, February 9, 2014

UPS for Raspberry Pi

As described in the previous post, I'm using the Raspberry Pi as a server for my calender and addressbook data. It is directly connected to my WLan station, and I want to be able to simply shutdown both devices by simply switching off power. Simply switching off power is not the best idea for a Linux system. That is, the preferred way is to neatly shutdown the system before. Since I do not want to start a terminal application before in order to shutdown the Pi properly, I found a different solution: CW2's Pi USV (USV is german for UPS). It is a battery powered UPS, which comes with a nice software package for Pi's Debian Linux. The UPS and the software shutdown the system when the USB power supply is switched off. This is exactly what I needed.

Installation is rather easy. On piusv.de you find a short movie demoing the device, along with some PDFs of how to connect the hardware and set up the software (there are english manuals, even though the web page is in german language only).

I have a case for my Pi, and in order to be able to use that case with the UPS, I had to cut three holes as shown in the picture. The installation of the hardware is nicely documented in CW2's manuals.

Software

CW2 UPS comes with nice software, which monitors the power and automatically shutdown the system if the USB power is switched off. The software comes as a Debian package, and the installation sets up everything -- usually you do not need to manually adjust things.

This is how I installed the software on command line (as I have no monitor attached to my Pi, I always connect via ssh):

Download piusvmonitor software on command line via wget:

wget http://www.piusv.de/support/piusvmonitor.deb

Install piusvmonitor as super user:

sudo dpkg --install piusvmonitor.deb

After installation, you will find a shell script

piusvautostart
in /etc/init.d for starting the piusmonitor automatically. After installation, the software is automatically started. The monitor actually is a service, running in the background.

Configuration and log files are found in

/usr/share/piusvmonitor

Check functionality:

tail -f /usr/share/piusvmonitor/log.piusv
Initially:
Sun Feb  9 12:21:38 2014
PRI_POW 
Now, remove one battery as shown on the demo on pisv.de: This will be shown in the log:
Sun Feb  9 12:21:39 2014
PRI_POW BAT_LOW 
Sun Feb  9 12:21:39 2014
PRI_POW BAT_LOW
Now, put battery back:
Sun Feb  9 12:21:53 2014
PRI_POW 
Sun Feb  9 12:21:53 2014
PRI_POW 
Eventually, try the shutdown by removing the USB power supply:
Sun Feb  9 12:22:02 2014
SEC_POW BAT_LOW 
Sun Feb  9 12:22:02 2014
SEC_POW BAT_LOW 
Sun Feb  9 12:22:12 2014
 PIUSV shutdown
Sun Feb  9 12:22:12 2014
 PIUSV shutdown
Sun Feb  9 12:22:16 2014
SEC_POW BAT_LOW 
Connection to xxx.xxx.xxx.xxx closed by remote host.
Connection to xxx.xxx.xxx.xxx closed.    
The last two lines a due to the ssh connection, of course. After rebooting and reconnecting to the PI, the piusv software is started automatically:
Sun Feb  9 12:22:28 2014
PRI_POW 
Sun Feb  9 12:28:20 2014
PRI_POW BAT_LOW 
Sun Feb  9 12:28:21 2014
PRI_POW 

Summary

The CW2 UPS is a nice little device, and the software is working great. Unfortunately the common Rasperry Pi case does not really fit. Most of all, it would be nice to have a real connector for the battery package instead of the press-stud connection. The CW2 UPS costs about 30€ and can be ordered irectly from CW2. Additionally, you need batteries, of course. Note that the UPS does not automatically charge the batteries, so there is still some "manual" maintenance necessary.