Uninterruptible power supply for the Raspberry Pi

A Nice Add-On Package

In addition to the core UPS functionality, the UPiS board provides the Raspberry Pi with several other useful capabilities. One of these is the mechanical on/off switch (Figure 1). Usually, users must bravely pull out the cable to power down the Raspberry Pi or implement one of the sets of handicraft instructions [10]. The UPS board presented here makes this superfluous.

Another interesting feature is the battery-powered real-time clock. A bit of preparatory work is required to make it function, though. The clock is accessed via the I2C bus of the Raspberry Pi, which by default is inactive. Theoretically, two jumpers should be attached to the UPiS, but they are usually already in their proper position.

Listing 3 shows the necessary steps that need to be executed via software. First, the kernel drivers for the real-time clock and the data bus need to be loaded and then logically connected. This step allows you to control the clock via the command-line program hwclock. You should first initialize the clock with the current time.

Listing 3

Activating the Real-Time Clock

01 $ modprobe i2c-bcm2708
02 $ modprobe rtc-ds1307
03 $ ls /sys/class/i2c-adapter/i2c-1
04 1-003b  1-004c  1-004d  delete_device  device  name  new_device  power  subsystem  uevent
05 $ echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
06 $ hwclock -r
07 Sun 26 Oct 2014 20:31:20 UTC

More details can be found in the manual [4]. The various Raspberry Pi versions have different ways of numbering the I2C buses. The commands in Listing 3 work for Model B. To arrive at a configuration that works properly after a system reboot, you need to automate the loading of the kernel modules and the initialization of the real-time clock. When using Raspbian, the appropriate files are /etc/modules, /etc/modprobe.d/raspi-blacklist.conf, and /etc/rc.local.

The real-time clock can be used to start and stop the Raspberry Pi automatically. To enable this, the UPS board stores the two values START and STOP. The first value defines the number of minutes the ARM computer will run before UPiS shuts it down via a predefined routine. The number stored in STOP determines how many minutes the UPS waits to boot up the Raspberry Pi again.

Summary

UPiS has considerable potential and does not need to hide behind the more established products by APC or Eaton. For example, the board also features a temperature sensor and an LED interface that I have not addressed here. The forum [11] furnishes a small C program that provides deep insights into the actual state of the entire UPiS board. Admittedly, the $52 (£35/EUR49) price for the basic version is higher than that of the Raspberry Pi nano-computer itself, but, in exchange, you will gain considerable functionality in addition to the uninterruptible power supply.

The Author

Dr. Udo Seidel studied to become a math and physics teacher and has been a Linux fan since 1996. After receiving his doctorate he worked as a Linux/Unix trainer, system administrator, and senior solution engineer. Nowadays, he is the Head of the Linux Strategy Team at Amadeus Data Processing GmbH in Erding (Bavaria), Germany.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Testing a Pi UPS module

    When the Raspberry Pi is connected to a car ignition or the USB port on a TV, you run the risk of data loss with a hard shutdown. The Pi UPS bridges short lapses in the power supply and shuts down your Rasp Pi safely when the power remains off.

  • Extensions for the Raspberry Pi

    The resourcefulness of private and commercial users has led to the creation of many practical and novel extensions for the Raspberry Pi. We provide an overview of some useful supplementary circuit boards.

  • Exploring the new Raspberry Pi Model B+

    The new Raspberry Pi Model B+ is the biggest change to Raspberry Pi since the Model B Rev 2 upgrade two years ago. Find out what's new with the B+ and how it will affect your Rasp Pi adventures.

  • SunRover Part 2 – Solar Power Controller/Power System

    Putting power in your robot is more than just running wires – you'll need to make sure the power supply doesn't cause interference that will disrupt other components. This article explores the problem of electrical noise and describes the design for a multiplexing solar power system.

  • Adding an On/Off switch to your Raspberry Pi

    Pulling the plug on your Pi without an orderly shutdown can corrupt the SD card. Also, many users prefer a convenient switch to clicking icons and entering shutdown commands. We show you some options for starting, stopping, and powering down.