raspberrypi, linux, powerboost comments edit

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")

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

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:
    label=font.render("Battery Low, Shutting down", 1, (white))

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.

raspberrypi, linux comments edit

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.

raspberrypi, linux, piglow, 3d printing comments edit

I got a printrbot simple metal kit on black friday so I have had it a little longer than those who got one for Christmas. It has printed at least 4 hours a day since and I think I have it up and running pretty nicely now, here are my tips for getting great prints quickly.

I really didn’t have any assembly issues other than accidentally using the 22mm M3 screws to connect the fan.

The printrbot documentation currently recommends Repetier Host which just went closed source and is hard to use and was buggy for me on both Ubuntu and Windows 8.1 While using Repetier Host I had to re-flash the firmware on my printrboard twice which was not a lot of fun.

I have been using Cura from Ultimaker and the free Windows 8 3D Builder app. I found that Cura is the best for both printing via USB and generating gcode for upload to OctoPi, I use 3D builder mostly to fix models.

I have been getting great results with cura after adding the bed auto leveling command to the default Cura Start gcode.

G28 Z0; move z to min endstops
G29; Auto level bed add this line
G1 z15.0 F{travel_speed}; move the platform down 15mm

Then make sure you have a spool holder of some kind, I made this one to go with my aluminum handle and have been happy with it. The spool holder made a huge difference in print quality for me.

The first thing I printed was the suggested fan shroud, and after I printed and installed it I started having more warping on my prints, when I put my hand behind the fan when the printer was running there was more back blow than air being pushed through the shroud opening.

After trying a couple of different models I found on thingiverse that didn’t work any better I tried this strange looking one that works great.

Once you are able to print some things you are happy with using Cura over USB, if you have some Linux / Raspberry PI experience I would highly recommend setting up OctoPi with the rasbperry pi camera to take timelapse videos of your prints easily, this really helps figure out what went wrong when unattended prints fail.

I even figured out how to upload all of my timelapses to youtube when they are complete using octoprint’s event hooks. You can find infomation on setting up youtube-upload here. I made a couple of adjustments to my config.yaml file

  enabled: true
  - command: 'youtube-upload --email="my email" --password="my password"
      --title="3D Printing Timelapse: {movie_basename}" --description="Timelapse of
      {gcode}, printed and recorded via OctoPrint on a Printrbot Simple Metal" --category="Tech"
      --keywords="OctoPrint, Printrbot, 3D Printing" --unlisted --private {movie}'
    event: MovieDone
    type: system

I did have one issue once I received a macro lens for my camera mount and the status led on the camera was creating a red moon shaped reflection in the video. Good News is there is a raspberry pi setting in order to disable the camera status led, you will need to edit the boot config file:

sudo nano /boot/config.txt

And add the following line


raspberrypi, linux comments edit

After playing with the raspberry pi a bit longer it became clear that I needed some way to make backups of the SD card used for the OS. I quickly remembered that I could easily use Win32DiskImager to write an ISO image and was able to backup my PI easily.

Then I bought bigger SD cards and moving the OS around became more of an issue as once you expand the file system to use the whole SD card any copies you make of that card are now the same size as full SD card on disk.

While I had enough disk space to back up my two distinct PI images, it seemed kind of silly. Then I ran across this blog post with some automated raspberry PI backup scripts.

Since Matt is a unix systems adminstrator for his job, it seemed like a good place to start. I have not yet implemented any of the more complex scripting of new PI creation, but I do have a process that allows me to back up the os to a smaller SD card for image backup. I can store the backups at their actual size on my ubuntu system, or you can copy the whole card to a smaller card allowing you to more easily use different size cards

raspberrypi, retropi, linux comments edit

Porta Pi Arcade

After completing a number of simple Raspberry PI tutorials, I decided I wanted to try and build a Porta-Pi Arcade Lite Raspberry PI retro gaming system. Since I already have a projector, several monitors and a TV the lite model without a built in screen really appealed to me.

I also liked that the Porta-Pi kits are designed and produced by one guy, Ryan Bates, that had a successful kickstarter. I really appreciated that Ryan had continued to design and provide new DIY kits after his kickstarter since a lot of other projects seem to stop providing DIY kits and outsourcing everything once they become popular.

On top of the standard build I wanted to add a power button, and use a joystick with individual micro-switches so it is more obvious how everything works for my daughter.

I ordered the laser cut wood kit from RetroBuiltGames and downloaded the PDF build manual with a bill of materials and set about ordering parts. Being a software engineer every project needs to have some feature creep so some of the parts I got are not necessary to build a working arcade.

I also wound up buying two extra buttons and two ball tops after my daughter Elsie decided that we each needed a button that was our favorite color (hers pink, mine purple) and that we should have a pink ball top. It turns out that a pink arcade button is a a real hard to find item, I finally managed to find one in Hawaii at Paradise Arcade Shop. They also had a purple button and a Zippyy joystick with 4 micro-switches and changeable ball tops.

