# Battery Powered Raspberry Pi Displays w/RaspiRobot Shield

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/018/411/medium800thumb/raspberry_pi_new.jpg?1448311786)

Although the RasPiRobot Board is primarily intended as a motor controller, it also includes a high current switch mode voltage regulator that allows you to power a Raspberry Pi from a wide range of battery types.

![](https://cdn-learn.adafruit.com/assets/assets/000/018/328/medium800/raspberry_pi_overview_copy.jpg?1406101997)

In this tutorial you will learn how to use the RasPiRobot Shield and an AA battery pack to make a portable Raspberry Pi powered display.  
The display will show the current time as scrolling text, but the project can easily be modified to display other scrolling text messages.  
The parts used in this project are listed in the Featured Products bar on the right of your screen.

# Battery Powered Raspberry Pi Displays w/RaspiRobot Shield

## Wiring

Wiring is really too strong a word for it. Just plug the RasPiRobot Board V2 onto the Raspberry Pi as shown below. Note that if you are using a Raspberry Pi B+ with extra pins, then make sure that the RasPiRobot Board V2 fits over the GPIO pins at the right hand side of the Raspberry Pi.

![](https://cdn-learn.adafruit.com/assets/assets/000/018/329/medium800/raspberry_pi_rrb_on_B__copy.jpg?1406102149)

If you are using a Raspberry Pi model B, then the RasPiRobot Board V2 will fit over all the GPIO pins, as shown below.

![](https://cdn-learn.adafruit.com/assets/assets/000/018/330/medium800/raspberry_pi_rrb_on_B_copy.jpg?1406102180)

You will need to solder together the LED Matrix display as it comes in kit form. You can find full instructions for this on the [display's product page](https://www.adafruit.com/products/902).

Then fit the LED Matrix display into the I2C socket o the RasPiRobot Board V2. Make sure that you get it the right way around, and if you are using the latest version of the RasPiRobot Board V2 with extended headers make sure that the header pins cannot reach up as far as the bare connections on the underside of the LED matrix module. If you think they might, then just fold a bit of electrical tape or even Scotch tape over the extended GPIO pins. Attach the flying leads of the battery box to the screw terminals maked Vin and GND on the RasPiRobot Board V2. Fit some AA batteries (rechargeable or single-use). Turn on the switch to the battery box and you will see the power light on the Raspberry Pi light up, as well as the two LEDs on the RasPiRobot Board V2.

For the battery pack - the red wire goes to **VIN** and the black wire goes to **Ground**

![](https://cdn-learn.adafruit.com/assets/assets/000/018/331/medium800/raspberry_pi_overview_copy.jpg?1406102235)

# Battery Powered Raspberry Pi Displays w/RaspiRobot Shield

## Software

To setup your Raspberry Pi to use I2C (needed by the display module) follow the instructions [here](https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c).

Please follow the steps [here](https://github.com/adafruit/Adafruit_Python_LED_Backpack "Link: https://github.com/adafruit/Adafruit\_Python\_LED\_Backpack") to install the Adafruit I2C library and PIL (Python Imaging Library).

You may also wish to try out some of the examples in the latter guide to check that I2C and the LED Matrix display is working correctly.  
The following example takes the display examples a bit further, allowing you to display scrolling text on them.  
Open an editor window using:  
  

```
nano scrolling_clock.py
```

Then paste in the following text and save the file using CTRL-X and then Y and then ENTER.

```
import time
from datetime import datetime
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from Adafruit_LED_Backpack import Matrix8x8

display = Matrix8x8.Matrix8x8()
display.begin()
 
font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", 9)
 
im = Image.new("1", (8, 8), "black")
draw = ImageDraw.Draw(im)
width, ignore = font.getsize("88 : 88 : 88")

def format_time():
    d = datetime.now()
    return "{:%H : %M : %S}".format(d)

message = format_time()
x = 8
while True:
    x = x - 1
    if x &lt; -(width + 20):
        x = 8
        message = format_time()
    draw.rectangle((0, 0, 7, 7), outline=0, fill=0)
    draw.text((x, -1), message, 1, font=font)
    display.set_image(im)
    display.write_display()
    time.sleep(0.1)
```

You can now run the program using the command:

```
sudo python scrolling_clock.py
```

The time should now slowly scroll across the display.

The code uses a number of libraries to do its job. The Adafruit\_LED\_Backpack library handles the low level interface to the matrix display. To be able to write text onto the display, we need to use the Python Imaging Library (PIL) and write the text to an image that can then be written to the display.  
After initializing the display, the Truetype font FreeSansBold size 9 point is loaded. This seemed to work the best from the pre-installed fonts. This can be changed to one of the other fonts in the directory /usr/share/fonts/truetype/freefont/ if you want to experiment. The fonts are really not intended to work in 8x8 pixels, so the results are legible but not great.  
An 8x8 image is created with a bit depth of 1. We are just going to write text in green for now. The following command works out how many pixels wide the text for the time is going to be:

```
width, ignore = font.getsize("88 : 88 : 88")
```

The formatTime function just returns the current time formatted for the display.  
The main loop of the program produces the scrolling text effect. It does this by writing the text of the time onto the display with a decreasing x offset, so that the message appears to move. Most of the time, the value of x will be negative (off the left of the display), but the _draw.text_ function automatically crops to the visible part of the display.

# Battery Powered Raspberry Pi Displays w/RaspiRobot Shield

## Next Steps

This arrangement can also be used to drive other Adafruit Backpack displays, such as the [4 digit 7 segment display](https://www.adafruit.com/products/878)and other [matrix backpack displays](https://www.adafruit.com/search?q=matrix+backpack+display).


## Featured Products

### 4 x AA Battery Holder with On/Off Switch

[4 x AA Battery Holder with On/Off Switch](https://www.adafruit.com/product/830)
Make a nice portable power pack with this 4 x AA battery holder. It fits any alkaline or rechargeable AA batteries in series. There's a snap on cover and an on/off switch which can be handy when wiring to something without a switch.

**New**! We now have 0.1" headers...

In Stock
[Buy Now](https://www.adafruit.com/product/830)
[Related Guides to the Product](https://learn.adafruit.com/products/830/guides)
### Raspberry Pi Model B+ 512MB RAM

[Raspberry Pi Model B+ 512MB RAM](https://www.adafruit.com/product/1914)
OMG OMG OMG, did you hear? There's a Raspberry Pi&nbsp;called the Model B+ and check it out...more USB ports, more GPIO, better power supply, four mounting holes, less sticky-out SD card! Yep, that's right, the fantastic engineers at Raspberry Pi HQ have blessed us with a new design....

In Stock
[Buy Now](https://www.adafruit.com/product/1914)
[Related Guides to the Product](https://learn.adafruit.com/products/1914/guides)
### RasPi Robot Board v3 by MonkMakes

[RasPi Robot Board v3 by MonkMakes](https://www.adafruit.com/product/1940)
The RaspiRobot Board v3 is an expansion board designed to turn your Raspberry Pi into a motor controller! This board comes fully assembled and includes a switched-mode power supply so you can supply your Raspberry Pi from a variety of battery packs.

The v3 fits right on top of your...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1940)
[Related Guides to the Product](https://learn.adafruit.com/products/1940/guides)
### Adafruit Bicolor LED Square Pixel Matrix with I2C Backpack

[Adafruit Bicolor LED Square Pixel Matrix with I2C Backpack](https://www.adafruit.com/product/902)
What's better than a single LED? Lots of LEDs! A fun way to make a small colorful display is to use a [1.2" Bi-color 8x8 LED Matrix](http://www.adafruit.com/products/458). Matrices like these are 'multiplexed' - so to control all the 128 LEDs you need 24 pins....

Out of Stock
[Buy Now](https://www.adafruit.com/product/902)
[Related Guides to the Product](https://learn.adafruit.com/products/902/guides)

## Related Guides

- [Adafruit LED Backpacks](https://learn.adafruit.com/adafruit-led-backpack.md)
- [CircuitPython Hardware: LED Backpacks & FeatherWings](https://learn.adafruit.com/micropython-hardware-led-backpacks-and-featherwings.md)
- [Circle of Fifths Euclidean Synth with synthio and CircuitPython](https://learn.adafruit.com/circle-of-fifths-euclidean-synth-with-synthio-and-circuitpython.md)
- [Matrix and 7-Segment LED Backpack with the Raspberry Pi](https://learn.adafruit.com/matrix-7-segment-led-backpack-with-the-raspberry-pi.md)
- [Tiny Arduino Music Visualizer](https://learn.adafruit.com/piccolo.md)
- [Animating Multiple LED Backpacks](https://learn.adafruit.com/animating-multiple-led-backpacks.md)
- [Trinket-Powered Conference Room Occupancy Display](https://learn.adafruit.com/trinket-powered-room-conference-occupancy-display.md)
- [Adafruit Microphone Amplifier Breakout](https://learn.adafruit.com/adafruit-microphone-amplifier-breakout.md)
- [LED Backpack Displays on Raspberry Pi and BeagleBone Black](https://learn.adafruit.com/led-backpack-displays-on-raspberry-pi-and-beaglebone-black.md)
- [Pi-Top Assembly ](https://learn.adafruit.com/pi-top-assembly.md)
- [Motion Controlled Matrix Bed Clock](https://learn.adafruit.com/motion-controlled-matrix-bed-clock.md)
- [Easy NeoPixel Graphics with the CircuitPython Pixel Framebuf Library](https://learn.adafruit.com/easy-neopixel-graphics-with-the-circuitpython-pixel-framebuf-library.md)
- [FPGA RGB Matrix](https://learn.adafruit.com/fpga-rgb-matrix.md)
- [TMP006 Temperature Sensor Python Library](https://learn.adafruit.com/tmp006-temperature-sensor-python-library.md)
- [Monster Matrix with WLED](https://learn.adafruit.com/monster-matrix-with-wled.md)
