Download as pdf or txt
Download as pdf or txt
You are on page 1of 116

DISCOVER THE WORLD OF RASPBERRY PI! NEW MAG!

Issue 02 // Spring 2017

20 AMAZING
RASPBERRY PI
APPS
Discover the best web browser,
media player, games and more

15
Pi projects
to try

Q&A SPECIAL

ALL YOUR PI
PROBLEMS SOLVED!
Revealed! Simple solutions to your
most common Pi questions PIU02 2017

Make a Pi Build the ultimate Learn to code


walkie-talkie Pi media server with our guides
Retro-syle fun! The perfect starter project Master Python and Scratch
;OLZV\YJLMVY[LJOI\`PUNHK]PJL
techradar.com
Speed
controller: this
adjusts the
power of the
motor (that’s it
just out of shot
on the left)
according to
signals received
from the
Raspberry Pi.

The Pi here is
protected by one
of two sturdy
boxes; the other
one protects
the battery. It’s
controlled
remotely via
Bluetooth.

Pi-powered skateboard
The Raspberry Pi Guy hits the road with a Pi-powered electric skateboard.
As Pi projects go, we have to say this one’s wheely good
atthew Timmons-Brown is well Cambridge, which is very flat – we suspect that
RECIPE
O1x
Raspberry Pi
Zero
M known in Pi circles: he’s the man
also known as The Raspberry Pi
Guy, and his site and YouTube
channel feature all kinds of
experiments served up to an audience of more
the hills of Yorkshire or San Francisco might prove
to be a much tougher challenge for the board’s
battery (and probably the rider’s stamina).
The electric skateboard’s power comes from
a single 3200W brushless motor that drives the
O1x than 57,000 people. He’ll happily show you how rear wheels. Two extra-sturdy boxes mounted
Nintendo Wii to control motors or rig up a camera, but our underneath the board protect the battery and the
remote
favourite video shows his skateboard, which electronics from the elements, debris, accidents
O1x features the unlikely combination of a board, and the occasional hedgehog. The motor is
brushless
electric a Raspberry Pi Zero and the remote controller operated by a speed controller, and that controller
motor from a Nintendo Wii. responds to signals from the Raspberry Pi.
The skateboard is capable of an impressive Using a Wii remote is a particularly clever touch:
O 1 x battery
30kmh (18mph) under electric power, which because it’s Bluetooth, the remote can connect to
“feels like a lot more when you’re actually riding the skateboard’s Raspberry Pi without any messy
it,” Matthew says. He hasn’t tested the range too wiring, so Matthew can use it to adjust the speed
much, but says that the board is quite capable of of the motor without worrying about getting
doing ten kilometres without running out of power. anything tangled. The only downside is that
It’s worth pointing out that those kilometres are in without the remote, the skateboard is entirely
people-powered. As you’d expect, the board is
steered the old-fashioned way, by leaning.
Matthew’s code is around 100 lines of Python,
and he’s put the code up on
Github so others can use it or CREATOR
tweak it. Sadly the skateboard
itself is a one-off: Matthew’s MATTHEW
TIMMONS-BROWN
already on to his next projects,
one of which is an attempt to Matthew is a 17-year-
See the board old student from
in action at www. create a Mars rover – Cambridge. Online,
theraspberrypiguy presumably powered by a Pi. he’s known as The
.com. How’s that for ambition? Raspberry Pi Guy.

6 // // Spring 2017
Our favourite HOME PI PROJECTS

Chessbord
No, it’s not a typo: the Chessbord is a chess board for the Internet of Things
hess and technology go back a long which in turn connects to a Raspberry Pi web

C way: the Mechanical Turk was a robotic


– and sadly, fake – chess player that
wowed crowds in the late 18th century,
and chess-playing computers have
been kicking around since the advent of cheap
server. The Pi communicates with the faraway
player and also checks players’ moves to ensure
that nobody breaks any of the rules.
“I’ve always been fascinated by how things work
and how they are built, and in recent years I’ve
RECIPE
O 1 x Arduino
O1x
Raspberry Pi
electronics in the late 1970s. And of course there’s developed this interest into a love of electronics
Deep Blue, IBM’s chess-playing supercomputer... and coding,” Ben says. “Since I was young I’ve O 1 x chess
board
not to mention Ben James’ Chessbord. been building contraptions of all shapes and
The Chessbord might not be quite as powerful sizes... A lot of my projects have micro-controllers O 64 x jack
plugs, LEDs
(or expensive) as Deep Blue, but it’s pretty clever at their heart.” Ben hopes to turn his love of and sockets
nonetheless. Ben’s design addresses a very simple building things into a career in engineering. We
problem: he likes to play chess online with others, think he’s already made a really impressive start.
but doesn’t like playing the game on a screen. “The
2D view on the screen feels very unintuitive to me,”
he says. “I much prefer playing with a physical
chess board.”
Enter the Chessbord. “It connects to an online
game so that the user can play chess with
anybody in the world, with a real board,” Ben
explains. After initially considering some kind of
robotic device to move the other player’s pieces,
Ben decided to go for something simpler: LEDs to
show you what to move where, and sensors to
detect your move and relay it to the other player.
Each piece would be fitted with a jack plug, and
each square would have a corresponding socket LEDs show you
with four poles: two to power the LED and two to where to move;
detect whether a piece had been inserted. sensors detect
Ben then connected the sockets to an Arduino, when you do so.

Four-pole jack
sockets: these
detect the
position of
the pieces and
also power the
Chessbord’s
LEDs.

Jack plugs:
where there’s
CREATOR a socket, there
needs to be
BEN a plug. These
JAMES were added
to each
Ben is 17 and would
individual
love to be an engineer. chess piece.
He shares his projects
online at Engineer
Cheer (engineercheer.
wordpress.com).

Spring 2017 // // 7
7-inch Touch
Display: David
found a way to
automatically
brighten and
dim the
display for
day and night
operation.

Black tape:
the ModMyPi
case leaked
too much
light, so its
holes were
blanked with
electrical tape.

TimePeace
Sometimes technology can be truly life-enhancing. TimePeace is a great
idea, extensively researched and thought through, and executed brilliantly
n 2015, David Penney’s father told him that no complex buttons and menus etc, although

I
RECIPE his stepmother had been diagnosed with these are found on most clock products,” he says.
Alzheimer’s. David went to visit, and one “So I used the Raspberry Pi Foundation’s 7-inch
O1x
Raspberry Pi of her comments resonated. “Her sense touch display. I also wanted a robust enclosure
of time doesn’t work properly,” he explains. that hides the electronics. The ModMyPi case for
O 1 x 7in “She asks many times a day what day of the week the display and Pi is OK but I would still prefer
Touch
Display it is.” She also woke in the night wondering something that seals firmly and has an option to
whether it was time to get up, and often felt hide all the sockets. I used black electrical tape
O1x that she was supposed to see someone or go over all the holes, which also stops the blinking
ModMyPi
case somewhere without being able to recall who or lights from the Pi from leaking out and keeping
where. David had a flash of insight: he could build a person awake at night!”
O 1 x roll
of black a special clock to help her. David also had to hack the display. “The 7-inch
electrical David undertook extensive research to identify display is also capable of dimming, but it isn’t
tape the best way to display the information, and then documented how to make it work,” he says. “So
he embarked on his build. “I wanted it to be an with clues from the Pi community, I managed to
appliance, not to look like a science project, so reliably dim and brighten the display in software,
then added a timer to tell it when to go dim at
night and when to brighten in the morning.”
David made two TimePeaces for his stepmother,
and the results have been very positive. “The first
night she woke, read ‘middle of the night’ on the
clock and went back to sleep,”
he says. CREATOR
David has now built three
devices, taking advantage of DAVID
PENNEY
Smart clocks
Amazon’s Alexa Voice Services
and other devices for voice control, and is working David is a former IT
director experienced
to tell you more on additional features in in financial services
useful stuff than software to help his and tech, interested in
just the time. stepmother further. cyber defence.

8 // // Spring 2017
Our favourite HOME PI PROJECTS

Gabian
Is it a bird? Is it a plane? No, it’s a flying machine – for fishing! It will help you
find where the fish are biting, drop bait and hook them for you, all remotely
uillaume Ramirez works with they’re spotted Gabian can then make repeated

G helicopters and loves fishing, so it


was perhaps inevitable that he’d find
a way to combine the two. He’s the
creator of Gabian, a very ingenious
fishing drone, which you can see in action at
runs to drop bait where the fish will bite, moving
the line until it hooks a fish and then handing
control over to the fisherman or woman.
As you’ve probably guessed, Gabian is no
hastily-assembled one-off: Guillaume hopes to
RECIPE
O 2 x Raspberry
Pis (the first
one drowned)

http://gabian-en.strikingly.com. market a new version of Gabian to switched-on O1x


Gabian is a waterproof quadcopter built around fishing fanatics. “I am doing a new prototype to Quadcopter
a Raspberry Pi, a Navio 2 board, an RPI Cam V2 possibly change the manufacturing technique O 1 x Navio 2
and a home-made gimbal – a device that keeps from 3D printing to plastic moulding,” he says. board
the camera steady – to stream HD video and drop “It isn’t production ready yet but my target is the O 1 x RPI Cam
fishing lines and/or bait. second quarter of 2017. I’m keeping my ambitions V2
“My inspiration came from buying my first Pi at modest: a DIY kit would probably be the right thing
the beginning of 2016 and finding out what cool to do if people are attracted by the concept.” You
things I could do with it,” Guillaume says. “I’m not can follow his progress and find out more about
an IT guy, but I’m keen on fishing. I have seen Gabian at www.gabian-drone.com.
some inspiring YouTube videos where people fish
with their drones, so I thought, why not me?”
Unfortunately for Guillaume, “after several Fishing isn’t
successful attempts my Raspberry Pi drone fell often strenuous,
into water – which is something that happens if but this way you
you try flying something very fast over water. So don’t even have
I wanted something waterproof that can resist to be present...
crashes and even be operated from a boat without
stress.” He picked the name Gabian, which is the
Mediterranean French name for a seagull.
Gabian uses GPS to find the right spots,
streaming live video so that the person controlling
the drone can see where the fish actually are. Once

Antenna: Gabian sends HD


video directly to its controller,
enabling him or her to see
where the fish are.

Waterproof
case: after
CREATOR discovering the
hard way that
GUILLAUME electronics and
RAMIREZ
the sea don’t
Guillaume, 37,
mix, Guillaume
made his drone
is a production waterproof.
engineer with Airbus
Helicopters in Aix En
Provence, France.

Spring 2017 // // 9
Get the UK’s best-selling
Linux magazine

OUT
NOW!

DELIVERED DIRECT TO YOUR DOOR


Order online at www.myfavouritemagazines.co.uk
or find us in your nearest supermarket, newsagent or bookstore!
Raspberry Pi apps TOP 20

THE TOP 20
Raspberry Pi apps
Discover how to do even more with your Raspberry Pi as Nate Drake
reveals our pick of the very best applications available for the Pi today
he Raspberry Pi is installed and many more can be search box at the top left of the Add/

T probably best known as a


platform for programming
and physical computing
projects, but it’s also a
fully-functional computer, and like
installed without much trouble.
Click Applications > Preferences >
Add/Remove Software to launch
Raspbian’s Package Manager. You’ll
see that the available programs have
Remove Software window, enter your
search terms and press Return. Click
the tickbox next to the name of
individual apps you want to add,
then click Apply at the bottom right
desktop computers and modern been neatly categorised to make it in order to install them. Some of the
mobile devices of all kinds, it has easy to sort through them. There’s programs listed here will already be
a wide range of apps available to even a small description of individual installed on your Pi, in which case
expand its capabilities. What you programs at the bottom to help they will already be ticked.
install will of course depend on what you decide what to install. This is Even if your Pi is not connected to
you want to do with your Pi, but this is especially helpful if you haven’t used a monitor, you can install programs by
our pick of 20 apps that we love, and Linux before and need to find an app connecting to it via SSH. You will first
that all work on the Pi with a default equivalent to one you might have need the name of the program. You
Raspbian install. used in Windows. For instance can then install it using sudo apt-get,
While the Raspberry Pi no longer LibreOffice’s Writer is an excellent for example as follows:
has an online “App Store” – the Pi substitute for Microsoft Office. sudo apt-get dosbox
Store ceased operating in early 2015 In order to find any of the programs Read on for the most exciting apps on
– some handy programs come pre- listed over these pages, click the the Pi today…!

Spring 2017 // // 11
TOP 20 Raspberry Pi apps

Minecraft Pi
Play the popular building game for free
Minecraft Pi is a version of the yourself from place to place. For
insanely successful Minecraft instance, to place a stone block
game written specifically for the immediately behind you, type:
Raspberry Pi. It is based on the x, y, z = mc.player.getPos()
Pocket edition, so may not have mc.setBlock(x+1, y, z, 1)
all the features of the full-blown Visit the official blog at http://
version. Gameplay is “Creative” bit.ly/minecraft-pi-guide for a
mode only, and multiplayer with worksheet of basic commands.
users of the regular Minecraft You can find Minecraft Pi
game is not supported. The pre-installed in Applications >
advantage to this, however, is Games on your Pi.
that no one can destroy your The Raspberry Pi will also
structures. happily run a Minecraft server,
If you want to get more from allowing you and your friends
Minecraft or just try Python to build your own virtual world
programming, press the Tab key provided you each have the
and open Python 3 (IDLE) from official version of the game.
Applications > Programming. There are a number of guides
From here you can type available to do this. We
commands to automatically drop recommend that you use the
Play the game, and make your first foray into Python blocks as you walk, automatically SpigotMC server software as it
programming by building Minecraft blocks. create structures, and teleport runs well on the Pi.

LibreOffice
Find all the office apps you need
Want to use office apps on your Another extremely useful
Pi, for free? LibreOffice provides feature is that with one click you
a familiar looking word processor can convert documents to PDF
(Writer), spreadsheet software format – useful because PDFs
(Calc), presentation program generally appear exactly the
(Impress) and even an app for same on every computer.
creating databases (Base). Help for specific programs
Need to share files with Mac and features is available at the
or Windows users? LibreOffice LibreOffice Community Support
bridges the gap: it supports ODF page at www.libreoffice.org/
(Open Document Format) by get-help/community-support.
default but can also open files If you like the app on the Pi, you
created in Microsoft Word, Excel can also download LibreOffice
and Powerpoint, as well as save for Mac or Windows from
files in Microsoft-compatible http://libreoffice.org.
.docx, .xlsx and .pptx formats The LibreOffice apps Base,
(among many others). Calc, Draw, Impress, Math and
Tired of Americanisms such Writer come pre-installed on the
as “color” appearing in your Pi. Note that the Draw program
work? Unlike Microsoft Office, can run slowly on older versions
The LibreOffice interface will be very intuitive to LibreOffice can install a version of the Pi – use the Raspberry Pi
anyone who has used office software before. that contains only UK English. 3 for best performance.

12 // // Spring 2017
Raspberry Pi apps TOP 20

Chromium
Surf the web in style with a shiny browser
Chromium replaced the former Foundation have included the
web browser Epiphany in the last h264ify browser extension,
major update for the Pi. As the which makes YouTube display
similarity of the name hints, it’s videos in a format that can be
related to Google’s Chrome web accelerated by the Pi’s hardware.
browser – Chrome derives most Also bundled with Chromium
of its source code from the open is the uBlock Origin extension,
source Chromium Project. One which blocks most annoying
consequence of this is that you popups and ads. They’re not just
can install many Chrome addons a pain but can slow down the Pi
such as the Google Hangouts dramatically if left unchecked.
plugin from the Chrome Web If you do not already have
Store (https://chrome.google. Chromium installed on your
com/webstore/category/ Raspberry Pi, back up any
extensions?). personal data, then open the
Chromium will support most of Terminal or connect via SSH and
your internet needs, although run the following commands,
you may find that playing certain one after the other, to upgrade
online games or streaming high to the latest version of Raspbian
quality video content is sluggish. complete with this new browser:
By default the Adobe Flash plugin is disabled. Click To assist with this, the good sudo apt-get update
“Always allow plugins” to enable them site by site. people at the Raspberry Pi sudo apt-get upgrade

Deluge
Download files via BitTorrent
The Pi supports a number of distributions can be downloaded
apps for downloading via this way), your ISP may restrict
BitTorrent, the peer-to-peer file or throttle BitTorrent traffic.
sharing protocol, but Deluge Consider using Deluge’s Blocklist
trumps them all in terms of the plugin to automatically block IP
sheer number of features. addresses of organisations who
If you run your Pi without a are likely to try to prevent you
monitor, Deluge can be accessed from using BitTorrent. See
via a web interface from another http://dev.deluge-torrent.
device. This is extremely useful if org/wiki/Plugins/Blocklist
you wish to download files while for full instructions. Blocklists
away from home. Simply open a themselves can be found at
browser and go to htt p:// www.iblocklist.com/lists.php.
ipaddressofyourpi:8112. Deluge You can install the Deluge
is protected by a password (the program using the Add/Remove
default is “deluge”). Instructions Software window. If you’re
are on the Deluge Wiki at http:// running your Pi without a
dev.deluge-torrent.org/wiki/ monitor and want to control
UserGuide/ThinClient. Deluge via SSH run the following:
While there is nothing illegal sudo apt-get install deluged
Access the Deluge web interface from another device in itself about downloading files deluge-console python-mako
by browsing to htt p://ipaddressofyourpi:8112. via BitTorrent (most Linux deluge-web

Spring 2017 // // 13
TOP 20 Raspberry Pi apps

VLC Player
Play and stream any type of media
To put it quite simply, VLC plays as YouTube clips from its
everything, from MP3 files, to Network tab.
Apple’s QuickTime format, to Another brilliant feature is
Windows Media Videos. This is the ability to convert files from
especially useful on the Pi as by one audio/video format to
default the Pi cannot play some another. This is especially useful
of the more exotic and non-free for people with Smart TVs that
media formats. VLC also has a can play only .avi video files.
handy plugin for your web Speaking of TVs, a Raspberry
browser to allow playing of Pi running VLC and plugged into
media files from websites. a TV can become a handy media
Although it is best known for centre, controlled by a web
being a universal media player browser. Enable this option in
with an unassuming interface, VLC’s preferences to allow you to
VLC has some extraordinarily select, pause and play music or
powerful extra features. For videos from another device.
instance if you wish to record Install VLC player via Add/
yourself using the Pi, VLC’s Remove Software. In order to
Capture Device option can play the range of video files
record whatever is running supported by VLC the system
on your desktop. VLC can also may ask you to agree to install VLC will play almost any media, and on a Pi connected
download online videos such some additional programs. to a TV can be the heart of a powerful media centre.

IceDove
Let your emails soar
IceDove is a version of the the cloud and send your
popular Mozilla Thunderbird recipient a link to them.
email program. Although the Pi You can extend IceDove even
does come with a built-in email further by heading to the Add/
client (Claws Mail), IceDove Remove Software window and
offers much more customisation. installing iceowl, which will
The mail setup wizard is very install a fully-featured calendar;
easy to follow, and all common another extension will also add
providers’ settings can be found support for Google Calendars.
in the Mozilla database. In most The default interface looks
cases you will simply need to rather dry but you can change
enter your email address and this by installing one of the many
password, and IceDove will then colourful themes. Go to Tools >
do the rest. Add Ons to see some of those
Aside from managing your on offer. There are also software
emails, it can also manage your add-ons for IceDove such as
news feeds and supports several Enigmail, which allows you to
chat services such as Google encrypt your emails.
Hangouts. IceDove also supports Install IceDove by going to
Filelink: as an alternative to Preferences > Add/Remove
sending large files, you have the Software and entering the IceDove is a more customisable email client, with
option to store attachments in name in the search bar. news feeds and chat, plus a range of available add-ons.

14 // // Spring 2017
Raspberry Pi apps TOP 20

Synaptic Package
Manager
Turbocharge your package management
Like Add/Remove Software available software for Raspbian
in Applications > Preferences, and update the Pi.
Synaptic is a pleasant graphical Another huge advantage of
front end for installing the vast Synaptic is that if you select a
number of programs available program for installation that
for the Pi. But if you already have requires others in order to work
something to install new apps, properly, it will automatically
why would you need Synaptic? mark these for download too.
First, Synaptic contains a good The buttons at the bottom left
many more categories than the help to narrow down the various
very broad ones offered by Add/ programs much more easily too.
Remove Software. Instead of one For instance clicking the Status
“internet” section, for instance, button followed by Installed in
you can select “Communication, the window above will list all
“Email”, “Networking” and so on. installed programs. Click Mark
Synaptic can also ensure that all Upgrades to automatically
you have the most up-to-date flag any programs that can be
version of each program. Click updated. When ready, click Apply Add/Remove Software is perfectly adequate. But
the Reload button to scan the to download the relevant files. Synaptic is much more, with useful extra capabilities.

Pidgin
Manage all your Messaging from one place
The popular cross-platform Pidgin can also be configured
messaging app Pidgin saves you in many ways. You can change
the trouble of managing multiple themes (icons, emoticons,
accounts like Google Hangouts, fonts etc.) by choosing from the
AOL Instant Messenger and thousands available online – see
Yahoo Messenger. All your https://developer.pidgin.im/
chats can be combined in one wiki/ThemingPidgin.
place. More chat protocols such For Pidgin plugins, see
as Skype and WhatsApp are https://developer.pidgin.im/
available via plugins (see below). wiki/ThirdPartyPlugins. Some
Sadly since Facebook dropped of these are quite benign and will
support for the open XMPP extend the messaging protocols
standard in 2014, Pidgin can Pidgin supports. The ultra
no longer be used to chat with paranoid can add the OTR (Off
Facebook contacts via the site. the Record) messaging plugin,
Pidgin does however also which will encrypt conversations
support IRC Chatrooms. By to allow you to chat privately
default it is configured for the over the internet.
huge Freenode network. Users Install Pidgin by going to
can join “channels” to discuss Preferences > Add/Remove
a huge number of topics from Software and searching for it Pidgin supports multiple protocols so you can chat
programming to jam making. using the bar at the top left. to a number of friends at once.

Spring 2017 // // 15
TOP 20 Raspberry Pi apps

GIMP
Edit all your photos professionally on the Pi
GIMP is an advanced image the level of transparency and
editor. It’s designed to be a colour of parts of any image.
serious alternative to some of Pi users can also make use
the expensive paid-for photo- of scripts written in Perl to
editing apps while still being automate common tasks – for
intuitive to use. GIMP contains example to bulk-convert a load
all the tools you’ll need for basic of .xcf images to .jpg and add a
image editing such as altering caption. You’ll find sample Perl
the contrast, cropping or cutting scripts plus plugins to extend
parts of an image. GIMP can also GIMP’s functions even further
open and convert various types in the GIMP Plugins Registry:
of image. This is particularly http://registry.gimp.org.
handy if you have a digital You might be surprised how
camera which takes high quality professional your images can
photos that you wish to reduce look after you spend just a little
in size to share over the web. time with GIMP. If you want to
Choose File > Export to make explore further, www.gimp.org/
them compact JPGs or similar. tutorials offers free tutorials.
More advanced features such Install GIMP by clicking
as selective colorisation are Preferences > Add/Remove
available through use of layer Software and searching for it You can select individual parts of an image to edit the
masks, allowing you to control using the bar at the top left. image further and/or export to a new image.

10
Dropbox Uploader
Sync, edit and delete your Dropbox files
There’s no official Dropbox client create a new app to allow the
on the Pi, although some other script to interface with your
cloud sharing services such as Dropbox account. Give it “full
Sparkleshare are supported. You access”. Once the app has been
can always access Dropbox by created, click Generate Token.
logging in using the Chromium Now copy and paste this into the
browser, but Andrea Fabrizi has Terminal window. The script will
created a command line script save it, and then will be able to
for basic Dropbox functions. access your Dropbox.
First connect via SSH or open A full list of all commands is
Terminal on your Pi and get the available at https://github.
necessary software with: com/andreafabrizi/Dropbox-
git clone https://github.com/ Uploader but the basic format
andreafabrizi/Dropbox-Uploader. for uploading is as follows:
git .dropbox_uploader.sh upload
Make the script executable pathtolocalfile /pathtoremotefile
and run it with these commands: For instance:
sudo chmod +x dropbox_ sudo ./dropbox_uploader.sh
uploader.sh upload /home/pi/letterlegal5.doc.
sudo ./dropbox_uploader.sh zip /docs/letterlegal5.zip
Select “Full Access” on Dropbox Uploader’s developer You’ll then need to visit www. The script displays a progress
page to allow the script to control your account. dropbox.com/developers and bar as the file uploads.

16 // // Spring 2017
Raspberry Pi apps TOP 20

11

SD Card Copier
Quickly and easily back up your entire Pi
As you start producing photos, a larger external drive for other
personal emails and intricate purposes, so consider devoting a
Minecraft structures on your Pi, USB stick solely to backing up/
you’ll want a reliable way to back transferring data.
everything up. While there are SD Card Copier is also very
various backup utilities available useful if you need more space
to install on the Pi, the built-in for new programs. Insert a
SD Card Copier will likely meet higher capacity SD card into a
your needs. It’s at Applications > card reader and connect to the
Preferences > SD Card Copier. Pi, then begin the copy process.
To begin the copy process, This will preserve all your
attach an external disk or other passwords, applications and
storage device and then select it other settings.
in the Copy To menu. Be warned If you have problems with
that the destination disk will be data corruption or media failure,
formatted before copying – any remove the current SD card and
files already on it will be lost. insert the backup one. You can
After copying, the resulting then use the utility in reverse,
drive will be an exact copy of the copying the contents of the
Pi’s SD card, right down to the current backup card to the
It looks simple, but SD Card Copier is very powerful. individual partitions. This can one you previously removed or
Back up any data already on the target drive before use. be problematic if you’re using restoring to a brand new card.

12
Zip Archiver
Create Zip files with a few mouse clicks
By default the Pi is capable of save the Zip file. Choose a
opening a range of compressed location, then click Archive Type
files such as Zip files. Simply at the bottom left and scroll to
right-click the file and choose the bottom to select Zip. Now
Extract Here. As you use the Pi click Create at the bottom right.
more, especially for email, you The Xarchiver program will
may well wish to compress files display a dialogue stating
as well. The Pi supports various “Adding to Archive” and the
Linux formats out of the box archive file will appear.
such as .bz2 and .tar, but these While adding support for Zip
are not particularly useful if you files, you may also wish to allow
wish to send a file or folder to the Pi to create and extract
Windows or Mac users. So install compressed files using the 7Zip
support for Zip compression by (.7z) format, which is more
clicking Preferences > Add/ efficient and supports options
Remove Software and searching such as splitting files and
for “zip”. The official name is encryption. Search for “p7zip”
“Archiver for Zip Files”. in the Add/Remove Software
Once it’s installed, you can window to do this. Once it’s
right-click on a file or folder and installed you will see .7z available
choose Compress. The system under Archive Type when you’re Install p7zip as well as Zip Archiver for compressing
will ask you where you want to compressing a file. and extracting using the ultra-efficient 7Zip format.

Spring 2017 // // 17
TOP 20 Raspberry Pi apps

13

FocusWriter
Pen a novel from the comfort of your Pi
Although the Pi does come with lines of text from The Matrix.
LibreOffice Writer pre-installed, There is also a more traditional
those who write for the love of “Writing Desk” theme.
it may find the options rather Although FocusWriter is
overwhelming, although not suitable for any kind of writing,
nearly as much as the urge to it’s clear that it has been made
quickly check on Facebook with those who love to write in
while working. FocusWriter is so mind. The Tools menu has timers
named because it runs as a full where you can set yourself goals
screen app, specifically designed as well as monitor your daily
to help you ignore distractions progress in terms of time spent
and get on with writing. writing or the number of words
Search for FocusWriter in the written. The Settings menu
search bar in the Add/Remove allows you enable Focus Text to
Software window. After installing highlight one or three lines, or
it you can launch the app from indeed an entire paragraph.
Applications > Office > The program can save
FocusWriter. Go to Settings > documents in plain text (.txt),
Themes to customise the Rich Text (.rtf) and the open .odt
appearance of your writing area. format. And did we mention that
Choose from several display options. Go to Settings > The “Old School” theme strongly FocusWriter makes typewriter
Focus Text to highlight individual lines or paragraphs. resembles the scrolling green sounds as you write?

14

USB Over IP
Access USB drives on your network
USB Over IP is a convenient way sudo usbip -D
to access drives over a network. Next connect your USB drive,
Once it’s installed on the Pi and and use the following command
set up, any device connected to to find its “busid”:
the network will be able to see usbip list -l
and modify files as if the drive A busid will be something like
were plugged into that device. 1-1.5. Bind it to your Pi with:
To install it, search for “usbip” sudo usbip --debug bind -b
in the Add/Remove Software (yourbusidhere)
window. The software also has to Once USBIP is installed on your
be installed on any client devices client device, you can run one
that are going to access the USB command from the Windows or
drive. Versions for both Windows Linux command line to make the
and Linux are available from USB drive accessible over the
http://usbip.sourceforge.net. network. See the SourceForge
Once installed, it needs only page for specific steps.
a few simple commands to start. Be aware that the USB device
Open Terminal or connect via will be available to anyone who is
SSH and start the usbip server connected to your network and
with the following commands: running the software. It also
sudo modprobe usbip-core doesn’t encrypt your data, so Your Bus ID may vary from those shown here. Use the
sudo modprobe usbip-host use it only on trusted networks. list command to discover your own device’s ID.

18 // // Spring 2017
Raspberry Pi apps TOP 20

15

DOSBox
Play the DOS classics with one handy app
If you grew up in the ’90s, you’ll no longer sold or supported by
remember DOS classics such as the copyright holder, meaning
Doom, Command and Conquer, prosecution is unlikely, but do
SimCity and the Ultima series. check that downloading games
Whether you’re nostalgic or is legal in your jurisdiction.
just curious, you’ll find that few Once you’ve downloaded the
machines are capable of playing Zip file of a game, extract it and
old DOS games natively. DOSBox copy the folder to /home/pi/
solves this problem by emulating dos-games. Launch DOSBox
old Intel x86 PCs, right down to from Applications > Games >
the DOS-like command prompt. DOSBox Emulator. Now you have
To install DOSBox, start by to mount the game. For instance
searching for “dosbox” in the to mount Neuromancer in the
search pane of the Add/Remove folder neuroman as drive C, type
Software window. After installing mount c /home/pi/dos-games/
it, create a folder in your home neuroman
folder named dos-games to Next, to access the drive, type
store your titles. C:, then dir to list the files. To run
Where can you find these? the game, simply type the name
One of the best known sites for of the .EXE file, for example
DOS classics is www.abandonia. NEURO. Press Ctrl+F1 inside any Neuromancer was all about the Matrix before the
com. Abandonware is software game to load the key mapper. Matrix was even cool. Relive the glory on your Pi today.

16

Guake
Become a Terminal virtuoso
No matter how accustomed you can tap F12 to have the Guake
are to graphical desktops and terminal drop down. Enter your
pointing-and-clicking, inevitably commands exactly as you would
there comes a time with the using the regular Terminal app.
Raspberry Pi where you will It’s much easier to pull up and
come to accept that using the dismiss, and you’ll also note that
Terminal is much easier. The the window is semi-transparent,
Pi’s built-in Terminal is adequate so you can see any apps running
but it can obscure your view of in the background.
the screen, and the black wall Right-click inside the Guake
of text can be foreboding to window to set its Preferences.
newcomers. Guake tries to These range from altering the
address these issues and others look and feel of the window to
by being easier on the eye and changing the keyboard shortcuts
much simpler to use. to show and hide Guake.
Guake is technically as a “top- Another huge advantage of
down” terminal. Install it via the Guake for budding programmers
Add/Remove Software window, is that it can open tabs which
then launch it from Applications are preconfigured to run Python
> System Tools > Guake programs. Usefully, Guake can
If you’ve played the game Quake you’ll recognise Terminal. A popup verifies that also open a new tab in the
Guake’s similarity to the game’s own chat terminal. Guake is running. By default you current working directory.

Spring 2017 // // 19
TOP 20 Raspberry Pi apps

17

Calibre
Convert, organise and share your ebooks
Calibre describes itself as a the metadata. This handy
“complete library solution”. It is feature allows you to type in the
perfect for anyone with a device correct author name and title.
capable of reading ebooks such Calibre can also search online
as the Amazon Kindle. for the correct book cover and
Install Calibre via the Add/ a plot summary.
Remove Software window, then Once a book has been
launch it from Applications > converted, you can then either
Office > Calibre. save it to a different folder on
On first run Calibre will ask the Pi or, if your device is
you some questions about your connected, effortlessly send it
e-book device and the format to the device’s main memory
it supports. For instance the using the buttons at the top of
Kindle can read both the open the Calibre window.
.mobi format and Amazon’s Another remarkably useful
own .awz3. You will then be able feature is Calibre’s ability to run
to add books to your library. A as an e-book server, which can
huge number of formats are be accessed by anyone via a web
supported. Before converting browser. Once your library has
into a format compatible with been set up, the Pi no longer
In the Calibre web interface, click on the cover of any your device, you can right-click needs a monitor, so you can run
book to download to your device. on one or more books to edit it “headless” if you wish.

18

Arduino IDE
Write code and upload to an Arduino board
The Arduino is a “microcontroller you can go to Tools > Boards to
motherboard”. Microcontrollers select from the dozens available.
are generally used to perform Install Arduino IDE using Add/
repeated actions – opening Remove Software by searching
doors, checking temperatures for “arduino”. To use it, go to
and so on. Arduino projects are Applications > Programming >
fantastic ways to get into both Arduino IDE. To start, you can
coding and electronics. While browse exciting sample projects
you can do this with the Pi itself, by clicking File > Examples.
the Pi is a full-blown computer, Like most programming
much more than is needed for platforms, Arduino can be
most such applications. extended further using Libraries.
The Arduino IDE (Integrated These provide extra functions
Development Environment) when working with new
makes it very easy to write code hardware or processing data.
and upload it to any Arduino For instance the LiquidCrystal
connected to the Pi. This is library enables you to control
usually done via USB, though connected Liquid Crystal
some boards can connect Displays. See www.arduino.cc/
wirelessly. By default the en/Reference/Libraries for a
To do more with a connected Arduino board, click Add software is preconfigured for the full rundown of the official
Library to import libraries downloaded from the internet. default Arduino Uno board, but Arduino libraries.

20 // // Spring 2017
Raspberry Pi apps TOP 20

19
YouTube Downloader
Download video clips from streaming sites
Although technically it’s possible “funnycatsandnicefish” as an
to use VLC Player (see page 14) MP4 file, you would enter:
to download and record video youtube-dl -o kitten.mp4
streams, the command line "https://www.youtube.com/
app youtube-dl makes it much watch?v=JlWlnBWVQLE"
easier to download videos from Be warned that the Pi may
streaming websites. The name is struggle to play high-definition
something of a misnomer as it is videos. These will also take up
actually compatible with several precious space. You can tweak
video sharing websites. the quality of your downloads
To install it, go to Applications with the -f (format) flag. For
> Add/Remove Software and instance, to ensure that the
search using the bar at top left video of Paris the fluffy kitten is
for “youtube-dl”. no more than 25MB in size, enter
Once installed it can be the above command like so:
launched at any time using youtube-dl -o kitten.mp4 -f
Terminal on your Pi. The basic 'best[filesize<25M]' "https://
syntax for downloading video is: www.youtube.com/
youtube-dl -o [name of output watch?v=JlWlnBWVQLE"
file] [YouTube URL] For a full rundown of all youtube-
For instance, to download a dl commands visit https://
video of Paris the fluffy kitten github.com/rg3/youtube-dl/ Download video clips using youtube-dl, then use the
from the YouTube channel blob/master/README.md indispensable VLC Player to play them.

20

Xpad
Smother your desktop with sticky notes
Xpad, which comes bundled contain important information
with some versions of Linux like vital internet links.
such as Lubuntu, is a handy app You can customise individual
for jotting down quick notes. notes even further by right-
To install it, go to Applications clicking on them individually and
> Preferences > Add/Remove selecting Properties. From here
Software and search for “xpad” you can choose to use the global
using the bar at the top right. Xpad theme or colour code a
Once it’s installed, launch Xpad note as you see fit. Click the +
from Applications > Accessories. button at the bottom left of any
Superficially Xpad windows pad to create a new note.
resemble Post-it Notes (other Right-click on the Xpad tray
brands of sticky label are also icon or any note to see the
available), but they can hold Note’s category. Each is named
unlimited amounts of text. Right- after the first line of text – for
click anywhere inside a window example “To Do”. Deleting notes
and choose Edit > Preferences to is just as simple. Just click on
change global settings. This will the wastebasket icon on any pad.
enable you to change the font, as Simply closing a note will not
well as the foreground colours. delete it, meaning you can have
You can also choose to lock your more notes than the available We don’t know if information wants to be free, but it’s
Xpad windows for editing if they space on your desktop. useful to have it to hand in customisable sticky notes.

Spring 2017 // // 21
POWER UP Super Pi

Push your Raspberry Pi to the limit with this


essential guide to enhancing and expanding
the best tiny PC known to man! Nick Peers
is your gamma ray source

he Raspberry Pi has as a desktop replacement or portable

T transformed the way we


look at computers and
computing. Thanks to its
ridiculously low cost of
ownership, you can build a fully
computer, capable of being powered
by batteries. Then we’ll reveal two
great ways in which it can be put to
more specific uses. First, as a media
centre or server the Pi’s low power
functional computer for under a demands coupled with its new quad-
tenner and put it to all kinds of uses. core processor make it a great tool
Sometimes that potential can be so for serving your music, video and
open as to seem overwhelming – other media wherever you are in the
this is a computer that has gone into home (or even further afield). Who
space, for goodness sake – but that even needs a quad-core Pi when the
shouldn’t stop you finding new and Pi Zero can perform sterling service
exciting ways to use it. as an audiophile-friendly music
The Pi’s versatility makes it the player or full-blown streaming stick?
perfect tool for just about any task And last but not least, the Internet
you could think for it to do. Looking of Things is all the rage, but there are
for a desktop computer to replace so many gaps and shortcomings in
your PC? The Raspberry Pi 3 has existing ecosystems that the Pi is
just about enough oomph – with an almost obligatory addition to your
the right support – to do that. How IoT setup. We’ll show you the key
about using it as a portable device? hardware considerations you need
A laptop maybe? Or at the very to follow, reveal a clever way of
least as a portable touch-friendly powering your Pi from up to 100
unit? No problem. metres away and deliver you a
In this feature, we explore how to software-building solution that will
build the ultimate Pi for use in a put you on the road to developing
number of essential and common your own IoT applications. Enough
roles. We’ll show you how to set it up preamble, let’s get stuck in…

22 // // Spring 2017
Super Pi POWER UP

Spring 2017 // // 23
POWER UP Super Pi

This aluminium
case from FLIRC
has a built-in
heatsink, which
works wonderfully.

The ultimate desktop Pi


Squeeze all the juice out of the Raspberry Pi for a desktop PC
he biggest advantage of using the Pi at then check out ModMyPi’s heatsink pack. It costs

T the heart of a desktop-based system is


its low cost. But if you want to eke every
last drop of performance from it, what do
you need to do? The first thing is – of course – to
£4, and pairs a 14mm-high sink for the CPU with a
10mm-high sink for the Ethernet controller. Again,
these should fit into most standard cases, but
won’t play nicely with any HATs.
choose the latest Raspberry Pi 3 model as the core An alternative is to look at the FLIRC case (£13,
of your desktop. It’s the fastest, most powerful Pi www.pi-supply.com). Its aluminium shell includes
yet, and you can squeeze additional power from it a built-in heatsink that basically protrudes from
through overclocking – setting the processor to a the shell to sit on top of the CPU and draw heat
higher speed (we’ll explain more over the page). away from it. The result is that your overclocked Pi
Overclocking raises the next issue: how can you 3 won’t max out at more than 65 degrees Celsius,
keep your Pi from overheating? The solution is to but again there’s no room for any HATs.
add a heatsink. You can purchase these for as little One final recommendation is to shell out for the
as £1 each from the likes of Pimoroni, but choose latest version of the official Raspberry Pi 3 power
carefully: the 7.5mm sink will dissipate that bit supply. It should supply 5.1V and 2.5A of power,
more heat, but you won’t be able to fit a HAT on as compared to the 5V/2A offered by older and
top of it. If this is a deal-breaker, choose the 6mm unofficial models. Doing so will give you all the
model. If you want to push things even further, juice you need to push your Pi that bit further.

A TRUE DESKTOP PI
If you want your Pi to form the heart of an to purchase a pi-topPROTO accessory,
all-in-one device, then visit www.pi-top.com which plugs into the mag rail and slides
to learn more about the Pi-topCEED, a into place on it. There’s also an optional
desktop-friendly chassis with built-in speaker component for adding sound.
14-inch HD screen (1,366x768 resolution) You can pick up a PiTop CEED Pro in
and space behind for your Raspberry Pi green or grey from £119 including VAT
(you can purchase it with or without a Pi 3). from RS Components (https://uk.rs-
Fitting is incredibly easy – remove the online.com). It’s undoubtedly an
front panel from beneath the display to attractive way to house your desktop
reveal a generous space for your Pi and any Pi, although the screen is a little small.
add-on boards you want to include. Hook
up the Pi to the HDMI cable, place it on the
mag rail and slide it to the end, where it An attractive way to house
clips securely into place. HATs and other a desktop Pi, although the
add-ons are easy to install too – you’ll need screen is a little small.

24 // // Spring 2017
Super Pi POWER UP

The Pi 3 has one other major advantage over better results – the SanDisk Cruzer Ultra and The clever
earlier models: it supports USB booting. This Extreme 32GB and 64GB drives have been Pi-topCEED turns
means that with a bit of work (see Run Ubuntu reported as both compatible and recommended your Pi into an
Mate from USB, over the page) you can pair it with thanks to their superior performance. all-in-one desktop
computer – see
a USB flash or SSD hard drive to deliver a more If you’d like your Pi to turn heads, then check
opposite page.
responsive experience. Some users have reported out the True Desktop Pi box opposite for details
success powering SSD drives from the Pi 3’s USB of an all-in-one chassis that includes a 720p
port using a Y-splitter cable, but we found the drive HD display. Speaking of displays, the Pi 3
was unstable and threw up errors when creating can output 4K on a suitable monitor, but
the root filesystem. If you fall into this category, you’ll need to tweak the config.txt file to
you’ll need to power the drive separately using its add a suitable mode at 15Hz:
own dedicated supply. hdmi_cvt 3840 2160 15
If you’re in the market for a suitable USB drive, You may also want to consider another
the obvious choice is the PiDrive range from distro in place of the standard Raspbian
Western Digital (http://wdlabs.wd.com) if you’re – Ubuntu Mate (https://ubuntu-mate.
after a larger hard drive, but SSD and flash drives org/raspberry-pi) is a slick alternative,
will produce better performance. Despite the USB but is a bit more demanding. We
2.0 bus, it appears USB 3.0 flash drives produce cover both in the next section.

Boost performance
Want to use your Pi as a desktop replacement? Here’s what you need to do
ou’ve purchased your kit and you’re

Y ready to build your ultimate desktop


system. First things first: which distro
will you choose? The obvious one is the
default Raspberry Pi operating system Raspbian,
but if you’re put off by its rather basic interface,
then Ubuntu Mate should appeal. It provides a
slicker, more desktop-like environment, but isn’t as
well supported and there’s a performance price to
pay for those bells and whistles – a slight trade-off
between desktop-like appearance and desktop-like
performance – although you’re less likely to feel
the pain with the Pi 3. If Ubuntu Mate sounds like
it could be your kind of thing, check out the Run
Ubuntu from USB box over the page.

Boot into Raspbian from USB problem might be down to the need for a longer To overclock
Instructions for preparing a Pi 3 for booting from delay at startup to allow the drive to be detected, your Pi 3 you’ll
USB 3.0 can be found at www.raspberrypi.org/ so followed the workaround at www.raspberrypi. need to edit the
documentation under Hardware > Raspberry Pi org/documentation/hardware/raspberrypi/ /boot/config.txt
file – it can’t be
> BootModes > Mass Storage Device. To put it bootmodes which involves formatting a SD card
done from the
simply, you’ll first update your Pi’s firmware with (any size will do) in FAT32 and placing an updated raspi-config tool.
the experimental boot files, then enable USB boot bootcode.bin file on it along with an empty file
mode. Reboot to test, then connect your USB you name timeout. With this in place, we were
drive and use parted to format it correctly with a able to run Raspbian from the USB drive.
100MB FAT32 partition and Linux ext4 partition. You may or may not notice an improvement in
You then create the boot and root filesystems, boot times, but you should quickly find that your Pi
mount the new filesystems and copy your is a little more responsive, which you can confirm
Raspbian system to it. Regenerate SSH host by benchmarking the drive using dd and hdparm :
keys, edit the boot files to look for the USB drive, $ dd if=/dev/zero of=~/test.tmp bs=500K
unmount your filesystems and then power off your count=1024
Pi. Remove the SD card, reconnect the power and $ sudo hdparm -t /dev/sda
if all is well you’ll be booting from your USB drive. By using dd , we get the drive’s sequential write
Sadly, the process isn’t guaranteed to work with speed by writing a 500KB file 1,024 times, while
all drives – we were unable to get our Kingston hdparm provides the drive’s sequential read
SSDNow 64GB drive mounted in a StarTech speed. We performed each test five times to get an
chassis to boot directly as a result. We thought the average score – the SSD drive managed 30MBps

Spring 2017 // // 25
POWER UP Super Pi

RUN UBUNTU MATE FROM USB


If you want to run Ubuntu Mate from your of where block sda2 starts (typically it’s Once resized, verify the change via df -h
USB drive, then you will need to follow a 133120). Now type d and hit Enter, then and then use sudo blkid to identify the
different procedure. The step-by-step choose 2 to delete the second partition. drive’s UUID. Next, sudo nano /etc/fstab to
guide (below) reveals the prerequisites— Press n and hit Enter to create a new edit the line from /dev/mmcblk0p2 to
you basically copy the Ubuntu Mate partition and type p for Primary partition UUID=e440adac-fcf9-4b68-9f94-
installer to your USB drive and copy the followed by 2 . Now enter the figure you 6bfd030f60b3 (or whatever your drive’s
boot partition to a freshly formatted micro noted earlier (133120 in our case) and hit UUID is). Save the file, reboot and you are
SD card for the initial installation. Enter, then hit Enter again to fill the finished. Note: You will still need to keep the
All being well, you should be able to boot remaining space. Finally, press w and hit micro SD inserted for Ubuntu Mate to boot,
from your micro SD card, which then Enter to make the changes. You’ll see the but it should be a bit more responsive, and
switches to the USB drive to complete the warning, so reboot by typing you shouldn’t have any problems booting
installation. Once you’re logged in properly, sudo reboot even when other USB drives have been
open a Terminal window and type the Once rebooted, open another Terminal attached. We’d recommend that you visit
following command: window and complete the resizing process http://bit.ly/Pi2UbuntuMateSetup as
$ sudo fdisk /dev/sda with: well for some other tweaks and tips to try
Type p and press Enter to make a note $ sudo resize2fs /dev/sda2 out for optimising Ubuntu Mate.

(write) and 33MBps (read), compared to 8MBps Sadly not all Pi 3s are equal, and you can’t
and 20MBps respectively for the SanDisk Ultra SD overclock using the official Raspbian configuration
card. It’s worth noting that these aren’t true real- tool (or raspi-config for that matter), but don’t let
life tests – random read/write times will see a that stop you, because you can easily overclock
smaller gap between the two – but a fast USB your Pi by editing the /boot/config.txt file.
drive will still be a step up, nonetheless. There’s actually three things you can overclock:
the processor, obviously, but also your Pi’s RAM
Overclock your Pi and GPU too. A list of suggested settings for all
If you’re looking to eke that bit more performance these can be found at https://github.com/
from your Pi, then obviously overclocking – that is, retropie/retropie-setup/wiki/Overclocking.
manually cranking the processor up to a higher We’d suggest sticking with the more modest
speed than its default setting – is the way to go. 1.35GHz overclock and skip the GPU overclocking

INSTALL UBUNTU MATE TO YOUR USB DRIVE

1 Download and Install 2 Write to USB drive 3Copy the root


First you’ll need to go to the website Insert your USB drive into your Pi and partition
https://ubuntu-mate.org, click the umount it if necessary. Now type the Insert a spare micro SD card using
Download button and download the following to identify it: a USB adaptor and format it using
Raspberry Pi build to your internal sudo lsblk FAT32. Next, copy the contents of
storage. This will be in XZ compressed For example, you’ll see drives your USB drive’s boot partition to
format, so open a Terminal window designated as /dev/sdb or /dev/ the micro SD card. Now open the
and type the following command: sdc). Now type the following cmdline.txt file on the micro SD card
$ sudo apt-get install gddrescue xz-uti command, replacing the /dev/sdc and change the /dev/mmcblkp2
&& cd ~/Downloads designation in the example with the reference to
$ unxz ubuntu-mate-16.04-desktop- correct device name: /dev/sda2
armhf-raspberry-pi.img.xz $ sudo ddrescue -D --force ubuntu- Save the file and exit. Plug the USB
mate-15.10.3-desktop-armhf-raspberry- drive into your Raspberry Pi, insert
pi-2.img /dev/sdc the microSD card and connect the
Now wait while the image is written power to start installation.
to the drive.

26 // // Spring 2017
Super Pi POWER UP

section (the gpu-mem setting refers to the PC. One of the remaining bottlenecks is the 1GB of Ubuntu Mate
amount of memory you allocate the graphics RAM – this is perfectly fine for one or two tasks, can be run from
card – 128MB or even 64MB should be adequate but you’ll need to keep your aims realistic and a USB drive too,
for basic desktop use) unless you’re looking to avoid opening too many applications or browser but you’ll still
need a microSD
boost your gaming performance. tabs at once. Train yourself to keep things lean
card for booting.
There are two things to consider. First, how do and mean, and you’ll be able to enjoy perfectly
you verify that the overclock settings are in place? adequate performance for basic desktop tasks
Use the following command to determine the such as web browsing (including using cloud
minimum and maximum clock speeds: applications) and office work.
$ lscpu | grep "MHz" One final tip: both Epiphany (Raspbian) and
Second, how can you tell if your overclock is Firefox (Ubuntu) browsers struggle to render
stable? Keep an eye on the CPU temperature by certain websites, particularly those loaded up
displaying it in the menu bar: right-click the menu with JavaScript. The simplest solution is to switch
bar and choose Add/Remove Panel Items. Click browser to Chromium, particularly if you’re
Add and select Temperature Monitor. You can then planning to make use of Google services like Drive
keep an eye on the temperature while you make
use of your Pi. Anything under 80 degrees is fine,
but with luck your cooling system will ensure that YOU CAN OVERCLOCK THE
even when overclocked your CPU temperature
remains under 60 degrees.
PROCESSOR, OBVIOUSLY, BUT
For a more in-depth look at overclocking, ALSO YOUR PI’S RAM AND GPU
including some other tweaks you can apply
(such as forcing your processor to always run in
performance mode), check out Jackenhack’s blog or Docs. Ubuntu Mate users can install Chromium
post at www.jackenhack.com/raspberry-pi-3- through the Software Center, but it’s not available
overclocking. There’s a mention of running a through normal means to Raspbian Jessie users.
custom Linpack script in the comments to No matter – just open a Terminal and enter the
stress-test your Pi, but we found that it locked up following to download and install it:
our Pi even without overclocking, and there’s a $ wget -qO - http://bintray.com/user/download
long discussion about what this means at http:// SubjectPublicKey?username=bintray | sudo apt-key
bit.ly/LinPackStressTest. add –
$ echo "deb http://dl.bintray.com/kusti8/chromium-
Desktop performance tips rpi jessie main" | sudo tee -a /etc/apt/sources.list
Even with its quad-core processor, the Pi 3 isn’t $ sudo apt-get update
going to provide you with the same level of $ sudo apt-get install chromium-browser rpi-
performance as even a modestly specified modern youtube -y

Spring 2017 // // 27
POWER UP Super Pi

The ultimate portable Pi


Discover how to take your Pi on the road with a portable touchscreen
he Pi’s small size and modest power You can power the display one of two ways, the

T demands make it the perfect candidate


for use as a portable device, and thanks
to the range of cases, displays and
battery power options out there, you can configure
most convenient of which is via the 2-to-1 micro
USB cable, which delivers power to both the Pi and
the display from a single power cable. With this in
mind, we recommend the newer 5.1V official power
it just about any which way you choose. We’ve supply, particularly if you’re planning to use HATs,
decided to build our ultimate portable Pi around which sit happily on top of the Pi’s cover. (You can
the official 7-inch touchscreen, but see the box purchase an optional ribbon connector to extend
below for alternatives you might want to consider. them to the front of your Pi too.)
The official touchscreen costs around £55 from
any reputable Pi outlet. You’ll also need to buy a Smart screen
suitable stand and case to attach your Pi to. There The only drawback with the SmartPi is that the
are plenty of options; we’ve plumped for the clever Pi’s own HDMI port is hidden away out of reach,
SmartiPi Touch case (£20, www.modmypi.com). which makes it impossible to connect up a second
The touchscreen fits snugly inside, secured by four display. (If this is a deal breaker, examine an
screws, and there’s a compartment on the back for alternative such as the £15 black touchscreen case
Free your
your Pi too, with all key ports left accessible (the from The Pi Hut – visit https://thepihut.com.)
portable Pi from micro SD card is the only exception, but thanks to All four USB ports and the Ethernet port are
the mains supply the design of the clickable cover that holds it in accessible, as is the 3.5mm audio jack for
by installing the place, it’s easy enough to take out, flip over and connecting to a speaker or headset. The case also
MoPi add-on. swap out the card). comes with a LEGO-compatible camera case that
clips neatly onto the front for video conferencing
(and there’s a handy slit in the compartment cover
for slipping the camera cable through).
The case comes with an adjustable stand,
which allows you to use it on any surface. More
permanent fixtures are provided – there are 75mm
VESA mount holes, and two small metal screw
mounts are included – but for portability you’ll be
wanting to use the stand.
Construction is simple thanks to an online
video; give yourself five to ten minutes and by
the end your Pi will be snugly fitted along with
the touchscreen, your camera mounted to the
front and your HAT sitting happily on top of the
compartment cover. If you’re worried about
overheating, the cover includes a knock-out for
a 6mm CPU heatsink.
We also recommend downloading the latest
version of Raspbian Jessie from www.raspberrypi.
org (click Downloads > Raspbian), and once it’s
installed bringing it fully up to date with:
$ sudo apt-get update

ALTERNATIVE FORM-FACTORS
You don’t need to build a portable Pi around inch display and keyboard, follow Chris with case, Wi-Fi dongle, tweaked Raspbian
the official 7-inch touchscreen. If you’ve got Robinson’s guide at https://youtu.be/ install (with LCD drivers) on an 8GB
£225 to spare, you can purchase the Pi-Top, NMkhRK2lV0E – it’ll cost you under £100, microSD card with a 3m long power supply.
a full laptop chassis with keyboard, 13.3- but you’ll need to be a bit of a whizz with a The main issue here is with the screen size
inch HD screen (1,366x768) and smart hacksaw blade and glue gun as well as a – while it’s technically possible to run the
battery offering up to 10 hours of life – soldering iron. Raspbian desktop environment, you’ll
see www.pi-top.com/product/pi-top. A simpler – and cheaper – way to add need to optimise it for the smaller
Or you could go to the opposite extreme a 3.5-inch display to your Pi is through screen. There’s space for around six
and experiment with a 3.5-inch resistive SB Components’ LCD Control Case (from desktop icons, for example, and you may
touchscreen. For a guide to building your £26, shop.sb-components.co.uk), which find it’s more suited to Terminal use as
own Nintendo DS sized computer with 3.5- comprises a 320x240 resistive touchscreen well as mobile-friendly interfaces.

28 // // Spring 2017
Super Pi POWER UP

ADD RIGHT-CLICK TO THE TOUCHSCREEN


On the whole, the touchscreen works well rebooting as instructed, however, you need $ twofing --debug
as a mouse substitute, but it lacks right- to perform some additional steps. First, If successful, this should launch the
click support. The solution given on the create a .rules file: calibration screen. Simply press Ctrl+c to
Raspberry Pi website works only in Wheezy, $ sudo nano /etc/udev/ exit, then type twofing and hit Enter to
but a better solution exists in the form of rules.d/70-touchscreen-egalax.rules launch it. Close the Terminal window and
twofing, which allows you to generate a Add the following line, then save and exit: experiment with tapping the screen with
right-click by tapping the screen using KERNEL=="event*",ATTRS{name}=="FT5406 two fingers and you should see the right-
two fingers. memory based driver",SYMLINK+="twofingtou click menu pop up. Finally, to have twofing
First, go to http://plippo.de/p/twofing ch",RUN+="/bin/chmod a+r /dev/twofingtouch" run automatically in future, add this line to
for the basic instructions on downloading $ sudo cp twofing /usr/bin/ ~/.config/lxsession/LXDE-pi/autostart:
and compiling the package. Before Reboot, then test it with the following: @/usr/bin/twofing

$ sudo apt-get upgrade best – AA rechargeables would supply 4.8V in


If you wish, you could also bring the firmware up to total, which would drop as the batteries
date using the following: discharged, while AA alkaline would supply 6V,
sudo rpi-update which is outside the Pi’s tolerance range.
This has no bearing on the performance of the The simplest solution is to power your Pi
touchscreen, although some users have reported using any kind of portable battery that’s used to
that the Pi’s CPU temperature drops by a couple recharge smartphones. Make sure they have a 5V
of degrees through reduced load. output setting, and then all you need to do is plug
You can plug in a wired keyboard and mouse, one into your Pi to power it up.
but you might want to consider going down the But what size battery should you go for? It all
wireless route; most wireless keyboards, including depends on your needs. First, determine how
Ebuyer’s own Xenta-brand range, should work fine. much power (measured in milliamps per hour
To save space, pick one with a built-in touchpad. or mAh) you’ll need to supply – not just to the Pi
You can, of course, interact with the touchscreen (up to 1,200mAh), but also to your touchscreen
itself, but it’s handy to have an alternative. (around 500mAh) and any other devices (the
If you find the backslash key is missing from camera requires 250mAh, for example). If you
your wireless keyboard, don’t panic – you can get want to calculate the power draw of your USB
the backslash character by holding the Alt Gr key devices, use the following command:
and hitting -, and then the | (pipe) symbol is $ usb-devices | grep 'Product=\|MxPwr'
obtained by holding Alt Gr as you hit the ` key in Tot up the figure and the result – 2,000mAh or
the top left-hand corner of the keyboard. upwards – is how much power you’ll need for each
If you’d rather avoid using any form of wireless hour of use. In theory this means a 10,000mAh
keyboard, you’ll need to add an onscreen keyboard battery will supply five hours of use, but in practice
to Raspbian with: it’s usually less because of the way they’re
$ sudo apt-get install Florence manufactured, plus the fact that batteries’
Once installed, Florence is run from the capacity drops over their lifetime.
Universal Access menu. You’ll see the onscreen An alternative way to supply portable power to
keyboard appear, plus a small floating keyboard your Pi is with the MoPi add-on (£25, https://
tile, which you tap to bring the virtual keyboard shop.pimoroni.com). This plugs into your Pi’s
to the screen and then dismiss it again. Sadly, it GPIO pins and enables you to connect a wide
doesn’t work well with the Terminal, so keep a variety of batteries, from solar and car batteries to
USB keyboard to hand. standard (and rechargeable) AA batteries, using
Elsewhere, the touchscreen works well as standard screw terminals. There’s also a handy
a mouse substitute, but there’s no right-click on/off button, and the MoPi will cleanly shut down
support and the recommended solution on the your Pi when power drops below a certain level.
Raspberry Pi website works only with Wheezy and You can even use it in conjunction with mains
not Jessie. However, there’s a workaround that power, which turns it into a handy UPS backup.
simulates a right-click using two fingers – see To keep things as portable as possible, we
Add Right-Click to the Touchscreen above. paired a MoPi with eight rechargeable AA batteries
using a cheap AA battery holder. The MoPi
Portable power supports input voltages from 6.2V up to 20V, so
As things stand, you have a compact, all-in-one you’d need a minimum of six rechargeable 1.2V AA
solution for your Pi that’s hamstrung by one batteries, but we’ve gone for eight because you get
critical problem: you need to be connected to longer battery life and it’s one of the default supply
mains power in order to use it. That’s a problem profiles – all you need to do is remove the small
that’s easily fixed, and how you do this depends jumper on the underside of the MoPi. Just follow
on your needs. The key consideration is that you the step-by-step guide (https://pi.gate.ac.uk/
supply a steady 5V of input, so you can’t simply pages/mopi.html) and you’ll soon have your
connect up four AA batteries and hope for the portable Pi running independently of mains power.

Spring 2017 // // 29
POWER UP Super Pi

The ultimate media Pi


Build a Pi-based media centre, audio player or media server
here’s one thing the Pi is brilliant at, and > NAS and Media Server > Install Plex Media

T that’s media. Whether you’re looking for


an audiophile-friendly music player, a
simple set-top box for playing media
through your TV, or a full-blown media server for
Server… for a suitable image and guide.
However, in the interests of flying the FOSS flag,
we’ve plumped for Emby Media Server. It looks as
good as Plex, although it isn’t as well tested on the
accessing your digital media from anywhere, Pi. You’ll find the basic steps required to get the
there’s a Pi capable of delivering what you want. server up and running in the guide at https://
In this section, we’re going to focus our efforts on akosresch.wordpress.com/2016/05/11/
creating a Pi media server, which will allow you to installing-emby-server-on-raspberry-pi-3. You’ll
share all your video, music and photos with your need to install imagemagick and the Mono library,
other devices, both at home and further afield. and then it’s a case of downloading and installing
For the purposes of this project, we’ll focus on the Debian version of Emby Server.
the Raspberry Pi 3, largely because it delivers Before launching Emby Server for the first time,
enough oomph to run a media server comfortably. we recommend doing the following, which will
But there are other benefits too – the Wi-Fi, in simplify issues accessing your media folders by
case you don’t want to site it next to your router, making Emby run under your Pi user account:
and support for USB booting should you decide $ sudo nano /etc/emby-server.conf
to dump the micro SD card in favour of an all- Add the following line to the end of the file
purpose drive for running your server as well as before saving and closing:
storing your media on. EMBY_USER=pi
The big choice you need to make is which We’d also suggest you apply the FFmpeg fix.
media server to run. Kodi’s built-in media server First type the following command:
will work, of course, but the experience isn’t as rich sudo apt-get install git
It’ll take a
on non-Kodi devices in terms of delivering artwork Once that lengthy process is complete, type the
little while, but and metadata to help you identify what you’re following to start up Emby:
eventually Emby watching or listening to. We’ve successfully run $ sudo service emby-server start
will show off your Plex Media Server on both a Pi 2 and a Pi 3 for a The server should now be up and running. Use
media collection number of years now. If this appeals, check out the ifconfig command to determine your Pi’s IP
in all its glory. www.htpcguides.com – go to Pi > Rasp Pi 2 and 3 address, then switch to another computer and
type the following into your web browser
(replacing 192.168.x.y with your Pi’s IP address):
192.168.x.y:8096
If Emby has been set up correctly, you’ll be shown
the setup wizard. Going forward, this is also how
you’ll administer Emby – through a web browser.

Next steps
One of the biggest issues with Emby is gaining
access to your stored media. Start by creating a
mount point:
$ sudo mkdir /media/emby
If your media is stored on an NTFS-formatted USB
drive, you need to first add the following:
$ sudo apt-get install ntfs-3g

AUDIOPHILE-FRIENDLY MUSIC
Imagine an inexpensive, pocket-sized audio required software to download at the adapter (£22) and suitable case (£15.60).
player delivering superb quality digital website, www.pimusicbox.com. The Pi-DigiAMP+ delivers up to 35W stereo
sound through your home stereo or even a We paired a Pi Zero with the superlative to a pair of two-wire speakers, which
pair of headphones. No, we’re not talking Pi-DAC Zero (from £12, www.iqaudio. connect directly to its speaker terminals.
about your smartphone or tablet, but a co.uk) and the Pi MusicBox distro to deliver How about building an internet radio, or
standalone audio player streaming music a headless audio player based on Mopidy. turning any speakers Wi-Fi-capable to play
from Spotify, SoundCloud, Google Music, Find the project at www.mopidy.com. music from a connected USB device, NAS
web radio or local music files. That’s the If you’d like to build a standalone audio or mobile device? We tackled these two
thought behind Pi MusicBox, a Pi-based receiver, then you can pair your Model A/B projects in the last issue of Pi User. If you
project. You’ll find all the details and the Pi with the Pi-DigiAMP+ (£55), power missed it, visit http://bit.ly/pi-user-01

30 // // Spring 2017
Super Pi POWER UP

BUILD A PI ZERO STREAMING STICK


If you want to build a Raspberry Pi-powered port hub and Wi-Fi from a single plug. Get it dedicated supply. If you want to free up
media centre you can tuck behind the TV, for £10 from most reputable Pi stores – see your keyboard for some other project,
you can pair a Pi Zero with the OSMC www.modmypi.com.) you can control OSMC using any Kodi-
(www.osmc.tv) distro, which offers an Once set up, you can remove the adaptor compatible mobile app – for example try
optimised version of Kodi for lower-end and replace it with a smaller Wi-Fi adaptor using Kore for Android.
machines. The initial setup requires access – we’re particularly fond of the Pi Zero Wi-Fi For more help and advice, including
to a wireless hub to give you a wireless micro USB dongle from ModMyPi at £8, for some handy tips for streamlining a Kodi
connection and USB keyboard/mouse for example. While you can technically power installation to improve performance on the
the initial configuration. (We suggest the your Pi Zero from your TV’s USB port, this Pi Zero, check out our guide on TechRadar
Broadcom Adaptor, which provides a two- is not usually reliable – instead, use its own at http://bit.ly/kodi-on-pi-zero

Now plug the drive into your Pi and type sudo


blkid to obtain the UUID of your mounted drive.
Write this down, then type sudo /etc/fstab to
have it automatically mount at startup. Add the
following line if it’s a FAT32 drive, replacing the
<UUID> with your drive’s UUID:
UUID=<UUID> /media/emby vfat
iocharset=utf8,rw,umask=000 0 0
If it’s an NTFS drive, use the following for read/
write access:
UUID=<UUID> /media/emby ntfs defaults,uid=
1000,gid=100,dmask=027,fmask=137,utf8 0 0
You can also mount network drives too – so if
your media is stored on an NAS drive, you can
identify it using the smbclient tool as follows,
replacing the “192.168.x.y” with your network the Home button in the top left-hand corner to OSMC will
drive’s actual IP address: browse your media. At first, you’ll see colourful happily run on
sudo apt-get install smbclient squares representing movie and other media, but a Pi Zero – and
smbclient -L 192.168.x.y over time, as Emby downloads metadata from the once you’ve
done the initial
Armed with this information, you can then internet, these will be replaced with proper artwork
configuration it
populate the fstab file with something like the as well as information about the shows, movies or
can run headless.
following, replacing “192.168.x.y” with your music in question.
network drive’s IP address, <sharename> with the This can take some time to complete – this
folder you wish to access, and <username> and is the Raspberry Pi, after all – but you can
<passwd> with the username and password immediately test your server by attempting to
required to access the share in question: watch or listen to your library through the web
//192.168.x.y/<sharename> /mnt/<share1> cifs user browser. Click the Play button next to a title and
name=<username>,password=<passwd>,uid=1000, wait for it to start – again there will be a short
gid=100 0 0 pause, but if all has been set up correctly, your
Save, exit and umount -a before cd /media/emby media should begin to play correctly, indicating
and ls -l to verify that the drive has been mounted that it’s now accessible.
and that your user has the required permissions to From here you can explore the various ways of
read and write data to and from it ( drwxr-x--- on enjoying Emby-hosted media on other devices.
USB drives, drwxr-xr-x on network drives). Return to the Dashboard by clicking the menu in
the top-left hand corner followed by Manage
Get set up Server, and you can then set up other libraries,
With your media drive now visible, it’s time to get manage multi-user access and perform other
up and running using the Emby setup wizard in tasks. For more about Emby Server and what it
your browser. While stepping through this, avoid can do, see the tutorials and guides on the Emby
any processor-intensive options like “Enable Community site at https://emby.media/
chapter image extraction” when setting up your community/index.php?/forum/49-server –
libraries. Also, if you’re booting from a small (8GB but note that some of the features covered, such
to 16GB) SD card, we recommend ticking “Save as setting up live TV support, are probably beyond
artwork and metadata into media folders” to store the capabilities of your Pi, and quite a few require
all the data on your media drive. some technical expertise to implement. We also
You’ll also be prompted to set up FFmpeg recommend restricting the Raspberry Pi’s use to
during the setup process – choose the “system purely serving locally hosted media that’s been
installed version” when prompted, then click Next. saved in a universal format (MP4 container,
From here it’s all pretty straightforward and you’ll H.264/MP3 codecs) to save the Pi the job of
soon find yourself at the Emby dashboard. Click having to try to transcode the stream.

Spring 2017 // // 31
POWER UP Super Pi

The ultimate IoT Pi


Build a cheap and effective IoT device using a Pi Zero
e’re still waiting for a single Internet

W of Things standard to emerge, and


chances are it never will. In the
meantime, each time you purchase
a piece of IoT kit from one manufacturer, be it a
motion sensor, security camera or smart lighting,
you’re gambling that it will not only work with your
current ecosystem but also prove flexible enough
to work with others should the horse you’re
currently backing fall out of favour. And let’s not The PoE Switch Hat powers your Pi using an Ethernet
talk about updates that break compatibility with cable – but you’ll need a suitable PoE injector or switch.
older devices, eh SmartThings?
Services like https://ifttt.com go a long way want to pack into a single unit. It’s also easier to
to helping bridge the digital divide between add HATs including one that provides you with the
devices, but why rely on a manufacturer’s piece of means to power your Pi from its Ethernet port.
expensive kit when you can custom-build your own Next, consider your device’s main purpose. If
versatile IoT gadgets using a Pi or Pi Zero? In this you want to use it as a camera, for example, then
project, we’re going to reveal the kit you need to ask yourself whether you want a camera for
build a core IoT device, then look at ways of adding daytime or night-time use – pick the Pi-NoIR
to it and integrating it into various ecosystems. model for the latter, paired with an infrared light
source. If you plan to use the camera with your Pi
Build your base unit Zero, remember to purchase the required cable
The key consideration for your IoT device is which (an extra £4). Also take the time to examine what
model of Pi you want to build it around. The Pi Zero cases are out there – two in particular caught our
is on the surface the obvious choice thanks to its attention. The ZeroView (£7, thepihut.com) is a
small size and low cost of entry, although you need clever case and mount for the Pi Zero that
to factor in additional effort and cost: in particular, attaches to glass surfaces, such as a window, and
you’ll need to be confident using a soldering iron provides you with the means to monitor what’s
to add on much-needed functionality, such as the happening on the other side with minimal glare or
GPIO pins and even an alternative power source, reflection. Or look at the Pi Camera Box Bundle
as we’ll see shortly. (£24, www.modmypi.com), which provides a case,
At the other end of the scale, the Raspberry Pi 3 wide-angle lens and wall mount for Pi B+, 2 and 3.
has the added advantages of built-in Wi-Fi and Another potential use for your IoT device is as
Bluetooth, and its extra processing power may be a sensor. The two obvious choices here are the
vital depending on how much functionality you SenseHAT (£25, from various outlets) for the main

BUILD YOUR OWN SOFTWARE PROJECTS


Python programming skills to make use image to a suitable microSD card – you
of its extensive libraries. If you’re just can also add Wyliodrin to an existing
starting out with programming or feel that installation via a lengthy script, but it
you want more flexibility in this kind of takes hours to complete. Once this is done,
project, you should take a look at the embed a custom .JSON file that links your
open-source Wyliodrin IDE. Raspberry Pi to your Wyliodrin account and
Wyliodrin is a web-based platform that reboot. As soon as you’re logged in, your Pi
tries to simplify the programming process should appear online in your Wyliodrin web
by supporting a wide range of languages console, ready for you to program.
in a platform-agnostic way to let you put From here the simplest approach is to
Get started programming your IoT device your projects together using a more user- install the Wyliodrin STUDIO Chromium
in Wyliodrin STUDIO by using the Visual friendly building-block approach called extension. This extension supports
Programming component. “Visual Programming” while the code is JavaScript and Python, but it also gives
written for you in the background. you Visual Programming as an accessible
Okay, so you’ve set up your hardware, but You’ll need to start by signing up for a way into coding, and the dashboard helps
how do you go about integrating these new free account at www.wyliodrin.com, then to visualise what you’re actually doing. Of
devices into your IoT infrastructure? While input the basic details of your Pi – its type course, if you’re already a programming
extensively documented and supported, and network connection (wired or wireless). whizz you can easily switch to code view
your hardware usually requires some Next, download the pre-built Raspbian if you prefer.

32 // // Spring 2017
Super Pi POWER UP

Raspberry Pi and the recently released Enviro n-o-d-e.net/tagged/


pHAT (£16, Pimoroni), sized to match the Pi Zero howto – find the entry
and offering temperature/pressure, light level/ for 11/01 marked ‘How to
colour, motion and analogue sensors (but you’ll power a Raspberry Pi
need to solder the supplied headers to it). If you’re Zero over Ethernet’. You’ll
looking for a straightforward motion sensor, then need to source a USB
the PIR Infrared Motion Sensor (£3, ModMyPi) is Ethernet adaptor that
all you need – it’s also built into the SPi-Box (£13, works with the Pi Zero,
shop.sb-components.co.uk) case, ready for plus 12V-5V step-down
pairing with your Pi camera. convertor, two micro
USB plugs and thin
Power your device wires. It’s a seven-step
A critical consideration for your IoT device is process, which requires
powering it. It’s not always possible to find a a soldering iron, clippers,
convenient wall socket, so you may be tempted to wire strippers and needle
go down the portable power route. The problem nose pliers, but there’s
here is that you’ll need to recharge the batteries a handy YouTube video
on a daily basis in most cases, so if your Pi is provided to give you a
supposed to be left to its own devices 24-7 then visual guide to follow.
this is not a practical solution.
One often overlooked option is Power Over Integrate with
Ethernet. Ethernet can be transmitted up to 100 other IoT kit
metres, and the cables can carry both power and If you’re looking to
network, so you don’t have to bother with a Wi-Fi integrate your Pi into an
adaptor or worry about weak or dead signals. A existing IoT ecosystem
100m cable can cost as little as £20, but spending but starting from scratch
a bit more will get you cable rated for outdoor use then the obvious choice is Energenie, thanks to its You’ll need to
– perfect if you’ve mounted your Pi at the other close integration with the Pi. On top of its own hub, set up BerryIO
end of the garden in a waterproof location. Just sensors and other IoT-related gadgets, there’s the in order to
one critical consideration before you begin: you’ll Pi-mote Control, with which you can remotely incorporate
your Pi into the
need a switch or router that provides 802.3af PoE switch electrical sockets on and off using your Pi,
SmartThings
support, or buy a special 802.3af PoE injector that plus a Mi|Home Adapter Plus, which monitors the ecosystem.
sits between your switch/router and your Pi. A electrical consumption of an appliance attached
good injector is TP-Link’s TL-POE150S (£20, PC to an Energenie smart power socket.
World), which provides its own power supply and It’s also possible to integrate your Pi into other
connects to any free port on your switch or router. ecosystems. Visit https://github.com/nfarina/
You then plug the other end into the PoE switch on homebridge for a guide to emulating Apple’s
your Pi, which can then draw up to 13W of power. HomeKit API on your Pi, for example. Samsung’s
If you plan to power multiple devices then a full- SmartThings API is another popular choice, and if
blown PoE-compatible switch may seem attractive, you go to https://github.com/nicholaswilde/
given that you often get up to four ports offering berryio-smartthings you’ll find a way to bridge
PoE connections. But check the total power the two using BerryIO as an intermediary. There’s
budget before you begin: for example TRENDnet’s a fair bit of work involved, and references to “My
TPE-S44 switch costs under £35 from Ebuyer.com Device Type” in the SmartThings setup process
and offers eight 10/100Mbps ports in total (four of
which support PoE), but it can only supply a total
30W across those ports. That should be sufficient WHY RELY ON MANUFACTURERS’
for low-powered headless devices, but doesn’t give
you much room for manoeuvre.
EXPENSIVE KIT WHEN YOU CAN
If this means of power appeals, then the PoE CUSTOM-BUILD YOUR OWN?
Switch Hat (£30, pi-supply.com) will work with
the Pi B+ or later, and it features a handy
programmable power switch too. A Model actually refer to the “My Device Handlers” section.
B-compatible switch can be purchased for £61 Nevertheless, it works, giving you remote control
(www.xtronix.co.uk/raspberry-pi-poe.htm). of your Pi through the SmartThings app among
If you want to use PoE with the Pi Zero then other things.
you’ll need to go down the DIY route. One project If all this feels like too much effort, there’s one
in active development is the PoEPi: Pi Zero project, other way you can use your Pi with other devices –
which has the added benefit of also providing your through IFTTT.com, which enables you to combine
Pi Zero with an Ethernet port. It’s shaped to sit devices and services using a series of triggers and
neatly on top of the Pi Zero board, but it’s still actions in the form of recipes that easily cross the
early days. You can follow its progress at https:// technology divide. Almost any IoT gadget worth
hackaday.io/project/9455. its salt is represented here, and you basically call
You’ll find a working guide to building your own scripts from your Pi using the Maker channel to
rudimentary PoE switch for the Pi Zero at http:// control or interact with other devices.

Spring 2017 // // 33
The Top 20
Raspberry Pi issues
Things can go wrong with even the best technology. Here’s how to tackle
some of the most common glitches you’re likely to encounter with your Pi
he Raspberry Pi is elegant in its simplicity. This connected devices, corrupted microSD cards, and out-of-

T may explain why in a blog post in 2013 the


Raspberry Pi Foundation revealed that only
0.02 percent of Pis are returned as defective.
Of these around half were actually experiencing
an issue that could easily be solved – so easily in fact that
date software. More specific issues can sometimes occur
with keyboards, displays, sound and internet connectivity.
Do not despair, however, if these solutions fail to resolve
your problem. The Raspberry Pi online community are
extremely active and willing to donate their expertise free
10 year old Jessica, the daughter of Director of Software of charge. Many of the tips outlined here focus on isolating
Engineering Gordon Hollingworth, was able to separate the your issue. Where possible try to cone down to precisely
good Pi units from the genuinely faulty ones. where the problem lies. For instance, if your Pi won’t
This being the case, if you are experiencing issues with connect to your home wireless network, try connecting at
your Pi, please don’t throw it away in frustration or send it the office. If your camera module fails to switch on, use a
back with an irate letter. It’s very likely that your issue can different power adapter, and so on.
be solved (if not by a 10-year-old, then using a remedy Above all, the best tip to begin with is to make sure
found by one of the other Pi users who’ve experienced it). that any hardware you buy, including the Pi itself and all
Over the next 10 pages we’ll explore some of the more cabling, comes from an authorised distributor. Pi kit is not
common problems with the Raspberry Pi and provide some expensive (just compare the prices of Apple branded tech,
tips on how to resolve these with minimal fuss. for example!), and pinching those few pennies is usually a
Pi problems typically revolve around a power adapter false economy. So, let’s look at the 20 most common Pi
simply not providing enough current for your Pi and problems and how to overcome them...

Spring 2017 // // 35
TOP 20 Raspberry Pi issues

Pi continuously reboots
Pi unable to boot up? Check your power supply and SD card

1
One of the most www.raspberrypi.org/help/ at the top right of the desktop
fundamental issues with faqs/#powerReqs. if it is underpowered but can
the Pi may be that it fails Speaking of USB ports, also simply reboot if too much
to boot up properly at all. Usually bear in mind that the power current is being drawn.
the Raspberry Pi logo will appear, requirements for the Pi will vary Ideally, you should buy an
then the screen will transform depending on what devices are official Raspberry Pi power
into a block of rainbow colour attached. The Pi will usually supply from an authorised
as the Pi self-tests its graphics display a lightning bolt symbol dealer such as the Pi Hut. Where
processor. Then occasionally possible, try to connect the Pi
the Pi will either display scrolling directly to the adapter itself
text on a black screen or simply This Micro rather than through a USB hub.
USB 5V Supply is
reboot repeatedly and fail to Although insufficient power is
available for just
load the OS. the most common reason that a
£5 from the Pi Hut
The most common reason (https://thepihut.
Pi is stuck in a boot cycle, there
for this is that your power supply com/products/ are other reasons why this may
is simply not providing enough micro-usb-power- occur. If your SD card has been
juice. The Pi is powered by a 5V supply-for-the- formatted incorrectly or an
micro-USB cable. The amount raspberry-pi) update to Raspbian has gone
of current required will vary awry, the Pi may also reboot.
depending on your model. For Try installing NOOBS to your
the latest Raspberry Pi 3 Model microSD card and reinstall
B, use a 2,500mA supply to Raspbian if changing the
make sure the Pi switches on power supply doesn’t help.
and that all four USB ports are See www.raspberrypi.org/
powered. For a detailed list of documentation/installation/
the Pi’s power requirements visit noobs.md for help with this.

No HDMI monitor
No problem, just use composite video

2
Fortunately for users composite cable and
with older televisions, keyboard to your Pi. Power it
the Raspberry Pi 3 has on while holding down the
a combined 3.5mm audio/ Shift key for around 10 seconds,
composite video jack, which then release the key. Do not
means even TVs without an worry at this stage if you
HDMI port can be used as a don’t see anything.
display. You will need a 3.5mm To switch the Pi from
to RCA A/V Composite cable, HDMI to the composite
available from sites such as display, press number 3
ModmyPi.com. Whichever on your keyboard for PAL
supplier you use, make sure that televisions or number 4 for
the A/V composite cable has NTSC. Televisions bought in Make sure reboot the Pi as before holding
three RCA connectors, so both the UK and Ireland will almost your composite Shift, then hold down the
audio and video are supported. certainly use PAL, whereas cable has three number 1 key to switch back
If you have a standard those in North America will RCA connectors, to HDMI.
installation of Raspbian, then the probably use NTSC. like this one from In the unlikely event your TV
ModMyPi (www.
Pi should automatically switch to If the display appears uses the Japanese version of
modmypi.com/
using your composite video distorted or black-and-white, NTSC or the Brazilian version of
raspberry-pi/
when it doesn’t detect an HDMI most likely you have selected accessories/
PAL, or if you wish to change the
device. If you are using NOOBS the wrong standard. Reboot the audio-cables/ aspect ratio used by the Pi, you’ll
to install Raspbian, however, by Pi and repeat the steps above av-composite- need to modify the Pi’s config.txt
default it outputs only to HDMI. to try another format. cable-3.5mm-to- file accordingly. See http://
You can modify this during Should you later decide to 3-x-rca-3m). elinux.org/RPiconfig#Video
startup. First connect your invest in an HDMI television, for information on this.

36 // // Spring 2017
Raspberry Pi issues TOP 20

Pi sticks on rainbow screen


Don’t panic if the Pi fails to boot beyond the GPU test loading screen

3
We mentioned opposite connect via SSH. If you haven’t
that on booting up, the Pi used SSH before, see problem 7
runs its own GPU (Graphics over the page. For recent
Processing Unit) self-test, which versions of the Raspbian OS, to
appears as a dazzling rainbow enable access this way you need
coloured screen. Occasionally to save a file named ssh onto the
the Pi may hang on this screen SD card’s /boot partition.
and refuse to load the OS. If you’re able to connect to
This can happen when the your Pi via SSH, run the following
Raspbian kernel image is two commands to attempt to
corrupted. An easy way to test reinstall the Pi kernel:
this is to use your computer to sudo apt-get update
install Raspbian onto a new sudo apt-get install raspberrypi-
microSD card, insert this new kernel
card into the Pi and try to boot. Once the update has
See www.raspberrypi.org/ the Pi’s SD card, insert it into If the Pi fails to completed, also edit the
documentation/installation/ a card reader, then connect load beyond this config file with the following:
installing-images for more this to a computer. The card’s screen, power off sudo nano /boot/config.txt
and insert the
information on this. second partition should contain Add the text boot_delay=1 on a
microSD card into
While this solution works well your /home/ folder. Make a new line. Press Ctrl + X, then Y,
your computer.
in theory, it can be a nuisance to copy of this to a safe place such then Return to save and exit.
have to configure your Pi all over as your computer’s desktop. Now try to boot the Pi again.
again. You might also have To try to repair Raspbian’s If the OS still won’t load, you’ll
personal files on the original kernel, you must run a system need to run a fresh install of
microSD card. If so, first back update. If the Pi will not boot Raspbian on another SD card
up your data: power off, remove normally, it’s best to try to as outlined above.

Keyboard types wrong letters


Internationalise your Pi using the Configuration file

4
As the Raspberry Pi was Although it’s not essential for
invented in the UK, the mapping keys, you may also wish
default keyboard layout is to change your system locale,
British English. This can cause language and time zone to your
some headaches for users with own country. In the Localisation
US or International keyboards. menu select option 1 to list
Even when keyboards are various locales and languages.
manufactured in the UK, yours These use the two-letter country
may have a different layout or code (see below). You can of
extra keys. Fortunately the Pi course change this back to
can be configured accordingly. English at any time if you wish.
Open Terminal on your Pi or On the main menu, you can
connect via SSH and run the also choose option 2 to change
following command: your time zone. Raspi-Config
sudo raspi-config will first ask you to choose your
Use the arrow keys to choose general geographic area, such as Foreign Find the line reading
Option 4 (Localisation Options) Europe, before honing down to keyboard? XKBLAYOUT=”gb” and replace
and press Enter. Next choose specific countries. Change “gb” to “gb” with the two-letter code of
Option 3 (Change Keyboard If you have a foreign keyboard, the correct two- your keyboard country, such as
letter country “us”. You can find a full list of
Layout). This will allow you to usually selecting the correct
code for your
choose your specific model of locale will map the correct keys the two-letter country codes at
keyboard.
keyboard, such as “Apple”. Use to the Pi. If not, run the following www.worldatlas.com/aatlas/
the arrow keys to click OK to command to open the keyboard ctycodes.htm.
confirm your changes and save configuration file: Press Ctrl+X, then Y, then
the modified file. sudo nano /etc/default/keyboard Return to save and exit.

Spring 2017 // // 37
TOP 20 Raspberry Pi issues

Screen goes blank periodically


Disable the screensaver to keep your display running at all times

5
The Raspberry Pi is If you’ve connected the Pi to The program itself takes only
designed to draw as little a touch screen, it’s usually not around 11MB. Once installation is
power as possible. For this too much trouble to tap it and complete, click the Pi Menu and
reason, by default the screen bring it back to life. However, if go to Preferences. You will see
will blank after around ten you are using a regular display there is a new option there
Click the
minutes of mouse and keyboard without a keyboard or mouse, named Screensaver. Click this,
Mode menu,
inactivity. This can be a huge then Disable the only way to wake the screen then click the drop-down menu
liability when you’re undertaking Screensaver to up is to connect a keyboard or labelled Mode, then Disable
various Pi projects, particularly stop the screen restart the Pi altogether. Screensaver in the main window.
where the Pi is being used to display powering Various well-meaning online If you wish simply to use
display the time or weather. off for good. contributors in Raspberry Pi an actual animated screen
forums have suggested some saver rather than disable it
command line hacking which altogether, note that the author
involves extensive use of the Pi of xscreensaver doesn’t
terminal and altering various recommend using this rather
values, which is not ideal for outdated version of the program.
newcomers to the Pi. You can When using xscreensaver you
in fact disable the screen saver may even see an alert to this
very easily from the Pi by effect. Consider installing a more
installing the screen saver recent screen saver utility such
management program as gnome-screensaver if you
xscreensaver. Open Terminal want something more colourful.
on your Pi and run the following To install this, simply run:
two commands: sudo apt-get update
sudo apt-get update sudo apt-get install gnome-
sudo apt-get install xscreensaver screensaver

Password problems
What is my password? Why can’t I see it?

6
Some newcomers to the to make sure it’s written
Raspberry Pi may be correctly. Next in the upper
surprised that no letters menu click Edit > Select All,
appear when typing passwords, then Edit > Copy. You can now
particularly in the Terminal paste the password into the Pi
program. This is a feature, not terminal when prompted by
a bug. Raspbian is based on holding Ctrl + Shift + V.
Debian Linux, and Linux is For multiple and/or lengthy
extremely security conscious, so passwords, consider using a
it doesn’t allow user passwords password manager such as
to be displayed. On the plus side, Keepass. Programs like Keepass
if this is a concern for you, you store all of your passwords in
needn’t worry – Raspbian is an encrypted database. This
behaving exactly as it should. database is protected by a Click the Add/Remove Software and enter
The default user password is “master key” – a single three dots next “Keepass2” in the search bar.
set to “raspberry” on first run, password which can be input to to the master Tick the first entry in the window
which isn’t too tricky to type. If retrieve the others. Password password field labelled “Password Manager”
to see what you
you do find you’re having trouble managers such as Keepass also and then click Apply at the
are typing. You
with this, first check that you allow you to right-click entries in bottom right.
can do the same
have the correct keyboard layout the database to copy and paste for other entries
Once it’s installed, you can
(see problem 4 on the previous the password into fields. This in the password then launch Keepass from
page). If this fails to resolve the can save an enormous amount database. Applications > Accessories. If
issue, go to Applications > of time and trouble. you need help getting started
Accessories > Text Editor and To install Keepass, go to visit the Keepass Forum at
type your admin password there Applications > Preferences > https://forum.keepassx.org.

38 // // Spring 2017
Raspberry Pi issues TOP 20

Trouble connecting via SSH


Enable SSH to connect to your Pi remotely and run commands without a monitor

7
SSH (Secure Shell) is a Using your arrow keys, choose
set of network protocols Option 5 (Interfacing Options),
for securing connections then select it by pressing Enter.
between computers. In plain Next choose Option P2 (SSH).
English this means that you can Raspi-config will ask if you’re
use a utility on another device sure you want to enable. Press
such as a PC to control your Pi, Enter once again to confirm.
pretty much as if you were using You will see a confirmation
the Pi’s Terminal directly. Visit message stating “The SSH
www.raspberrypi.org/ server is enabled”.
documentation/remote- If you do not have a monitor,
access/ssh for information on don’t worry. Power off the Pi,
connecting to the Pi via SSH remove its SD card, insert it into
from different platforms such as a card reader, and plug this into
Mac (which has SSH built-in) or your computer. Find the /boot
Windows (which needs it added). partition and create a file there
Because your Pi has a default named ssh. You can use a text If possible, see a warning that the default
username and password, it editor such as Microsoft’s hook your Pi up password for the Pi user has not
could be targeted remotely by a Notepad or Apple’s TextEdit to to a monitor to been changed from “raspberry”.
hacker, and for this reason SSH do this but make sure that the enable SSH using To fix this, open Terminal and
raspi-config.
is disabled by default. If you can file has no filename extension enter the following command:
connect your Pi to a monitor such as .txt. Safely eject the SD sudo passwd pi
temporarily, you can enable SSH card and reinsert into your Pi. You’ll be asked to enter the
yourself. First open Terminal and SSH will now be enabled. new password twice. Note that
run the following command: The next time you load the Pi this command itself can also be
sudo raspi-config with a monitor attached, you will run over SSH.

Touchscreen troubles
Overcome the most common quibbles with the Raspberry Pi touchscreen

8
The official Raspberry Pi raspberry-pi-7-touch-screen- DSI ribbon – gently pull straight
7-inch touchscreen display assembly-guide) backwards with finger and
is an incredible add-on. Before attempting to thumb. The entire apparatus is
When combined with a battery assemble the screen, provide fairly delicate and, in keeping
pack and an on-screen keyboard, yourself with a flat, well-lit space. with the “bare bones” feel of the
it can even transform your Pi Make sure to run updates on the Pi, there’s no back case to the
into a mobile device. Pi to be certain you have the display, although you can buy
The touchscreen is designed latest version of Raspbian too: one separately if you wish.
so that the Pi can be connected sudo apt-get update The default setup can cause
via the DSI (Display Serial sudo apt-get upgrade issues if you want to use the
Interface) cable and screwed This handy The display comes with four GPIO pins for projects. The Pi
cable gives you
onto the back of the display. M.25 screws, so buy yourself a Hut has an innovative solution
use of the GPIO
Power is supplied by jumper suitable screwdriver. Make sure in the form of a Short MicroUSB
pins when using
wires which connect to the GPIO the touchscreen the display powers on correctly Power Cable which neatly
pins on the Pi so that it and the display. See before connecting anything attaches to the USB port, no
display can share power from http://bit.ly/ permanently. Be extremely messy wires required.
the same microUSB cable. pihut-microUSB careful when pulling out the If you wish to change the
Connecting the devices for information. small clamps which attach to the orientation of the touchscreen
requires a little time and display, open Terminal and run
patience. If you buy the display the following:
via the Pi Hut website, there is sudo nano /boot/config.txt
a link to assembly instructions Paste the text lcd_rotate=2 in a
(https://thepihut.com/ new line at the very bottom. Save
blogs/raspberry-pi- and exit. The display will reorient
tutorials/45295044- the next time you reboot.

Spring 2017 // // 39
TOP 20 Raspberry Pi issues

Playing Flash or DRM content


Can’t play DRM protected content? Streaming video is easy... if you don’t use Flash

9
In September 2016, another machine to work with Player Wiki (http://kodi.wiki/
Adobe announced that it the Pi, but you need to be very view/HOW-TO:Install_Kodi_
will once again develop its comfortable with Linux and use on_Raspberry_Pi) for
Flash Player for Linux, having of the command line to do this. installation instructions.
previously abandoned the Instead, bear in mind that major If you are using Raspbian
project in 2016. This doesn’t sites such as YouTube and Daily with NOOBS, you can also
do much good for Raspberry Motion now stream video via simply restart the Pi holding
Pi users, though, because the HTML5, which the Pi supports. Shift to install the LibreELEC
player will not work with the Pi’s Flash is generally not required. Operating System, which is
Kodi Media
ARM processor architecture. player on the
The Pi is designed to be free specifically designed to display
There are unofficial plugins Pi can stream and open source. As such it does Kodi content.
for the Pi’s Chromium browser Netflix and Hulu not contain proprietary software If you wish to watch DVD
such as Pepperflash which can from a Windows for playing content encrypted by or Blu-ray discs, either via an
theoretically be copied from PC via PlayOn. various forms of DRM (Digital external DVD drive or from a
Rights Management) and “ripped” ISO image, you can also
streamed via providers such purchase an MPEG-2 and/or
as Netflix and Hulu. One VC-1 Licence key inexpensively
possible workaround if you from www.raspberrypi.com/
have a Windows PC in addition license-keys. In order to place
to your Pi is to install PlayON the order, you’ll need to provide
(available from www.playon.tv). your Pi’s serial number, which
This program enables you to you can find by opening Terminal
stream Netflix content from on your Pi or connecting via SSH
the PC to other devices such (see problem 7) and running the
as a Raspberry Pi running Kodi following command:
media player. See the Kodi cat /proc/cpuinfo

Big SD cards not recognised


Format large capacity SD cards to be recognised by the Pi

10
Since the Pi was first Foundation recommends using
launched, the cost of Guiformat (www.ridgecrop.
microSD cards with a demon.co.uk/guiformat.htm).
capacity of 64GB and more has Mac and Linux users can use
fallen, allowing for much greater their OS’s own disk utility to
amounts of data to be stored. If format the entire card to FAT32.
however you use the official SD Once this is done, continue
Card Formatter tool on the SD with installation of NOOBS onto
Association’s website (www. your microSD card by following
sdcard.org/downloads/ the steps at www.raspberrypi.
formatter_4) to format high- org/documentation/
capacity microSD cards, the Pi installation/noobs.md. Windows Another easy workaround for
might not recognise them. This Card still not recognised? users can use Raspberry Pi 3 users is simply
is because the tool uses the First visit the Pi Foundation’s the Guiformat to boot from a USB stick or hard
exFAT file format for cards over website for a list of other tool to prepare drive instead of an SD card.
the SD card. Mac
32GB in capacity, and this is not programs you can use to format Note, though, that this feature is
users can use
recognised by the Pi. a card (www.raspberrypi.org/ still experimental. You will need
the built-in Disk
In order to make sure your Pi documentation/installation/ Utility in macOS.
to enable USB boot mode on the
will recognise your high-capacity sdxc_formatting.md). If all Pi, as well as format the USB
card, first format it using the else fails, digital cameras use device in a specific way. For
official tool. Next use a third- a slightly different method for instructions, see the Raspberry
party tool to format the SD formatting microSD cards, so Pi website at www.raspberrypi.
card’s partition to FAT32, which you could try inserting the card org/documentation/
is recognised by the Pi. For and formatting it using your hardware/raspberrypi/
Windows, the Raspberry Pi camera’s built-in firmware. bootmodes/msd.md.

40 // // Spring 2017
Raspberry Pi issues TOP 20

Sound problems
Troubleshoot sound issues and select the correct speakers for output

11
If your Raspberry Pi codecs. Go to Applications >
is plugged into an Preferences > Add/Remove
HDMI television, Software and install VLC Media
sound will be output there and Player. This should enable your
should work out-of-the-box. If Pi to play almost all audio and
not, you will need to isolate the video formats.
issue to find out where the If the issue persists, then
sound problem lies. In the first double-check your Pi’s sound
instance, eliminate the obvious settings by opening Terminal
by clicking the volume control again and running the command:
during playback to make sure sudo alsamixer
the volume is turned up and is This retro interface allows
not muted. you to alter the volume of your Use the up/ sudo /etc/init.d/alsa-utils reset
If this fails to resolve the various sound devices (by down keys to Certain computer monitors
issue, find out whether this issue default there is just one) and control your connected by HDMI may not
is related to playing only certain even select another sound card device’s volume. output audio correctly. You also
Press F6 to
content by using Terminal to play if you have one. By default only may want to connect speakers
choose a different
some of the WAV files bundled playback devices are displayed or headphones to the Pi’s 3.5mm
sound card.
with the Pi. These files are saved but you can press F5 to include jack. If so, first open Terminal
in /usr/share/scratch/Media/ sound recording devices if you and run the following:
Sounds. For instance, run the so wish. sudo raspi-config
following command: If selecting the correct sound Choose Option 8 (Advanced
aplay /usr/share/scratch/Media/ device and increasing the Options), then Audio. This
Sounds/Vocals/Singer2.wav volume fails to fix the issue, try will enable you to switch the
If you hear sound, the issue is resetting your sound settings output between HDMI and the
likely to be related to media with the following command: headphone jack manually.

USB devices not recognised


Eliminate some common pitfalls of USB devices

12
The Pi supports a error messages relating to it.
wide range of USB If the USB device is not listed
flash drives and other then there’s either a hardware
devices, and it’s usually a matter fault or it possibly requires more
of simply plugging and playing. If power than the Pi’s USB ports
however nothing happens when are able to supply. Consider
you first insert the device, try to buying a powered USB hub
hone down on the actual issue. from a Pi reseller.
Your first step should be to If the device is detected but
try the device with another non- still is not working, it’s possible
Pi computer such as a desktop that the Pi doesn’t have the Use dmesg or you cannot contact them,
PC to check whether it’s simply software drivers necessary to to check for don’t despair. There may be a
faulty. If it is, contact the seller interface with your USB device. any USB device community-maintained driver
or manufacturer about a To begin with, use Terminal to error messages. developed independently of the
Here a flash
replacement under warranty. run the following commands to manufacturer or the driver for a
drive has been
If it’s not faulty, open Terminal ensure you have the most recent similar device may work.
detected but was
on your Pi and run the following version of Raspbian: not unmounted
With the USB device still
command: sudo apt-get update properly. inserted run the following
sudo dmesg -C sudo apt-get upgrade command in the Pi Terminal to
Next insert your USB device and If updating your system fails to list all attached USB devices:
run the command resolve the issue, contact the lsusb
dmesg device manufacturer in the first Note down the device’s ID, e.g.
If your USB device has been instance to ask if there is a 1307:0163, and enter it into your
detected, then it will be listed suitable Linux driver. If the favourite search engine with the
here. You should also see any manufacturer says there isn’t words “Linux driver”.

Spring 2017 // // 41
TOP 20 Raspberry Pi issues

Wi-Fi connection issues


Troubleshoot issues with connecting to Wi-Fi networks

13
If you’re using the Pi device such as a mobile phone to change the wireless security
3, then Wi-Fi is built- to the same wireless network protocol to WPA (Wi-Fi Protected
in. If you’re using a to check if you have the same Access) or ideally WPA2.
separate USB wireless stick, difficulty. If possible, try to set If this fails to resolve the
follow the steps we’ve outlined If your Wi-Fi up a hotspot on your phone and issue, open Terminal on the Pi
network is not
under problem 12 on the attempt to connect to that from or connect via SSH and run the
listed, enter the
previous page to make sure the the Pi to further identify where following command:
settings here
stick itself isn’t the problem. manually. Use the issue lies. sudo nano /etc/wpa_supplicant/
Certain routers have an upper raspi-config If you are abroad, different wpa_supplicant.conf
limit on the number of devices to change the countries have varying This contains the name, settings
which can be connected to a country if the regulations on what Wi-Fi and password for all Wi-Fi
network. Try connecting a new code isn’t correct. channels can be used. You can networks connected to the Pi. If
configure the Pi to use these by your network is listed, verify that
opening Terminal and running the password and other settings
sudo raspi-config are correct. If not add your
Choose Localisation Options, network at the bottom of the
then Change Wi-Fi Country. You file in the following format:
will see a list of countries. Select network={
your current location using your ssid="your-network-ssid-
arrow keys. name"
The issue may be security. psk="your-network-password"
By default the Pi 3 cannot }
connect to any wireless network If you have an SD card reader
secured by WEP (Wireless this is also an excellent way to
Encryption Protocol). Contact connect your Pi to your Wi-Fi
the router manufacturer for help network without using a monitor.

RetroPie gaming problems


Solve common problems with RetroPie through using the GitHub page

14
One of the most for your specific gamepad on
common uses for the the GitHub page. For instance
Pi is as a retro games steps for the PS3 Controller
emulator. If like many others can be found at: http://bit.ly/
you wish to enjoy playing arcade RetroPie-PS3. The Raspberry
classics of the ’80s and ’90s, Pi 3 has built-in support for
your first port of call should be Bluetooth and will provide the
RetroPie’s GitHub page (http:// best performance. If you’re using
bit.ly/RetroPie-setup). other Pi models you will need a
Some users buy Pi bundles Bluetooth USB dongle to use
on sites like eBay which include wireless controllers.
the Pi itself, an SD card with For copyright reasons, Before into the computer and download
RetroPie pre-installed and some RetroPie does not come with using RetroPie the ROMs to there.
pre-installed games, known in any ROMs. If you have a legal make sure to The Internet Archive (http://
retro-gamer parlance as “ROMs”. copy of a ROM, the easiest read the “First archive.org) maintains large
Installation” page
If the microSD card doesn’t work method to transfer it to the Pi amounts of “abandonware”
on GitHub, which
out of the box, go through the is to create a folder named ROMs, which they claim are free
should resolve
RetroPie setup again to make retropie on a USB stick, then most common
to download. Make sure this is
sure you have the latest version. create another named roms issues. legal in your jurisdiction before
The latest version of RetroPie inside it. Safely eject the USB copying to RetroPie.
should automatically detect stick from your computer and For troubleshooting some
and configure most controllers insert it into the Pi. RetroPie will common sound, video and speed
connected via USB. If you want automatically create subfolders issues, visit the RetroPie wiki at
to set a wireless Bluetooth for various games consoles. You https://github.com/retropie/
controller, follow the instructions can then reinsert the USB stick retropie-setup/wiki.

42 // // Spring 2017
Raspberry Pi issues TOP 20

Display and desktop glitches


Border and resolution problems, including overly large desktops, are easily solved

15
By default the Pi’s extends past what the monitor
display resolution is can display), then instead of
800x400 pixels. This disabling overscan, remove the
may well not cause any issues # at the start of the lines
but certain monitors are set up overscan_left, overscan_right,
for a higher resolution. On overscan_top and overscan_
startup the Pi will request a bottom, and manually adjust
monitor’s settings and if the Pi the values there, using negative
cannot find a suitable one, parts numbers if necessary to reduce
of the desktop may not display, the border size.
or the display may seem blurry, If the entire desktop displays
or possibly both. but is overly large or small, or
If you see a black border of the above steps fail to resolve
unused pixels, try to disable the issue, you may need to
overscan on the Pi. Open adjust your console size. Disable
Terminal or connect via SSH overscan as outlined above.
and run the command Make a careful Now find the line reading Next scroll down to the section
sudo nano /boot/config.txt note of any lines #disable_overscan=1 and use beginning uncomment to force
Before making any changes, you modify to the backspace key to remove the a console size. Remove the #
make a note of the original make sure you # at the start of the line. Press symbols at the start of the two
can revert to
settings in your config.txt file. Ctrl + X, then Y, then Return to lines beginning framebuffer to
previous settings.
That way if the display becomes save and exit. Reboot the Pi to set an alternative resolution. For
unreadable, you’ll be able to have the changes take effect. instance if the current height
connect via SSH or plug your If you have the opposite and width are 1280x720 you may
microSD card into a card reader problem in that parts of the wish to adjust this to 1024x768.
and restore the original settings. desktop are not visible (i.e., it Reboot to apply your changes.

Vanquishing VNC
Master the art of connecting remotely to your Pi’s desktop

16
VNC (Virtual on the colourful VNC icon to see
Network Computing) the connection details and the
is a way to control server signature, which is used
one computer remotely from to verify that no-one is trying to
another. This is especially handy spy on your connection.
in the case of the Pi as it allows If you have a web browser
you to use your computer that supports Java on your
keyboard and mouse. The most computer, simply navigate to
recent versions of Raspbian the address listed, e.g.
actually come with VNC Server http://192.168.4.87:5800.
software provided by RealVNC You will see a warning message To connect problem 7, page 39) and enable
pre-installed. This makes the first time you connect. to the virtual VNC by running the command
accessing the Pi much easier, Choose to continue and enter desktop, make vncserver
but for security this handy your Pi’s current username and sure to enter the This will start the VNC software.
feature is disabled by default. password. The desktop will entire IP address, You’ll see a message stating the
including the
In order to begin using it open appear in a new window and IP address of the virtual desktop,
colon and number
Terminal on your Pi or connect you can access it just as on for example:
e.g “:1”.
via SSH and run the command the Pi. If you don’t have Java- “New desktop is raspberrypi:1
sudo raspi-config enabled browser or prefer to (192.168.43.87:1)”
Go to Option 5 (Interfacing access the Pi from a mobile Make a note of this. Now in your
Options), then select VNC. Hit device, visit www.realvnc.com Java-enabled web browser go to
Enter while Yes is highlighted for links to suitable software. http://ipaddressofyourpi
and VNC will be enabled. If you’re running your Pi :5800. In the VNC Viewer enter
If you already have a monitor “headlessly” – without a monitor the IP address you noted to
attached to your Pi, double-click – then connect via SSH (see connect to the virtual desktop.

Spring 2017 // // 43
TOP 20 Raspberry Pi issues

Programs don’t auto-run


Ensure your software starts up without prompting

17
Certain Pi projects, again manually. This is very easy schedule this using the tool
particularly those to do. To make a program launch Cron. Open the Terminal and
where the Pi is at startup, first open Terminal on run the following command to
continuously displaying your Pi or connect via SSH and open Cron:
information like the weather or run the command: crontab -e
This script
stock prices, work much better sudo nano /etc/rc.local Press Return to choose the
will launch
if they launch automatically. automatically
Find the line reading “exit 0”. default Editor. Scroll down to the
For instance if the Pi reboots on boot. Make It’s essential to place your very bottom of the file to add
after a power cut, it can be very sure to put any commands above this line. For your scheduled job. The basic
annoying to have to start the commands example, if you have a Python format for Cron is minutes/
various programs up all over above “exit 0”. script, you could paste the hours/day of month/month/
following above “exit 0”: day of week. Naturally you can
python /home/pi/stockticker.py & customise this however you
The ampersand at the end of want. For instance to schedule
the line tells the Pi to continue the script “check-temperature.
booting once it has run the sh” to run every hour, you’d add:
script. Press Ctrl + X, then Y, 0 * * * * /home/pi/check-
then Enter to exit and save temperature.sh
your changes. Save and exit in the usual way.
Some projects may require If you’re having trouble working
you to run a script at certain out how to write the scheduled
times of day. For instance you job in the timing format used
may have a script that by Cron, the helpful website
automatically checks the https://crontab.guru allows
temperature and sends you you to enter numbers to be sure
an e-mail summary. You can you have it exactly right.

Camera calamities
Iron out issues with official Raspberry Pi Camera Module

18
The Pi’s Camera slight click when the connector
Module V2 is designed is correctly in place.
to be easy to set up Once the camera is connected
and use, and is compatible with open Terminal on your Pi and run
the Raspberry Pi 1, 2 and 3. The sudo raspi-config
camera attaches via a ribbon Scroll to Option 5 (Interfacing
cable and usually works out-of- Options) and then press Enter
the-box. over the first option (Camera).
The Raspberry Pi Foundation Choose Yes to enable it.
website (www.raspberrypi.org/ If video is not working after
documentation/ you’ve enabled the camera, Assign at double-check your power supply.
configuration/camera.md) make sure you have connected least 128MB The camera draws around
cautions that the Pi Camera the camera ribbon to the CSI-2 of memory to 250mA of extra current. See our
Module is very sensitive to (Camera Serial Interface), not the GPU to be solution to problem 1 (on page
certain the Pi can
static. So it’s worth investing the DSI (Display Serial 36) for tips to ensure you’re
handle footage
in an earthing strap to ground Interface). Make sure also using a reliable adapter.
from the camera.
yourself before touching either that the ribbon connectors are Should the camera module
the camera or the Pi. Be seated straight in their sockets. still fail to load, try assigning
extremely gentle when pulling If the camera is enabled and more memory to the GPU. This
out the tabs on the end of each connected correctly, try running allows the Pi to handle video
connector to attach the ribbon the following commands to better. Open Terminal and run
cable. Gently push the tabs back ensure Raspbian is up to date: sudo raspi-config
on the camera end to lock the sudo apt-get update Choose option 7 (Advanced
cable in place or you may find it sudo apt-get upgrade Options), then Option A3
comes loose. You should hear a If the camera is still not working, (Memory Split) to set this.

44 // // Spring 2017
Raspberry Pi issues TOP 20

Unavailable software
Unable to install new programs, or unsure what programs to use? All is not lost...

19
Although the Pi no Ideally you should do this before
longer has a dedicated attempting to install any new
app store, clicking applications. It can’t hurt to run
Applications > Preferences > the following as well to make
Add/Remove Software will open sure you have the most recent
a window which enables you to version of the Add/Remove
choose from the various Software program:
programs available in the Pi’s sudo apt-get upgrade
software repositories. If you’re uncertain whether a
Categories are available on program is available for the Pi, Case in point: first to see if there is an ARM
the left, and you can click on use the search bar in the Add/ The official version of the software available.
individual programs to see a Remove Software window or run Dropbox client If there isn’t but the developer
more detailed description before the following command (be sure doesn’t run on has provided the source code of
the Pi but the
installing. Sometimes, however, to spell the program correctly): the program, you can attempt
open source
the Add/Remove Software sudo apt-cache search compiling it yourself on the Pi.
alternative
window may hang or say it is <softwarename> Sparkleshare is
This is tricky to get right, can be
unable to find a package. If the software seems to be compatible. time-consuming, and usually
If this happens it’s most likely unavailable for the Pi, use your requires additional software
because your software sources favourite search engine to see if libraries as well as the source
are out of date. Click Options at there’s a suitable alternative. Not code. Visit www.aboutdebian.
the top left of the Add/Remove all programs will work on the Pi, com/compile.htm for a basic
Software window and choose even if there’s a Linux version, introduction to transforming raw
Check for Updates. Alternatively because the Pi has an ARM code into a workable program.
open Terminal on your Pi or processor rather than Intel, like Use the most recent version of
connect via SSH and run: most desktop machines. the source code unless you’re
sudo apt-get update Check the developer’s website specifically told otherwise.

When all else fails...


Take some time to research your issue before giving up

20
While we’ve covered occur with a cabled device?
some of the more If you conclude that the
common problems problem relates specifically to
with the Pi, there is a near the Pi itself, then consider
infinite number of ways in posting on the Raspberry Pi
which yours can be set up, so forums (www.raspberrypi.org/
there’s no way to cover every forums) to ask for help. Do this
eventuality. Whatever your even if you see that someone
problem, however, there are has posted about a similar issue, Providing see if you can contact the
some standard troubleshooting because they may have used links to any developer or find a user forum
approaches you can try. Even an older version of the Pi and/or accessories for that program. The same
if you’re not very experienced Raspbian. Your first post must be you purchased holds true for hardware devices,
enables other
with computers, try to eliminate pre-approved by a Moderator, so although the Raspberry Pi
users to check
likely or possible causes before do not be surprised if you don’t forums may be able to point you
the exact model
concluding that the Pi must see it right away. number.
in the direction of the correct
be physically faulty or that you Try to include as much software driver (see above).
have done something wrong. information as possible in your If after troubleshooting you
Does the problem occur post. If you are receiving long find that your Pi falls into the
when you use a different power error messages, use PasteBin 0.01 percent of devices which
adapter? Does running an (http://pastebin.com) to copy actually are faulty, contact
update or trying using a new and paste the text, then provide your Pi distributor to arrange
microSD card make any the link to this in your post. a replacement or a refund. Do
difference? If you use wireless If your problem relates to not contact the Raspberry Pi
peripherals such as a keyboard using one specific program and Foundation – it does not sell
and mouse, does the same issue the Pi otherwise works properly, the devices itself.

Spring 2017 // // 45
THE EASY WAY TO
LEARN WINDOWS

100%
JARGON
FREE

AVAILABLE IN STORE AND ONLINE


www.myfavouritemagazines.co.uk
Pi PROJECTS
Put your Pi to use – we show you how, step-by-step!
53

DOOM IS A LANDMARK IN THE


HISTORY OF GAMING, AND YOU
CAN RECREATE THE ORIGINAL
’90s EXPERIENCE AND EVEN 56
PLAY AGAINST FRIENDS

61

48 48 Play Doom
on your Pi

53 Make any
printer wireless

56 Create a Pi
Media Centre

61 TalkiePi: Make
a walkie-talkie

66 71 66 Protect yourself
with a firewall

71 Build a Pi-based
photo gallery

September 2016 // // 47

Spring 2017 // // 47
Love it or hate it,
Doom redefined the
gaming industry.

Play Doom on your


Raspberry Pi
Nate Drake adds a touch of chocolate to your Raspberry Pi through
installing a version of this iconic First Person Shooter
oom is a landmark in the history of spawning a number of official sequels, spin-off

D gaming, set in the not too distant


future. You are a Space Marine, exiled
to Mars for a dull, routine assignment
after striking a superior officer. The
Martian Marine Base is secretly conducting
games and fan-made levels.
Even those who are too young to remember
when Doom was initially released will likely be
familiar with the FPS genre through the numerous
examples around. As Doom is the most iconic, it’s
experiments into teleportation through creating important to recreate the original ’90s experience
wormholes between Mars’ two moons. as closely as possible and for this reason we have
Events take a horrifically dramatic turn for the selected the “Chocolate Doom” Engine to run on
worse when one of the moons, Deimos, suddenly your Raspberry Pi.
disappears. Taking the role of the hero of this This project assumes you have a Raspberry Pi
cyber-tragedy, you are quickly dispatched on 2 or 3, running the latest version of Raspbian. Use
a shuttle to the other moon, Phobos. You soon the commands sudo apt-get update then sudo
discover that the hapless research scientists apt-get upgrade to be sure of this. If you want to
have accidentally opened a doorway to hell itself play Doom’s multiplayer Deathmatch mode, you
and that you will have to fight your way through will also need your Pi to be connected to your
demonspawn, possessed personnel and the forces home network and/or the internet.
of darkness to have any hope of escaping.
Despite the retrospectively clichéd plot and Getting the Lowdoom
clunky graphics, id Software’s Doom has enjoyed Being a First Person Shooter means that all the
huge popularity since it exploded onto users’ action is experienced as if you’re looking through
PCs in 1993. It helped cement the First Person the eyes of the main character (unnamed in
Shooter (FPS) genre of video games as well as Doom but sometimes referred to as “Doomguy”).

48 // // Spring 2017
Chocolate Doom PROJECT

The basic premise of the original game is that you


must fight through the moons of Phobos, Deimos
and then Hell itself. This is accomplished through
punching, shooting and even (if you wish) gashing
with a chainsaw any zombies, flaming skulls and
demonic henchmen that get in your way as you
progress through all 27 levels.
The satanic imagery and ultra-violence were not
welcomed by several religious groups and political
pressure groups, who campaigned in vain to either
censor Doom or make it more family friendly after
its release. Germany banned the game out of hand
for containing “bloody, sadistic violence”, although
this ban was repealed in 2011.
However, there appears to be no such thing as
bad publicity. Doom sold 1.1 million copies between
1993 and 1999, making it the eighth best selling
game of that time. Developer id Software claimed
it was probably the number one cause of reduced
productivity globally. This was meant as a joke but
by 1995 there were an estimated 10 million PCs
globally with a version of Doom installed. On start-up you can choose from various imaginatively-named difficulty levels.
Gameplay is simple in theory if not in practice.
On each level you must locate the exit to the next Another advantage is the arsenal of in-game
area. Helpfully enough these are marked with an weapons. Although you begin with a pistol, as
exit sign. However, you have to make your way the game progresses you can lay your hands on
through a maze of levels, identical corridors and shotguns, chain-guns, plasma rifles and even the
locked doors. Some help is available in the form unholy BFG (Big Fragging Gun) 9000.
of power-ups, which have been liberally scattered Pi bites
around the place by persons unknown. These Chocolate and Vanilla
include key cards, armour, weaponry and first aid Both “Chocolate Doom” and “Vanilla Doom” are A reboot of Doom
kits. You can also make use of the in-game map by different forms of the Doom Engine. It helps to was released in
May 2016 by id
hitting the Tab key to see where you have been. think of the Doom Engine as been the executable Software for
Monsters have an irritating habit of showing up parts of the game, as opposed to the WAD files Microsoft
when least expected. They also guard valuable (see “Where’s all the Data” overleaf) containing Windows,
items and exits and have an unfortunate tendency raw data like graphics, sound, weapons and so PlayStation 4
to shoot at you or throw fireballs from a distance. and Xbox. We live
on. The engine handles aspects of the game like
in hopes there’ll
Although Hell has numbers on its side, the the overall structure of levels and movement. The be a Pi version in
enemy AI is not particularly advanced and they will official Doom Engine developed by id is known as due course.
attack each other if one gets in another’s way. “Vanilla” because of its relatively bland flavour.

CHEATERS NEVER PROSPER


Chocolate Doom mirrors the original will equip you with the chainsaw. Press 1
closely, including the built-in cheat codes. to select it.
These can be used at any time during
play, simply by typing them on the idclev##: Use this cheat code to warp to
keyboard. In most cases you will see a the Episode or Map of your choice – for
message confirming that the cheat has example idclev02 would take you to map
been activated. The cheats below assume 2. This has the same effect as starting a
you’re using a QWERTY keyboard. new game in that your health will return
Cheats can work in multiplayer to 100 percent and any power-ups and/or
Deathmatches, depending on the weapons you picked up will be lost.
settings made by the person setting up
the game – it is possible to add the flag iddqd: This cheat sets your health
“– nocheats” to prevent others from permanently to 100 percent. This “God
having an unfair advantage. Mode” will make you immune to most
All cheats are prefixed by “id”, the name forms of damage, though certain types of Enabling God Mode leaves you free to get up
of the original game’s developer. floors can still harm you. You can also be close and personal with the chainsaw.
A few select cheats in no particular killed by “telefragging” – where other
order are: players or creatures teleport onto a spot
where you’re standing.
idchoppers: Why shoot the spawn of Hell skilled player. For a full list of cheats see the
humanely when you can carve them up There are plenty more along these lines Doom Wiki at http://doom.wikia.com/wiki/
with a gardening implement? This cheat for the lazy, desperate or perhaps less Doom_cheat_codes.

Spring 2017 // // 49
PROJECT Chocolate Doom

DOOM DEATHMATCHES
Chocolate Doom supports multiplayer with minimal fuss. Whether you play multiplayer over the internet or via a LAN,
Unlike “Vanilla Doom”, you can play Chocolate Doom either one of the participating players must act as the server and host
over the internet or via LAN (local area network). To keep things the game. Rest assured that the host player will be able to play
simple, however, make sure all the players who wish to take part the game too. UDP port 2342 must be open on each player’s
are running Chocolate Doom and using the same WAD file router and/or firewall. (See “The Doom is in the Details” on the
before going ahead. next page for more info.)
To host a Deathmatch game on your Pi, open Terminal or
connect via SSH and run the following command:
chocolate-doom -server -privateserver -deathmatch
In order to join your game, internet players should run the
following command:
chocolate-doom -connect 1.2.3.4
Replace 1.2.3.4 with the public IP address of the host player’s
machine. You can find your public IP by visiting websites such as
http://whatismyip.com.
For players who are connected to a local network, life is even
easier: simply run the game in the usual way but add the
argument -autojoin, for instance:
chocolate-doom -WAD DOOM1.WAD -window 640x480 -autojoin
The multiplayer window will be displayed, showing the various
clients which are connected. Press the space bar when ready to
start playing.
Further help for Multiplayer Mode, if you need it, is available
from Chocolate Doom’s Wiki: www.chocolate-doom.org/wiki/
When all players have joined, press the space bar to begin. index.php/Multiplayer

Doom Enthusiasts refer to “Vanilla Doom” to The only area where Chocolate Doom differs
Pi bites distinguish between the official game engine for significantly from the original is when playing in
Budding coders
running Doom and any variants. The distinction is the multiplayer Deathmatch mode. One player’s
can view the important because the Doom Engine was modified machine has to act as a server, unlike in Vanilla
original Doom and re-used in several commercial games such as Doom where players would connect directly to
Source code Heretic and Hexen. each other. Fortunately this is very easy to set up
at https://
Since id released the source code of the Doom (see Doom Deathmatches above).
github.com/
id-Software/ Engine in 1997, a number of community developers
DOOM have also adapted it to their purposes. Chocolate Where’s all the Data?
Doom is one such project. To play Doom you’ll need both the engine and
Despite modifying the game engine, Chocolate some so-called WAD files. WAD (Where’s All the
Doom aims to reproduce the experience of playing Data) files contain game data such as details of
TeamTNT’s
Eternal Doom
the original version of Doom as much as possible. levels, graphics, sound effects and background
was praised for Any modifications to the original game engine do music. The idea behind WADs is to make it easy for
its rich graphics, not interfere with the authentic gaming experience. people to make custom levels and modifications
stunning More importantly Chocolate Doom strives to be for the game. WADS exist separately from game
architecture compatible with all Doom Expansion files (WADs) engines such as Chocolate Doom and must be
and huge levels. that were designed to work with Vanilla Doom. downloaded from elsewhere. There are two main
types of WADS. For the purposes of this project
we’ll focus on iWADs (short for internal WADs),
which contain data for entire levels.
When Doom initially came out, although
enthusiasts were keen to jump on the bandwagon
and start creating new graphics, sound effects
and so on, they couldn’t do much to change some
of the game’s fundamental values such as how
much damage was dealt by monsters. Since the
release of Doom’s source code and some
remarkable efforts by the community at large,
however, all aspects of the game can now be
changed and there are thousands of WADs. Some
of these are simply slight alterations to the game
itself, whereas others expand hugely on the
premise of the original game. One of the best
known of these “MegaWADs” is Eternal Doom,
which contains 32 full levels, each of which is

50 // // Spring 2017
Chocolate Doom PROJECT

RECIPE FOR CHOCOLATE DOOM

1 Install Dependencies 2 Download and 3 Compile Chocolate


Your Pi will need certain programs in extract Chocolate Doom Doom
order to compile Chocolate Doom. Fire up your web browser, and head to Use the cd command to switch to
Open Terminal from Applications > www.chocolate-doom.org/wiki/ the newly created directory:
Accessories > Terminal or connect to index.php/Downloads to find the cd chocolate-doom-2.2.1
the Pi via SSH and install these with link for the Chocolate Doom Source Next, run configure to prepare the
the following command: Code. You can then use the wget necessary files. Now run make to
sudo apt-get install libsdl-mixer1.2-dev command in the Pi’s Terminal to begin compiling them. This can take
libsdl-net1.2-dev python-imaging download it. At the time of writing, for some time, so feel free to take a
Press Y when asked to confirm that instance, this would be: break. Once this has completed run
you wish to proceed with the install. wget https://www.chocolate-doom.org/ the following command to actually
downloads/2.2.1/chocolate-doom- install the program:
2.2.1.tar.gz sudo make install
Once the file has downloaded, extract
it using tar – for example:
tar xzf chocolate-doom-2.2.1.tar.gz

4 Download WAD file 5 Run Doom Setup 6 Run Chocolate Doom


(or files) Use the following command to launch To launch Doom run the following:
For the purposes of this project, we setup: chocolate-doom -WAD DOOM1.WAD
will download the shareware version of chocolate-doom-setup -WAD DOOM1. Doom will automatically launch in full-
Doom, using wget . Make sure you are wad screen mode, which can place a strain
still inside the Chocolate Doom folder You can use this to configure the on the Pi, so consider opening it in a
and run the following: display, sound, keyboard layout, window with this command:
wget http://www.doomworld. mouse and even a gamepad if you chocolate-doom -WAD DOOM1.WAD
com/3ddownloads/ports/shareware_ have one. -window 640x480
doom_WAD.zip Technically you can use this If you have a different WAD file,
Once the file has downloaded, extract screen to host and join multiplayer replace DOOM1.WAD with the name
it by running the following: Deathmatches as well, but it’s of the file of your choice.
unzip shareware_doom_WAD.zip actually easier just to do this from
You’ll see that the resulting file is the command line. See Doom
called DOOM1.WAD. Deathmatches on page 50 for
more information.

Spring 2017 // // 51
PROJECT Chocolate Doom

Freedoom’s set of Deathmatch levels known as


“FreeDM”. Unlike the regular deathmatch levels
you’ll find in Vanilla and Chocolate Doom, the
focus is on the players – there are no monsters.
If playing Doom has whetted your appetite
to try your hand at level design, the Freedoom
website also has hundreds of original textures and
sound effects that can be used royalty-free. Visit
https://freedoom.github.io to find these and
find out more.

Your Eureka moment


In true Raspberry Pi spirit you might be one of
those who do not want to play with WADS created
by others but want to edit and create levels of their
own. Doom was created to be hacked, expanded
and modified, so this is entirely in keeping with
game’s proud tradition.
Raspbian contains Eureka, the only Linux-based
Doom Level Editor under development. Go to
Click on around four times larger than the levels in the Applications > Preferences > Add/Remove
individual items original Vanilla Doom. Software and search for it using the search bar at
to reposition As impressive as this achievement is, Eternal the top left, or visit https://sourceforge.net/p/
them. Use the is simply an expansion of the Doom Universe. eureka-editor to download the software.
pane on the right
Other WADs are considered “total conversions” Eureka works by editing or creating WAD files,
to change their
in that they replace all resources used in the allowing you to write new levels from scratch or
attributes.
original game. The first of these was Justin change the layout or objects in existing ones. You
Fisher’s awesome Aliens TC, which is based on may find help with using the editor, if you need it,
the eponymous film franchise. from the Doomworld.com forums.
Those interested in working in the industry
should not consider designing game levels as a The Doom is in the details
waste of time – Fisher was offered employment by For the sake of simplicity, this project has
game developer Dreamworks, which he declined in focused on the shareware DOOM1.WAD, which is
order to finish his university degree. However other downloaded to the chocolate-doom directory. If
designers of popular WADs such as Iikka Keränen your WAD file is located anywhere else, simply
did go on to find employment with major video specify this when launching Chocolate Doom –
Pi bites game companies to work on official projects. for example:
View Doomworld’s For copyright reasons, in this project we’ll chocolate-doom -WAD /home/pi/Downloads/
entire archive of focus on the official shareware WAD of Doom DOOM1.WAD -window 640x480
WADs at https:// (DOOM1.WAD), downloaded from fan site Chocolate Doom is quite pedantic about filenames
www.doomworld. Doomworld.com. This contains only the first (capitalisation matters), so if you are trying to
com/idgames.
View the Doom
episode of the game, Knee Deep in the Dead, and locate the WAD file using the Setup screen, you
Community’s was initially released to encourage interest in the may want to rename your files “.wad” rather than
most popular game. Upon completion of the first level players “.WAD”. This is also true for the Eureka Level Editor
WADS at http:// were encouraged to order the full version. (see above) – during testing the program failed to
www.doomworld.
This said, there are a number of official and recognise the DOOM1.WAD file until it was
com/20years/
best1.php. unofficial WADs available for download, so renamed to “doom.wad”.
provided it is legal in your jurisdiction feel free A full list of all command line arguments and
to load and experiment with these. further help with Setup are available from the
Chocolate Doom User Guide at www.chocolate-
Freedoom isn’t free doom.org/wiki/index.php/User_guide.
The Freedoom Project is an excellent example of In order to play deathmatches in Doom you will
the enduring popularity of Doom. The stated aim need to open UDP Port 2342 on your firewall and/
of the project is to create Doom-style WADs made or router. Steps to do this will vary depending on
entirely of free content. Since id Software have your router. Check with your manufacturer or visit
released the source code to Doom, the underlying the website http://portforward.com for steps on
game code is free. Freedoom builds on this with how to do this.
a number of levels, artwork, sound effects and Chocolate Doom sadly is not compatible with
music. The result is a free and open source game, the single player Freedoom WADS. You might find
devoid of any proprietary content. other WAD files may not work well or cause issues
Freedom provides only WAD files, so needs a for your Pi. Ideally you should have a Pi dedicated
compatible game engine in order to be played. The to gaming so there’s no risk of losing any data.
Chocolate Doom website claims that the single On behalf of everyone at Pi User, please also
player Freedoom WADs are not compatible. It does accept our warmest thanks for your efforts in
however recommend downloading and playing fighting the forces of Hell. Good luck, soldier!

52 // // Spring 2017
The Pi simply
needs to connect
to the printer
via USB before
you install the
software. You
do not need
to connect to
a monitor for
this project.

Turn any printer into


a wireless printer
Nate Drake explains how to transform your old (or new) USB cabled
printer into a wireless printer by using a Raspberry Pi as a print server
ere’s a question for you: what do your wireless network and also has a handy

H Chateau Petrus 2012, petrol and USB port, to which you can connect any printer. Pi bites
milk have in common? The answer In this project we will explore how to connect your
Remember, if
is that, measure for measure, they Pi to an old-style wired printer via USB to make it you’re running
are all less expensive on average possible for anyone connected to your wireless short of mains
than printer ink. network to print to it. plug sockets and
The trend these days is that manufacturers have a micro USB
sell reasonably priced wireless printers but rather Printer preparations cable you can
power your Pi
costly ink. We do not mean to demonise printer One of the excellent features of this project is that from a USB socket
companies – the costs of raw materials such as it works with any model of Raspberry Pi, and you on a computer.
resin and oil have also increased in recent years – can even install additional software on the Pi after
but anyone who prints at home regularly knows you’re done. For a quick and easy setup use the
that this can blow a huge hole in your budget. Raspberry Pi 3 as this has built-in wireless.
Some people invest in laser printers, which – Aside from that you will need to connect the
while more costly up-front and typically used only Pi to the printer via a USB cable and switch both
for black-and-white documents – can hugely the Pi and the printer on before
reduce your printing getting started.
expenses. Older laser This project assumes that
printers in particular you are comfortable with
are very efficient... but accessing the Pi over The HP
many do not have SSH and that it is LaserJet Pro
support for wireless, already connected to P1102 is relatively
inexpensive but
and those that do your wireless network.
connects by
are sometimes not Once the Pi is USB only and is
compatible with the connected, we will incompatible with
most recent versions of install CUPS (Common Windows 10. Use
Windows or Mac OS. Unix Printing System) the Pi to turn it
Enter the Raspberry in order to discover and into a working
Pi. The Pi can connect to set up your particular wireless printer.

Spring 2017 // // 53
PROJECT Make any printer wireless

CUPS is
your printer. You can do this by opening the
developed by
Apple for its OS
CUPS web interface and clicking Manage
and other Unix Printers. Click on your own printer to get the
based systems, right address for it, which will be something like
such as Linux. https://192.168.1.2:631/printers/Canon_
It manages MG4200_series
print services If you’re using a Mac, try following the steps
for some of the on Apple’s support website at https://support.
most popular apple.com/en-us/HT202167. Enter the IP
versions such as address of the Raspberry Pi – for example
Ubuntu Linux.
printer. You don’t have to do this directly on the Pi 192.168.1.2 or whatever it is in your specific case
as CUPS can be accessed over a web browser on – to set up the printer. If the Mac fails to find the
any device connected to your home network (see printer, you may wish to follow the steps on the
Connecting to CUPS on the opposite page). excellent Pi3g Blog to set up an AirPrint Service
CUPS quite simply is a printing manager on the Pi: http://bit.ly/Pi3g-AirPrint.
which can transform your Pi into a print server, In either case if you’re asked to specify a print
capable of accepting print jobs across your protocol, the CUPS manual recommends to use
wireless network from other devices and then HP JetDirect, which is seen as the most reliable.
sending them to your printer. If you’re using Linux, setup should be very
This project is focused on printers that connect simple, as CUPS was made specifically for it.
over USB, but will also work for wireless printers However, almost every version of Linux has a
even if they no longer work with your particular different way of setting up printers. For more
operating system. On the whole, most Linux information, see www.linux.com/learn/how-
users tend to upgrade equipment less often manage-printers-linux.
than software, so you may find that your computer
will be able to print via CUPS even if it couldn’t Printer hicCUPS
connect directly to your printer. When connecting to the CUPS web interface for
the first time, you might receive a warning that
Post setup your connection is insecure. This is because your
Once you have followed the steps here and CUPS Admin page’s security certificate has only
Pi bites successfully printed a test page from the CUPS been signed by the Pi (known as a “self-signed
web interface, you will most likely want to add your certificate”) and not a third party certificate
If you don’t new wireless printer on your computer. authority. There is no cause for concern as you
yet own a laser
printer, try to find
The steps for doing this will vary depending on will have set up the page yourself, and you can
one that supports your setup. For Windows 10 users, it’s best to tell your web browser to make an exception for
duplex (double- follow the steps outlined on the Microsoft support CUPS to allow you to connect in future.
sided) printing. website http://bit.ly/Win-10-addprinter. If your Although CUPS has drivers for most printers, if
This saves on both
printer isn’t listed, simply select the option saying it cannot find yours then you will need to locate a
energy and paper.
so. You’ll be asked to type in the exact location of PPD (PostScript Printer Description File) for your

SET UP YOUR PI-BASED WIRELESS PRINTER

1 Install CUPS and other 2 Modify CUPS to allow 3 Add your user to
useful packages Remote Access admin group
Open Terminal on your Pi or connect This step is optional but Again in Terminal or over SSH enter
via SSH and run the command: recommended as it allows you the following command, replacing
sudo apt-get install avahi-daemon to access the CUPS web interface “yourusername” with the appropriate
cups cups-pdf python-cups from another browser on your user name:
The installation process will take some network. See “Connecting to CUPS” sudo adduser yourusername lpadmin
time as CUPS downloads drivers for for information. This will make sure you can
some common printers. administer printers.

54 // // Spring 2017
Make any printer wireless PROJECT

CONNECTING TO CUPS
By default, when you install CUPS on your Port 631
Raspberry Pi, the web interface can be Next, scroll down to the section reading
accessed only on the Pi itself. This can be a “Restrict Access to the Server” and look for
nuisance if you cannot connect the Pi to the the words “Order allow, deny”. Put a new line
printer, keyboard/mouse and a TV screen at after this with the following words:
the same time. Allow @Local
Fortunately it is possible to modify the Scroll down to the next section headed
CUPS configuration file to allow access from “Restrict Access to the Admin Pages” and
other devices on your home network. First once again after the text “Order allow, deny”
connect to your Pi over SSH and run the place the words “Allow @Local”. Finally
following command: scroll down to the next section, reading To enable remote access to CUPS, first type
sudo nano /etc/cups/cupsd.conf “Restrict Access to Configuration files”, and a hash sign on the two lines after “Only listen
Scroll down until you find the text “Only again insert “Allow @Local” after the text for connections from the local machine”.
listen for connections from the local “Order allow, deny”.
machine”. Type a # at the start of each of the Press Ctrl+X, then Y, then Return to save You will now be able to access the CUPS
next two lines to comment them out, then and exit. Restart the CUPS service to apply interface from any web browser connected
on a new line after this, type the following your changes with the following command: to your local network by visiting https://
text (see the illustration): sudo service cups restart yourpiIPaddress:631.

printer. This file simply details your printer’s After you’ve got
specifications such as paper size, available everything set
fonts, resolutions and so on. You may be able to up, you’ll be able
download this file from the printer manufacturer’s to manage your
printer just as if
website or get help by contacting its technical
it were connected
support number. directly to your
If no driver is available, or you still haven’t computer.
decided which printer to buy, the Open Printing
website, which is affiliated with the Linux
Foundation, has an extensive database of printers
that are compatible with Linux and therefore
should be compatible with CUPS running on the
Pi. Visit www.openprinting.org/printers for
more information. scan wirelessly by downloading and installing
If your device is a multifunction device printer- SANE (Scanner Access Now Easy). The Pi3g Blog
scanner or you also have a USB scanner you’d like has an excellent tutorial on this at http://bit.ly/
to use wirelessly, then you may also be able to Pi3g-scanner-share.

4 Connect to CUPS 5 Configure Default 6 Print test page


interface and add printer Options This step is optional but an excellent
In a browser go to the CUPS interface Provided you selected the correct idea before you try to add the printer
by visiting the address https:// driver in the previous step, the to your home network. To verify that
yourpiIPaddress:631 (for example default options such as paper size, everything is working, click the
https://192.168.1.2:631). Click the ink type and so on should be correct, Maintenance menu at the top-left
grey Add Printer button on the left- but feel free to change these if need and choose Print Test Page.
hand side of the screen. By default the be. Once you’re happy, click Set
username is “pi” and the password Default Options to complete setup.
“raspberry”. With luck you’ll see your
printer. Select it, then click Continue.

Spring 2017 // // 55
A preview of
things to come.
Kodi’s menus
are very easy
to navigate.
Videos will
continue to
play in the
background if
you’ve already
selected them.

Create a Pi-based
Media Centre
We show you how to make your Pi a one-stop media centre – for movies, TV
shows, music and internet streams – through the power of LibreELEC + Kodi
ouldn’t it be great if you could have website (www.raspberrypi.org/documentation/

W a smart home media centre for a


fraction of the cost of an off-the-
shelf system? Thanks to LibreELEC
and the Raspberry Pi, you can now
have your own fully-featured media centre for
installation/noobs.md) or buy an SD card with
NOOBS pre-installed for around £6 from Pi dealers
and websites such as www.thepihut.com.
We also strongly recommend that you use
a Raspberry Pi 3, as it has the best support for
your TV shows, films and music, with support for audio and video playback. You can use your
internet streaming via YouTube and other services. existing keyboard if you wish but true couch
LibreELEC describes itself as “just enough OS potatoes may prefer to opt to use a remote
for Kodi”. It’s a free, fast, open source Operating (see Taking Control on the opposite page).
System which is available to install on any SD You will also need to connect your Pi via
card using the handy OS installation manager HDMI to a television for this project, both for
NOOBS. It is a complete media centre suite which setup with NOOBS and for media playback. You
comes with a modified version of Kodi (formerly can connect to the Pi later via SSH to change the
known as XBMC), an open source media player configurations or add codecs remotely if you wish
capable of streaming media from the internet as (see Kodi Codecs over the page).
well as playing downloaded files.
As confusing as this terminology may be, the Kodi conventions
actual setup process is very simple. You can have Where possible Kodi will try to display information
a fully-featured media centre set up in minutes. about movies and TV shows in the database such
For this project, you’ll need a microSD card with as a plot summary, episode name, trailer and so
NOOBS installed. You can make this yourself by on. It does this through use of built-in “scrapers” –
following the instructions on the Raspberry Pi small programs that analyse videos and gather the

56 // // Spring 2017
Create a Pi Media Centre PROJECT

above information from online movie and TV show


databases such as IMDB and TheTVDB. In order
to help Kodi display the correct details, you should
name movie files both with the correct title and
year, for instance:
\Movies\Night of the Living Dead (1968).avi
The year is especially important if you wish to
distinguish between remakes of an original film.
Night of the Living Dead, for instance, was remade
in 1990.
Use folders to organise your collection of TV
shows. Individual episodes follow the format
“<name> seasonNNepisodeNN” – for example:
\TV Shows\Adventures of Superman\superman_
s01e03
You can find more detailed information on
naming conventions in the Kodi Wiki at http://
kodi.wiki/view/Naming_video_files.

Adding your media files


Once you’ve named your downloaded files, copy
them to an external drive so that they can be Set “This directory contains” to the correct media type, in this case Movies.
accessed by your Raspberry Pi. Provided you
have abided by the naming conventions above, source, or just stick with Movies. Next click OK.
it doesn’t really matter how you organise your The Set Content window will open. Click on the
collection – for the purposes of this project we drop-down menu below the words “This directory
used an external hard drive named “KODI”, inside contains” at the top left. Click on the small arrows
which there are three folders for “Movies”, “TV to select Movies. Pi bites
Shows” and “Music”. If you’ve organised your movies into separate
The initial setup process is easiest using the folders, click the option reading “Movies are in You can return to
the Set Content
keyboard and mouse. You can add more files later separate folders that match the movie title” and
window later to
using the remote. click OK. Otherwise simply click OK to continue. change the
To add movies. First click on Videos, then Files You’ll be taken back to the Files section of the settings for
in the main menu. Choose Add Videos from the Video menu. Click Movies to see your films. Right- individual folders.
menu on the left, then click Browse in the window click on any film and select See Information to Visit http://kodi.
wiki/view/Set_
that appears at the top right. You’ll now need to view the film poster, read a plot summary and content_and_
navigate to your external drive. On the Pi this is even play the trailer if available via YouTube. scan for more
usually found by clicking Root FileSystem, then Adding TV shows works in exactly the same information.
Media and searching in the Pi folder. way except that in the Set Content window you
Select the Movies folder, then click OK. The should set the “This directory contains” menu to
Add Video Source window will appear. At this TV Shows. Do this by clicking the white up arrow
stage you can type a new name for the media at the right of the menu.

TAKING CONTROL OF KODI


Although you can keep using your Pi’s existing Setting up is similar no matter what device
keyboard to control Kodi,this isn’t particularly you use. After installation of Official Kodi
elegant, especially considering that the Remote, launch it from your device’s home
software is designed to be run with a simple screen. Click Add Host at the bottom left of the
remote control. screen to go to the Kodi New Server screen. If
If you’re willing to part with £20, the Pi Hut you have not done so already, enable remote
sells the handy Flirc USB device. In simplest access to your Kodi server as outlined under
terms it is a Universal Infra-Red Receiver. It “Remote Access” over the page.
connects to your Pi and in combination with Enter anything you wish in the “Description”
a smart application can “learn” infra-red field at the top. Next type the IP address and
commands from your existing TV remote, the port number (default is 8080) of your Pi.
allowing you to control both the television and Click the Find Kodi button to have the app
the Pi. If you don’t have a remote, the Pi Hut automatically find your Pi. You will now be
also sells a small one which can be used with able to search, scan and play content via
the Flirc USB device. your device.
If the tactile sensation of a remote (or maybe
the clutter of another device lying around) isn’t Enter your Pi’s IP address (find this with the
for you, Android and iPhone users will be ifconfig command) and Port 8080, then click
pleased to hear there’s an official Kodi Remote Find Kodi to automatically search for your Pi. Be
app in their respective online stores. sure to enable remote access first from the Pi.

Spring 2017 // // 57
PROJECT Create a Pi Media Centre

KODI CODECS
The licences to use the AVI and WMV codecs can be bought cat /proc/cpuinfo
inexpensively from the Raspberry Pi website. The MPEG-2 codec, Copy down the 16 digit number next to “Serial”.
which allows playback of .avi files, costs £2.40, and the VC-1 Next visit www.raspberrypi.com/license-keys and click on
codec, which allows playback of .wmv files, is £1.20. Bear in mind the name of the codec you’d like to buy. Enter your serial number
that there are a number of media files LibreELEC will play out-of- in the box marked “Serial”, then Add to Cart. Your licence key for
the-box and you will not need these codecs to stream video the codec will be sent to you via e-mail within 72 hours.
through YouTube and so on. Once you have received the licence key, connect to your Pi via
In order to proceed you will need your Pi’s serial number. To get SSH once again. Use the following commands to open your
this, open Terminal on the Pi or connect via SSH and run the configuration file:
following command: cd /boot
sudo nano config.txt
Next paste your licence code(s) at the bottom in the following
format:
decode_MPG2=0x00000000
decode_WVC1=0x00000000
Replace the “0x00000000” in each case with the actual licence
key you received by e-mail.
Press Ctrl + X, Y, then Return to save and exit. Reboot your Pi
for the changes to take effect. Kodi will now be able to play back
files in these formats.

Paste your Pi’s serial number, then click Add to Cart for each
codec you want to purchase.

Kodi will automatically check for new content The YouTube add-on is one among hundreds
Pi bites and use scrapers to download the necessary available. Browse the “Look and Feel” category to
metadata for you each time it starts. select a different skin for Kodi. You can also add
The LibreELEC
website also has
automatic downloads for subtitles from popular
a handy tool to A word on add-ons websites such as OpenSubtitles.org from the
automatically Kodi can download enhancements to allow it do Subtitles category.
download the OS much more than play media files. These can be If you do choose to install add-ons, try to make
to an SD Card. See
installed via the AddOn Manager. For instance to sure you install just one for each purpose. For
http://bit.ly/
LibreELEC-SD for install the YouTube add-on, go to the Kodi main instance there’s no need to have more than one
more information menu and go to System > Settings. Next choose scraper for movies and it can cause errors.
Add Ons from the menu on the left. Scroll down to
Video Add Ons, select this, then go through the list Remote Access
to select YouTube, then click Install. The Kodi server can be accessed remotely via SSH
Once the installation is complete you can and Samba file sharing, but this is more for adding
The YouTube
access YouTube from the main menu by going to new content and maintenance. If you wish to
search in action.
Complete the
Videos > Add Ons, then clicking YouTube. The first access the server in order to play content, head to
setup wizard to time YouTube runs within Kodi, you will be asked System > Settings > Services > Web Server. Click
access the main to sign in and choose your language and region. the option to “Allow Remote Control via HTTP”. You
menu and look From there you can select a video in your playlist may set a password here if you wish but by default
for fluffy kittens. or search for others. it’s blank. The web interface is quite simplistic by
default but can be used to have your Pi play
content without using a keyboard or mouse.
If you want to use the official Kodi Remote App
on your mobile device, you should also click the
Remote Control tab in this Settings > Services
window and highlight the option to “Allow Remote
Control by programs on other systems”. In order
to set this up, you will need to know your Pi’s IP
address. To view this, connect to the Pi via SSH
and run the command ifconfig . Alternatively
install the handy app Fing to your mobile device,
which will list the IP addresses of all devices
connected to your network.

AirPlay support
Thanks to changes made by Apple to its wireless
protocol, AirPlay is not very well supported any
more in Kodi. Users of iOS 9 or newer devices can
stream downloaded music via AirPlay by going to

58 // // Spring 2017
Create a Pi Media Centre PROJECT

SETTING UP YOUR MEDIA CENTRE

1 Install LibreELEC 2 Set Device Name 3 Set up networking


Connect your Pi to a monitor and Once the installation is complete, the If your Pi is connected to your router
restart holding down the Shift key. LibreELEC setup wizard will appear. via Ethernet cable, this window will
The NOOBS menu will provide you a Click Next to continue to the first step, not appear, so you can ignore this
choice of OS to install. Tick LibreELEC. which is to set a meaningful name for step. Otherwise LibreELEC will inform
If you don’t see this option, make sure your device. If you plan on having you that it needs internet access to
your Pi is connected to the internet by more than one media centre, consider download data for movies and TV
clicking Wireless Networks. Confirm numbering them, along the lines of shows as well as to run updates.
that you understand installing “jane-librelec-1”. This will also help Choose your network from the
LibreELEC will delete anything that’s identify the device on the network if available wireless networks and
already on the SD card. you use file sharing later. enter your Wi-Fi password.

4 Set up sharing 5 Install Add-Ons 6 Set up remote control


This step is optional but can be helpful This step is also optional but If you have a Flirc USB device, you
if you want to access your Pi via recommended if you want to add free need to set it up using a different
another computer. Enable the ability streaming TV channels or websites to computer. Download software for
to connect via SSH and/or Samba by Kodi. Official add-ons can be accessed Windows, Mac or Linux from https://
highlighting the radio button next to from System > Settings > Add Ons. flirc.tv/downloads. Next go to
each. If you choose to connect via Follow the steps outlined under “A https://support.flirc.tv and click
SSH the default username is “root” word on add-ons” (on the opposite “How to Set up Flirc” for instructions
and the password is “libreelec”. You page) to enable support for YouTube. on how to calibrate your remote. If you
can change these to something more Install extra codecs now if necessary prefer, download the Kodi remote app
secure if you wish. (see Kodi codecs opposite). to your mobile device. Further help is
available from http://kodi.wiki/
view/Official_Kodi_Remote.

System > Settings > Services in Kodi and changing Be warned – installing LibreELEC will replace
the Settings Level at the bottom left. Click the the Raspbian OS on your microSD card, along with
AirPlay tab on the left. Click “Enable AirPlay any files you created and/or downloaded. Either
Support” and disable “Enable AirPlay ‘Videos’ and obtain a fresh SD card with NOOBS installed or
‘Pictures’ Support”. The Pi should now appear as back up any files on your existing card before
an AirPlay device on your Apple devices. AirPlay setting up your media centre.
support is patchy, though, depending on your Should Kodi be unable to see your external
version of iOS, so do not be surprised if this drive, this may be because the drive requires more
doesn’t work. Visit http://kodi.wiki/view/ voltage than the Pi’s USB ports can deliver. Try
AirPlay for more information. again using a powered USB hub.

Spring 2017 // // 59
PROJECT Create a Pi Media Centre

Pay close If you have issues with playing certain video If you’re having video or audio issues, from
attention to files, this may be due to missing codecs. These are the main Kodi menu go to System > Settings
file names to computer programs for encoding/decoding large and select either “Video Output” or “Audio Output”
make sure the data files such as video. There are hundreds of to adjust your resolution or change your sound
metadata is
different codecs but they’re generally considered channels, among other options.
correct. Place
a necessary evil as they help to compress media Finally, make sure that you either have the
the year of the
film in brackets files to a size where they can be easily managed permission of the copyright holder to download
after the title. and shared over the internet. any films or TV shows, or that they are in the
The year 1968 Public Domain. Because of differing copyright
has been added Codec confusion laws there is no one definitive list of public domain
to the above film Some codecs are free, open and unpatented, such films, but the Internet Archive (www.archive.org)
to distinguish it as Ogg Vorbis, which can be used to encode music is an excellent place to start.
from the 1990 files. As a result, computer manufacturers can
remake. bundle them with devices so they can be played
out of the box. Other codecs are proprietary, in
that they can be downloaded and used only on
payment of a licence fee. In order to support the
principles of free and open software (and keep
Pi bites costs down), the Raspberry Pi doesn’t include
such codecs.
Select the In practice this can mean that if you try to play
Programs media files in quite common formats such as
category, then Windows Media Video (.wmv) or AVI (.avi), you
“Get More” from
may find LibreELEC doesn’t have the right codec
the Kodi main
menu for extra to play them. Follow the steps in Kodi Codecs on
apps to check page 58 to download and install them.
your e-mail, If movies and TV shows you add do not display Kodi can automatically check for new content and even
post to Facebook, correctly, make sure you have followed the naming
chat on IRC and
use scrapers, mini-programs which download metadata for
much more.
conventions as laid out in the Kodi Wiki, being sure TV shows and films for you. The default scraper is The Movie
to include the movie year. Database (themoviedb.org).

60 // // Spring 2017
Image credit: Daniel Chote, http://chote.com

TalkiePi: Make
a walkie-talkie
Nate Drake tickles your nostalgia bone with Daniel Chote’s awesome
TalkiePi project to create a retro-style Wi-Fi walkie-talkie

hose who have been following the The interface of the TalkiePi couldn’t be simpler.

T awesome TV series Stranger Things


may have felt a twinge of nostalgia at
the retro walkie-talkies used by the
children. Fortunately, New Zealander
Daniel Chote decided to take his own homage to
When the button is depressed, it lights up and you
can talk. When it’s released the channel is clear.
There are two other status LEDs, indicating your
connection to the wireless network and whether
others have joined your particular channel.
the ’80s one step further. The TalkiePi, which is his Clearly, this project is a labour of love but it isn’t
brainchild, is a project to turn your Pi into a simple useful only to children. Many gamers make use of
push-button walkie-talkie which works over Wi-Fi. the Mumble protocol to talk privately while playing.
Chote designed the project with his kids in Or two TalkiePi’s can also be used as a handy
mind, hence the simple interface. By default, once intercom for your front door.
the software is installed it will automatically
connect to his own server using the Mumble Getting started
protocol, enabling users to chat right away. Along To begin you’ll need a Raspberry Pi with Raspbian
with the software on his GitHub page are detailed installed on the SD card for each TalkiePi you want
instructions about components and even a casing to build. The Raspberry Pi 3 is perfect for this
design that can be produced with a 3D printer to project as it has integrated Wi-Fi. The microphone
provide a nostalgic experience that will tug at the originally used in the projects is US Robotics’ USB
heartstrings of the average 30-something or older. Speakerphone (USR9610), which will be removed

Spring 2017 // // 61
PROJECT TalkiePi

Image credit: Daniel Chote, http://chote.com


Before you from its casing and connected to the Pi. This can for the “talk” button. There are some basic light-up
start taking your be hard to obtain outside the US, however, so plastic buttons available in blue, green, red, white
speakerphone either search eBay for the same model or see if and yellow for £3 each. There are also more
apart or soldering you can find a USB speakerphone. Be careful to sophisticated metal pushbuttons in blue, green,
things together, choose a speakerphone which works over a USB red and white for £5 each. The original TalkiePi
try assembling
cable and not Bluetooth. project was built with a plastic pushbutton but feel
the parts on a
To power the Pi you’ll also need a short 90 free to change this if you feel confident.
breadboard first
to check that degree USB cable. (For example, Amazon UK lists The TalkiePi also needs three 330-Ohm
everything works. a 10cm version for £1.84 from the seller SWUK.) If resistors. These should be readily available at your
you’re planning on printing the TalkiePi casing local electronics supplies store, but if you don’t
you’ll also need five M3 nylon screws and one have one nearby the ever-handy Makersify sells
M3x20 nylon standoff. You can buy a pack of both a “basic components mixed pack” for £4, which
of these items for £2 and £3 respectively on the Pi among many other handy accessories includes
Hut’s sister site Makersify (https://makersify. 10 suitable resistors.
com). The case will also require two M3 15mm and If you plan to use the TalkiePi as a home
two M3 25mm bolts. As an example, Amazon UK intercom you will most likely connect it to mains
seller Sourcingmap sells 50-packs of each of these power, but if you want a truly portable transmitter
for £3.70 and £3.86. The speaker itself requires consider investing in a battery pack like the PiBorg
two M3 10mm bolts and nuts and, for example, (more about this shortly).
Amazon seller Falcon Workshop Supplies Ltd Needless to say, if you’re serious about
offers four-packs of these for £1.40 each. assembling this project you’ll also need wire and
To connect your wiring and LEDs to the Pi you’ll access to a soldering iron. The Pi Hut, for example,
need a GPIO Header connector. Pretty much any sells a handy Breadboarding Wire Bundle of 75
header will do. Pi Hut, for instance, sells a 2x20 flexible stranded cord wires for just £3. For the
female header for £3. same price, you can also invest in a half-size
Both the “status” LEDs (see below) should be breadboard to experiment with.
5mm, each with its own holder. Makersify sells a Bear in mind that if you want to communicate
50-pack of LEDs as well as a variety of Adafruit with other people you will want to build two units,
LED holders for £4-£5 each. Makersify also sells so you’ll need double the components listed. As
pushbutton LEDs, one of which will be necessary you’ll have seen, however, most of the components

62 // // Spring 2017
TalkiePi PROJECT

come in packs so you should be able to make as casing as well as the speaker cover for you. A
many TalkiePis as you’re likely to need. simple search online for 3D print services in the
Pi bites
UK will reveal any number of companies who are If you wish to
Buttons and pins happy to make as many or as few parts as you customise your
The basic setup for the GPIO pins is easy to grasp. need. The usual procedure is that you will fill in an TalkiePi further,
There’s an LED built into the pushbutton on the online web enquiry form and upload the STL files PLA doesn’t
work well with
front of the TalkiePi itself which lights up when to the 3D printing company’s website and they regular paint but
you’re transmitting. There are also two separate will contact you with a quote. One such firm we you can achieve
“online” and “participant” status LEDs. contacted to enquire about two sets of TalkiePi top good results
If this is your first project, it’s best to work casing, bottom casing and speaker covers quoted with acrylics
or nail polish.
through the steps on the website on your £142.54 for manufacturing and shipping the parts!
Alternatively use
breadboard before you solder anything. Also Considering that DIY 3D printers now retail for as coloured tape.
pay close attention to the GPIO diagram on little as £178, you may prefer to either invest in one
the website before you start. For full assembly or find a friend who will let you use theirs.
instructions, visit the main project page at
http://bit.ly/Wi-FiWalkieTalkie. Safety in Mumbles
If you decide to mimic the TalkiePi project, you Mumble servers are highly customisable, and it’s
don’t necessarily have to use a 3D-printed case, possible to create select groups or channels for
but it’s certainly much handier to have trailing everyone you wish to talk with. For instance, you
wires boxed up. The actual 3D designs for the may prefer that your friends playing World of
casing as well as the speaker cover are based on Warcraft can’t hear everyone who buzzes your
a retro walkie-talkie, and you can find them on front door intercom. If you do set up your Mumble
Daniel Chote’s GitHub page https://github.com/ Server (see Managing Mumble, over the page),
dchote/talkiepi/tree/master/stl. The STL make sure to group conversations together. You
(StereoLithography) file format is compatible with may need to use the go run command each time
most 3D printers. The TalkiePi project was done you switch channels.
on a Monoprice Select Mini 3D printer using PLA To prevent your conversations being monitored,
plastic with 100 percent infill. PLA has the you should also consider generating an SSL
advantage of giving off a pleasant sugary smell certificate for your Mumble client (see Certified
when printing as well as being quite sturdy. Mumbler below for information on how to do this).
Bear in mind that the casing was designed If you choose to install the standard Mumble
specifically for the US Robotics speakerphone client, it comes with its own certificate, but you
listed on the website, so other speakers may not can choose to generate another in your own name
fit as well. Carefully check the dimensions of your by running the certificate wizard – see www.
components to avoid wasting precious material. mumble.com/support/mumble-creating-a-
If you already have a 3D printer you will most certificate.php. This enables you to generate a
likely be comfortable enough from previous self-signed certificate, which is ideal for a small
projects to simply produce the parts yourself. If group of people. If you plan to open your Mumble
you don’t have a 3D printer, then it’s best to ask a server to the public, you may wish to obtain a
third-party company to make the top and bottom trusted certificate from a bona fide certificate

CERTIFIED MUMBLER
Mumble software, like the TalkiePi when asked press Return to choose the
program, can use certificates to connect default options such as location, e-mail
to Mumble servers. This avoids the need address etc. Next run the following:
for typing in passwords and allows you to openssl rsa -in key.pem -out nopasskey.pem
register accounts easily with new servers. Enter the password one last time. Finally
By default, this feature is switched off in run the following to combine your files into
TalkiePi as Daniel Chote’s own server, a single certificate:
which he set up for his children, doesn’t cat nopasskey.pem cert.pem > mumble.pem
require certificates. If you wish to use other Now switch back to the root user with:
Mumble servers, however, connect to sudo -i
your Raspberry Pi via SSH, then run su Then use the following command to edit
mumble to switch to the Mumble user and Mumble’s configuration:
cd ~ to switch to the home directory. nano etc/systemd/system/mumble.service
You’ll need to generate a container for Scroll to the following line:
your certificate with the command: ExecStart = /home/mumble/bin/talkiepi You can generate a certificate from the
openssl genrsa -aes256 -out key.pem Leave a space and type the following on command line or alternatively if you can
You’ll also be asked to enter a password. the same line, replacing “yourusername” connect your Pi to a monitor and use the
Next create the certificate itself with the with your user name: Mumble client’s easy certificate wizard.
following command: -username yourusername -certificate /
openssl req -new -x509 -key key.pem -out home/mumble/mumble.pem changes. The Raspberry Pi will now use
cert.pem -days 1095 Press Ctrl+x, then y, then Return to save a TLS certificate when connecting to
Enter the same password as before and and exit. Finally reboot the Pi to effect your supported Mumble servers.

Spring 2017 // // 63
PROJECT TalkiePi

SET UP YOUR TALKIEPI

1 Create a Mumble user 2 Install dependencies


Open the Terminal on your Raspberry Pi or connect via SSH and Switch to your new Mumble user with su mumble . Next create the
switch to the root user with the command sudo -i . Next, create the installation directories with mkdir ~/gocode and mkdir ~/bin . You’ll
user by running the following command: need to create softlinks for these two directories with the commands:
adduser --disabled-password --disabled-login --gecos "" mumble export GOPATH=/home/mumble/gocode
Give this user the necessary permissions with the following: export GOBIN=/home/mumble/bin
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input, Finally, move to the install directory with cd $GOPATH .
gpio mumble

Image credit: Daniel Chote, http://chote.com


3 Download and build software 4 Connect your USB speakerphone
To download everything run go get github.com/layeh/gopus and go Connect the USB speakerphone to an available port on the Pi. At this
get github.com/dchote/talkiepi . Next, cd into the TalkiePi directory: point you’ll need to refer to the instructions on the TalkiePi website at
cd $GOPATH/src/github.com/dchote/talkiepi . Now build TalkiePi: http://bit.ly/Wi-FiWalkieTalkie and take it stage by stage. If you
go build -o /home/mumble/bin/talkiepi cmd/talkiepi/main.go print the project’s case on a 3D printer, it’s specifically designed to fit
Run sudo -i and makeTalkiePi boot up every time the Pi restarts: the PI 3 and the US Robotics speakerphone. You attach the right/left
cp/home/mumble/gocode/src/github.com/dchote/talkiepi/conf/ angle USB cable to the bottom-right USB port of your Pi and will need
systemd/mumble.service /etc/systemd/system/mumble.service to mount the Pi and then mount the speaker to the front panel.
Image credit: Daniel Chote, http://chote.com

5 Optional LEDs and casing 6 Configure Mumble Server settings


Again, this optional stage requires following the steps on the project We recommend certifying your Mumble server so that you don’t
website at http://bit.ly/Wi-FiWalkieTalkie. You need to do such need to use passwords to connect, which we explain how to do in
things as solder your positive and negative LED wires to the GPIO Certified Mumbler on the previous page. We’d also advise referring to
pins, add heat shrink to stop shorting, put together the button GPIO Managing Mumble on the opposite page for more information on how
connector and position and fasten the LEDs. You can also place the Pi to use your own Mumble Server and channel. You can, however, use
inside an enclosure with a power cable or battery pack. the TalkiePi Mumble server straight away, if you wish.

64 // // Spring 2017
TalkiePi PROJECT

authority. There are several to choose from; the


Mumble wiki has a guide to doing this via Comodo
(instantssl) at http://wiki.mumble.info/wiki/

Image credit: Daniel Chote, http://chote.com


Obtaining_a_Comodo_Certificate.
By default, the TalkiePi software connects to
Daniel Chote’s own Mumble server and generates
a username automatically for you. This keeps
things simple but besides being not very fair on
Chote’s bandwidth, it isn’t the most secure setup.
See Managing Mumble below for how to configure
TalkiePi to work with your own Mumble server.
Technically you could run the Mumble server
software on the same Pi on which you’re talking,
but this can cause network errors, so it’s best to
have a separate device. If you plan to use the Pi
only within the same building, consider having a
machine connected to your network dedicated to If nostalgia wins out and you decide you prefer The TalkiePi
running Mumble’s server software, Murmur. an authentic looking walkie-talkie, bear in mind project’s GitHub
By default, the Pi may not use the USB that it will be effective only while connected to the page has handy
speakerphone you’ve attached as the sound same wireless network on which the Pi was set up. schematics for
device. If you can connect your Pi to an HDMI This can be an issue if you need to move the Pi the case. Feel
free to print
monitor, this is fairly easy to fix by right-clicking elsewhere, as it’s not possible to connect the HDMI
these with a 3D
on the volume button and adjusting your sound cable while it’s inside the TalkiePi casing. Instead printer or make
preferences. If you have no monitor or the Pi has connect via SSH and run this command to edit your own.
already been placed in its casing, connect via your network settings:
SSH, and run the following commands: sudo nano /etc/wpa_supplicant/wpa_supplicant.
sudo -i conf
aplay -l At the very bottom of the file, paste the details of
This will list all sound devices. Make a note of the the new wireless network as follows:
“card” number of the USB device (most likely it’ll network={
be “card 1”), then run: ssid="yourwifinetworkname"
nano /usr/share/alsa/alsa.conf psk="yourwifipassword" Pi bites
Scroll down and change defaults.ctl.card 0 to the }
corresponding number of your speakerphone. Do Press Ctrl+x, then y, then Return to save and exit. For a guide for
the same for defaults.pcm.card 0 . The TalkiePi is only as good as the battery pack setting up Murmur
for Windows and
powering it. You can either use a USB battery pack
Linux machines go
Cross Talk as outlined on the TalkiePi website or if you prefer to http://bit.ly/
The default setup for the TalkiePi is that you push a neater solution, you may want to consider using Murmur-Server
the button to talk, as with old style walkie-talkies, a PiBorg (https://thepihut.com/products/
but Mumble doesn’t have to work this way. If you battborg?variant=1103793752). This is a
want to use it with a keyboard shortcut or with a custom power converter for the Pi, which works
headset when you raise your voice, the easiest way with most batteries and even comes with an eight-
is to run the graphical audio wizard with the official battery AA pack. The Pi Hut website recommends
Mumble client. Connect your Pi to a monitor, open using rechargeable batteries.
the Terminal and run sudo apt-get install mumble . The TalkiePi project is a work in progress.
Next run Mumble and you’ll be asked to configure Currently, Chote is working on running it on a Pi
your microphone and sound preferences. If you’ve Zero, which would be much smaller and less power
set up your own Mumble server you can also use hungry. For the latest updates see https://
the handy menus to input the details here. github.com/dchote/talkiepi.

MANAGING MUMBLE
In order to make sure your setup is secure also think of a username you’d like to On the line beginning username you
you’ll need your own Mumble server. You register and set up a channel specifically may wish to insert a permanent username
can set this up yourself on a separate for you and your friends. (The default is between the quotation marks. Enter a
Raspberry Pi if you plan on communicating Root.) Next connect to your Pi via SSH or password only if your Mumble server
only over your home wireless network, for open the Terminal and run the following requires one.
example for an intercom. Alternatively, you command to edit TalkiePi’s configuration: If you have previously created a
can rent a Mumble server online. If you sudo nano /home/mumble/gocode/src/ certificate, find the line starting insecure
want to play around with a Mumble server github.com/dchote/talkiepi/cmd/talkiepi/ and change true to false. Press Ctrl+x,
of your own you can get a free one-month main.go then y, then Return to save your changes.
trial at www.mumble.com/free-mumble- Scroll down to the line beginning server Finally to start the TalkiePi software with
server.php. and replace the TalkiePi server address your new settings, run the following:
Once your server is set up, note down talkiepi.projectable.me:64738 with your go run /home/mumble/gocode/src/github.
the domain name and its port. You should own, e.g. natedrake.mumble.com:64248. com/dchote/talkiepi/cmd/talkiepi/main.go

Spring 2017 // // 65
The tiny
Raspberry Pi
can become your
bulwark against
online threats of
all kinds.

Protect yourself with


a Pi-based firewall
Turn your Pi into an ultra-secure access point complete with firewall
to protect your computer from the dark side of the internet
ou probably remember the news. In AP (access point). In other words, the Pi itself will

Y December 2016, the BBC reported


that the infamous Mirai worm had
infected a substantial number of
routers used by customers of UK
ISP TalkTalk, stealing their Wi-Fi passwords. The
create a wireless network for you to connect to.
The Pi can then be connected to your router, so
that anyone connected to its wireless network
can continue to access the internet.
The second part of this project involves
worm exploited the default admin passwords that installing an easy-to-use firewall on your Pi
are hardwired into a number of machines, and which will block any open ports that attackers
although the focus was on enslaving devices to can exploit. You can also configure the firewall to
take part in DOS (Denial of Service) attacks, the allow access to legitimate programs, as well as
implications are staggering. Even those handful of block any websites you think are unsafe. Provided
users who take the trouble to change their router’s you have the correct equipment, you can have
default passwords seldom bother to use firewalls. your own secure AP with firewall up and running
In plain English, this means your router’s in under 20 minutes.
settings, and theoretically devices on your home
wireless network, could be laid bare by attackers. The bare necessities
Fortunately the Raspberry Pi comes to the rescue The wireless device you use must be compatible
once again. We’ll show you how. with hostapd (more about this shortly). This
This project can be roughly divided into two project is technically compatible with all models
parts. The first is to set up your Pi as a wireless of Pi, although the Pi needs to be both wireless-

66 // // Spring 2017
Pi-based firewall PROJECT

enabled and have an Ethernet port to connect to


your router. The Raspberry Pi 3 lends itself very
well to this. Setup if at all possible should be done
using a keyboard and monitor rather than SSH as
once the Pi has created its own AP, you won’t be
able to connect to it wirelessly. You can however
connect to it through your router’s wireless LAN
network if you know the IP address.
If you prefer the compact Pi Zero, make sure
you have both a USB OTG Host cable or a USB
to MicroUSB OTG shim (available from all Pi
accessory suppliers – from The Pi Hut, for
example, it’s just £2, https://thepihut.com/ WAN
products/usb-to-microusb-otg-converter-
shim). You’ll also need an RJ45 to USB converter
to attach to the USB port. You’ll then be able to Firewall
connect the Pi Zero to your router.
In addition to the Pi itself, you’ll need a
secondary device to check that the wireless AP A diagram of how a firewall sits between your home network (LAN) and the
is functioning correctly, as well as a network cable internet (WAN). Individual “bricks” can be removed to let legitimate traffic through.
to link the Pi to the router. Most modern routers
have at least one USB port, so you should be able
to power the Pi from there. router via Ethernet cable first. If you have a
For security reasons and to save on resources, mobile device, the handy app Fing can be used Pi bites
it’s best to have a dedicated Pi for your home to easily identify the IP address of all devices on
To find out if your
firewall, rather than one that you might use for your local network. Fing is available to download wireless card
other purposes in addition. If at all possible, plug free of charge from both the iOS App Store and supports AP
your Pi into a monitor and work from Terminal Google Play. mode, open a
directly when going through this project rather Once you’re satisfied that the AP is working Terminal and run
the command iw
than connect via SSH. This reduces the chance as you’d like, make sure to disable the wireless
list . If it does, you
that your connection will drop at a vital stage in function on your router to prevent people from should see the
the proceedings. connecting to it instead of the Pi firewall. initials “AP” under
As always, it’s best to start with a clean install “valid interface
of the latest version of Raspbian on the Pi. Once Talking points combinations”.
the install is complete, open Terminal and run the The access point is set up and managed by the
following commands to be certain your system is handy program hostapd. Step 3 of our guide on
fully up to date: page 69 covers creating a configuration file
sudo apt-get update wherein you’ll specify the settings for the Pi’s
sudo apt-get upgrade new wireless network such as name, password
If you do not have access to a monitor, you can and encryption type used. You can return to this
connect to the Pi wirelessly through your router’s hostapd.conf file at any time to change your
Wi-Fi network via SSH. Connect your Pi to the settings if you wish.

DOMAIN DENIAL
Its full name, Uncomplicated Firewall, might to view an objectionable page’s IP address –
sound modest, but Ufw is a powerful firewall for instance:
and can be used to block access to certain host strawberryfunk.com
websites. Although technically you can also This will output the IP address of the site in
do this with dnsmasq, this would be a form question. Next, use ufw deny to block this
of “DNS hijacking”, which is a rather dastardly domain – for example:
procedure usually carried out by scammers. sudo ufw deny out from any to 205.178.189.29
The advantage of using Ufw is that it blocks You can check that the domain has
domains by IP address. This means you have successfully been blocked by using ping –
to write down only one rule per address rather for example:
than remember the various domains and ping -c 1 strawberryfunk.com
subdomains used by sites. Imagine trying to If you have set up Ufw correctly, ping will
block every variant of Facebook.com, for report that the domain is unreachable. Use ping to check that a domain has
instance – fb.com, m.facebook.com... the list Ufw can also block outgoing connections been successfully blocked. Some websites
goes on. to certain ports. For instance if you want to have more than one IP address, so block
It stands to reason, then, that in order to reduce the chance of your Pi being used to each of these in turn.
block websites by IP address you’ll need that send spam messages, you can disable Port 25
information. Open Terminal on your Pi or with the following:
connect via SSH and use the host command sudo ufw deny out 25

Spring 2017 // // 67
PROJECT Pi-based firewall

firewall program out there – in fact there are


entire distributions of Linux such as IPFire in the
wild which are specifically designed to act as a
gateway between your computer and the internet,
1
2 complete with colourful windows. Why then use a
rather mundane command line application? Aside
4 from the fact that Ufw has withstood the test of
time, it’s very easy to install and set up. Once
enabled, it will launch automatically. By default
3 it will block all incoming connections and allow
all outward ones. This can be a nuisance if you
and other users on your network want to use
Serving
certain applications like BitTorrent or Skype, but
suggestion for
Pi Zero internet
fortunately configuring exceptions to these rules
connection. The is easy. Ufw also has a graphical companion for
OTG cable (2) While every wireless card can connect you to those who are still not entirely comfortable with
allows connection a Wi-Fi network, not all Wi-Fi cards can generate the command line. See Configuring your Firewall
of regular USB their own wireless networks. Fortunately the Wi-Fi below for more information.
devices. The RJ45 module built into the Raspberry Pi 3 does support Ufw also has the ability to block connections to
converter (3) this feature, which is a good reason to consider specific IP addresses or ranges, so you can prevent
allows connection using one for your firewall. network users from visiting certain websites – see
via Ethernet.
We’ll also install the devilishly clever program Domain Denial on the previous page).
dnsmasq to handle the network infrastructure. It Although Ufw can be used to block individual
also draws its settings from a small configuration websites, any web pages that do load will display
file, which you will set up in Step 4. The suggested banner advertisements and pop-ups. By far the
settings have dnsmasq use Google for its DNS easiest way to deal with these is for you and
Pi bites server (8.8.8.8) but you can change this to another other users on your network to install browser
DNS provider if you wish, such as OpenDNS extensions such as Ublock Origin and Ghostery
For a full rundown (208.67.222.222). For best performance, you may to prevent both adverts and tracking cookies.
of Ufw’s features want to list more than one DNS server. To do this, Mobile users can also benefit from the official
see https://help.
simply add a new line for this in the dnsmasq.conf Adblock Browser.
ubuntu.com/
community/UFW. file, for example If this isn’t feasible, you can remove the Pi’s
server=208.67.222.222 default DHCP (Dynamic Host Configuration
server=208.67.222.220 Protocol) server and configure dnsmasq in its
place to automatically redirect known ad servers
Uncomplicated firewall to an internal IP address. By default this will create
Ufw (Uncomplicated Firewall) comes bundled with ugly blank spaces in the middle of your web pages,
a number of Linux distros and true to its name is but you can solve this by also installing the handy
very simple to use. It is by no means the only app pixelserv. Pixelserv’s sole purpose in life is to

CONFIGURING YOUR FIREWALL


Once enabled, Ufw will automatically launch on startup, blocking nano /etc/services
all incoming connections and allowing all outgoing ones. This If your service isn’t listed, you can simply open the port it uses.
might not be the ideal setup for you, particularly if you like to For instance RealVNC, which can be used to connect remotely to
connect to your Pi via SSH or VNC. To configure Ufw, use Terminal the Pi’s desktop, runs on Port 5800. To have Ufw open it, run:
on your Pi. Ufw recognises most services like SSH, so in most sudo ufw allow 5800
cases you can enable access using ufw allow – for instance: To allow connections only from a specific IP address, use from
sudo ufw allow ssh – for instance:
To see a full list of services you can enable in this way, simply run sudo ufw allow from 192.168.1.12
the following command: For a complete readout of the Firewall settings in Ubuntu, use
the following:
sudo ufw status verbose
To make life even easier for you, Ufw has a graphical companion,
Gufw. To open it, run:
sudo gufw
There’s a handy rocker switch as well as a list of open and blocked
ports. Click the + button to add additional rules. Click “Show
extended actions” to see preconfigured settings for certain
popular applications such as Skype.

Gufw is the graphical companion to Ufw. It has preconfigured


rules to allow more popular apps such as Skype. This saves you
the trouble of having to work out which port numbers to open.

68 // // Spring 2017
Pi-based firewall PROJECT

CREATE YOUR FIREWALL WITH UFW

1 Install prerequisites 2 Set Static IP 3 Set up Access Point


Plug your Pi into the Ethernet port on Open your network interfaces Open the hostapd.conf file by running
your router, then connect via SSH or configuration with: sudo nano /etc/hostapd/hostapd.conf
ideally open Terminal on the Pi. Install sudo nano /etc/network/interfaces Paste the following:
the necessary programs by running: Find the line “iface wlan0 inet static” interface=wlan0
sudo apt-get install dnsmasq hostapd and change it to: driver=nl80211
Next, run the following to open the iface wlan0 inet manual ssid=piVPN
configuration file: Press Return to start a new line, then hw_mode=g
sudo nano /etc/dhcpcd.conf paste the following: channel=1
Add these lines to the very bottom address 172.24.1.1 macaddr_acl=0
of the file: netmask 255.255.255.0 auth_algs=1
interface wlan0 network 172.24.1.0 ignore_broadcast_ssid=0
static ip_address=172.24.1.1/24 broadcast 172.24.1.255 wpa=2
Press Ctrl+X, Y, then Return to save Place a # at the start of the line wpa_key_mgmt=WPA-PSK
and exit. beginning “wpa-conf”. Save and exit wpa_passphrase=raspberry231
in the same way as before. wpa_pairwise=TKIP
rsn_pairwise=CCMP
Change the SSID, passphrase and
network encryption as you see fit.
Next run:
sudo nano /etc/default/hostapd
Find the line starting #DAEMON_
CONF="". Remove the # at the start
of the line and change it to:
DAEMON_CONF="/etc/hostapd/
hostapd.conf"

4 Configure dnsmasq 5 Set up IPV4


Move the old dnsmasq configuration Forwarding
file with: Open Terminal on your Pi and run:
sudo mv /etc/dnsmasq.conf /etc/ sudo iptables -t nat -A
dnsmasq.conf.orig POSTROUTING -o eth0 -j
Then create a new one by running: MASQUERADE
sudo nano /etc/dnsmasq.conf sudo iptables -A FORWARD -i eth0 -o
Paste in the following text: wlan0 -m state --state
interface=wlan0 RELATED,ESTABLISHED -j ACCEPT 6 Set up Firewall
listen-address=172.24.1.1 sudo iptables -A FORWARD -i wlan0 Run the following commands, one
bind-interfaces things elsewhere -o eth0 -j ACCEPT after the other:
server=8.8.8.8 sudo sh -c "iptables-save > /etc/ sudo update-rc.d hostapd enable
domain-needed iptables.ipv4.nat" sudo update-rc.d dnsmasq enable
bogus-priv Next, run: Reboot the Pi, and reopen Terminal. To
dhcp-range=172.24.1.50,172.24.1.150, sudo nano /etc/rc.local install and then enable the firewall run
12h Paste the following two lines just the following:
Save and exit. Now run: above the line reading “exit 0”: sudo apt-get install ufw gufw
sudo nano /etc/sysctl.conf iptables-restore < /etc/iptables.ipv4.nat sudo ufw enable
Find the line starting “net.ipv4.ip_ /usr/sbin/hostapd /etc/hostapd/ You may wish to configure the firewall
forward=1” and remove the # at the hostapd.conf at this stage – see Configuring your
start. Save, exit, and reboot the Pi. Firewall on the opposite page.

Spring 2017 // // 69
PROJECT Pi-based firewall

IT-literate users on your network may bypass


this via a VPN. You can of course use Ufw to
block the ports commonly used by VPNs, such as
1154, or block all outgoing traffic and then enable
it for specific applications and services. Some
applications will randomise the ports used, making
it difficult to lock down specific protocols like
BitTorrent. You might consider disabling UDP
(User Datagram Protocol) if you want to prevent
streaming of most music and video sites.
If you choose to use a browser extension or
pixelserv to block ads, certain sites may display
incorrectly or fail to load altogether. Adblocking
extensions can usually be disabled temporarily by
clicking on their icon in your browser’s menu bar.
For security reasons, it would be wise to use a
dedicated Pi exclusively as an Access Point and
avoid placing any personal data on it. For extra
Connecting to support ad-blocking via serving a transparent 1x1 safety, make sure to use a long, robust password –
a hidden network pixel GIF image in place of adverts. This makes the one in the tutorial is only by way of example.
makes life only your ad-blocking a much tidier experience. For the uber-cautious, consider creating a
slightly more If you’re interested in adding an ad-blocking hidden Wi-Fi network for the Pi. Edit the hostapd
difficult for other
feature to the Pi, a tutorial is available on the configuration by opening a Terminal and typing:
network users but
Adafruit website: https://learn.adafruit.com/ /etc/hostapd/hostapd.conf
much harder for
hackers, as they
raspberry-pi-as-an-ad-blocking-access-point Change “ignore_broadcast_ssid=0” to “ignore_
need both the broadcast_ssid=1”.
network name Building bridges From now on all devices will have to enter the
and password. This project focuses on bridging the connection name of the network as well as the password in
between your Pi’s wireless interface and the order to connect. Consider setting a new name
Ethernet interface. This allows your Access Point when editing the file to be extra secure.
to remain connected to the internet. If you need If you have devices using a cabled connection
to double-check the names of your interfaces, you like a home server, you can continue connecting
can run the command ifconfig at any time. By these directly to your router for internet access
default the names of these interfaces should be but bear in mind that they won’t be visible on
“wlan0” and “eth0” respectively. the Pi’s wireless network. This works both ways,
If you’re unable to plug the Pi into a router, however – the Pi will not interfere with their
theoretically you could add another wireless operations at all.
interface such as the official Raspberry Pi Wi-Fi Finally, bear in mind that your router may
module and use it to access your router’s wireless also use a firewall. If you’re comfortable with
network. However, this is less secure and will configuring your router, you can choose to
reduce your connection speed. If your router is open and close ports to match Ufw’s settings.
somewhere hard to reach (or actually out of Alternatively you can disable the router’s firewall
range), consider using a “homeplug” style device altogether and let the Pi manage everything.
which uses the power lines in your home or office
for network connections.
Do not despair if the Access Point or the firewall
do not work the first time you go through the
steps. Fortunately the Pi’s network settings are
very flexible, so you can usually go back over the
steps again without having to reinstall Raspbian.
If you’re using a Wi-Fi driver besides that built
into the Pi 3 or the official Raspberry Pi Wi-Fi
adapter then you may have to change the
“driver=” value in hostapd.conf. For information
visit http://linuxwireless.org/en/users/
Documentation/hostapd.
You can disable the Ufw firewall permanently
and delete all rules with the following command:
sudo ufw reset
If required, you can also restore the settings you
previously backed up with dnsmasq by reversing
the original command: The handy browser add-on uBlock Origin in action. You
sudo mv /etc/dnsmasq.conf.orig /etc/dnsmasq.conf can click on the unobtrusive icon at any time to temporarily
If you choose to block specific ports or services disable ad-blocking if you wish to do so on a particular page
(see Domain Denial on page 67), bear in mind that or see which sites have been blocked.

70 // // Spring 2017
Build a Pi photo gallery PROJECT

While pictures
of your favourite
fruits and Turner-
esque sunsets
are innocuous
enough, you
may prefer to
be certain that
pictures of
your loved ones
stay private.

Build a Pi-based
photo gallery
We show you how to view, collate and organise your favourite
snaps by setting up an easy photo server on the Raspberry Pi
hese days most of us have thousands We’ll be using the most recent version of SFPG

T of digital photos, usually scattered


over hard disks or removable media
of some kind, just crying out to be
organised, viewed and enjoyed instead
of languishing in digital limbo. SFPG (Single File
(4.7.0), which was released in December 2016. We
recommend you check the Downloads section of
the developer’s website (http://sye.dk/sfpg)
before you begin, to make sure the links are right.
Pi bites
To see a quick
demonstration of
what SFPG can do,
visit https://sye.
PHP Gallery), the creation of Danish developer Can’t I just use...? dk/sfpg/demo.
Kenny Svalgaard, enables you to set up your very From Google Photos to Instagram to Facebook, Remember that
loading times will
own photo server within minutes, capable of the number of websites offering to collate and sort not be as fast over
displaying your photos, organising them into your most personal pictures is as boundless as the the web as when
albums, running slideshows and much more. sea, to paraphrase Shakespeare. So why add the you’re accessing
In this project we will explore first drop that is SFPG to the vast ocean photos on your
Pi’s home network.
how to set up your Pi as a server, of photo gallery software? It doesn’t
using the light and open source even come with a handy mobile app
software Lighttpd (pronounced or the ability to place a dog’s nose
“lighty”). Once the server is up and and ears over your face.
running, it’s a simple matter of setting Well, the most compelling reason
up the necessary folders, then for using SFPG is that it is truly cross-
downloading and extracting SFPG. It’s platform – all you need to view and
not every day that you can become browse your photos is a web browser.
a server administrator and organise Unlike other self-hosting image
your digital life with three easy steps solutions, it also doesn’t require you
but here at Pi User we aim to please. to spend ages setting up an SQL
This project is compatible with database to store all your pictures.
Click the
all models of Raspberry Pi. Before With its default configuration SFPG
Information
proceeding, note that your images makes photos on the Pi available
button to see
will be stored on the Pi’s SD card, so only to your home network. This the lowdown on
either make sure you have sufficient makes it perfect for families, schools, individual images.
space or use the Pi’s own SD Card workplaces or indeed any situation You can add a
Copier utility to move your data to where not everyone needs to see that description using
a card with larger capacity. picture of you or one of your loved Admin Mode.

Spring 2017 // // 71
PROJECT Build a Pi photo gallery

html/. If the photos are already inside a folder,


rename it to something meaningful, such as
“Planes”, so you won’t become confused. If you’ve
followed the steps in the tutorial on the opposite
page, you can Copy and Paste using Ctrl+C and
Ctrl+V between your Pictures folder and the
photos folder.
If you’re connecting to your Pi via SSH or just
want to avoid repeatedly copying and pasting, you
can move files or folders with the cp command.
For instance to copy the folder “Planes” in your Pi’s
Pictures folder over to SFPG’s photos folder, use
the following:
cp -a /home/pi/Pictures/Planes /var/www/html/
photos/planes/
SFPG will automatically create a gallery album
using the folder name and list the photos inside.
If your gallery fails to load at all, double-check
that lighttpd server is running by opening a web
browser on another device connected to your
network and going to htt p://ipaddressofyourpi
SFPG supports ones spilling out of a taxi last Friday night wearing (for example, http://192.168.43.87 – to find your
a slideshow mode a pirate hat. Naturally many third-party photo Pi’s IP address, simply run the command ifconfig
so you can cycle hosts have strict privacy policies and offer settings on your Pi). You should see a placeholder page
your pictures of to limit the audience for your pictures. However (see opposite page). If not, work through the first
fluffy kittens these are only as useful as the company’s ability step of the tutorial again.
according to
to protect themselves from hackers, subpoenas The default viewing mode for Gallery doesn’t
your mood.
and users who haven’t configured their privacy allow you to alter the photos or upload new ones
settings properly. from your web browser. Enable admin mode to do
Finally, SFPG is extremely customisable. this (see the Admin Mode box below).
You can change the way the date appears, add If changes you make in Admin Mode aren’t
Pi bites watermarks, change the size and appearance of taking effect, you most likely have a permissions
If your photos are image thumbnails... and there’s no limit on how issue. You can run the following command on the
located on another many images you can store – the only restriction Pi to fix this:
device such as is the capacity of your SD card. Hardened coders sudo chmod -R 777 /var/www/html/photos
a laptop, enable may also appreciate the ability to customise the Bear in mind that this will give read/write
Admin mode to
create new albums
default index.php file to use backgrounds and permissions to the photos folder to any user
and upload them colours of their own choosing. on your network
via your web If you followed the steps in the tutorial opposite,
browser (see the Moving photos then your Pi is now working as a web server, so
“Admin Mode” box
Once SFPG is up and running, you’ll need to copy there’s no reason why others can’t connect to the
for details).
your pictures to the photos folder in /var/www/ photo gallery remotely. You will however need to

Enabling Admin Mode in SFPG


By default Single File PHP Gallery displays now rename the file, move it, delete it and
only content, and the only way to create new more. You can also use the Upload button to
albums, add and remove photos and edit copy one or more files into the Gallery. Hold
their metadata is by working directly with down Ctrl and click to select multiple photos.
the photos on the Pi. With this setup, anyone connected to your
Fortunately SFPG can be run in Admin network can both view and modify your
mode. To do this, first open Terminal on the images. For extra peace of mind, you can
Pi or connect remotely via SSH and edit the set a password to your photo gallery. Run
index file by running: the command below once again:
sudo nano /var/www/html/photos/index.php sudo nano /var/www/html/photos/index.php
Scroll down to the text define('ADMIN', Scroll down to define('PASSWORD', '');.
FALSE); and change “FALSE” to “TRUE”. You’ll find this just above the value you
Press Ctrl + X, Y, then Enter to save and exit. changed earlier to enable Admin mode.
Reload the page with your photo gallery if Insert the password of your choice within
it’s already open. The Admin button will now the quotation marks – for instance:
appear on the right-hand side. When viewing define('PASSWORD', 'password123');
albums or photos, first click the Admin Alternatively if you wish to set up a Public One use of the admin tool: you can add
button so it’s highlighted. Next select an Gallery with Admin access for select users, new albums by clicking Admin, then Create
individual album or photo. A red border will follow the steps outlined in the readme.txt Directory. Click on the new album, then on
appear around the selected item. You can file in /var/www/html/photos. Upload to add images.

72 // // Spring 2017
Build a Pi photo gallery PROJECT

INSTALL AND SET UP SFPG

1 Install server 2 Modify Folder 3 Install SFPG


software Permissions and reboot Open Terminal again and run wget
Open Terminal on your Pi or connect Create the server’s directories, then to download the current version of
via SSH and first update your system allow yourself write access to them, the SFPG software – at the time of
with the usual command: by running the following commands: writing, this is as follows:
sudo apt-get update sudo mkdir /var/www/html/photos wget http://sye.dk/sfpg/Single_File_
Next install Lighttpd with: sudo chown www-data:www-data / PHP_Gallery_4.7.0.zip
sudo apt-get -y install lighttpd var/www Extract it to your new photos folder
Install the required PHP files with sudo chmod -R 775 /var/www with unzip – for example:
sudo apt-get -y install php5-common sudo usermod -a -G www-data pi sudo unzip Single_File_PHP_
php5-cgi php5 php5-gd Reboot the Pi when you are done to Gallery_4.7.0.zip -d /var/www/html/
Next, enable the Fast CGI module with apply the changes. Check that the photos
sudo lighty-enable-mod fastcgi-php server is running by navigating to your Now run the following:
Pi’s IP address on another device sudo nano /var/www/html/photos/
connected to your network. (If you index.php
don‘t know your Pi’s IP address, you Scroll down to define('SECURITY_
can find it by simply running the PHRASE', '');. Enter a random string
command ifconfig on your Pi.) here, for example define('SECURITY_
PHRASE', 'Dj5remJIpQ');
Move your pictures into /var/www/
html/photos. To view them, go to
htt p://ipaddressofyourpi/photos
in your browser.

forward ports on your router so that others can


connect to the Pi outside your home network. You
will need to find your Pi’s IP address, as already
explained, then use this to enable port forwarding.
The steps for port forwarding will vary from router
to router, but you may find instructions for your
specific model on http://portforward.com.
Remember that if the connection to your Pi is
not secured via SSL then anyone monitoring your
connection can view the photos, even without a
password. Web browsers often cache images, so
try to encourage users to view SFPG in Private or
Incognito browsing mode, which won’t retain any
data once the web browser is closed.
Alternatively, see Lighttpd’s guide at https://
redmine.lighttpd.net/projects/1/wiki/ If you’re worried about your images being stolen This page
HowToSimpleSSL to easily set up a secure and reused, the index.php file can be configured should appear
connection to your server. This will create a “self- to include a watermark for images. See the if lighttpd is
installed correctly.
signed” certificate, so users may see a warning the readme file for more details.
Feel free to
first time they connect. It’s safe to ignore this. Should you run into further problems, visit the replace it if you
Read through the readme.txt file in /var/www/ developer’s website at http://sye.dk/sfpg and wish – it exists
html/photos to view all options for configuring follow the steps there to download the SFPG test only to confirm
SFPG, such as setting the size for thumbnails or script. This will output messages that can be the server is up
changing how the date and time are displayed. helpful for troubleshooting. and running.

Spring 2017 // // 73
GET THE MOST FROM
YOUR RASPBERRY Pi

OUT
NOW!
WITH
FREE
DIGITAL
EDITION

ORDER YOUR COPY TODAY!


Order online at www.myfavouritemagazines.com
Also available in all good newsagents
GET STARTED
Take your first steps with a Raspberry Pi...

76

NEW TO THE RASPBERRY PI?


OUR QUICK-START GUIDE WILL
GET YOU UP AND RUNNING

78 80

76 Get started with


a Raspberry Pi

78 How to install
Raspbian

81 82
80 Install NOOBS
with any OS

81 Use Linux to
install Raspbian

82 Using networks
and the internet

Spring 2017 // // 75
GET STARTED Get connected

Get started with


a Raspberry Pi
Before you can actually do anything with your Raspberry Pi, you’re
going to need to hook up all the right peripherals. Here’s how...
ven though it might use and compatible wireless unpowered hub is an option,

E not look like it, the


Raspberry Pi is in
a fundamental way
just like any other
desktop computer you might
adaptors, for example – before
we can move on to creating a
boot disc to start it up.
To use the Pi as a computer,
you’ll need to connect at least a
while powered hubs can handle
any devices, no matter whether
power is required or not.

Display me
have owned or used in the past. keyboard, a mouse, a display and Technically, the Raspberry Pi
That is to say, it has a processor, a compatible SD card. In today’s works with most types of
memory and storage and, in environment, it’s going to be displays using the correct cable
order for you to use it, it requires useful to at least have a wired or adaptor. It’s envisioned to be
being connected to all the usual internet connection around, or used with an HDMI monitor but
peripherals – a display, inputs a suitable USB wireless adaptor works with older monitors with
and more. For most people, this for wireless networking. The a DVI adaptor or an HD TV.
should be straightforward, but final touch would be desktop With the HDMI connector, both
there are some finer points that speakers. On a technical level, the Pi and the display should
you should know about – details peripheral support is provided automatically configure
about the correct SD card to by the Linux kernel that powers themselves correctly; we’ve
the Raspbian OS, but more on successfully used the Raspberry
that later… Pi on a 4K display without issue,
beyond manually setting the
Need input! higher 4K screen resolution.
Ever since the Model B+, the It’s possible to connect the
Raspberry Pi has been well Pi to an old TV or monitor
furnished with four USB ports. using an analogue composite
This ensures that it’s easy to connector – this is usually a
connect all the peripherals you round yellow RCA connector.
need. The base minimum of With the Pi, the 3.5mm jack
these is a USB mouse and that’s usually used for stereo
keyboard for standard input – audio output carries an extra
especially considering you’re line for the video. To access this,
able to get keyboards that you need a 3.5mm jack to stereo
provide additional USB ports, and composite RCA.
helping to save one or more on
ON THE CASE the Raspberry Pi itself. Sounds good
Pretty much any keyboard The Raspberry Pi is perfectly
We admit, it can be unnerving having a naked and mouse should work, but capable of producing plenty
Raspberry Pi sitting on your desktop, and it’s don’t expect support for any of audio, and later we’ll see
certainly true that it could short on random wires, unusual buttons (you’d be projects that enable the use of
screws or metal surfaces. So, a common extra that surprised at how many do the Pi as an audio streamer and
people get for their Pi is a suitable case. At this work, though...). media centre. You can get audio
point, there’s quite a range available, and many leave
The important thing to out of standard Pis in two ways.
the GPIO pins and other ports open for easy access.
remember is that even with just The first is over the HDMI line.
There are more exotic options that can mount the Pi
within a display, a desktop-style case that expands four USB ports – or the single When you plug the Raspberry
its capabilities, and even a laptop chassis, so you port on the Pi Zero – it’s easy to Pi into a display that also has
can take your Pi with you. Just be aware that this expand your USB connectivity speakers, audio generated by
means you can spend anything from £5 up to £100 with a hub. For devices that don’t the Pi is automatically sent over
or even more for your Pi case. require additional power, an the HDMI line, too.

76 // // Spring 2017
Get connected GET STARTED

The alternative option is to All Raspberry Pis use a normal desktop PC. The fact is, Connect it up
use the standard 3.5mm audio micro USB port to supply their the Pi was envisioned to be that and a Raspberry
jack, which can easily be plugged power. This has the advantage and so much more. A big part of Pi will form the
into most speakers. that, on the whole, you can its extra abilities comes through heart of a
power a Pi from almost any the bank of GPIO (General powerful but
Network and power phone power adaptor. The power Purpose Input Output) pins. We’ll very compact
computer setup.
We’re going to look into Pi requirements vary, depending on explore these later through fun
networking in more detail over which Pi you have and what and exciting projects, but for
the page, largely because we you’re doing with it. Old power now, it’s enough to know that
want to look in full at wireless supplies that provide only 5W these enable the Pi to control,
networking adaptors and the Pi should cope with a basic Pi monitor and power external
3’s built-in wireless capabilities, Model B setup, which draws devices and projects. You don’t
alongside the Bluetooth features 3.5W, but the more peripherals have to use them, but they’re
and how they work. Besides you add, the more power it always there if you want them.
this, all Model B Pis come with requires. The Pi 2 and 3 use 4W, Additionally, the Pi comes with
a wired Ethernet network port. so the draw is more critical. a camera interface – although
This can be plugged into any Ideally, you want a 10W (2A, 5V) you can also use standard USB
router, and boom – instant supply, which is more common cameras – plus there’s a
network access, including these days because modern dedicated digital touch display
internet access if that router tablets and phones also have interface, too.
is online. For the bare-bones higher power requirements. All you have to do now is
Model A Pis and Pi Zero, a USB At this point, you would have follow our installation guide over
wireless adaptor is required. your Raspberry Pi all set to be a the page and boot it up!

SD CARDS
The main storage for a Raspberry Pi is an out at 25MBps. It’s also not capable of
SD card, typically a microSD card, though utilising the technology of the latest UHS
the original Model B and Model A Pis used high-speed SD cards.
a full-sized SD card. On the whole, you With all that in mind, the key thing to
can just run out and buy any microSD look for in an SD card is to get one with
card and it should work, but it certainly fast read/write access, rather than pure
makes sense to ensure that the card you throughout. It’s also worth keeping an eye
buy will not only work, but will also be on the list of compatible tested SD cards
large enough and as fast as possible. at http://elinux.org/RPi_SD_cards.
Not all SD cards are made the same. You should also aim to get a card at
There are various speed categories, such least 8GB in capacity. The latest build of
as Class 6 (which denotes a minimum Raspbian – the main Pi OS – is now larger
6MBps write speed) and Class 10 than 4GB. That said, given the price of SD
(denoting 10MBps write speeds), along cards, it makes sense to go for a 16GB or
with the newer and faster UHS-1/2 (Ultra 32GB card. You need to balance the slight
High Speed). One thing to keep in mind increase in price against the fact that a
here is that the Pi’s SD controller maxes larger card is likely to be of use far longer.

Spring 2017 // // 77
GET STARTED Install

How to install
Raspbian
Before you can do anything on your Raspberry Pi, you need some software
for it to run. With a microSD card in hand, we guide you through the process
efore the Raspberry Unlike traditional computers, needs to be at least 4GB in

B Pi can do anything
(apart from sitting
there looking cute) it
needs an operating
system (OS). The most popular
the Pi has no internal storage,
so the OS needs to be loaded
from an SD card. The original Pi
models (models A and B) use
full-size SD cards, whereas
capacity. If all this seems too
technical, you may wish to look
at NOOBS (over the page).
Note that on macOS computers,
it’s also possible to write the
OS for the Pi is Raspbian, which newer models (B+, 2, 3 and Raspbian image using the dd
is based on Debian Linux. A Zero) use the smaller (and tool from the command line. If
number of other operating much easier to lose!) microSD you’re comfortable working
systems are also available for variety. SD cards pre-loaded this way, the procedure is very
the Pi. Some of these can be with an OS can be purchased similar to the Linux instructions
downloaded from the Raspberry from pretty much wherever the on page 81. Alternatively, check
Pi Foundation website (https:// Pi is available, and are commonly out the instructions on the
raspberrypi.org/downloads) included in bundles, but it is also Raspberry Pi Foundation website
and some can be installed using straightforward (and cheap) to at www.raspberrypi.org/
NOOBS (over the page). There’s make your own. This can be documentation/installation/
Ubuntu MATE (Pi 2 and 3 only), done using freely available tools installing-images/mac.md.
an ARM port of Arch Linux, the on Linux, macOS or Windows.
classic RISC OS, the OSMC If you already have a pre- Enjoy Raspbian
media centre, not to mention loaded SD card, you can skip this Once your SD card is ready
the RetroPie vintage gaming section entirely. If not, the most (whichever road you choose),
platform. There’s also Snappy straightforward way to get going you’re all set to boot up your Pi.
Ubuntu Core and even Windows with the Pi is to download the Remove the SD card from your
10 IoT Core. If you’re a beginner, latest Raspbian image and write computer, plug it into your Pi
Raspbian is good to start with. it directly to an SD card, which (along with all the other gubbins
– display, power, keyboard and
Raspbian mouse), power up and it should
should be your boot up to the raspi-config
first choice, but program. From here, you should
the other OSes expand the filesystem (if your
can be fetched
card is greater than 4GB),
and installed with
minimum fuss.
change the default password and
enable Boot to Desktop. Select
Finish and you’ll be able to
reboot to the Raspbian desktop.
There’s all manner of interesting
things you can play with right
away, including Minecraft,
Wolfram Alpha and Sonic Pi.
If you have a wired network
connection, then that will work
out-of-the-box. Some wireless
ones will as well, but for many,
this will be their first encounter
with the recalcitrance of Linux.
Just be patient, and remember,
Google search is your friend...

78 // // Spring 2017
Install GET STARTED

INSTALL RASPBIAN WITH WINDOWS OR MACOS

1 SD card tools 2 Download Raspbian image


We first have to download some additional image-writing software. You’ll find the Raspbian image at www.raspberrypi.org/downloads/
For Macs, the simplest tool is Rpi-sd Card Builder (http://alltheware. raspbian. The current edition is called Jessie, the same as the Debian
wordpress.com/2012/12/11/easiest-way-sd-card-setup), but you release it’s based on. Be sure to choose the full edition, rather than
may also want to look at Pi Filler (http://ivanx.com/raspberrypi) or the Lite one, at this stage – unless, of course, you’re sure that you’re
ApplePi-Baker (www.tweaking4all.com/hardware/raspberry-pi/ happy at the command line, with no desktop environment. You may
macosx-apple-pi-baker). On Windows setups, we recommend using wish to save the Foundation some bandwidth and use the BitTorrent
Win32 DiskImager, which can be downloaded from https:// link. This requires you to have a BitTorrent client installed, such as
sourceforge.net/projects/win32diskimager. Installation of all of Transmission or uTorrent. Whatever your download method, the full
these programs is straightforward. Raspbian image is a 1.3GB download, so will take a few minutes.

3 Unzip file 4 Write the image


You’ll end up with a file in your downloads folder, called something Win32 Disk Imager needs special privileges to write to the SD card.
such as 2017-01-11-raspbian-jessie.zip. Make sure that you’re not So, instead of double-clicking its .exe, right-click it and select Run as
running short of hard disk space, because this file will be close to Administrator. Now select the image file you extracted in the previous
4GB in size when it’s uncompressed. Double-click the Zip file (if step. In the Device section, pick the drive letter of the SD card. Click
you’re using a Mac), or right-click it and select Extract All (on Write, double-check you have the right device, and writing begins.
Windows). It should extract to a file called something along the Wait for it to complete and, hey presto, all done. Mac tools work
lines of 2017-01-11-raspbian-jessie.img in the same folder as the similarly (you may be asked for a root password), but be sure to
downloaded Zip file. This is the image file that we need write to the select the correct SD card device, not your hard disk. Whatever
SD card in the next step. destination you choose is wiped, so you don’t want to get this wrong.

Spring 2017 // // 79
GET STARTED Install

Install NOOBS
with any OS
Possibly the easiest way to get a new OS up and running on your Pi can be
achieved using any operating system – as long as you know how!
OOBS (New Out Of so it will load the next time the – just plug in and turn on.

N the Box Software)


makes it easy to
install Raspbian (or
other OSes) on your
Raspberry Pi. You can buy an
Pi is rebooted. Or you can hold
down Shift as the Pi boots to use
the NOOBS installer once again.
Preparing a NOOBS SD card
with Raspbian on it requires at
Once your card is ready,
reboot the Pi with power,
mouse, keyboard and monitor
all connected. You should see
a list of OSes (tailored for your
SD card with NOOBS on it from least a 4GB SD card – other Pi model). The Raspbian entry
many vendors, or we’ll show you OSes (in particular, Windows 10 should have a picture of an SD
how to do it yourself below. IoT Core) will require 8GB. The card on the right, indicating that
With a correctly-prepared simple process of installing it can be installed even if the Pi
NOOBS SD card, the Pi can boot NOOBS to an SD card is outlined is not connected to the internet.
to a menu offering you a choice below. Note that if you’ve bought Tick the box to its left, hit Install
of OSes. Pick one and NOOBS an SD card with NOOBS already and, before long, you’ll be able to
installs the OS on the SD card, on it, you don’t need this section reboot straight into Raspbian.

INSTALL RASPBIAN WITH WINDOWS OR MACOS

1 Format the SD card 2 Download NOOBS 3 Unzip and copy


Before you can do anything, your SD card must NOOBS is available in two forms: the regular You should have a file named something like
be correctly formatted. Freshly purchased blank edition (weighing in at 1GB, zipped) and NOOBS NOOBS-V-2-1-0.zip in your downloads folder.
cards tend to already be formatted as FAT32, Lite (a mere 27MB). The Lite edition does not This must be decompressed and the contents
but if you’re recycling an old one, you need to do include the Raspbian image – it has to be put on the SD card. On Windows and Mac, you
this yourself. First make sure there isn’t anything downloaded from within the NOOBS installer. should be able to extract the files by just double-
important on it – it will be erased. Formatting The full-fat edition allows Raspbian to be clicking the Zip file. The files extract to a folder
can be done directly from Windows Explorer installed without an internet connection, but named something like NOOBS-v2-1-0. Now
(right-click the SD card and choose Format) or other OSes have to be downloaded. Again, this is they must be copied to the SD card. Be sure to
from Disk Utility in macOS (go to the Erase tab). easily achieved from the comfort of the NOOBS transfer only the files inside the NOOBS folder,
In both cases, choose FAT32, not the NTFS or installer. Both versions can be downloaded from rather than the folder itself, otherwise it won’t
HFS+ filesystems. Linux users can format www.raspberrypi.org/downloads/noobs, either work. Open the NOOBS-v2-1-0 folder and select
SD cards using Gparted, Gnome Disks or the directly or via BitTorrent. The latter is a little all the files (click the first one, hold Shift, then
command line with mkdosfs -F32 /dev/sdX1 , more considerate of bandwidth but requires a click the last one). Drag them on to the SD card
for example. Note that NOOBS requires that BitTorrent client. Many Linux distros include the icon and wait for them to finish copying (the full
only a single FAT32 partition exists on the card, Transmission BitTorrent client (also available for version can take a while). Right-click and safely
so if there are others, these should be removed macOS), and there are plenty to choose from on eject the SD card. You should now be able to use
with appropriate partitioning tools. Windows (uTorrent, Deluge, Bitcomet…). this card to boot your Pi, as explained above.

80 // // Spring 2017
Install GET STARTED

Install Raspbian
with Linux
If you’re running any flavour of Linux on your computer, then you have an
even easier life when it comes to getting Raspbian on to your Pi
inux users can get The Etcher

L Raspbian set up image writing


from the comfort program is
probably the
of their operating
slickest way to
system, too. Much
make SD cards
the same as on Windows and under Linux,
Mac, the first steps are to and saves you
download the Raspbian image from getting
(either from a web browser or your hands
using Wget) and unzip it. There dirty at the
are a few different options for command line.
writing the image. You can use
a graphical tool such as Etcher
(see www.etcher.io) or Ubuntu’s We’ll refer to the SD card as network to side-step filesystem
Startup Disc Creator. These work /dev/sdX (replace the X with the incompatibilities amongst OSes.
very much like the image-writing actual drive letter) and assume Still, it can sometimes be handy
tools for macOS and Windows. you’ve unzipped the Raspbian (for example, if the Pi is shut
As with most tasks on Linux, IMG file to the Downloads down) to just be able to grab the
the usual approach is to use directory. In a terminal type: SD card, slip it in a slot, and grab
the command line. $ sudo dd if=~/Downloads/26- photos or edit configuration files.
Insert the target SD card into 05-16-raspbian.img of=/dev/sdX If you’re not (yet) a Linux
the machine. We’ll use the dd bs=1M user, it’s also possible to use the
tool, which is part of all standard This process can take a long live disc mode of a distribution
Linux installations, to transfer time, particularly on older or (Ubuntu, Fedora, openSUSE,
the image. You definitely don’t cheaper SD cards. Sometimes, Mint, for example) and create
want to accidentally wipe your even when the command the SD card from there. There’s
hard drive this way (and it’s completes (when you are able a slight problem downloading
possible to do just that if you to enter another command), the the image to the root filesystem,
get this wrong), so first use the job is not done. If your SD card however, because this is all in
lsblk command to see which or adaptor has an activity light, RAM for live discs (their modus
device node it is attached to. then you can see if anything’s operandi is to not touch your
You should be able to identify still being transferred, but if not, hard drive), and there typically
the SD card by its capacity. It try the sync command. If it isn’t enough space for several
could be /dev/sdb or it could be doesn’t complete right away, gigabytes of OS image. This
/dev/sdc. Newer PCs that have data is still in-flight. Once can be worked around, though,
a native MMC controller will give everything is ready, you can because the image can be
it a slightly different name, such remove the SD card, boot your downloaded to a USB stick
as /dev/mmcblk0p1. Note that Pi and tweak the raspi-config beforehand and copied from
it is the device, not partitions on program as per the Windows there. On Ubuntu, USB sticks
that device (such as /dev/sdb1 and macOS instructions. are mounted in a directory inside
or /dev/mmcblk0p1n2), that /run/media/ubuntu, so change
we are interested in. Any existing Linux luck the if parameter of the dd
partition information will be lost Under Linux, there is a slight command accordingly.
when we transfer the image to advantage in that the SD card Alternatively, you can use the
the device. Writing the image to can be browsed natively. It’s Startup Disk Creator on an
a partition won’t work at all well, only a slight advantage because Ubuntu live DVD if you don’t
so don’t do that. things can be sent over the feel like typing things.

Spring 2017 // // 81
GET STARTED Networks

Using networks
on the Pi
Getting hooked up to a local network and the wider internet is easier
than you might think, as long as you have all the right bits...
veryone (and, it of the nitty gritty of networking You can confirm whether a

E seems, everything)
is online these days,
and that means that
if you want your
Raspberry Pi to do anything
from you, combined with the
need to add wireless dongles to
all Raspberry Pi models except
the latest Pi 3, which comes with
built-in wireless and Bluetooth.
USB device is working correctly
– other than the Raspbian
wireless being enabled – by
opening a terminal and typing
lsusb , then pressing Return.
“interesting” – even if that’s just The first thing you need to do This provides a list of all your
browsing Facebook – you need before buying a wireless adaptor USB devices, and one should
to get it networked. As with is to check whether the one you be something that sounds like
everything Raspberry Pi, it’s already have or plan to get will your USB Wi-Fi device.
Raspbian
now supports
made as hard as possible, to work with your Raspberry Pi. A second command, iwconfig
easy GUI- ensure you learn as much as That’s where http://elinux.org/ provides a list of working
based wireless possible along the way! No, RPi_USB_Wi-Fi_Adapters wireless adaptors connected to
connections – actually, the only complication is comes in – this is a huge list of your Pi. This offers a slightly
so modern! that Raspbian doesn’t hide any both verified adaptors and those more direct confirmation that
that cause issues. the USB dongle is connected
The good news is that a huge and working.
range works with Raspbian, An easy way to avoid any
thanks to its Linux kernel. It worry is to buy an official
comes with built-in support for Raspberry Pi Foundation Wi-Fi
a large number of adaptors. dongle. Designed to work with
Because of the way Raspbian is all Raspberry Pis and Raspbian,
built, an adaptor that doesn’t this eliminates any worries.
work with Raspbian might work There’s also the added point
with another Linux OS, such as that it helps fund the Foundation,
Arch or OpenELEC, because of too. You can get more details
the particular version of the from www.raspberrypi.org/
Linux kernel they ship with. products/usb-wifi-dongle.
Back in the day, you had to
edit text files to configure your
TCP AND YOUR SORE IP wireless dongle, but these days
Raspbian has been fully updated
If you’re new to PCs and networking, then the typically, an address would be something to provide a GUI (or Graphical
sudden talk of IP numbers and the like might like 192.168.0.1 or 192.168.100.23. Generally, User Interface) for connecting
be confusing. Let’s just say that local networks your home and business network has its to any wireless network. How
and the internet all use a very clever system own IP range – the broadband router you civilised! Wi-Fi connections can
called TCP/IP. On a pedantic level, that’s two – use to connect to the internet creates this be made via the familiar network
yep, two – communications protocols: TCP, automatically using something called a DHCP icon at the right-hand end of
alias Transmission Control Protocol; and the IP server, and uses Network Address Translation, the menu bar. If a working Wi-Fi
part, alias Internet Protocol. You don’t really or NAT, to route messages to and from your dongle is plugged in, left-clicking
need to know anything about it, other than local network and the wider internet. See, it
this icon brings up a list of
this: it assigns a unique number to each and does get awfully complicated very quickly!
available Wi-Fi networks, as
every device on the internet. This enables Usually, when we talk about IP addresses,
messages to get to and from your devices, it’s when you want to know the address of a shown in the picture on this
finding their way to the right place. device or server on your network or on the page. If no networks are found,
Each device gets an address made up of internet, or you want to give a device a specific it shows the message “No APs
four numbers, separated by full stops. Each address. Luckily, you won’t have to know much found – scanning...” Wait a few
number can be between 0 and 255. So, more than this! seconds more without closing

82 // // Spring 2017
Networks GET STARTED

for transferring files and getting


an internet connection. In terms
of having to do anything, you
don’t – just plug in the cable,
and as long as it’s connected to
a working router that already has
an internet connection, Raspbian
is allocated an IP address.
Most Ethernet ports provide
two status LEDs (the original Pi
did not; these status lights were
moved to the board itself). The
green confirms a working
connection (any blinking shows
activity), while the amber one
announces a full-speed 100Mbps
connection (10Mbps if it’s off).
It’s also worth noting that the
Linux kernel can happily handle
multiple network connections
over different network adaptors.
The iwconfig the menu, and it should find to show that a connection is This means you can connect to
command helps your network. being made; once it is ready, the a different network or the same
check whether a The icons on the right show icon stops flashing and shows one via both a wired connection
wireless adaptor whether a network is secured or the signal strength. and wireless at the same time –
is working.
not, and its signal strength. Click Older versions of Raspbian the kernel’s TCP library happily
the network that you want to provided a Wi-Fi Config tool on balances transfers over both the
Wired connect to; if it is secured, a the desktop. There’s no reason adaptors. It also means you can
networking is the dialog box appears, prompting why you should encounter an remotely connect to the Pi via
fastest and most you to enter the network key. Do older version at this point, but if either assigned IP address.
reliable way to so and wait a couple of seconds. you do, it’s no more complicated As with USB Wi-Fi dongles,
connect things. The network icon flashes briefly than running it and then using it’s also possible to add wired
its Scan button to locate your Ethernet adaptors via a USB
desired wireless network. port – a full list of verified and
problem adaptors can be found
Wired networks at http://elinux.org/RPi_USB_
We should also mention wired Ethernet_adapters. While this
networks while we’re here. All doesn’t make total sense for a
Model B Raspberry Pis have a Model B board, it may be exactly
wired network connection called what you need when it comes to
an Ethernet port. This uses an the Model A or the Pi Zero.
Ethernet cable to connect to The subject of networking
a standard router. A wired can get highly involved, so
connection remains the most we’re going to leave things
reliable and the fastest option with a standard IP connection.

BLUETOOTH DEVICES
With the addition of the embedded dual connecting to a wireless network. This
wireless/Bluetooth abilities in the Pi 3, goes for all Bluetooth devices, but you
Raspbian was updated to support first need to make them “discoverable” –
Bluetooth out of the box. Prior to this, you this enables other Bluetooth devices to
had to “hack” in the Bluetooth support, then attempt to connect with them, at
with the command sudo apt-get install which point you have to allow those
--no-install- recommends bluetooth and, connections or not, as the case may be.
once it was installed, use sudo service Left-click the Bluetooth icon in the top-
bluetooth status to enable it. right of the Raspbian desktop, select Make
While this was a simple case of installing Discoverable, then choose Add Device to
a manager tool, it’s far neater having it pull up a list of nearby Bluetooth devices.
around by default. If you use a smartphone Select the correct one and click Pair. With
you’re likely to have used Bluetooth, with keyboards and devices, you often have to
all the Bluetooth speakers, keyboards and enter a code on the device to finalise the
headsets available these days, but if not, connection. You’ll want to ensure that you The Raspberry Pi should pair with most
the good news it that it’s far simpler than choose Stop Discoverable afterwards. Bluetooth devices without an issue.

Spring 2017 // // 83
Pi CODE
Learn how to code in your language of choice

95
86

92

GIVE YOURSELF GODLIKE


86 Design a game
in Scratch 2

POWERS TO CREATE A 92 Get started


with Python
SKYSCRAPER, A ROAD OR
A RIVER... OR TO DESTROY 95 Build your own
Minecraft city

Spring 2017 // // 85
Design a game
using Scratch 2
Les Pounder shows how you can create a simple console game using a few
blocks of Scratch code and a creative imagination
he popularity of Scratch has soared Scratch which has been tweaked to also work with

T
since the Raspberry Pi was released. the Pi’s GPIO. But in late 2016 the Raspberry Pi
Children across the United Kingdom Foundation introduced an update of Raspbian that
have started their coding journey using now comes with the Pixel Desktop, the Chromium
this effective tool. Why is it so popular? web browser and Flash – a contentious inclusion
Scratch beautifully demonstrates the basics of given that it is not free software, but required so
Computer Science, loops, iteration, variables, that Scratch 2, the latest version, could be made
arrays etc. But Scratch manages to keep all of available. The Foundation, always keen to ensure
these concepts relatively simple and easy for the that they provide the relevant software for
user, typically a child, to use. When children first learners, chose to include Flash in order to ensure
use Scratch, they simply treat it as a set of that users had access to the latest version of
building blocks, connecting blocks together and Scratch aligned to the latest learning resources.
seeing what they can create. But over time and In this tutorial we’ll introduce a number of
with the help of the curriculum in our schools, coding concepts, such as inputs, loops, variables
children are learning key skills which can be and conditionals, by creating a clone of the
applied to all languages, all thanks to Scratch. Nintendo classic game Duck Hunt, which was
The Raspbian operating system, the de facto popular in the 1980s on the NES console. So let’s
standard for all versions of Raspberry Pi, comes start our project with an overview of the new
with version 1.4 of Scratch, an older version of Scratch 2 interface.

Scratch 2 – take your projects anywhere


Scratch 2 is seen as a significant which can contain extra functionality, much projects at home, with no specialist software
improvement over 1.4, largely thanks to the same as a function in Python or a macro install, and it also ends “the dog ate my
being online. You don’t need to sign up for in Office applications. homework” scenarios. Children can share
an account, but the benefits of doing so are Another big benefit of Scratch 2 is that their projects in class blogs and similar
that you can share your work with others, you can access your projects from anywhere channels by embedding their game in much
and you can remix their work to create your in the world using any computer. This the same way as we can embed YouTube
own. You can also build your own blocks, enables children to work on their school videos into posts.

86 // // Spring 2017
Scratch CODING

GETTING YOUR DUCKS IN A ROW


The Stage The Stage Scripts All of the Costumes Costumes Sounds Sounds can
is where the user can blocks that we use to are how we can be loaded via the
interact with their code are contained in change the look of a library so that our
project – for example the Scripts tab. They sprite. We can edit a sprites and the game
sprites will move are categorised by sprite by hand or use as a whole can have
inside the stage, and their function, and the Sprite library to sounds effects and
players can control handily by colours. create a quick change. music while we play.
elements of their
game in this panel.

Sprite options Create


a new sprite from a
library, draw your own
sprites, import from
your computer, or use
a webcam to take a Code The Coding
picture to use. area is where blocks
can be placed and
used to build up a
project. The Coding
area displays the code
for the current sprite,
Sprites We can see so it is vital that you
all of the sprites for a select the correct
project in the Sprites sprite before starting.
select area. Each
sprite has its own
blocks of code, and
we can click on a
sprite to start coding.

1 Creating our duck 2 Creating our crosshairs


We’ll start the project by changing our default sprite, which is that We now create a new sprite. Click on the paintbrush under the
iconic Scratch cat, into a duck. To do that we need to click on Stage to open the editor. The editor works in two modes, bitmap
Costumes, then look for the first icon under New costume. In the and vector. For this sprite, switch to vector and then draw your
costume library select the duck and click OK. We also added a star aiming crosshairs, ensuring that they are in the centre of the editor.
explosion costume for later. Delete the cat costume by clicking on When done, click the Scripts tab to go back to coding. Our crosshairs
the X in the top right of the sprite. will be used to target the duck, ready for us to open fire.

Spring 2017 // // 87
CODING Starting Scratch

3 Coding our crosshairs 4 Adding sound


To enable an easy aim we code the crosshair sprite to follow our Adding sound is handled in the same way as adding sprites. Click on
mouse pointer across the screen. First click Events in the Categories Sound, then click on the Speaker icon under New sound. From the
panel at top-left, and drag “When Green Flag clicked” into the Scripts library choose “laser2” and click OK. Now create the sequence of
panel. Next click Control and add a Forever loop. Now click Motion blocks shown, which will play a sound when the mouse button is
and add “Go to mouse-pointer” to the script. Now our sprite will pressed. Remember to place the blocks inside the Forever loop, so
follow our mouse, which is triggered by clicking on the Green Flag. that Scratch constantly checks for a button press.

5 Creating variables 6 Create a timer


Variables store data, and we’ll create two to store our score and timer Our timer uses a “repeat” loop from the Control section. We’ll need to
data. In the Data panel (the new name for “Variables”) click on “Make edit this loop in order to repeat our code 30 times, thus giving us a
a Variable”, name it “score” and make it available for all sprites. Now 30-second timer. Inside the loop, therefore, we wait for one second,
repeat this step to create another variable called “timer”. Once done, then deduct 1 from the “timer” variable, which effectively creates a
next create the blocks shown, which will reset the score and timer countdown. Outside of the loop we use “show” from Looks to ensure
when the game starts. that our sprite is visible once the timer ends.

88 // // Spring 2017
Scratch CODING

7 Broadcast yourself 8 Hiding our duck


Underneath the code for our timer, but still attached, we create a Our duck can disappear from view thanks to this sequence of code.
new block, a broadcast. As we mentioned last time, broadcasts We first ensure that the duck is visible, using “show”. Next we use a
enable sprites to communicate with each other. Broadcasts are “forever” loop from Control and inside we add a hide and show block.
found in Events. Click on the drop-down for “broadcast” and create But in between these blocks we place a “wait 1 secs” block from
a new message called “gameover”, then connect it to our timer code Control and then place “pick random” from Operators over the “1”
just underneath the show block. and alter accordingly.

9 A moving target 10 Conditions are True


A sitting duck is no fun, so we’ll give it a bit of life. Using another Using a forever loop and an If condition, we can now have our code
“forever” loop we place four “glide” blocks from the Motion category, check to see if our duck sprite is touching the mouse pointer – you
which will deal with the motion of the sprite. The x and y coordinates can find this block in the Sensing category. Note that the shape of
are generated by moving the duck around to places where you want the block is a hexagon, and so is the condition to test in our
it to go. This updates the coordinates in the block, which you then conditional loop. Drag the block into the hexagon space and ensure
drag into the loop, one by one. that it says “mouse-pointer”.

Spring 2017 // // 89
CODING Scratch

11 Costume change 12 Adding a new sprite


Inside of our “If” loop we now use a “change” block from the Data Now we create a new sprite. Look for the New Sprite text under the
category to alter our score by five points every time we target the Stage and click on the New Sprite icon to load the library. We chose
duck. We then change our costume using the “switch costume” a Unicorn as our sprite to announce the score at the end of the game.
block from Looks. We briefly change to a star pattern explosion, Feel free to choose any sprite that you wish.
then change back. Inside the else section we ensure that our duck
remains in its normal costume.

13 Unicorn powers ACTIVATE! 14 Broadcast received...


Our Unicorn must disappear when the game starts – when the Green Remember the “gameover” broadcast that we created earlier? Well,
Flag is clicked – so we use blocks from Looks to clear any special now we use it. In Events look for “when I receive..” and drag it into the
effects that we will later use on the sprite, then set its size to normal. coding area. Then drag another “show” block from Looks and
Then we ensure that the Unicorn is in the bottom-left of the screen connect it under the previous block. We then need to drag an “If..
using the “go to” block from Motion. Finally we hide the Unicorn. Else” block from Control and place it under our previous blocks.

90 // // Spring 2017
Scratch CODING

15 Conditional Rewards
Using a comparison block from Operators, we check that the value
stored in our “score” variable is greater than 50. (We chose this value
to give the player a chance to get a rewarding end result, but you can 16 Colour changing giant Unicorn
change this as you see fit...) If the player’s score is greater than 50 Unicorns are famous for looking fabulous, so using a repeat loop
then we go into the “If” condition code. from Control and two blocks from Looks, we change the colour
effect, cycle through colours, and change the size of the sprite by
25 percent. This happens three times before the loop ends and the
Unicorn gracefully glides to the centre of the screen.

17 Announcing our score 18 Adding a forest


No matter what the player’s score is, the Unicorn will announce it by We added another sprite in the shape of a tree, and then used it to
using a “say” block from Looks. But we replace the text with “join” provide cover for our duck. To duplicate a sprite, right-click on the
from Operators and change the first block of text. For the second sprite and select Duplicate. We also clicked on the stage icon, to the
block of text we drop our “score” variable, from Data, inside the left of the panel, and changed the backdrop in the same way that we
space. Lastly we use “stop all” from Control to stop the game. changed costumes for our duck sprite.

Spring 2017 // // 91
First steps in Python:
Control structures
Mayank Sharma takes your fledgling Python skills further by introducing
new concepts and helping you write your first Python script
e introduced two types of variables but is rather used in conditions for loops

W variables in our introduction to


Python in the previous issue:
integers and strings. That’s
actually a little misleading since
unlike in other programming languages Python
and if statements, which we’ll cover in more detail
a little later.
As well as these simple data types, Python
allows us to bring data together in various ways
to create structures. The simplest structures are
variables do not need explicit declaration. Instead called sequences, which store information one
this happens automatically when you assign a after the next. There are two sorts of sequences,
value to a variable. Besides whole numbers and called lists and tuples. In many ways, they’re very
Pi bites a collection of characters, you can also store similar. A list contains a collection of data in a
decimal numbers and boolean values inside specific order while a tuple contains a collection
The Pi uses only variables. of immutable data in a specific order. This means
around 5-7 watts Every piece of data has to have a type that while you can update an item in a list you
of power. The
consumption associated with it so Python knows what it’s cannot do so in a tuple.
varies with how dealing with. You can find out what type Python You create a list by enclosing it in square
you use it – 1.2A has associated with a bit of data by using the brackets, while tuples are surrounded by round
will be enough
for most tasks, type() function. In a Python interpreter, enter: ones (parentheses). You can retrieve an individual
though it needs item from either by putting square brackets after
2.5A to use all
four USB ports.
>>> type (3.5) it along with an index number. Note that indexes
<type 'float'> start at 0, so list_1[0] and tuple_1[0 will retrieve
the first item in either sequence.
>>> type ("Quotes make it a string")
<type 'str'> Entrance fee
Now let’s work on a program to demonstrate how
>>> type (1>3) to use variables and different data types and also
<type 'bool'> understand the important concepts of conditional
Boolean or bool is the simplest type of variable statements and loops.
because there are just two values it can take: True A particular zoo in London determines the
or False. Unlike other variable types, however, a price of admission based on the age of the visitor.
bool value isn’t usually stored explicitly in Visitors 3 years of age and under are charged a

92 // // Spring 2017
Python CODING

nominal £0.99 fee. Children between 3 and 15 is waiting for you to enter something from the
years of age are charged £17.25. Seniors aged keyboard. Without the prompt, Python would
60 years and over get a concession and are just sit there waiting and the user would not
charged £19.35. All other visitors are charged know what was happening.
as adults at £21.50.
We’ll create a program that’ll read the ages Control structures
of all the visitors in a group and add up their A program is usually executed linearly from top
admission fees based on the above given criteria. to bottom, one line at a time. However, certain
When the user enter 0 to indicate that there are statements, referred to as control-flow
no more visitors in the group, the program will statements, have the power to change the path
then display the admission cost for the group. of the code execution.
First up we’ll store the different admission “While” loops are one of the most common
prices and age limits in variables, such as: control-flow statements. The “while” loop has a
condition that can be anything with a bool data
# The various admission prices type, and the code block will continue looping
baby_price = 0.99 until that condition is False. The condition can be
child_price = 17.25 as complicated as you like, as long as it comes
adult_price = 21.50 back to either True or False. However, in order
senior_price = 19.35 for the loop to eventually terminate, the code
block must include one or more variables that
# The applicable age limits can change inside the loop. Pi bites
baby_age_limit = 3 Secondly, many programs require you to go
child_age_limit = 15 through more than one thing at a time, such as 100,000
adult_age_limit = 60 in our case where we have to calculate totals Raspberry Pis
were sold on
based on multiple ages. One of the simplest the first day
# Variable to hold the total admission price ways to control the flow of a Python program of launch in
February 2012,
total = 0 is to branch off and execute different pieces and more than
of code depending on a condition. This is best 10 million units
In this block of code, we’ve first stored the done with the “if” loop. Like “while” loops, “if” have been sold
worldwide as
applicable admission prices as floating point statements take a condition that has to have the of September
numbers and the age limits as integers. We’ve bool data type. Also, “if” statements only execute 2016.
also created a variable that’ll hold the final one block of code. Once Python finds a condition
computed admission price. The line beginning that is True, it’ll execute that block and then exit
with # is a comment that explains the code. Any the “if” statement.
characters on the same line that follow the # That said, “if” statements can also have an
symbol will be ignored by Python. “else” statement and additional “elif” statements.
Next up we’ll ask the user to enter the age of Of these, “elif” is used to create an extra set of
a person in the group: conditions in the if-else statement. The “elif”
visitor = input ("Enter the age of the visitor (0 to clause is a combination of the “else” clause and
exit): ") a separate “if” statement. When an “if” condition
Python provides the input() function, which has is False, Python skips the indented block and
an optional prompt string parameter. When the looks for an “elif”, which it then evaluates. Once
input function is called, the program flow will be again, if this is determined to be True, Python
stopped until the user has given an input and has then executes the following block. When the “elif”
ended the input with the Return key. First it prints condition turns False, Python then moves forward
the string you give as a parameter, and then it and looks for another “elif” or an “else”. The “else”
waits for a line to be typed in. In the line above, block is executed if none of the conditions are
the entered value is assigned to the variable True. Note that “if” blocks don’t have to have an
named visitor, which we’ll use later. “elif” or “else” statements. If there’s no “else”
Note that while the parameter inside the statement, and none of the conditions are True,
parentheses after input is optional, it is very then Python simply exits the “if” block without
important since it prompts you that the program executing anything.

Programming languages vs. scripting languages


While people might squabble over it, Python humans. For example, when you write a since it runs inside the Java Virtual Machine,
is strictly speaking a scripting language. A program in C and compile it, the resulting .o which is what makes it so portable. Also,
scripting language differs from a true file is what is read by the computer. programming languages tend to be more
programming language in a couple of ways. Scripting languages, on the other hand, complex and difficult to learn. This is in fact
The foremost difference between the two is are read, interpreted and acted upon every one of the reasons for the popularity of
that programming languages are compiled, time you run them. programming in Python on the Raspberry
unlike scripting languages. Languages like There are other differences as well. Pi. Together they lower the entry threshold
C, C++, and Java must be compiled by Programming languages most often run and make programming accessible to
a compiler, which then creates a file of directly on top of the hardware on which people who would never have dreamt of
machine code that is unreadable by they are written, though Java is an exception programming a computer.

Spring 2017 // // 93
CODING Python

Python uses a colon to indicate the start of


Naming variables a block of code and then continues until the
indentation changes. In practice what this mean is
Python gives you a wide latitude to verbose variable names such as that you add a colon and then hit the Enter key to
assign a name to your variables as vendor_number while some prefer start a new line. You then hit Tab once and then
long as you follow certain rules. abbreviated versions like vnum.
type your first line. Every line that’s also tabbed
The variable name can include Similarly, many people use the
numbers, letters and special underscore character to separate
will then be executed one after the other.
characters, as long as the first the words in their variable names
character isn’t a number or the while others use camelCase, where Variable formatting
underscore character. Also out of each word begins with a capital To keep things moving forward, we’ll ask the user
bounds are words that Python uses letter. You can use any of these to enter the age for the next visitor in the group.
itself, such as if, for, while. Your practices as long as the names are We’ll copy the line that we used earlier to enter
variable names also must be single readable. Also, irrespective of the the “while” loop. This one refreshes the value in
words and can’t contain spaces. system you use, always make sure the age variable to evaluate whether the “while”
Some people prefer to create you are consistent. loop still holds true:
visitor = input ("Enter the age of the visitor (0 to
exit): ")
All this might sound a bit overwhelming at first
but it really isn’t once you get used to it. Let’s put But what happens when the user enters 0 and the
this knowledge to work to compute the entrance condition for the “while” loop becomes False? In
fee for a group of people. We’ll start off with a that case, we’ll exit the loop and display the value
“while” loop: of the total variable, which now holds the
while visitor != 0: admission price for the entire group.
age = int(visitor) print "The total entrance fee for the group is %.2f"
%total
The visitor variable holds the age of a visitor as
entered by the user. Python will stay within this Displaying values from variables in Python seems
loop until the user enters 0 as the age of the a little bit odd at first. The f following the first %
visitor (or rather, enters this to indicate that there is short for float. The .2 tells Python to display
are no more visitors to consider), at which point the value in the floating point variable with two
the condition for the “while” loop turns False and decimal places. The left % tells Python where
Python skips the indented “while” block. Once you want to put the formatted string. The value
inside the “while” loop, we call upon Python’s int() following the right % is the variable that we want
function to convert the entered age into a plain to display. Python takes the value following the
integer. The converted age is then stored inside second % and formats it according to the first %.
Pi facts another variable called age. Then it places the second value in place of the
Now comes the crucial bit: first %. The above line will produce a string that
The credit-card- if age <= baby_age_limit: reads something like this:
sized Pi is so total = total + baby_price The total entrance fee for the group is 56.94.
compact and
well designed elif age <= child_age_limit:
that it has no total = total + child_price We’ll look at Python formatting in more detail in
moving parts elif age <= adult_age_limit: our next tutorial in the next issue.
and hence
doesn’t produce total = total + adult_price Head to https://github.com/geekybodhi/
any noise or else: piuser/blob/master/entrance-fee.py to grab
vibrations.
total = total + senior_price the complete code for the admission example
used in this tutorial. The code includes hints to
These few lines are the meat of the program that also calculate the number of individuals in a
do all the heavy lifting. The “if” and “elif” lines group. As an exercise, extend this example to
check whether the age falls within one of the record and then list the number of visitors in
predefined age limits. If the age is less than or the group based on their ages.
equal to the age defined in the baby_age_limit
variable, then the price of their admission is
added to the current value of the total variable. Jargon buster
If this condition is false, Python looks for an
“elif” condition and then evaluates it. Once it Variable: A named storage location that is used to hold
information which will be referenced and in all likelihood
has evaluated all the conditions and none of them
be manipulated in the program.
hold true, it then enters the “else” block.
The “else” block is triggered only when the Function: A block of reusable code that is called upon
entered age doesn’t match any of the defined age to perform a specific task. Python comes with a
limits. This will happen only when the age is over predefined set of functions, which are stored in a library.
60. To make it simpler, we could have replaced the
“else” statement with an “elif” to check if the age Parameter: Also known as an argument, this is a
meets the criteria for the senior price, like this: value that is passed to a function. A function can
elif age > adult_age_limit: have multiple parameters, and they can be either
total = total + senior_price required or optional.

94 // // Spring 2017
Building your own
cities in Minecraft
Les Pounder shows you how some simple Python code can enable
anyone to create – and destroy – their own city in Minecraft
ack in the 1980s an ambitious game With our blank document open we start writing

B saw players building and running their


own city: SimCity. It has been ported
to many different machines, from ZX
Spectrum to PC and everything in
between, but the basic game element is to create
the Python code. We first import a series of
modules – code libraries that enable Python to do
more. First is the Minecraft library, which enables
our code to talk to Minecraft. Next import one
class from the random library: randint, short for
your own sprawling city out of nothing. You have random integer. Finally import the sleep class from
godlike powers to do and build whatever you wish, the time library, used to add delays to our code.
but will you use them for good or for evil? from mcpi.minecraft import Minecraft
Well, we’ll use some Python code and Minecraft from random import randint
to create our own SimpleCity, which will shape the from time import sleep
Minecraft world into our vision of the future. All of Next we create an object that will create a
the code for this tutorial can be downloaded from connection from our code to Minecraft:
https://github.com/lesp/PiUser002-Simple- mc = Minecraft.create()
City/archive/master.zip Our next line of code is a dictionary. A dictionary
can be used to store multiple items, which can
Coding the project then be referenced and used by calling their name,
The goal of our project is to create an easy-to-use otherwise known as a “key”. For example if we use
menu that will enable the player to quickly build the key air then we return the value 0. Here we use
their own city in the Minecraft world. To start, open a dictionary to store the block IDs for a selection
the Python 3 editor from the main Programming of blocks that we use in the project.
menu. Once it’s open you will see the Python shell. buildingblocks = {'air':0, 'cobblestone':4,
Click File > New to create a new file. You now see 'diamond':57, 'road':44, 'sandstone':24, 'water':8}
a blank document. Click File > Save and save the We now start a section where we create a series
project as “SimpleCity.py”. Subsequent saves will of functions, which is a block of reusable code that
now take less time. Remember to save often! we use to handle building or destroying sections of

Spring 2017 // // 95
CODING Minecraft

The inventory the Minecraft world. We start our functions by building has started. We then repeat the process to
contains lots creating a block of code that will destroy a locate the player in the world, but then we split the
of extra blocks 50-cubed area of the world. First we give the data stored in “pos” into separate x,y,z variables.
and items that function a name: “destroy”. Notice the colon at the The next three lines create variables width, height
you can use to
end of the line – this tells Python that the next line and length, each with a randomly generated
decorate your
should be indented. Our editor will automatically number as its value. We use randint and specify a
home and the
city around it.
do this for us. The first line of indented code range in which the number can be selected. In the
creates a variable called pos that will store the last line we set the blocks for an area starting from
position of the player in the world using the the player’s position and ending at the randomly
getTilePos command, which returns a coarse but chosen coordinates. We used a diamond block to
adequate position for placing blocks. Once we give our skyscraper a shimmering tower of glass.
know the player’s position, we next set the blocks, def skyscraper():
using setBlocks, from the player’s position (x,y,z) mc.postToChat('Building a skyscraper')
to 50 blocks away for each axis. This creates a 50 pos = mc.player.getPos()
cubed box containing air, effectively destroying x,y,z = pos.x, pos.y, pos.z
everything in that cube. width = randint(4,20)
def destroy(): height = randint(10,50)
pos = mc.player.getTilePos() length = randint(6,20)
mc.setBlocks(pos.x, pos.y, pos.z, pos.x+50, pos. mc.setBlocks(x, y, z, x+width, y+height,
y+50, pos.z+50, buildingblocks['air']) z+length, buildingblocks['diamond'])
Our next function creates rather than destroys. As well as skyscrapers we need a simple home
It creates a Skyscraper at the player’s position. for the people who live in the city, and our next
First it will post to the Minecraft chat screen that function, building, will build a modest sized home,
ready for you to decorate. Building works in the
same way as our skyscraper function, but it builds
SNAKE CHARMER only homes of a certain size, and out of
cobblestone. The key difference with this function
Python is a wonderful language. In this project we have used it to conjure is that after we create the cobblestone that makes
up new worlds and give us godlike powers. But the true power of Python the building, we create another smaller space
on the Raspberry Pi is that we can use any Python library in our projects.
within by creating a building one cube smaller in
This includes the GPIO Zero library, which enables easy use of the Pi’s 40
every axis, out of air, essentially hollowing out the
GPIO (General Purpose Input/Output) pins. So we can now have Minecraft
react to the physical world. For example in our project, the functions that home. We will leave doors and windows to you –
create roads, rivers and skyscrapers are triggered using a menu, but we just remember to press “e” on the keyboard to
can also use buttons, sensors and triggers in the real world to invoke these access the inventory for your belongings.
functions. Think of destroying a 50-cubed area of the world just by waving def building():
your hand in front of a sensor – true godlike powers can be yours with mc.postToChat('Building commencing')
Python! You can find out more about GPIO Zero by reading the official pos = mc.player.getPos()
documentation at http://bit.ly/gpio-zero x,y,z = pos.x, pos.y, pos.z

96 // // Spring 2017
Minecraft CODING

width = 10 of the player, just enough for the player to sink but
height = 5 not too deep that we get lost. Our player cannot
length = 6 drown, so you are free to explore the underwater
mc.setBlocks(x, y, z, x+width, y+height, world. When creating a river it is wise to remember
z+length, buildingblocks['cobblestone']) that water flows, and that if the river is created
mc.setBlocks(x+1, y+1, z+1, x+width-1, somewhere high, say a hill, then water will cascade
y+height-1, z+length-1, buildingblocks['air']) and flood the ground – but this can be used to
We have our buildings, now we need roads. This your advantage if you’d like a skyscraper waterfall!
function is a little different, in that it takes an def river(direction):
“argument” – in other words, we give the function mc.postToChat('Can I swim?')
Pi bites
an extra piece of information. In this case we tell pos = mc.player.getTilePos() In Minecraft Pi,
the function which direction to build the road in. x,y,z = pos.x, pos.y, pos.z if the player
The function replicates the chat message to the width = randint(1,5) tries to play full
screen, they
user, gets the position of the user, and sets the depth = 6 cannot access
width of the road to 6 blocks and the length to 100 length = randint(1,100) all items in the
(these can be changed to suit your needs). We if direction == "north": inventory. So
always play
then enter into a conditional test that will check mc.setBlocks(x, y, z, x+width, y-depth, Minecraft in
the direction given by the player. This uses two z+length, buildingblocks['water']) a window.
conditions, the first being if and the second elif, elif direction == "east":
short for “else if”. If the direction is “north” then mc.setBlocks(x, y, z, x+length, y-depth,
the road is built ahead of the player. Else if the z+width, buildingblocks['water'])
player types “east” then the road is built across Our functions are now complete and we move
their path. on to the next section of code. Here we create two
def road(direction): lines that use the chat window to welcome the
mc.postToChat('Roadworks commencing') player and advise them on what to do in the game.
pos = mc.player.getTilePos() mc.postToChat('Welcome to our Simple City.')
x,y,z = pos.x, pos.y, pos.z mc.postToChat('You are free to destroy and create
width = 6 using the menu')
length = 100 Next we create a variable called “answer” and
if direction == "north": into it we store the integer 0:
mc.setBlocks(x, y, z, x+width, y, z+length, answer = 0
buildingblocks['road']) Why do we do this? Well, in order for us to use a
elif direction == "east": “while answer” loop, we first need to create the
mc.setBlocks(x-1, y-1, z-1, x+length, “answer” variable, otherwise we cannot enter the
y,z+width, buildingblocks['road']) loop. This while loop will compare the value stored
Next we create the function that will build rivers. in “answer” and if it does not equal the value “8”
This is essentially the same as our road function, then the code in the loop will run.
including the ability to pass an argument, But where does this value come from? Well, we
direction, so that we can build roads in front of our create a menu, which has a number attached to a
path or across our path. But the river code differs function. This menu is a multi-line print function,
in that we can also set the depth of the water. We which is neater than creating a print function for
chose 6 blocks depth as it is three times the height each line. You will notice that at the end of each

Starting our
project launches
a simple menu
in the Python
shell and a quick
message pops up
in Minecraft.

Spring 2017 // // 97
CODING Minecraft

Our city has a


massive waterfall
that cuts into a
skyscraper. Water
is extremely
damaging in
Minecraft, so use
with caution.

line is \n – this is an escape character and tells is highly likely the player chose “8”, which will exit
Pi bites Python to create a new line. After the print the menu by using the “else” condition. This will
function we update the “answer” variable with print “Goodbye” in the Python shell and print a
The “building”
function is input from the user. Here the user is asked to message in the Minecraft chat window.
intentionally choose a number, which is then stored in the if answer == '1':
bare-bones. So variable. For example if we wish to build a skyscraper()
to decorate your
home, press the skyscraper we press 1 and then Enter. This is elif answer == '2':
“e” key to open captured and stored in “answer” ready for the building()
your inventory
and select your
next section of code. elif answer == '3':
furnishings. while answer != "8": road('north')
print('Main Menu \n' elif answer == '4':
'1: Create a skyscraper\n' road('east')
'2: Create a building\n' elif answer == '5':
'3: Build a road, north to south\n' river('north')
'4: Build a road, east to west\n' elif answer == '6':
'5: Create a river, north to south\n' river('east')
'6: Create a river, east to west\n' elif answer == '7':
'7: Destroy a 50 cubed area around you\n' destroy()
'8: Exit the menu') else:
answer = input('What would you like to do? ') print('Goodbye')
Our final section of code is a conditional test, mc.postToChat('Exiting menu,
which will check the value stored in “answer”, our connection terminated')
variable that stores the player’s choice. If the value break
stored matches one of the hard-coded values then And that is all of our code complete. Make sure
it will run the respective function. For example if you save your work before continuing.
“answer” contained “4” then the correct choice In order to use our code, we first need to start
would be to run road(‘east’). If the value stored in a game of Minecraft – you can find it in the Games
“answer” is not a number between 1 and 7, then it menu. With Minecraft open we now need to go
back to the Python editor – but we can’t, our
mouse is stuck in Minecraft! Fear not, simply press
MUSICAL MINECRAFT the Tab key. This will release the mouse, and you
can now click on your code. Click on Run > Run
We used Python in our project, but did you know that you can also hack Module to start your code and then select an
Minecraft with Sonic Pi? Sonic Pi comes pre-installed on your Raspberry Pi and
option from the menu to build your own city
with it you can create music of any genre – and create Minecraft worlds. Sonic
made of blocks!
Pi was created by Dr Sam Aaron, a gifted computer scientist and musician.
Sam uses Sonic Pi to “live code” compositions for events, rewriting the Ruby
To get back into Minecraft, click on the
code live in front of an audience and reacting to the cues given by a live band. Minecraft window in the taskbar at the top of the
The Minecraft functionality was introduced into Sonic Pi as a result of a screen, and then move your mouse. Minecraft
conversation between Sam and Martin O’Hanlon, an expert in Minecraft. As should respond. If not, just click in the Minecraft
a result of this meeting we can use Minecraft as an input for a performance – game window and it will register your click.
for example changing music depending on the block that we are stood upon. Now go forth and build your own city – or
You can read more at http://sonic-pi.net destroy it!

98 // // Spring 2017
GET STARTED WITH
LINUX THE EASY WAY

OUT
NOW!
WITH
FREE
DIGITAL
EDITION

ORDER YOUR COPY TODAY!


Order online at www.myfavouritemagazines.com
Also available in all good newsagents
Pi REVIEWS
Tested and rated: the latest add-ons for your Pi 102

110 104

106

BEAUTIFULLY MADE
AND ROBUST, THIS ADDS
ETHERNET AND FULL-SIZE
102 Kano
Screen Kit

USB PORTS TO A PI ZERO 104 Pi-Top


laptop kit

106 S.USV
Advanced
Pi

108 112 108 Enviro


pHAT

110 Pi& USB


Zero RJ45
Hub

112 display
ZeroSeg LED
kit

Spring 2017 // // 101


REVIEW Kano Screen Kit

Kano Screen Kit


In his quest to create the ultimate Raspberry Pi portable hack station,
Les Pounder finds a portable screen that will fit in his rucksack
ew trends in made with Gorilla Glass, which attaches to a convenient screen

N
In brief... Raspberry Pi means it’s well protected from controls board.
A portable 10.1- accessories are knocks and scrapes. The screen There’s also a retention space
inch Raspberry like buses: you comes as a kit which the user is to attach your Kano Raspberry
Pi screen that wait ages for a encouraged to build. This kit Pi case to the screen, creating
offers HD
resolution in a portable Raspberry Pi solution has a strong plastic frame into a rather nice single unit. The
strong and kid- and then they all turn up at which the screen is clipped, and screen is powered via a bespoke
friendly chassis.
The Kano ethos
once. We’ve seen many different the frame can be laid down on a micro USB cable that also
is to enable screens for the Raspberry Pi, table in a similar way to an old powers your Raspberry Pi.
learners to including the official 7-inch school desk or upright like a Building the screen takes just a
experience
building their screen, and the next one to traditional monitor. On the back few minutes; the only tricky bit
own computer turn up is this kit from Kano.
and this is
supported by
This company knows about
packaging and marketing, and
THERE’S NO SPEAKER, SO YOU’LL
a series of
workbooks
written with
the Kano Screen Kit comes in a NEED TO ATTACH ONE, NOR DOES
quality box with everything well
children in
mind. protected and labelled. The box IT HAVE TOUCH INPUT, BUT THE
also includes an assembly guide
written for young hackers,
PICTURE QUALITY IS EXCELLENT
designed to be similar to Lego
instructions, which enables of the screen is a driver board is attaching the driver board
users to start building as soon that connects it to a Raspberry case to the screen.
as the box is open. Pi via a conventional HDMI
The Kano screen measures cable, and attached to the driver Tough contender
10.1 inches diagonally and is board is a breakout cable which We tested the screen with the
latest Kanux distro and the
latest Raspbian image. For both
Features at a glance screens the initial view appeared
upside down, requiring us to lie
the screen down so that it
looked like an old school desk,
and then rotate the screen 180
degrees in the OS. In Kanux this
is achieved by going into the
System Settings and selecting
Display. In Raspbian you have
to edit the config.txt file found
in the boot partition and
manually add display_rotate=2
as the last line. For both distros
the desktop was displayed at
the correct size and no further
configuration was necessary,
Adjustable display Works with all but using the controls on the
Provides two display positions and handy The Kano screen uses an HDMI driver board,
controls on the back to get your screen just which means that it can also be used with back of the screen we could
right (and somewhere to stash a keyboard). other devices. quickly alter the setup of the
screen if needed.

102 // // Spring 2017


Kano Screen Kit REVIEW

The screen is a
balanced mix of
portability and
features. It’s clear
to read at most
angles and can
be powered along
with your Pi from
a USB adapter.
(Keyboard is
not included in
Screen Kit.)

The screen does not provide can take a fair amount of socket. The Kano Screen is not
any audio output, so you’ll need punishment, unlike other a cheap screen solution, but it
to attach a speaker/headphones screens on the market. is one of the most robust at this
to the jack on your Raspberry The Kano Screen is currently price point. It successfully
Pi, nor does it have touch input. priced at something of a sweet merges portability with usability,
Picture quality is excellent, spot: it’s not as cheap as the offering a lot of screen for
however, with the 10.1-inch official screen and doesn’t have a fair price.
screen running at 1,280x800, a touchscreen capability, but it
giving us 150 pixels per inch is built to last and right now
(PPI). The resulting image is it’s a good alternative for users Verdict
bright and clear, providing the and schools when compared to
ideal platform for hacks. other solutions, such as the Pi
Kano Screen Kit
Developer: Kano
The Kano Screen is a tough, Top (see overleaf). The lack of Web: kano.me
well built and well specified audio output will be an issue for Price: £120
product, and it’s clear that the some buyers, especially those
target market, young learners,
is well catered for as this screen
using the screen with the Pi
Zero, which has no headphone
Rating 8/10
Spring 2017 // // 103
REVIEW Pi-Top laptop kit

In brief
A Raspberry Pi
laptop solution
offering an
impressive level
of portability
and features
that are
aligned with
Features at a glance
the UK GCSE
curriculum. But
these features
come with a
hefty price tag
and a number of
rough edges to
a relatively new
software base.
That said, this
is a powerful Pi-Top isn’t quite
package for Practical package Applications
your typical laptop, The Pi-Top laptop case Standard Raspbian apps
those who can
work around and under the lid provides easy access to the are included, such as
the issues. it’s all Raspberry GPIO via a sliding panel LibreOffice and the
Pi powered. above the keyboard. Chromium web browser.

104 // // Spring 2017


Pi-Top laptop kit REVIEW

Pi-Top laptop kit


Les Pounder gets hands-on with an education-focused Raspberry Pi
laptop kit that promises to make the class green with envy…
ight now the but the keyboard can feel a little During our tests there were

R Raspberry Pi
sports a plethora
of portable options.
September 2015
saw the release of the official
spongy and imprecise at times.
On the software side, you
get the pi-topOS, built upon
Raspbian Wheezy 7.8. Pi-topOS
acts as a layer on top of the
a couple of issues. Logging in as
an incorrect user prevented us
from re-attempting a login with
the correct details. A reboot
solved this issue, but it did
touchscreen, and other Raspbian OS. On first boot you take time. Also, an update
companies such as Kano offer are prompted to set up your bug prevented pi-topOS from
their own portable (or near- Pi-Top, which includes creating connecting to the update server
portable) setups – see the an online account. This is used despite constant reminders and
previous page. Pi-Top started life to save your learning progress to using an Ethernet cable to
as a crowd-funded project and the Pi-Top cloud-based learning connect to the router.
combines both hardware and system, which is aligned with Pi-Top also has its own
software. The hardware is a the UK Computing curriculum software, a game called CEED
sturdy plastic laptop shell for 13 to 15 year olds. Universe, which teaches coding
(supplied as a kit) and includes and making concepts via an
a 13.3-inch HD (1,366x768) LCD Learning interactive retro game – a great
screen with eDP interface, an experience idea that keeps children engaged
8GB SD card, a battery with Like Raspbian, the Pi-Top comes while learning key skills. It’s
a claimed life of 10 hours, and with a bundle of applications. reminiscent of Kano OS,
a Wi-Fi dongle. You can buy it These include Scratch, Libre which itself uses gamification to
with or without teach core
a Pi 3. The kit concepts.
is fairly simple FAIRLY SIMPLE TO ASSEMBLE CEED
to assemble
but might
BUT MAY REQUIRE ADULT HELP Universe is a
lot of fun and
require adult FOR A FEW FIDDLY BITS provides a
supervision great level of
for a few fiddly interaction for
bits, such as attaching the LCD Writer, Minecraft Pi, Sonic Pi children wanting to learn more.
screen to the driver board. and the Python editor IDLE. We The Pi-Top is a great idea and
The driver board handles tested IDLE 3, the Python 3 provides a portable Pi solution,
connecting the Pi to the built-in editor, with the RPi.GPIO library, but it’s not as high-quality as the
battery, recharging the battery the most popular library for price might lead you to expect,
via an included external power hardware hackers and makers. and the cost of $300 (around
supply, and sending HDMI Being based on Wheezy, IDLE3 £200) is high, with just a 30-day
video input to the LCD screen. was unable to access the GPIO warranty, for its target education
Connecting the GPIO of your Pi using the default user – it market. The software bugs will
to the driver board enables required opening a terminal and doubtless be tackled, but the
battery management, but will running the command via sudo cost is the main barrier.
cover all 40 GPIO pins; it can be – but we successfully built and
removed, enabling use of the tested a simple LED project. This
GPIO. The driver board and the is a step backward for those Verdict
Pi (located at the right of the used to the latest Raspbian
Pi-Top laptop kit
laptop) are covered by a slide Jessie image, but we’d expect
Developer: CEED Ltd
cover, for quick access to the Pi. this to be fixed in a future Web: www.pi-top.com
Access to the Pi’s USB and release. Of course, as it’s based Price: $300 with a Pi 3, $265 without
Ethernet ports is tricky but on Raspbian, you are free to
possible. The keyboard and install your favourite applications Rating 6/10
trackpad are fine for daily use via the package manager.

Spring 2017 // // 105


REVIEW S.USV Pi Advanced

S.USV Pi Advanced
Les Pounder has always loved Star Trek and often pretends to be Captain
Kirk, but can Scotty provide more power? Maybe with this board...
he Raspberry Pi has configuration and installation which comes with a 300mAh

T
In brief... been used to power is handled via the Terminal, (milli-Amp-hour) battery. A
A flexible UPS many different and while being quite involved noticeable feature present only
(Uninterruptible projects, including and requiring a number of on the advanced model is the
Power Supply) some where it is a changes to the default inclusion of an alternative power
that provides
multiple power mission-critical component. Raspberry Pi configuration, source which can be used with
sources, such For these sorts of dedicated installation is straightforward any power supply rated between
as batteries
and solar power,
projects it is prudent to have a and well covered in the 7V and 24V. The software that
for critical secondary means of powering supporting documentation. handles the functionality of
Raspberry Pi the Pi, should the mains supply (Sadly the same cannot be the board is controlled by a
projects. The
board attaches suffer a sudden interruption said for all of the documentation background process, a daemon,
to the GPIO and or shutdown.
comes with an
extensive suite
An Uninterruptible Power
Supply (UPS) provides a
THE CLIENT TOOL PROVIDES THE
of software
tools that
enable
temporary solution to powering STATUS AND CONFIGURATION OF
your Pi. The S.USV HAT is
configuration
and compatible with all versions of THE BOARD AND POWER SOURCE
management
of even the
Raspberry Pi that come with
the 40-pin GPIO and features
VIA A TERMINAL INTERFACE
most minute
details of the a pass-through connector
board and the enabling the use of other – more on this shortly.) which provides the options
attached
sources of Raspberry Pi add-on boards. The S.USV board connects to start, stop and restart the
power. The S.USV HAT, being a HAT and communicates with the daemon process. Installing
compliant board, comes with Raspberry Pi using the I2C the daemon also enables the
an EPROM connected to pins protocol, requiring only two use of two buttons, S1 (used
27 and 28 of the GPIO, which GPIO pins for data, and an to turn off or reboot your Pi)
communicates with the additional 5V and GND and S2 (which can be used to
Raspberry Pi and handles initial connection to power the board. power up your Pi).
configuration. The rest of the We tested the Advanced version,
Power user
The software is installed to
Features at a glance /opt/susvd and comprises the
aforementioned daemon and a
client tool which can provide the
status and configuration of the
board and the attached power
source via a handy terminal
interface. The client tool has
options to read and set the
charging current for the battery,
and we used it to ensure that
the supplied 3.7V 300mAh
battery was charged and ready
Multiple power sources GPIO access for use. Also present are options
The Advanced version (tested here) has Some add-on boards prevent access to the
inputs for two power sources – an LiPo GPIO but the handy pass-through enables to create shutdown timers and
battery plus other sources you can also access to it for direct connection or the use timed boots, using the clock
connect as backups. of other boards. embedded in the board, and the

106 // // Spring 2017


S.USV Pi Advanced REVIEW

facility to upgrade the firmware the essentials of that promise – but is well worth considering. The S.USV
to ensure that your board is it just needs a little refinement There are other UPS boards on board fits very
running the latest version. to make it a better product. The the market, though, and when neatly on top
Sadly the documentation documentation is generally considering a purchase it would of all models of
Raspberry Pi with
for this board has a few issues, great and it covers every aspect be prudent to look around for a
40 GPIO pins.
chiefly found when trying to of installing and configuring the board that provides exactly the
enable the real time clock board; it is just let down by a functionality you require.
(RTC). We found a few faults few errors that cause “hiccups”
with the configuration for the user. On the plus side,
necessary to enable the RTC, this board provides full access Verdict
and this meant that we spent to all of the GPIO pins – and
S.USV Pi Advanced
rather too much time to enable since it uses I2C you can easily
Developer: SEProtronic GmbH
such a simple, yet key, piece of add more boards to your Web: www.s-usv.de/index_en.php
functionality. Hopefully this can Raspberry Pi projects with Price: Basic €29.99 (about £26),
be fixed in future revisions of little fear of conflicts. Advanced (tested) €54.99 (about £48)
the documentation. This is a powerful UPS board
This board promises so
much, and it does deliver on
that offers so much flexibility. It
has a few documentation issues
Rating 7/10
Spring 2017 // // 107
REVIEW Enviro pHAT

In brief
A Raspberry Pi
Zero sized add-
on board that
offers sensors
to read
temperature,
pressure, light
levels, colours,
orientation
and compass
headings.
Designed to
provide data via
a robust Python
library which
can be easily
integrated into
existing
projects. The
board uses only
the I2C pins of
the Raspberry
Pi, enabling
other boards
to be used as
unique methods
of output.

Features at a glance

The Enviro
pHAT is a
compact sensor
board designed
to fit atop the Sensors Analog input
Raspberry Pi The Enviro pHAT has The Raspberry Pi GPIO
Zero and sit with sensors for temperature/ does not have an analog
a flush profile, pressure, light/colour and input by default. The
enabling small, motion/orientation. These Enviro pHAT comes with
neat projects. are simple to integrate into its own ADC for extending
any Python project. the number of sensors.

108 // // Spring 2017


Enviro pHAT REVIEW

Enviro pHAT
Les Pounder loves data and is always looking for new ways to integrate
real-time data into his projects. Perhaps this board can fulfil his needs?
he Pirates of Sheffield magnetometer. So with this The Enviro pHAT comes into

T bring us another board


using their own pHAT
standard for smaller
add-on boards
primarily designed for the
single sensor we can create an
input based on the orientation or
heading of the board, handy for
gesture controlled projects.
As well as sensors the board
its own in a data logging project.
Each of the sensors can be
polled and data recorded into an
external file, such as a CSV file,
which can then be imported into
compact Raspberry Pi Zero but comes with an ADS1015 four- a spreadsheet application, or the
compatible with all Raspberry Pi channel analog-to-digital data can be used with an online
boards with 40 GPIO pins. It’s converter (ADC) that can be resource such as plot.ly.
also worth noting that the used with external analog As mentioned earlier, the
Enviro pHAT uses only three sensors. Attaching a sensor board uses only the I2C pins of
I2C pins (I2C being a simplified to the ADC is rather simple if the GPIO, meaning that other
communication protocol) and it uses 3.3V logic, requiring that boards can also be connected.
two other pins for power, which we simply attach the sensor to For example you can use the
means it is possible to attach the the header pins present on the Enviro pHAT to gather data and
board to older Pis using jumper board. If your sensor uses 5V then display that data via a chain
cables or a breakout board. logic, and this can be identified of WS2811 LEDs, commonly
The Enviro pHAT is a platform in the data sheet for the sensor, known as Neopixels, where
for data gathering, similar to the then you will need to use a different colours denote different
Sense HAT used for the Astro Pi voltage divider, commonly weather conditions or react to
project. The Enviro pHAT comes three resistors of equal value. severe accelerometer input.
with a plethora The Enviro
of sensors. pHAT is a
The BMP280 THE BOARD HAS A PLETHORA OF great board
temperature
and pressure
SENSORS AND A FOUR-CHANNEL that can
be easily
sensor can ADC FOR CONNECTING MORE integrated
work between into a home
temperatures automation
of –40C and +85C, and Assembling the Enviro pHAT project or an experiment. The
pressures of 300 to 1100 hPa requires some basic soldering build quality is exceptional and
(hecto Pascals). The TCS3472 skills. Controlling the Enviro the supporting Python libraries
light and RGB colour sensor can pHAT is then handled via a are easy to use while providing
provide a reading for the light robust and easy to use Python an extensive range of data
level, enabling it to be used as 2 / 3 library that can be used capture options for those
a trigger for light dependent with all of the sensors, or who wish to take on advanced
projects, and can also identify individual sensors can be projects. A cost-effective and
colours, returning the value used by importing each class easy-to-use add-on board for
detected as a comma separated as needed. Installation of the gathering real-time data about
list of values, known as a tuple. Python libraries is automated your environment.
The sensor’s accuracy can be thanks to an install script
increased by illuminating objects available from the Pimoroni
using two white LEDs on each website. Typically using install Verdict
side of the light sensor. Next is scripts from random websites
Enviro pHAT
an LSM303D accelerometer is not the done thing, but in
Developer: Pimoroni
and magnetometer. The this case we can trust the Web: http://bit.ly/enviro-pHAT
accelerometer detects source. For those who wish to Price: From £16
orientation and motion of install manually there are full
the board. A basic compass instructions and a step-by- Rating 8/10
heading can be taken using the step guide.

Spring 2017 // // 109


REVIEW Pi Zero Ethernet RJ45 and USB Hub Shield

Pi Zero Ethernet
RJ45 and USB Hub
Les Pounder tests a community-produced board that provides 100Mbps
Ethernet and full-size USB ports for the Pi Zero. But is it worth the price?
hen the connectors to be used. Next PP6, PP22 and PP23). The

W
In brief... Raspberry Pi to the USB ports is a single board is compatible only with
A community Zero first came Ethernet port rated for 10/100. v1.3 of the Pi Zero, released in
made project out, many All of the USB and Ethernet early 2016. This is because of
that enables applauded the ports are routed via a LAN9512 the placement of PP1 and PP6
full-size USB
and Ethernet reduced cost but some were USB control chip – the same being different on the previous
ports to be unhappy with the micro USB chip used on all Pi models prior version, 1.2. With any luck, this
added to the
Pi Zero. A solid
port and lack of Ethernet. Many to the release of the Raspberry shouldn’t matter to many users,
PCB and no different community boards Pi B+ in 2014. considering that v1.3 has now
configuration were created to address this
enable this
board to be issue, including this one. The
used for
permanent
Raspberry Pi Zero Ethernet NO SOFTWARE INSTALLATION OR
RJ45 and USB Hub Shield is a
projects,
or used project created by an individual CONFIGURATION IS REQUIRED –
temporarily
for configuring
maker in Scotland and available
for sale via the open hardware
DRIVERS FOR THE CONTROL CHIP
a project. Pogo
pins provide
a temporary
marketplace Tindie.com.
It’s created using a four-layer
ARE ALREADY IN RASPBIAN
yet stable
solderless printed circuit board and has
connection been made with great attention The board attaches to the been with us for much longer
between board to detail. On the board, there Pi Zero using pogo pins that than the short-lived 1.2. With
and Pi Zero.
are two USB 2.0 ports mounted lightly connect to the USB and the board attached to the
on their side with sufficient power test pads present on the underside of your Pi Zero you
clearance for cumbersome USB underside of the board (PP1, still have access to all 40 of the
GPIO pins. The board is secured
using the included fastening kit,
which we found a little fiddly
Features at a glance but ultimately not that difficult
to install.

Zero effort
Once the board is attached, all
you need to do is connect your
accessories and power up using
the Pi Zero micro USB power
port. Here is where we hit
another issue. Once the board
is attached, the Pi Zero’s own
micro USB port, normally used
for keyboards and mice etc, is
now non-functional and all
connections have to be made
using the add-on board. This
USB and Ethernet Pogo pins isn’t a deal breaker by any
The LAN9512 USB/Ethernet controller chip Use light pressure to create a temporary
is used on all models of Pi up to the B+. As contact between the board and the gold test means but it would have been
a result, it works out-of-the-box with no pads on the underside of the Pi Zero. nice to have three USB ports,
additional configuration required. even if one was micro USB.

110 // // Spring 2017


Pi Zero Ethernet RJ45 and USB Hub Shield REVIEW

The Raspberry
Pi Zero Ethernet
RJ45 and USB Hub
Shield is remarkably
well made for a
community product.

On the positive side, there’s and full-size USB ports to need to use a Pi Zero in your
no software installation or your Pi Zero. The fact that it’s project and you need USB and
configuration needed, largely compatible only with the current Ethernet, then this is the board
thanks to the LAN9512 USB v1.3 of the Pi Zero should not be for you.
control chip, for which drivers a real drawback, but something
are already present in Raspbian. to be aware of for any potential
For advanced Pi users there are purchaser. The price might Verdict
breakout points for the 5V and however be an issue. Because
Raspberry Pi Zero Ethernet
GND pins present on the GPIO. this is made by an individual,
RJ45 and USB Hub Shield
This means that power can be the cost of each board is higher
Developer: Marcel
provided using an alternative than you’d expect of boards Web: http://bit.ly/
connection to the micro USB. mass-produced in a factory. PiZeroEthandUSBHub
Beautifully made and robust, Adding on the cost of shipping, Price: $22 (about £18)
this board isn’t cheap, but it plus the initial cost of a Pi Zero,
does deliver an effective and
elegant way to add Ethernet
takes us over £20 and into Pi 2
and 3 territory... But if you really
Rating 9/10
Spring 2017 // // 111
REVIEW ZeroSeg

ZeroSeg
Les Pounder looks at a kit that can The ZeroSeg kit is fun to build. Sure,
there’s a few tricky bits of soldering
be used to add a classic ’80s display to your Pi involved, but that’s part of the challenge.

rowing up in the Steady hands and good eyesight primer for you to get to grips
In brief...
A dual seven-
segment LED
display
controlled using
a MAX7219 SPI
G ’80s, we remember
the humble seven-
segment display
that flashed “12:00”
on our family’s first VCR. This
are required.
The board has two four-digit
seven-segment displays (so
eight characters in all) and two
tactile switches. The displays are
with the board. They address
common use cases such as
scrolling text, simple date, time
and temperature data.
Within a few minutes we were
chip and a simple method of output controlled using a MAX7219CNG scrolling text across the displays
straightforward
Python library, provided enough information chip designed for driving 8-bit and we hit a little snag: “@” or
which presents to use the VCR, from just seven LED displays via an SPI interface “w” cannot be displayed. This
a humble yet LEDs per character. In the 21st – something the Pi is capable of is no fault of AverageManVsPi,
powerful
platform for century we have OLED displays using for communication. This but a design limitation of seven-
makers. As a kit and basic holographic displays, common chip is also used to segment displays. This apart, for
that requires
some soldering,
but there’s still a place for the drive 8x8 grids of LEDs for projects where you need simple
the board offers seven-segment display. digital signage and it’s nice to output – say a camera timer,
a cost-effective The ZeroSeg is an add-on see that it’s housed in a holder, system monitor or IoT coffee
entry for those
interested in board for all 40-pin Raspberry Pi allowing replacement should pot monitor – this board is ideal,
using the models but is designed primarily the need arise. To use the board and at only £10 it’s a great
display and its for the Pi Zero and fits neatly you need to install a number of opportunity to dust off your
two tactile
switches to atop it. The board was originally drivers and libraries, and all this soldering iron and build your
control a designed by a community
headless
Raspberry
member, AverageManVsPi, who
has started a small range of
WITHIN A FEW MINUTES WE HAD
Pi project.
boards aimed at the beginner. TEXT SCROLLING ACROSS THE
The ZeroSeg comes as a self-
assembly kit and requires DISPLAYS, THOUGH NOT @ OR W
soldering. While this is mostly
trivial there are a few moments, is well documented in a concise own kit. It might not do anything
such as soldering the displays PDF download, which also unique – you could just build
next to the plastic housing of includes assembly instructions. your own seven-segment display
the female GPIO header, where on a breadboard – but this is a
it can become a little tricky. Neat display fun, inexpensive board providing
With the set-up complete, we a functional (although limited)
can start using ZeroSeg. The method of output that can be
Features at a glance Python library for this board is a used in many different projects.
fork of Richard Hull’s MAX7219 If you’ve never used a seven-
library, tweaked for ZeroSeg use. segment display, try it and learn
The library is Python 2 only, how our old VCR talked to us.
though; it would be better to see
a Python 3 library as standard.
The tactile switches can be Verdict
used with RPi.GPIO and GPIO
ZeroSeg
Zero Python libraries, and we
MAX7219 Design hear whispers of seven-segment
Developer: AverageManVsPi & Pi Hut
The common chip is used Careful thought has led to Web: http://bit.ly/ZeroSeg
to drive the dual seven- small components being display compatibility being Price: £10
segment display and it
connects to the Pi using
an SPI interface.
on the back and their
solder joints covered by the
larger, front facing parts.
added to GPIO Zero, enabling
even easier hacks. The example Rating 8/10
scripts provide enough of a

112 // // Spring 2017


LIFE OF Pi

The Picademy
The Raspberry Pi Foundation rolls out
more free training for educators in 2017

Image credit : Raspberrypi.org


Some people, possibly teachers, in
Manchester, behaving perfectly normally.

he Raspberry Pi was created to help courses available for 2017. They are at The

T
children learn programming skills TramShed in Cardiff on 21/22 February, the
from a young age, so it’s no surprise MadLab in Manchester on 14/15 March and 2/3
that the Raspberry Pi Foundation has October, the Learning Hub @ Birmingham Airport
always had close links to schools and 10/11 April and 4/5 December, and The Raspberry
education. In fact, the Code Club Pi Foundation in Cambridge 15/16 May. There will
concept (www.codeclub.org.uk) – where an also be dates in May and November in London at
enthusiast teams up with a school or library to a location to be confirmed.
run an after-school club for kids aged 9-11 using A Picademy course lasts two days, and is a
specially created resources – was a big hit last mixture of digital making workshops, project-
year. There are now 75,000 children in the UK based learning and hacking. The Pi Foundation
regularly attending 5,000 code clubs. are keen to stress that you don’t need to have
Another of the had any previous
initiatives the Pi
Foundation have set
PICADEMY GIVES TEACHERS experience to
attend the
up recently to help
educators get to
THE SKILLS AND KNOWLEDGE Picademy, just a
love of computing
grips with the Pi is TO USE A PI, WHATEVER THEIR and an enthusiasm
the Picademy, a free for teaching it to
CPD (Continuing COMPUTING EXPERIENCE kids. So, if you
Professional work in education
Development) and think you’d
programme that aims to give teachers the skills benefit from the course, then head to https://
and knowledge they need to use a Raspberry Pi www.raspberrypi.org/picademy/picademyuk/
in their place of work, no matter what level of apply and fill in the application form.
computing experience they have. The only bad news is that the courses tend to
2016 was a great year for the Picademy, with be over-subscribed, so make sure you spend a
540 people graduating the courses, but the decent amount of time on your application, giving
Raspberry Pi Foundation want 2017 to be even them the chance to see who you really are and
better. They have just released details of the why the course would benefit you.

114 // // Spring 2017


Helping you live better & work smarter

LIFEHACKER UK IS THE EXPERT GUIDE FOR


ANYONE LOOKING TO GET THINGS DONE
Thousands of tips to improve your home & workplace
Get more from your smartphone, tablet & computer
Be more efficient and increase your productivity

www.lifehacker.co.uk
twitter.com/lifehackeruk facebook.com/lifehackeruk
Discover
the world of
Raspberry Pi
The latest Pi projects,
news and reviews

Perfect for owners of all models


of the amazing Raspberry Pi
and the fantastic Pi Zero
116
PAGES OF Pi
GOODNESS
INSIDE!
LEARN HOW TO...
P22 P61 P86
9001

Improve and enhance Build a Pi-powered Code with Scratch,


your Raspberry Pi Wi-Fi walkie-talkie! Python and Minecraft
9000

You might also like