When Nwazet closed down I bought a number of 8x8 Led Matrices for $1 each. I had these for a while and then bought some Adafruit 16x8 Led Matrix Driver Backpacks - HT16K33 to power the Matrices.

This seemed like an awesome plan, but this backpack was my first lesson in making sure that the products I was using are popular and well supported. While there are tons of examples of how to wire the adafruit backpacks with the same chip that are integrated, I could not find anything using my backpacks.

Eventually I found a datasheet for my matrix and used a piece of paper to map out the pins from the matrix and where they needed to connect to on the backpack

Paper Pinouts

Then I laid out the breakout and a matrix on some breadboards and started wiring it all together.

Circuit Image

I cobbled together some code from a few different examples and finally got the matrix working. The code is on github and there is a video of the matrix in action below.

Part of the reason I bought a 3D Printer was to add some polish and portability to Raspberry Pi and Arduino projects, my favorite of those projects has been the 3D Printed Touch Pi battery powered Raspberry Pi case with Adafruit 3.5” PiTFT Touchscreen.

After building a Raspberry Pi laptop with a Motorola LapDock I have been looking for a reasonable way to make the Pi more portable. Even when it worked the LapDock based laptop was a loosely connected horror of strange cables and adaptors and Konami code like startup sequences.

I also saw the Pi-Top laptop, but it costs more than my ChromeBook 2 did and is huge. I have the small keyboard and mouse in the original Pi-Top kit and really just wanted a way to do simple tasks like opening the desktop, restarting, shutting down or setting up wifi without having to use the keyboard at all.

For about a hundred bucks the Touch Pi is a really nice way to have a neatly contained battery powered portable raspbery pi with touchscreen. Wanting to learn a little bit of python I took a few different projects and cobbled together a menu for my Touch Pi to handle many common tasks, as well as displaying the hostname and IP address to make it easier to connect to the Touch Pi remotely.

Touch Pi Menu

You can find the code for the menu here Simple PiTFT TouchPi Menu System.

After using my new menu for a few days I found the awesome PiFi project and added a WiFi Settings button that runs the PiFi python script. My only issue with the Touch Pi at this point was that it would shut down without warning when running on the battery.

I read a bit a about setting up some sort of battery indicator using the PowerBoost and it looked annoying, so I soldered half a female jumper wire to the LBO - Low Battery Output pin on my PowerBoost and plugged it into pin 21 (Bottom Right Pin) of the GPIO on my B+. The documentation of the LBO pin appears to be cut off in adafruit’s docs, but it does say the pin defaults to high. One of my favorite things about the pi and adafruit products, is that the little bit of documentation available is really all I needed to know to get started.

Touch Pi LBO GPIO Wiring

To see how the LBO pin behaved I wrote a small python script and saved it on my pi. I then ran it from a SSH session on my desktop so that I could see the output from just before the battery died. When running the following script I would see 6-9 Pin Low prints before the pi powered off (60-80 seconds before powerdown)

import RPi.GPIO
import time
RPi.GPIO.setmode (RPi.GPIO.BCM)

RPi.GPIO.setup(21, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP)

while True:
  if RPi.GPIO.input(21) == RPi.GPIO.LOW:
      print ("Pin Low")
      time.sleep(10)

  if RPi.GPIO.input(21) == RPi.GPIO.HIGH:
      now = time.strftime("%c")
      print ("Pin High " + now )
      time.sleep(60)

The LBO pin returned High when my touch pi battery switch was turned off and the unit was being powered from the regular micro usb power port, and while the switch was turned on an the battery had enough power for the pi. The LBO input switched to low when the battery was only able to power the Pi for about another 60 seconds. This would be perfect for setting up automated shutdown in the menu. I put together a bit of python code that runs in the menu’s while loop

# LBO Pin from Powerboost setup before while loop
RPi.GPIO.setmode (RPi.GPIO.BCM)
RPi.GPIO.setup(21, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP)


# Inside loop
if RPi.GPIO.input(21) == RPi.GPIO.LOW:
    screen.fill(black)
    font=pygame.font.Font(None,48)
    label=font.render("Battery Low, Shutting down", 1, (white))
    screen.blit(label,(20,120))
    pygame.display.flip()
    time.sleep(10)
    pygame.quit()
    shutdown()
    sys.exit()

I ran the battery out on my Touch Pi, and then charged it for about 20 minutes and started it up. A few minutes starting up I saw the following:

Touch Pi Low Battery shutdown screen

I ran the battery out a few times with the actual shutdown function line commented out, and it showed the low battery screen moments before the pi abruptly powered off every time.

I am sure my approach here is not great for battery life, but I don’t know anything about writing battery efficient python code at this point.

Don't have a 3D Printer?

Get a printed touch pi case for your project in the project store

Just completed a simple touch menu for Raspberry Pi projects using the 3.5” Adafruit PiTFT 480x320 touch screen.

Runs as a python script in the framebuffer without needing a desktop environment.

I have made a model b+ Touch Pi 3D printed case for my screen and raspberry pi, and with a battery and PowerBoost 500c charger it makes a great base for raspberry pi projects.

I wanted a way to do common tasks like going to the desktop, rebooting and shutting down without needing to use a keyboard. I also wanted the screen to display the current IP address to make it easier to ssh into the device.

Touch Pi Menu

You can get the source code from github.

Featured on the adafruit blog for pi day: