Science and technology

Adding a show to a travel-ready Raspberry Pi Zero

In my earlier article, I defined how I transformed a Raspberry Pi Zero right into a minimal, moveable, go-anywhere pc system that, though small, can truly obtain helpful issues. I’ve since made iterations which have proved fascinating and made the little Pi much more helpful. Read on to study what I’ve accomplished.

After the highway journey

My preliminary Pi Zero setup proved its worth on a highway journey to Whitby, however afterward, it was largely consigned to the “pending” shelf, ready for an additional task. It was powered up weekly to use updates, however apart from that, it was idle. Then at some point, as I used to be flicking via emails from numerous Pi suppliers, I got here throughout a (barely) diminished e-Ink show provide: hmmm… and there was a model for the Pi Zero as properly. What might I do with one?

ModMyPi was promoting a fairly neat display and driver board combination and a small case with a clear window on prime. I learn the standard evaluations, and other than one remark in regards to the boards being a really tight match, it sounded constructive. I ordered it, and it turned up a couple of days later. I had famous from the product description that the show board did not have GPIO headers put in, so I ordered a Pi Zero WH (wi-fi + headers pre-installed) to avoid wasting me the hassle of soldering one on.

Some meeting required

As with most of this stuff, some self-assembly was required, so I rigorously opened the containers and laid out the elements on the desk. The case was properly made other than ridiculous slots for a watch strap (?!) and a few unusual holes within the facet to permit tiny fingers to press the 5 I/O buttons on the show. “Could I get a prime with out holes?” I inquired on the evaluation web page. “No.” Okay then.

With the case unpacked, it was time to open the show field. A properly designed board was first out, and there have been clear directions on the Pi-Supply web site. The show was so skinny (zero.95mm) that I practically threw it out with the bubble wrap.

The first job was to mount the show board on the Pi Zero. I checked to ensure I might connect the show cable to the driving force board when it was joined to the Pi and determined that, with my sausage fingers, I might connect the show first and depart it flapping within the breeze whereas I hooked up the driving force board to the Pi. I rigorously acquired the boards lined up on the GPIO pins, and, with these in place, I folded over the show “screen” to sit down on prime of the board. With the piggy-backed boards in place, I then verrrry rigorously shoe-horned the meeting into place within the case. Tight match? Yeah, you are not kidding, however I acquired all of it safely in place and snapped the highest on, and nothing gave the impression to be damaged. Phew!

How to arrange your show

I’ll skip a piece of messing about right here and refer you to the maker’s instructions as a substitute. Suffice to say that after a couple of installs, reboots, and coffees, I managed to get a working e-Ink show! Now all I needed to do was work out what to do with it.

One of the principle challenges of working with a small gadget like my “TravelPi” is that you do not have entry to as a lot display screen actual property as you’ll on a bigger machine. I like the dimensions and energy of the gadget although, so it is actually a compromise as to what you get out of it. For instance, there is a single display screen accessible through the HDMI port, and I’ve used tmux to separate that into 4 separate, usable panes. If I actually need to view one thing else urgently, I might all the time Ctrl+Z into one other immediate and do the mandatory configs, however that is messy.

I needed to see numerous settings and possibly have a look at some system settings, and the e-Ink show enabled me to do all that! As you may see from the picture beneath, I ended up with a really usable information panel that’s up to date by a easy(-ish) Python script (qv) both manually or by a crontab entry each 10 minutes. The producer states that the replace frequency must be “no more than 1Hz if you want your display to last for a long time.” Ten minutes is okay, thanks.

Here’s what I needed to have the ability to see at a look:

Hostname And gadget serial quantity
IP handle Current inner IP handle
VPN standing Inactive/nation/IP handle
Tor standing Inactive/IP handle
“Usage” Percentage disk house and reminiscence used
Uptime So satisfying to see these lengthy uptimes

And right here it’s: a show that is the identical dimension because the Pi Zero and 1″ deep.

How to populate the show

Now I wanted to populate the show. As appears to be the norm today, the e-Ink help software program is in Python, which, in fact, is put in as customary with most Linux distros. Disclaimer: Python will not be my first (dev) language, however the code beneath works for me. It’ll most likely be just right for you, too.

#!/usr/bin/env python

import os
import sys
import time
import datetime
import socket
import netifaces as ni
import psutil
import subprocess

