Communicating with the UPiS UPS from RasPlex

Standard

As part of my recent media centre build, I wanted to have a Raspberry Pi running RasPlex power down gracefully when power was removed. The UPiS Advanced UPS to the rescue! Despite the terrible name, this UPiS comes complete with a battery and UART so that the power status can be monitored from the Raspberry Pi.

The script is straightforward enough — it queries the UPiS every few seconds. If it detects that power is removed, it shuts itself down and triggers the “file sfe shutdown” on the UPiS. After 30 seconds or so, with everything safely shut down, the UPiS cuts power.

The script is in Python and requires PySerial. However, RasPlex is very bare-bones, python libraries can’t be compiled and nothing can be installed (there is no package manager). It turns out, however, that this doesn’t matter — PySerial can be installed to a local folder and run from source.

The (small) code and instructions for running are on my GitHub repository. PySerial is included.

 

About Me

Standard

Based in Shanghai, China, I’m an experienced knowledge and digital marketing leader with a particular interest in social media and web application design.

I’m passionate about sharing knowledge, and am a strong advocate for open source and software freedom.

Some of my recent personal work includes:

  • WP-United: A project that integrates leading social software to make better social sites. WP-United empowers hundreds of communities all over the web, from small university clubs to large newspapers and corporate intranets.
  • rmbtb.com: One of the first Bitcoin exchanges in China, with top notch security and features, including an advanced secure API. One of the few Bitcoin sites not to get hacked and lose a bunch of money! RMBTB is now closed due to Chinese legislation banning Bitcoin.