Simplified Parts List

  • Porta-Pi Lite Wood Kit and PDF Manual — $31.00 Shipped
  • 10 Arcade Buttons from SparkFun — $30.00 Shipped
  • Assorted Cables from DX .com— $13.00 Shipped
  • Mausberry Circuits Shutdown Circuit — $15.00 Shipped
  • PLATT Electric Solderless Connectors (50) — $16.oo
  • Joystick 2 Ball Tops and 2 extra buttons — $23.00 Shipped
  • Assorted Screws and Nuts for Joystick — $2.00

Total Parts Cost without Raspberry Pi $130.00 Shipped

I already had a rocker switch to use with the shutdown circuit and a raspberry pi and power supply. I also used rubber feet, stain, wood glue and clamps I already had.

All of the parts started shipping quickly after I ordered them and I received the wood kit and buttons in the mail in a few days.

Porta Pi Arcade

Wood kit and buttons mocked up.

I followed the instructions in the manual and fitted the pieces together a couple of times before staining and gluing. I have found my iPad to be really useful for viewing PDF’s, videos and tutorials while working on projects with the Raspberry Pi.

After fitting things together I laid out the pieces on some newspaper and stained the wood.

raspberrypi, piglow, linux comments edit

I have not played with linux in probably 10 years, when i did then everything was a hassle. I made a firewall media server device out of a loud and huge dell power edge server. After buying a raspberry pi for my daughter and I to play with I was amazed at how easy it is to install and update linux now, especially on something with common hardware like the pi.

First thing is to download the newest version of Raspbian from the Raspberry PI foundation and put it on your sd card.

Start up your pi and log in with user pi password raspberry, once logged in type the following command to open raspi-config.

sudo raspi-config

Once you are in the configuration wizard expand the file system, overclock your pi if you want, and if you are in the US update region, timezone and keyboard settings if you are in the US. Make sure and change the default password.

Tab over to finished in the raspi-config and reboot your pi. Log in again with your new password and run the following commands in order to get the latest updates on your pi. Each of these may take a while to run depending on how fast your SD card is and how much you overclocked your pi.

sudo apt-get update
sudo apt-get dist-upgrade
sudo rpi-update

If you want to use scratch with the GPIO ports on your raspberry pi install Scratch GPIO

sudo wget http://goo.gl/Pthh62 -O isgh5.sh
sudo bash isgh5.sh

The PiGlow board works with Scratch, fits nicely in the pibow case and has many lights. Run the following commands to get your piglow all ready to use.

sudo apt-get install i2c-tools
sudo apt-get install python-smbus
wget https://github.com/heeed/pi2c/raw/master/pi2c.sh
sudo bash pi2c.sh
mkdir piglow
cd piglow

Now that we have everything all set up lets run some example code from the internet. A quick warning, the PiGlow is really bright especially the three center white LEDS don’t look directly at it when you first run the scripts or you may see black spots for a bit.

wget https://github.com/pimoroni/piglow/raw/master/examples/piglow-example.py
sudo python piglow-example.py

#more piglow python examples
wget https://github.com/Boeeerb/PiGlow/raw/master/piglow.py

#python psutil for cpu example
sudo apt-get install python-psutil
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/all.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/arm.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/clock.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/cpu.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/cycle.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/cycle2.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/halloween.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/indiv.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/indiv2.py
wget https://github.com/Boeeerb/PiGlow/raw/master/Examples/test.py

diy, projector comments edit

I have an Infocus IN72 projector that I have been very happy with, in my old apartment I mounted my screen made of Do-Able board to the wall using industrial velcro and was happy. When I left my apartment, the industrial velcro removed the paint and a pretty substantial paper layer from the drywall.

Since I now own the walls I will be mounting the screen to I decided to figure out a more visually appealing option that would not create so much damage if removed.

My screen is 65" by 37" and my new house has a similar sized area, so I am keeping the Do-Able board as it is already cut. I decided to add a frame to the screen to make it match the living room better. Having discovered the DoAble board on AVSForum, I decided to see if anyone else there had built a frame for their board. Quite a few people have built frames for their board, but all of the pictures I found used felt to wrap the material and butted the corners together. I wanted to use a dark brown matte paint for the frame and miter the corners.

Here are the materials I bought at the ace hardware down the street:

  • 3 1/4 8' Hardwood boards
  • 1" Corner Join pieces (these handy deals pull the mitered corners together for a good fit)
  • 5/8 wood screws
  • 4 18" hangman picture hangers (these came from Lowe's)
  • Glaziers Points
  • Mitre Box and saw



After routing out the inside of the frame for the do-able board, I used wood glue and the corner join pieces to put the whole thing together. If your screen is large, you are going to need a big area for this to sit for at least a day while it drys.

Upon reflection, I think Part of the reason that there were not any mitered corners in any of the projects listed at AVSForum is because building a large frame with mitered corners is hard!! In order to get clean corners, the entire frame must be assembled at the same time, and the size of the frame makes each corner pretty fragile. I did have to use a little wood filler to take up a corner that did not quite fit properly.

Yesterday I was in a conference room at Microsoft where they had a projection area, and the border was thin metal covered in felt, while it did darken the small areas of light leakage, it was only slightly less noticible then the matte brown paint.

Here is the finished frame:


Here is a corner:


a-team comments edit

Touch Pi Menu

Beautiful autographed photo of faceman from a bed and breakfast in park city