from netifaces import AF_INET, AF_INET6, AF_LINK, AF_PACKET
from papirus import PapirusText, PapirusTextPos, Papirus
from subprocess import check_output
from datetime import timedelta

rot     = zero
display screen  = Papirus(rotation = rot)
fbold   = '/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf'
fnorm   = '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf'
textual content    = PapirusTextPos(rotation = rot)

def GetBootTime():
        return datetime.datetime.fromtimestamp(psutil.boot_time())

def GetUptime():
     with open('/proc/uptime','r') as f:
       uptime_seconds = float(f.readline().break up()[zero])
     u = str(timedelta(seconds = uptime_seconds))
     length,junk = u.break up(".")
     hr,mi,sc = length.break up(":")
     return "%sh %sm %ss" % ( hr,mi,sc )

def getHostname():
        hostname = socket.gethostname()
        return hostname

def getWiFiIPaddress():
                [ 'wlan0', ]
                return ni.ifaddresses('wlan0')[AF_INET][zero]['addr']
                return 'inactive'

def getVPNIPaddress():
                [ 'tun0', ]
                return ni.ifaddresses('tun0')[AF_INET][zero]['addr']
                return 'inactive'

def GetTmuxEnv():
        if 'TMUX_PANE' in os.environ:
                return ' (t)'
        return ' '

def GetCPUserial():
        cpuinfo = subprocess.check_output(["/bin/cat", "/proc/cpuinfo"])
        cpuinfo = cpuinfo.substitute("t","")
        cpuinfo = cpuinfo.break up("n")
        [ legend, cpuserial ] = cpuinfo[12].break up(' ')
        cpuserial = cpuserial.lstrip("0")
        return cpuserial

def GetMemUsed():
        memUsed = psutil.virtual_memory()[2]
        return memUsed

def GetDiskUsed():
        diskUsed = psutil.disk_usage('/')[three]
        return diskUsed

def ExamineTor():
                TS = "active: pid %s" %check_output(['pidof','tor'])   
                TS = 'inactive'
        return TS      

def CheckVPN():
        return VPNlo
# ---------------------------------------------------------------------------
def important():

if __name__ == '__main__':

VPNlo = 'inactive'

if (len(sys.argv) == 2):
                VPNlo = sys.argv[1]
                VPNlo = 'inactive'

textual content = PapirusTextPos(False,rotation=rot)
textual content.AddText("%s %s %s"% (getHostname(),GetCPUserial(),GetTmuxEnv()),x=1,y=zero,dimension=12,invert=True,fontPath=fbold)
textual content.AddText("IP  %s" % getWiFiIPaddress(),x=1,y=16,dimension=12,fontPath=fnorm)
if ( getVPNIPaddress() == 'inactive' ):
        textual content.AddText("VPN %s" % CheckVPN(),x=1,y=30,dimension=12,fontPath=fnorm)
        textual content.AddText("VPN %s" % getVPNIPaddress(),x=1,y=30,dimension=12,fontPath=fnorm)
textual content.AddText("TOR %s" % ExamineTor(),x=1,y=44,dimension=12,fontPath=fnorm)
textual content.AddText("MEM %s% DISK %s% used" % (GetMemUsed(),GetDiskUsed()),x=1,y=58,dimension=12,fontPath=fnorm,maxLines=1)
textual content.AddText("UPTIME %s" % GetUptime(),x=1,y=72,dimension=12,fontPath=fnorm)
textual content.WriteAll()


Normally, the script runs with none arguments and known as by a sequence of Bash scripts that I’ve written to start out up numerous subsystems; these are, in flip, known as from a menu system written in Whiptail, which is fairly versatile. In the case of the VPN system, I’ve a listing of entry factors to select from and that replace the placement on the show. Initially, I name the show updater with the placement identify (e.g., Honolulu), however at that time, I am unable to show the VPN IP handle as a result of I do not comprehend it: $accesspoint
   openvpn --config $PATH/Privacy-$accesspoint.conf --auth-user-move credfile

When the show updater runs once more (outdoors the VPN startup script), the IP handle is readable from the tun0 interface and the show is up to date with the IP handle. I could change this later, nevertheless it works wonderful now. I take advantage of the PapirusTextPos perform (fairly than PapirusText), as this permits a number of strains to be written earlier than the show is up to date, resulting in a a lot sooner write. The textual content.WriteAll() perform does the precise replace.

Adding extra software program

I used to be more than happy with my preliminary alternative of functions, however since I might managed to slim the entire set up all the way down to 1.7GB, I had loads of out there house. So, I made a decision to see if there was anything that may very well be helpful. Here’s what I added:

Irssi IRC shopper
FreeBSD video games There are nonetheless many text-mode video games to take pleasure in
nmon very complete top-alike utility for all features of the system
Newsbeuter Text-mode Atom/RSS feed reader

And I nonetheless have about 300MB free house to take me as much as 2GB, so I could add extra.

We keed to speak about Kevin Bluetooth

Observant readers will bear in mind my hatred for Bluetooth and attempting to pair terminal-based software program with a Bluetooth gadget. When I purchased a brand new Pi, I noticed that I needed to pair the rattling factor up with the keyboards once more. Oh, woe is me! But a search-engine session and a chilled espresso enabled me to truly do it! It goes one thing like this:

sudo su


[bluetooth]# scan on
Discovery began
[CHG] Controller B8:27:EB:XX:XX:XX Discovering: sure

[bluetooth]# agent on
Agent registered
[NEW] Device B2:2B:XX:XX:XX:XX Bluetooth Keyboard
Attempting to pair with B2:2B:XX:XX:XX:XX
[CHG] Device B2:2B:XX:XX:XX:XX Connected: sure
[agent] PIN code: 834652
[CHG] Device B2:2B:XX:XX:XX:XX Modalias: usb:v05ACp0220d0001
[CHG] Device B2:2B:XX:XX:XX:XX UUIDs: zzzzz
[CHG] Device B2:2B:XX:XX:XX:XX UUIDs: yyyyy
[CHG] Device B2:2B:XX:XX:XX:XX ServicesResolved: sure
[CHG] Device B2:2B:XX:XX:XX:XX Paired: sure
Pairing profitable
[CHG] Device B2:2B:XX:XX:XX:XX ServicesResolved: no
[CHG] Device B2:2B:XX:XX:XX:XX Connected: no

[bluetooth]# belief B2:2B:XX:XX:XX:XX
[CHG] Device B2:2B:XX:XX:XX:XX Trusted: sure
Changing B2:2B:XX:XX:XX:XX belief succeeded
[CHG] Device B2:2B:XX:XX:XX:XX RSSI: -53

[bluetooth]# scan off
[CHG] Device B2:2B:XX:XX:XX:XX RSSI is nil
Discovery stopped
[CHG] Controller B8:27:EB:XX:XX:XX Discovering: no

[bluetooth]# exit
Agent unregistered


I used to be gobsmacked! No, actually. I paired my different keyboard and am now contemplating pairing a speaker, however we’ll see. I had a beer that night time to have a good time my new-found “l33t” tech abilities! Here is an excellent guide on how you can do it.

One extra hardware mod

Until not too long ago, I have been utilizing as giant a good-quality microSDHC card as I might afford, and in case of issues, I created a backup copy utilizing the rsync-based rpi-clone. However, after studying numerous articles on the ‘web the place folks complain about corrupted playing cards as a consequence of energy issues, unclean shutdowns, and different mishaps, I made a decision to spend money on a higher-quality card that hopefully will survive all this and extra. This is necessary should you’re touring lengthy distances and actually want your software program to work on the vacation spot.

After an extended search, I discovered the ATP Industrial-Grade MicroSD/MicroSDHC playing cards, that are rated military-spec for demanding functions. That sounded excellent. However, with high quality comes a value, in addition to (on this case) restricted capability. In order to maintain my pockets glad, I restricted myself to an 8GB card, which can not sound like rather a lot for a working pc, however making an allowance for I’ve a real 5.3GB of that 8GB free, it really works simply wonderful. I even have a degree of reassurance that larger however lower-quality playing cards cannot give me, and I can create an ISO of that card that is sufficiently small to electronic mail if want be. Result!

What’s subsequent?

The Zero goes from energy to energy, solely needing to exit extra. I’ve gone technically about so far as I can for now, and every other modifications will likely be small and incremental.

This was initially revealed on Peter Garner’s blog beneath a CC BY-NC-ND and is reused right here with the writer’s permission.

Most Popular features the latest multimedia technologies, from live video streaming to audio packages to searchable archives of news features and background information. The site is updated continuously throughout the day.

Copyright © 2017 Breaking Express, Green Media Corporation

To Top