Sie sind auf Seite 1von 100

NEW RASPBERRY PI ZERO W OUT NOW!

The official Raspberry Pi magazine Issue 55 March 2017 raspberrypi.org/magpi

BUILD A DIGITAL MAKE AN


WHOOPEE CUSHION ALEXA ROBOT
Have a laugh with Take voice control
physical computing with Amazons Alexa

RETRO
GAMING
BLISS
Build this handheld gaming masterpiece
with the brand new Raspberry Pi Zero W

BACK UP YOUR ADVANCED


RASPBERRY PI GPIO CONTROL
Kee our le ae Improve your projects

Also inside:
PI ZERO NOW HAS
> THE TINY PI-POWERED SMARTPHONE
> UPGRADE YOUR TV WITH A PI HTPC
WIRELESS!
And its hidden
> 3D MODELLING ON RASPBERRY PI inside this months
Issue 55 Mar 2017 5.99

> KODI 17 REVIEWED AND RATED big-build project 03

THE ONLY MONTHLY MAGAZINE WRITTEN BY AND FOR THE PI COMMUNITY 9 772051 998001
Welcome

WELCOME TO
PAGE 2
8

THE OFFICIAL
MAGAZINE
ts been extremely hard to keep the
I existence of the Pi Zero W secret over
the last few months. When Eben Upton
first revealed that he had something new in the
pipeline, we spent the rest of the day discussing
how much of a game-changer it could be for
hackers and makers around the world.
Now that the wireless connectivity of the
Pi Zero W has been revealed, you can find
SEE PAGE 28 FOR DETAILS
the definitive breakdown including some
background into its making starting on
page 64. And beginning on page 14, this
months big build integrates the new Pi model THIS MONTH:
with Adafruits amazing PiGRRL handheld
console, making it even better than before.
To celebrate even further, weve got a new 14 BUILD THE ULTIMATE HANDHELD
subscription offer that lets you walk away Upgrade the famous PiGRRL console in this months big build
with your own Pi Zero W and brand-new
official Pi Zero case that comes with three
42 MAKE AN ALEXA-POWERED ROBOT
This Alexabot responds to your emotions
interchangeable covers. Youll also get cables
for the Camera Module, HDMI, and USB ports.
64 THE PI ZERO W IS HERE!
Learn more on page 28. Enjoy the issue! The latest version of the Pi Zero is amazing. Heres why

Rob Zwetsloot 74 KODI 17 REVIEWED


Features Editor The most popular HTPC software in the world gets better

FIND US ONLINE raspberrypi.org/magpi GET IN TOUCH magpi@raspberrypi.org

EDITORIAL DESIGN PUBLISHING


Managing Editor: Russell Barnes Critical Media: criticalmedia.co.uk For advertising & licensing:
russell@raspberrypi.org Head of Design: Dougal Matthews russell@raspberrypi.org +44 (0)7904 766523
Features Editor: Rob Zwetsloot Designers: Lee Allen, Daiva Bumelyte, Publisher: Liz Upton
News Editor: Lucy Hattersley Mike Kay CEO: Eben Upton
Sub Editors: Laura Clay, Phil King, Lorna Lynch Illustrator: Sam Alder

DISTRIBUTION SUBSCRIPTIONS CONTRIBUTORS


Seymour Distribution Ltd Select Publisher Services Ltd Sam Aaron, Alex Bate, Jamie Bailey, Germano Cesari,
2 East Poultry Ave PO Box 6337 Rachel Churcher, John Cole, PhilKing, Simon Long,
London Bournemouth Carrie Anne Philbin, Ben Nuttall, Matt Richardson,
EC1A 9PT | +44 (0)207 429 4000 BH1 9EH | +44 (0)1202 586 848 and Richard Smedley

This magazine is printed on paper sourced from The MagPi magazine is published by Raspberry Pi (Trading) Ltd., 30 Station Road, Cambridge, CB1 2JH. The publisher,
sustainable forests and the printer operates an editor, and contributors accept no responsibility in respect of any omissions or errors relating to goods, products or services
environmental management system which has referred to or advertised in the magazine. Except where otherwise noted, content in this magazine is licensed under a
been assessed as conforming to ISO 14001. Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0). ISSN: 2051-9982.

raspberrypi.org/magpi March
April 2016
2017 3
Contents
Issue 55 March 2017 raspberrypi.org/magpi

TUTORIALS COVER FEATURE


> PI 101 BUILD A HTPC 38
Make the ultimate Kodi media centre

> PI 101 BACK UP YOUR PI 40


Keep your important files safe

> VOICE-CONTROLLED ROBOT 42


Build an Alexa-powered Pi robot

> INTRO TO C 9 USER INPUTS 46


Get user input and implement it in your C code

> MAKE 3D MODELS ON YOUR PI 48


Create a squid in Glise on Raspberry Pi

> SONIC PI SOUND DESIGN


Make new sounds by removing synth elements
52 14
> ADVANCED GPIO ZERO 54
Use Source/Values to make your code more efficient

BUILD A RETRO
HANDHELD
> MAKE A WHOOPI CUSHION 56
Create an electronic farting machine

> REMOTELY MONITOR PROCESSES 60


Create a process dashboard with email alerts

COUNTERFEIT GOOGLE
IN THE NEWS CASES SURVEY
PI CURRICULUM

New school curriculum uses digital making


6 Dont get caught out
by these fake Pi cases
10 Google wants to know
if Pi users want AI tools
13
4 March 2017 raspberrypi.org/magpi
Contents

THE BIG FEATURE

94

FOSDEM

PI ZERO W
You asked for wireless LAN. You got wireless LAN. Heres 64 The open-source development
82
everything you need to know about the improved Pi Zero community come together

YOUR PROJECTS REGULARS


> NEWS 06
> TECHNICAL FAQ 62
> BOOK REVIEWS 80
> FINAL WORD 96

COMMUNITY
> THIS MONTH IN PI 84
What else happened in the world of Pi?

> COMMUNITY SPOTLIGHT 86


30 This month its time for some Pi and Chips

> CODE CLUB INTERNATIONAL 88


How Code Club is helping kids globally

ZEROPHONE
A Raspberry Pi Zero thats also a phone
> EVENTS
Find a community event near you

> LETTERS
90

92
We answer your pressing questions about the mag

PI TELESCOPE 32
View the stars with Pi-aided accuracy
REVIEWS
> KODI 17 74
HEARTBEAT 34 > PI METRE 76
MONITOR > SPEAKER PHAT 77
A fitness project that monitors your heart rate
> CLUSTER HAT 78
raspberrypi.org/magpi March 2017 5
News FEATURE

RASPBERRY PI
CREATES
CURRICULUM New curriculum aims to teach the power of digital making
he Raspberry Pi For the community Individuals who run digital
T Foundation is determined
to put the power of digital
We have a large and diverse
community of people who are
making clubs at schools,
community centres, and
making into the hands of people interested in digital making, Raspberry Jams may draw
all over the world. explains Carrie Anne Philbin, on it for extra guidance.
It has taken an exciting step director of education at the Some teachers may wish to use
in this journey, by defining its Raspberry Pi Foundation. the curriculum as inspiration for
digital making curriculum that Some of those people what to teach their students.
Below Teachers
will help people everywhere learn might use the curriculum to We want to help people to
can use the
curriculum to new skills. help guide and inform their make things so that they can
develop their skills
You can view the new curriculum learning, or perhaps their become the inventors, creators,
and as inspiration
for school lessons online (magpi.cc/2kZD18j). childrens education. and makers of tomorrow, says

HOW TO GET INVOLVED


The Raspberry Pi Foundation is
proud to be part of the maker
movement. It is looking for
feedback from the community
on its new curriculum.
Please add your feedback to
this form: magpi.cc/2kKfQ3e.

6 March 2017 raspberrypi.org/magpi


RASPBERRY PI CURRICULUM News

Carrie Anne. Digital making, Learning for all ACCESS THE CURRICULUM
STEAM, project-based learning The Raspberry Pi Curriculum is
and tinkering are at the core of the open to everybody, regardless of A PDF version of the curriculum is available to
Foundations teaching philosophy. age or experience. We wanted download direct from the Raspberry Pi Foundation:
This principle can be summed up to avoid the age-related and magpi.cc/2kZzvuO.
simply as we learn best by doing, stage-related labels that are
Carrie Anne tells us. often associated with a learners e am specifications in a fun and
progress, reveals Carrie Anne, tangible way.
The curriculum [along with] the preconceptions, The Foundation is continuing
The curriculum has five strands these labels bring. to expand its catalogue of free
Design, Programming, Physical The Raspberry Pi Foundations educational resources. It expects the
Computing, Manufacture, and digital making curriculum is not curriculum to grow and improve,
Community and Sharing. Each of
these encapsulates key concepts
and skills in digital making. Users We want to help people to make things
so that they can become the inventors,
will progress in each strand. You
start with certain skills and
knowledge, says Carrie Anne.
Then, with guidance, practice,
and understanding, you progress
creators, and makers of tomorrow
towards broader and deeper
knowledge and competence. intended to be a replacement for but is requesting input into that
Characters are used to represent computer science-related curricula process. This is vital says Carrie
different levels of ability. around the world. Anne. So please do take a closer
Progression starts with Creator, It hopes that following the look at the program (see Access
and moves onto Builder and learning pathways will support the curriculum) and send your
Developer before becoming Maker. the study of formal curricular and feedback (see How to get involved).

raspberrypi.org/magpi March 2017 7


News HIGH SCHOOL REPLACES COMPUTERS WITH RASPBERRY PI

HIGH SCHOOL
REPLACES
COMPUTERS
WITH RASPBERRY PI
MC2 STEM High School using Raspberry Pi to boost computer science skills
ne school in Cleveland,
O Ohio has chosen to use
Raspberry Pi rather than
buy expensive new computers.
Instead of the Raspberry Pi
being a limitation, the smaller
boards have enabled MC2 STEM
to implement a full computer
science curriculum.
MC2 STEM High School is a
unique school, says Feowyn A
MacKinnon, head of school.
There are 50,000 students in the
A mobile Fab Lab enables MC2
district, and 100% of them qualify STEM students to build projects and
demonstrate them to nearby schools
for free and reduced meals. As a
result, the technology situation
can be quite bleak. Feowyn, we have come to depend I imagine we may be one of the
The computers at MC2 were completely on Raspberry Pi. only high schools doing this,
ten years old and hopelessly out of It turns out the Raspberry Pi says Feowyn.
date. More useful as paperweights is better for teaching STEM than The Raspberry Pi then evolved
than technology, Feowyn tells us. traditional equipment. Our from just a cool, fun, learning
experience to an all-encompassing

The Raspberry Pi is better educational tool that our school


and curriculum truly depend on,

for teaching STEM than he continues.


2 is also the first high school

traditional equipment
in the US to own a mobile Fab Lab.
The mobile Fab Lab comes in
handy when we want to express
Traditionally, schools in America students experience an innovative our ideas to other schools, says
would have a fund-raising drive to and fun project while building MC2 STEM student Brandon
try to secure the money required their Raspberry Pi computers, (magpi.cc/2kLla6s). I like the
for new technology. However, MC2 reveals Feowyn. idea of project-based learning and
had a better idea. MC2 is now teaching a full year being able to build stuff with your
Rather than try to fund-raise long computer science curriculum hands, instead of always doing
for new technology, explains using only Raspberry Pi computers. writing work.

8 March 2017 raspberrypi.org/magpi


News WATCH OUT FOR FAKE CASES

WATCH OUT
FAKE CASES Fake Raspberry Pi cases doing the rounds
nscrupulous dealers are computers, cases, cameras, and
U selling fake Raspberry
Pi cases on third-party
other products goes straight
into our charitable fund to train
websites and eBay. teachers, provide free learning
Kinneir Dufort designed the resources, teach kids, help build the
official Raspberry Pi case. While foundations of digital making in
there are many third-party cases schools, and much more.
available, the fake cases are Let The Raspberry Pi Foundation
intended to mimic the official case. know if you find fake cases in the
The Raspberry Pi Foundation wild. It damages our reputation
managed to get its hands on a when something shonky comes on

It damages our reputation


when something shonky
comes on the market
sample through a proxy pretending the market and it looks like weve
to be a Pi shop. It supplied some made it, explains Liz. It damages
pictures so the community can see the Raspberry Pi Foundations
the differences. pockets too, which means we cant
The fake cases are not as well do the important work in education
made as the real thing, says Liz we were set up to do.
Above This fake case has two sets of light pipes
Upton, director of communications. You can see examples of
Below The shoddy feet on this case are a clear sign of a fake They also deprive us of some fake versus real cases on the
much-needed charitable income. As Raspberry Pi Foundation website
you probably know, the Raspberry (magpi.cc/2kLw3pf). Please let
Pi Foundation is a charity. All them know in the comments if you
the money we make from selling come across any fakes.

10 March 2017 raspberrypi.org/magpi


HELLO WORLD News

HELLO NOW TRENDING

WORLD
The stories we shared that
flew around the world

New free magazine for educators

he Raspberry Pi Foundation that will help educators connect,


T has launched a new
magazine called Hello World
share great practice, and learn
from each other.
(magpi.cc/2j4HuJ9). Hello World is available free,
Hello World is a magazine about forever, for everyone online as a
computing and digital making. downloadable PDF. The content
Its written by educators, for is written to be internationally SHARE YOUR POWER WITH BOINC
educators, says the Foundation. relevant, and includes features on
magpi.cc/2l2sQzI
Hello World is designed to be the most exciting developments
cross-curricular and useful to all and best practices from around Got a Raspberry Pi that idles away most of its day?
kinds of educators, from classroom the world. Lend some of its CPU power to science.
teachers to librarians. While it A print version of the magazine
includes lots of great examples of is free to the homes of serving
how teachers are using Raspberry educators in the UK. The list of
Pi computers in education, it is eligible subscribers is wider than
device- and platform-neutral. you think and includes teachers,
As with everything we do at teaching assistants, librarians, and
the Raspberry Pi Foundation, youth workers. Alternatively, you
Hello World is about community can subscribe for 15 per year.
building, says Raspberry Pi Visit the Hello World website to
Foundation CEO, Philip Colligan. sign up for your free subscription
Our goal is to provide a resource (magpi.cc/2l0KN1R).
PROGRAMMING A RASPBERRY PI
magpi.cc/2jyzU4V

Discover the joy and art of computer


programming with your Raspberry Pi.

Hello World is a
WIRE AND LOOP GAME
new magazine from
the Raspberry Pi magpi.cc/2hNaep3
Foundation thats
free to all educators This Wire and Loop game is a great project for learning
basic circuits, electronics, and Python coding.

raspberrypi.org/magpi March 2017


February 11
News ROBOTS

ROBOTS AT THE
SCIENCE MUSEUM
Above Baxter
is the worlds New exhibition brings 100 robots under one roof
r o arme
robot designed
ver 100 robots are who built, commissioned or Some of the robots are incredibly
O
to work together
i h eo le on display at a new gazed upon these mesmerising lifelike. Zeno R25 has incredible
exhibition at the Science mechanical creations over the past expression, while Nao will dance,
Museum, London. 500 years reveals so much about blow kisses, and exercise.
The exhibition is called Robots humanitys hopes, fears, dreams, iving head-first into the
and is set to last all summer. and delusions. uncanny valley is Animatronic
It explores humanitys 500-year Pepper is a humanoid companion baby. The baby breathes, sneezes,
quest to reimagine ourselves as created to communicate with and moves its arms and legs. Its
machines, explains the museum. humans through voice and touch designed to make you feel strong
Robots is open daily until and movement. This robot invites emotions towards a robot.
3 September 2017. Tickets are on visitors to touch its hands and fist- Ben Russell, the lead curator
Below
RoboThespian was sale now (magpi.cc/2kLvyeO). bump while sharing a story using of Robots, says: Coming face to
he r ull i e
Ian Blatchford, director of the the screen on its chest. face with a mechanical human
humanoid robot to
be commercially Science Museum Group, says: Baxter, REEM Service Robot, and has always been a disconcerting
produced
This stunning exhibition explores Amico are industrial robots with experience. That sense of unease,
Below right Robs the fascinating question of why, amazing precision, while robots like of something you cannot quite put
Open Source
rather than how, we build robots. ROSA, Inhka, and RoboThespien are your finger on, goes to the heart of
Android was built to
move like a human To look through the eyes of those used to interact with humans. our long relationship with robots.

All images courtesy of the Science Museum

12 March 2017 raspberrypi.org/magpi


GOOGLE TOOLS News

GOOGLE
TOOLS
Tech giant asks makers for advice on AI tools
oogle is going to arrive in style in 2017. The tech
G titan has exciting plans for the maker community.
It intends to make a range of smart tools available
this year. Googles range of AI and machine learning
technology could enable makers to build powerful projects.
To make this happen, Google needs help from the
maker community. Raspberry Pi fans are the best
makers around, and its their ideas that will give the tech
company direction.
Heres what Google has to say: Hi, makers! Thank you
for taking the time to take our survey. We at Google are
interested in creating smart tools for makers and want
to hear from you about what would be most helpful. As a
thank-you, we will share our findings with the community
so that you can learn more about makers around
the world.
The company can produce some serious tools for the
maker community, so make sure you have your say to get
the tools you need.
Let Google know what you would like by filling out the
survey: magpi.cc/2l152MR.

raspberrypi.org/magpi March 2017 13


Feature THE BIG BUILD

RETRO
GAMING
BLISS
Build upon Adafruit's amazing Pi GRRL 2 using the brand new
Pi Zero W to create the ultimate retro handheld console

ortable gaming has been hugely the Raspberry Pi is powerful enough


P popular ever since the Nintendo
Game Boy was released in the
to emulate several popular retro home
consoles, while also being small enough
late eighties. Building on the work of the to carry around.
Game & Watch LCD games, the Game This is why the PiGRRL projects
Boy allowed you to take one machine from Adafruit are popular: handheld,
wherever you went. It played a multitude old-school consoles you can use on the
o a e a hand artr d e lled w th go. There are many versions of them,
code, including video game classics such based on everything from original models
as Tetris, The Legend of Zelda: Links of the Raspberry Pi to the Pi Zero.
Awakening, and Pokmon. With the release of the Pi Zero W, these
Since then, handheld gaming and projects can go even further thanks to the
computers have evolved. Mobile phones built-in wireless LAN, and it also leaves
have become a great source for providing more space for a bigger battery. And a
quick hits, while Nintendo is going all bigger battery means longer play time. In
out with its hybrid Switch system. On this guide, were going to show you how
the computing side, processing power to take the PiGRRL 2 and do just this. Grab
has advanced to such a degree that your work dungarees and lets-a go!

14 March 2017 raspberrypi.org/magpi


BUILD A HANDHELD GAMES CONSOLE Feature

raspberrypi.org/magpi March 2017 15


Feature
News THE BIG BUILD

ASSEMBLE
YOUR PARTS Heres what youll need to make the Pi GRRL Zero W

Pi Zero W
> magpi.cc/2l6zurq <
The key to this project is the Pi Zero W. The wireless-
enabled version of the Pi Zero is as powerful as the
Pi Zero, yet saves a load of space thanks to the radio
chip included in it, so no WiFi dongle is needed. It
runs at 1GHz, which makes it powerful enough to run
emulators of many eighties and nineties consoles.

Adafruit
TOOLS 3D-printed PiTFT 2.8
FOR THE JOB
case > magpi.cc/2lob5Ky <
Soldering iron This is actually a touchscreen, although
> magpi.cc/2kS9K1f <
Wire we wont be making use of it in that way.
Heat shrink The PiGRRL 2 case repurposed for our needs. t fits neatly in the case and provides
Glue It has some spaces for USB and Ethernet on four extra buttons to use when playing
Blu-Tack a B+/2/3 board, but the Pi Zero will require games. You can also assign system and UI
Wire strippers extensions if you want to make use of the gaps. shortcuts to the buttons.
Hobby knife

16 March 2017 raspberrypi.org/magpi


BUILD A HANDHELD GAMES CONSOLE News
Feature

PiGRRL 2
controller
board
> magpi.cc/2lohZzr <

This Custom Gamepad PCB is


designed to fit the case perfectly.
We did try to see if a standard USB
SNES or NES PCB would fit inside,
but they were far too big.

PowerBoost
1000C Slide switch
> magpi.cc/2lo5aFg < > magpi.cc/2lojfTb <
This is one of the cool bits: were going This switch allows you to turn the power
to use this PowerBoost to actually on and off. Its best to do the software
charge a battery within the handheld. shutdown of RetroPie first before
With the low power draw of the Pi and switching the power off, though.
advancements in modern battery tech,
youll get a lot out of one charge.

Microswitches
GPIO hammer > magpi.cc/2lo890i <

headers
The beauty of proper retro gaming is tactile
controls. Youll need ten 6mm switches,
and a couple of 12mm buttons.
> magpi.cc/2lohN2U <
A wonderful innovation from Pimoroni,
these GPIO headers require zero
soldering and can be (carefully) 2500mAH
battery
hammered onto the empty
pins of a Pi Zero.

> magpi.cc/2lQzVmr <


We squeezed the biggest battery into
here that we possibly could. This way,
it should last for hours and hours.

SCREWS
A selection of
Bluetooth audio (optional) screws to attach
the parts to the
Theres no dedicated Audio Out on the Pi Zero W, but it does case. This includes
have Bluetooth. RetroPie doesnt support Bluetooth audio yet, 14 #4-40 and
but there are workarounds: see magpi.cc/2oMboUz 6 #2-56 3/8
machine screws.

raspberrypi.org/magpi March 2017 17


Feature
News THE BIG BUILD

PRINT THE CASE


What you need to know about 3D-printing the Pi GRRL 2 case

he proliferation and advancement of 3D e en n e wh le al o allow n or a ull


T printing has been a huge boon for the
maker community, enabling you to create
o erat onal handheld
For this project, were going to make use of the
wonder ul ha and a e or our nal rodu t slightly larger PiGRRL 2 case for maximum comfort,
The PiGRRL series has a number of cases built and also so we can use the extra space to install a
around the Raspberry Pi that allow for maximum er atter nto t ere how to a e our own

HOW TO PRINT
YOUR 3D CASE
pigrrl2-top.stl
>STEP-01
pigrrl2-bot.stl
GET THE FILES pitft-buttons.stl
he ull a e le an e dpad2.stl
downloaded from magpi.cc/2kS9K1f, action-btns.stl
althou h there are ore le here than pause-start.stl
what ou a tuall need to r nt he one shoulder-btns.stl GET THE FILES AT
youll need from the pack are: shoulder-mount.stl
magpi.cc/2kS9K1f

>STEP-02
FIND A 3D
PRINTER
t an e tr to nd a ood r nt n er e
online, so unless you have access to a 3D printer, we
highly recommend using 3DHubs.com t l t lo al
printing services, along with an estimated completion
t e and re ew he le we downloaded al o wor
USE 3DHUBS.COM
w th the er e to print your case!

>STEP-03
UPLOAD FILES
Once youve selected your printer, youll be asked to upload
the le ou le he ou e ele ted the orre t one and
a e ure the u load ro erl ou ll et an error the a l
uall tr n a a n w ll wor ou al o onl need one o ea h
and or are reat ater al to u e or the art

18 March 2017 raspberrypi.org/magpi


BUILD A HANDHELD GAMES CONSOLE News
Feature

PREPARING YOUR PI
Get your Pi Zero W ready to be made into a retro gaming treasure

The configuration screen starts by asking


about your current controller setup
or this project, were going to be using the
F excellent RetroPie to power our emulation
o tware ou ll r t need to download
the image for RetroPie from its website here:
magpi.cc/25UDXzh r te t to an ard and o t
nto our ero et that hoo ed u to a on tor
alon w th a e oard and we an et t read
ou ll r t need to a o e utton a the
controller isnt hooked up yet, well have to quickly
u e the e oard or the n t al etu a e ure the
directional keys, Start, Select, A, and B are assigned a
key and just hold down the space bar to skip anything
el e n e that done onne t to the w rele u n
LEFT SHOULDER RIGHT SHOULDER
the n o n the ett n u w rele o out
o et our nal u ld wor n we need to a e
D-PAD UP
sure to install support for the PiTFT, as its not
D-PAD LEFT
X u orted nat el nto the ero at
Y A retropie.local or press F4 to enter the command
D-PAD DOWN
B line on RetroPie, and enter the following:
D-PAD RIGHT

SELECT START $ cd
$ curl -O https://raw.githubusercontent.
When you come back to reconfigure your buttons, refer to this handy guide
com/adafruit/Raspberry-Pi-Installer-
Scripts/master/pitft-fbcp.sh
$ sudo bash pitft-fbcp.sh
SETTING UP WIRELESS
rele onne t t on the new ero reat ut the
on urat on ethod or w rele on the etro e er ele t and don t re oot ow we need
a ou ll need to now the na e o our w rele networ to add u ort or the u to utton a n the
(SSID) along with the password, as it wont be able to search for command line, use:
a a la le networ ou an al o ort deta l load n a t t
le onto the oot art t on
$ cd
$ curl -O https://raw.githubusercontent.
com/adafruit/Raspberry-Pi-Installer-
Scripts/master/retrogame.sh
$ sudo bash retrogame.sh

ele t a a n and then re oot the te


Once weve put all the parts together, and before
t a e led n the a e we ll need to on ure
the controls for the buttons weve made and added
to the ro e t re the utton a ned to tart
and ele t on ure n ut and then o throu h the
on urat on ro e a a n

raspberrypi.org/magpi March 2017 19


Feature
News THE BIG BUILD

BUILD THE SYSTEM


Follow along and build your retro handheld

>STEP-01
PREPARE THE
GAMEPAD BOARD
ur r t o to older the header n onto the
a e ad oard ou an ee t all n la e w th a
l ttle lu a e ore older n t on a e ure ou re
older n the header onto the orre t de o the oard

>STEP-02
ADD THE
BUTTONS
Now its time to carefully solder
the ten 6mm microswitches
to the front of the board.
Some helping hands would
be good here.

>STEP-03
TURN ON
THE BACKLIGHT
de ault the doe n t ha e t a l ht
turned on ou need to ta e a ra t n e and ut the
r u t etween the lo n the o that ou
an ee r led n the ture

20 March 2017 raspberrypi.org/magpi


BUILD A HANDHELD GAMES CONSOLE News
Feature

>STEP-04
RESIZE
THE
RIBBON
CABLE
t a ood dea to horten
the r on a le
a arentl the er e t e ut
ou an o a l ttle lon er n e
ou e ea ured t ut the a le

>STEP-05
ASSEMBLE
THE CABLE
Using something like a pen or pin, youll need to push
in the clip that holds the connector in place on the
part youre discarding. Very carefully remove the cable
and install it at the end of your newly trimmed cable.

>STEP-06
PREPARE
FOR POWER
o a e all our older n ea er we ll da o e
older onto the ot where we need t or the
o ent n the ower oo t add o e
older to the o t e and ne at e n and the
and n ut one o the le o the ower
w t h and ut o e older on the other two

raspberrypi.org/magpi March 2017 21


Feature
News THE BIG BUILD

>STEP-07
SOLDER ON THE SWITCH
a e ure the ower w t h w ll t n the hole or t n the a e t on
the de o the otto art ou a need to le awa the la t a t
n e that done tr two hort t o w re to a out lon and older
one to ea h le older tho e to and t doe n t atter wh h wa
around the o

>STEP-08
SHOULDER
BUTTONS
The shoulder buttons (the 12mm ones) need to
be attached to the controller board much like the
switch was connected to the power board. Clip two
legs off each and use a pair of pliers to atten the
remaining two. Solder wires to each pin (about 14cm
long) and then solder the other end to the bumper
pins on the controller board. Again, polarity doesnt
matter, but keep each one as a pair in the row.

>STEP-09
WIRE IT
ALL UP
ow we an o ne the ower
w th the ontroller oard wh h
w ll allow u to ro de ower
to the whole te older two
w re a out lon to the
under de o the and n
on the ontroller oard he
w re hould then e oldered to the
o t e o the ower oo t oard
w th the to the ne at e

22 March 2017 raspberrypi.org/magpi


BUILD A HANDHELD GAMES CONSOLE News
Feature

>STEP-10
HAMMER
THE HEADS
Its now a good idea to add the GPIO
headers to the Pi Zero W. Gently
hammer them in until theyre secure,
and youre done. >STEP-11

TEST IT ALL OUT! BEGIN CONSTRUCTION!


ow the ea t a e the to o the a e and n ert all the utton
At this point you can test the r nt n e that done n ert the reen and rew t n ollowed
entire system, otherwise well the ontroller oard n h u the to t onne t n the two w th the
move onto final construction r on a le and then n ert the ero nto the header on the

>STEP-12
BACK PLATE
ou ll now need to ount the a utton and
the ower oo t he rear utton ha e a late
that ee the n la e and da ru t u e t
u n a l ttle lu a to t the w t he n
o t on ou ll atta h the ower w t h and then
nall rew on the ower oo t e are ul w th
the w re that ou e oldered on

>STEP-13 WANT
TO KNOW
CLOSE IT UP MORE?
ow ou an nall lo e t u n ert Prefer to use a
the atter and ta e t down need full-sized Pi? Check
e e ore rew n t hut a e ure out the original
all the a le are a el n de the a e PiGRRL 2 guide
e ore t hten n t thou h magpi.cc/2l0ALzQ

raspberrypi.org/magpi March 2017 23


Feature THE BIG BUILD

USING A
WIRELESS
PIGRRL
Heres some of the amazing advantages
of having the PiGRRL powered by Pi Zero W

CONNECT
VIA SSH
Physically connecting to the Pi Zero inside is a massive hassle once the
case is screwed together. With the Pi Zero W connected to your home
UPDATING
network, though, its easy to connect to it remotely from another
computer using SSH.
RETROPIE
On a Mac or Linux machine (which includes another Raspberry Pi!), You can update RetroPie from the handheld itself
you can simply open the terminal or command line and enter the or via SSH in the command line. The keyboard
following to connect: might be better suited for this, so if youre by your
computer it wouldnt hurt to use it instead.
From the handheld, you need to go to the
ssh pi@retropie RetroPie menu in EmulationStation and activate
the setup script. From the terminal (if youve
SSHed in), you can use the following command:
It will prompt you for a password, which is raspberry. The
user name in this instance is pi, with retropie being the default
name for the system on the network. sudo ~/RetroPie-Setup/retropie_setup.sh
For Windows machines, youll have to connect using an SSH
application like PuTTY
(magpi.cc/2lBHCRm). Once From here, look for the Update All Installed
its installed, you need to set Packages option. There are many options here
the host name to retropie, that you can select from, including managing the
the port to 22, and then click individual packages in case you want to remove
Open. Youll need to put or add any. To update, you can select the option
in pi as the user name and Update all installed packages (which will also
raspberry as the password. update the RetroPie-Setup script as well) or
Once inside, you can control you can go to Manage packages and update the
many aspects of the system packages individually. This could be useful if any
via the command line. If packages have some problems updating, or if you
youve used the terminal in want to do the essential updates before running
You can ignore a lot of the PuTTY interface Raspbian, youll know how it out the house.
when just connecting to the handheld works: sudo reboot, ls, cd, etc.

24 March 2017 raspberrypi.org/magpi


BUILD AN AWESOME RETRO HANDHELD Feature

UPLOADING
FILES
If you want to upload ROMs to the handheld, PLAYING
ONLINE
you can do so with the Pi Zero Ws wireless
connection. Otherwise, youd have to manually
load them onto the SD card, which would
require dismantling the console to get to the Otherwise known as netplay in emulation circles, this allows you to play
Pi Zero not particularly easy or practical multiplayer games with friends, even if theyre on the other side of the
to do. Luckily, RetroPie includes Samba and world! Lets see the SNES do that! Not every emulator supports it and
SFTP, which allow you to transfer the files over if it does, you need to follow three extra rules: both parties need to be
the network. running the same version of RetroArch, both must be running the same
For Samba its nice and easy: when your emulator, and both need to be running the same ROM.
handheld is connected to your network, you You then need to configure netplay from the setup script. If youre
can go to your main computer and find it on hosting, change your Netplay Mode to host, make the host IP your IP
the network shares as \\RETROPIE. Here you address, and pick a nickname. The client (other player) needs to go to
can upload any necessary extra files to the the same menu, change Netplay Mode to client, change the host IP to
handheld with minimal hassle. the other handheld, and pick your nickname. You may need to open up
For SFTP youll have to make use of a specific TCP/UDP port on the hosts router, which you then need to
specialsoftware. For Windows, the set as the same on both systems.
RetroPieteam recommend WinSCP Now both of you need to open the same ROM using the js0 key
(magpi.cc/2lCwRhz); for Mac, you can try (which should be X on a SNES layout) and select Launch with netplay
Cyberduck (magpi.cc/2lCwjs9). enabled. If its been set up correctly, youll connect!
Once booted up, you can use the same SSH
settings as we used for PuTTY. You can then
drop the files into the corresponding folder in
the roms directory.

CAUTION!
PIRATING VIDEOGAMES IS BAD,
NOT TO MENTION ILLEGAL!
Dont use illegally downloaded
content on your PiGRRL.

raspberrypi.org/magpi March 2017 25


Feature
News THE BIG BUILD

MEET THE
RUIZ BROTHERS
We talk to the original creators behind the Pi GRRL and many other amazing Adafruit projects

PIGRRL HISTORY T
wo of the superstars of the maker scene are No Ruiz
and Pedro Ruiz, otherwise known as the Ruiz Brothers.
How the PiGRRL project has evolved Theyve done many amazing projects for Adafruit,
including a lot of 3D printing and wearables, which always go
down well with the community. So its surprising to hear theyve
onl een n the a er ene or a out e ear
rother and ur ha ed our r t r nter n and
quickly started using it in our work, No tells us. While looking
for a way to integrate lighting into our 3D-printed designs, we
discovered Adafruit and the Arduino platform. We built some
projects using their parts and came up with some unique ideas.
We went on Adafruits weekly live show-and-tell show, and the
rest is history.
hat tarted o a a load o ool ha that added to
existing products or enabled you to create great light-up projects
quickly evolved into doing more. Part of this was to do with the
introduction of the Raspberry Pi.
PIGRRL ur r t ro e t w th the a err wa the eara le
The original PiGRRL celebrated the 25th anniversary with Near-Eye Video Glasses, explains No. We were interested
of the Game Boy and used the original Raspberry Pi
Model B to power it. Its a lot bigger than the version
were building, although it more accurately matches
the size of the original Game Boy.

PIGRRL 2 PIGRRL ZERO


This should look familiar this is the version weve The latest version of the PiGRRL is a tiny device,
based ours on! Its an upgrade over the PiGRRL as reminiscent of the GBA or the Game Boy Micro. It
it uses a lot more custom components, including a uses a Pi Zero and a series of other small components,
custom PCB for the controls instead of a repurposed all squeezed into a tiny little 3D-printed case.
SNES board. You could easily switch a Pi 3 in there if The Pi Zero is still powerful enough to run a lot of
you wanted a bit more power. emulators, though.

26 March 2017 raspberrypi.org/magpi


BUILD AN AWESOME RETRO HANDHELD News
Feature

MORE FROM THE


RUIZ BROTHERS
Other amazing things you can find
by No and Pedro

RASPBERRY PI
POKMON FINDER
> magpi.cc/2lKXpcA <
Based on the Lure Modules found in Pokmon GO, this
project caused a little bit a stir at the time, as it used
some APIs that people possibly shouldnt have had
access to. It would tell you if there were any Pokmon
in your immediate area, and even display a coloured
light for how rare the Pokmon was.
in Google Glass and thought wed make a DIY version with the
Raspberry Pi. We hacked apart a pair of video glasses, and designed
a custom 3D-printed housing for the display and driver. It was a fun
experiment and this is how we learned about the Raspberry Pi.
Things escalated even further when the brothers made the
original PiGRRL. Originally an idea from Limor Fried, founder of
Adafruit and Ladyada herself, the idea was to improve upon her
earlier Game Grrl project but this time use a custom 3D-printed
enclosure. It was their biggest project to date, so they were
extremely happy to see that it had such a positive reaction.
The PiGRRL projects have since become the Brothers favourites
to work on, according to No. NEOPIXEL YOYO
I think its become a classic Raspberry Pi project because it > magpi.cc/2lKRd4c <
loo l e an on de e that o er lot o la t e eo le lo e A simple playground toy turned awesome with the use of
to play games, and being able to build your own gaming console is some NeoPixel LEDs. The yoyo itself is also 3D-printed,
super-rewarding. Every year we create a new version with better allow n or u to art o that ou an t the
hardware and han e the or a tor to tr d erent de n o electronics inside. It even has a USB charging port. Check
many folks have built one and its really awesome to see parents out the link for some cool GIFs of the yoyo in action.
building them with their kids.
Whats in the future for the PiGRRL and the Ruiz Brothers? Well,
PiGRRL 3 is happening this year with a bigger screen and better
audio, and should be a much quicker build. Watch this space!

HALO ENERGY SWORD


> magpi.cc/2lKKSWC <
This one isnt a completely custom build instead, its
an u rade u to at on o a re e t n l en ed
Halo Energy Sword toy by Mattel. The Ruiz Brothers
took the already pretty cool design and added a ton of
NeoPixels to make it pulse with energy, similar to how
the sword looks in the Halo games.

raspberrypi.org/magpi March 2017 27


SUBSCRIBE
Tutorial WALKTHROUGH TODAY AND RECEIVE A

FREE
PI ZERO W
Subscribe in print for 12
months today and receive:
A free Pi Zero W (the latest model)
Free Pi Zero W case with 3 covers
Free Camera Module connector
Free USB and HDMI converter cables

AND FREE CAMERA MODULE Other benefits:


L CONNECTOR AND USB / HDMI
OFFRIOCCIA
ASE CONVERTER CABLES
Save up to 25% on the price
PI ZE
COVERS
WITH 3 Free delivery to your door
lu e o er and d ount
et e er ue r t e ore tore

28 March 2017 raspberrypi.org/magpi


SUBSCRIPTION FORM
Pricing YES! Id like to subscribe to The MagPi magazine and save money

This subscription is: n For me n A gift for someone*


Tutorial
Mag#55

Get six issues: YOUR DETAILS Mr n Mrs n Miss n Ms n


First name ........................................... Surname .......................................................

30 (UK) Address .......................................................................................................................

....................................................................................................................................

45 (EU) Postcode .............................................. Email ............................................................

Daytime phone .................................... Mobile ...........................................................

$69 (USA) *If giving The MagPi as a gift, please complete both your own details (above) and the recipients (below).

GIFT RECIPIENTS DETAILS ONLY Mr n Mrs n Miss n Ms n


50 (Rest of World) First name ........................................... Surname .......................................................

Address .......................................................................................................................

Postcode .................................................... Email ..................................................................

Subscribe for a year: PAYMENT OPTIONS

1 DIRECT DEBIT PAYMENT 12.99 every 3 issues (UK only)


Instruction to your bank or building society to pay by Direct Debit

55 (UK) lea e ll n the or and end to


The MagPi, Select Publisher Services Ltd,
PO Box 6337, Bournemouth BH1 9EH
Service user number 8 3 8 7 7 3

80 (EU) Name and full postal address of your bank or building society:

To: The Manager Bank/building society ......................................................................

$129 (USA)
Address ..........................................................................................................................

........................................................................................................................................

..................................................................................... Postcode ...................................

90 (Rest of World) Name(s) of account holder(s) ...........................................................................................

n n n n n n Account number n n n n n n n n
Branch sort code

Reference n n n n n n n n n n n n n n n n n al u e onl

Instruction to your bank or building society

Get three issues: Please pay Select Publisher Services Ltd Direct Debits from the account detailed in this instruction
subject to the safeguards assured by the Direct Debit Guarantee. I understand that this instruction
may remain with Select Publisher Services Ltd and, if so, details will be passed electronically to my
bank/building society.

12.99 (UK) (Direct Debit) Signature .................................................................... Date n n / n n/ n n


Banks and building societies may not accept Direct Debit instructions for some types of account.

$37.50 (US) (quarterly) SUBSCRIPTION PRICING WHEN PAYING BY CHEQUE OR CREDIT/DEBIT CARD

6 ISSUES n UK 30 n Europe 45 n Rest of World 50


12 ISSUES n UK 55 n Europe 80 n Rest of World 90
How to subscribe: 2 CHEQUE
I enclose a cheque for .............................. (made payable to Select Publisher Services Ltd)

3 CREDIT/DEBIT CARD n Visa n MasterCard n Maestro n Switch


magpi.cc/Subs-2 (UK / ROW)
Card number nnnnnnnnnnnnnnnn
Expiry date nn nn Valid from n n n n (if shown)
imsnews.com/magpi (USA) Issue number n n (if shown) Security number n n n
(last 3 digits on the back of the card)

Call +44(0)1202 586848 (UK/ROW) Signature .................................................................... Date n n / n n/ n n

Call 800 428 3003 (USA)


I would like my subscription to begin from issue ........................................... (month + year)

RETURN THIS FORM TO:


MagPi Magazine Subscriptions, Select Publisher Services Ltd, PO Box 6337,
Bournemouth BH1 9EH
Please tick this box if you DO NOT want to receive any other information
from Select Publisher Services Ltd.
Please tick this box if you DO NOT want to receive any other information
from other companies.
Please tick this box if you DO NOT want to subscribe to The MagPi newsletter.

raspberrypi.org/magpi March 2017 29


Projects SHOWCASE
ARSENIJS PIUGINS
Arsenijs is an 18-year-old student from
Riga, La ia e a rogrammer an
hardware repair person who works
clo el i h Linu
crimier.wordpress.com

ZEROPHONE Turning a Pi Zero


Quick into a mobile phone
Facts eroPhone is an open-

> The display Z source project to create


a mobile phone kit for
resolution is
12864 the Pi Zero.
> Currently, it Owners of ZeroPhone will be
costs around able to make calls and send text
$50 in parts messages. It will also have basic
> It connects to apps such as an alarm clock,
a 2G network
calendar, calculator, web browser,
(a 3G model
is planned) and music player.
Behind the project is Arsenijs
> The OS is
based on Picugins, an 18-year-old student
Ra ianLinu from Riga, Latvia. He now has a
> There are plans team of people helping him.
to crowdfund Its open-source, Linux-
the project
powered, and you can make one
as a kit
yourself for $50, he says.
Arsenijs has been studying
mobile phones for a couple
A SIM800 GPS module
and antenna are used to of years. He hopes to sell a
connect to the mobile commercial kit, while keeping
phone network
it all open-source for people to
build themselves.
A small LCD screen The phone hardware is at
displays the operating
system (based on
alpha stage, he tells us.
Raspbian Linux) Arsenijs has designed the
first revision of P s printed
circuit boards) and is developing
Buttons are connected the software.
to the PCB, and an
ATMega328P module The next revision will be
is used to convert ready-to-assemble, reveals
button pushes into
phonecommands Arsenijs. Raspbian is being
customised to run on the
ZeroPhone. It can be tailored
to suit our purpose very easily,
explains Arsenijs.
Ive currently got a framework
Im using for headless Pi
configuration, he continues.
Python is being used to create
a user interface . An

30 March 2017 raspberrypi.org/magpi


ZEROPHONE Projects

DESIGNING A PI
ZERO PHONE KIT

Above The components and software are under development,


and a kit will be made available when its ready

earlier project called pyL Thats what Im focused on, and


>STEP-01
magpi.cc/2kjv2oA) forms the that means extensively testing
SIM module
A SIM800 module is used to connect to the GSM
base of the interface. the hardware ve got now, to find
ne or en ion comman , rom he a e
Developed by Arsenijs in everything that has to be fi ed.
command set (magpi.cc/2jvCYyO), are used to control
2 16, pyL is a Linu control nce v1. is ready, he will
he mo em connec ion o he mo ile ne or
interface. It enables you to publish the design files and
control and configure your Pi with instructions, so people will be
SSH, networking, or using an able to start assembling their
HDMI monitor. phones if they wish. Hell then
I developed it because thats prepare a crowdfunding campaign
what I needed to improve to fund a manufacturing run and
my Raspberry Pi tinkering software development.
and development work ow, Its the only phone you can
recalls Arsenijs. assemble by getting all the parts
eveloping a good is one of yourself, claims Arsenijs. It
the primary goals of this project, doesnt use any rare parts or fine-
Arsenijs adds. pitch soldering. You can even

>STEP-02
I developed it because thats LCD and battery
what I needed to improve my mall LC creen i u e
in er ace a er i h
o i la he u er
cell i u e o o er
Raspberry Pi tinkering he Pi ero, i la , an S mo ule

Because Linux is the base, it can breadboard this phone if youre


support a range of programming dedicated enough.
languages. Arsenijs expects For me, this project is a
original ideas for apps. He will huge undertaking that, if done
be working on productivity and right, will in uence the way we
healthcare apps. perceive mobile phones, remarks
The open-source software Arsenijs. He explains that it will
approach is likely to be secure help solve privacy and security
and not privacy-invading, says concerns, as well as allow us to
Arsenijs. You can disable features develop better open-source GSM
you dont like, and it doesnt technology. It will also help power
depend on any cloud services. You mobile phone hacks. >STEP-03
will be able to install firewall, 2P, Besides, this is an open-source Controls
and TOR nodes, as well as secure Linux-powered phone you can Two-layer PCBs (two 410cm and one 46cm) are
messenger services. independently assemble for less u e Regular u on are lace on he PC o orm a
Arsenijss current goal is to than $50, observes Arsenijs. an ar e a all hoo e u o an ega P
make the v1. P revision. Thats pretty cool. ha u e o rea he u on u he

raspberrypi.org/magpi March 2017 31


Projects SHOWCASE
MIKE HAMENDE
Mike Hamende hails from Manteno,
Illinois. With a passion for making,
his projects continuously gain him
online recognition.
imgur.com/a/iOkCI

TRACKING
TELESCOPE
MOUNT
For Mike Hamende, making something is far more exciting and rewarding than
logging into an online store, as his Pi-powered tracking telescope mount proves

I
f you search for Mike

Quick Hamendes user name Mike 3D-printed several

Facts
8PumpkinDonuts online, parts of the mount
when he was unable to
youll soon realise that hes quite find the correct pieces
the craftsman. From a suspended
> Mike has lounger for his fianc e, to a
no previous
experience of wristwatch built completely from
coding Python scratch, Mike is a true maker. So
> The tracking its really no surprise that hed
mount is set to eventually build a Raspberry Pi
n re e project that we could sink our teeth
locations
into. Despite his lack of previous
> The mount runs
Python knowledge, and ignoring
on a battery,
making it the fact he could easily purchase
portable what hed decided to build, Mike
> It cost produced a tracking telescope
mount for his 8 rion re ector.
o uil
This is definitely the most
> See a video involved project Ive ever
of the mount
completed, Mike tells us. Im
working here:
magpi.cc/ aware there are mounts I could
2lGLgWf have bought to accomplish the
same thing, but, while astronomy
is a hobby of mine, building things
is what Im really into.
Mike used two Nema 17 stepper
motors, powered by a Raspberry
Pi 3, to angle the mount. For
the frame, he used T-slot The Raspberry The mount runs on a
aluminium, utilising his CNC Pi sits beneath a 12V/12AH SLA battery
touchscreen, housed hooked to the back of
mill, CNC router, and CNC lathe in a 3D-printed case the frame
to cut further pieces of aluminium
for the mount.

32 March 2017 raspberrypi.org/magpi


TRACKING TELESCOPE MOUNT Projects

SCOPING THE
SOLAR SYSTEM

>STEP-01
Creating the parts
Mike used his own tools to design and cut the
a ro ria e ar or he moun ou o aluminium
The red tint to the screen
helps to better protect hi allo e or grea er con rol o he nal loo
Mikes night vision when
realigning to new objects

Two turntables with 60mm to control the stepper motors and


thrust ball bearings act as the basis linear acceleration, so he was still
for the motion mechanics, cut faced with the challenge of quickly
from 1 2 thick aluminium. ike learning enough Python to see
then had to build his own drive him through.
pulleys using -printed parts and nce hed cleared up his
fibreglass anges. e amended prototype breadboard and
technical documents hed found soldered the boards into
online, removing teeth, until the place, ike fitted the Pi with a
pulley fitted perfectly within the
build. From here, he also went on
touchscreen. The screen enables
him to select one of 800 preset
>STEP-02
3D-printing pulleys
to print, rout, and fit all the pieces targets for the telescope to focus
i e re e igne re e i ing echnical ocumen o
needed for the mount and frame on. If he wants to view any other
ma e hem i hin he moun ih ee h, hi
pulley was the largest he could print.
My hobby is making things and
Ive been doing it since I was old
enough to hold a screwdriver
before turning to a less-familiar object, he simply uses a small
subject: the Raspberry Pi. wireless keyboard to enter the
Mike originally created a script chosen coordinates manually.
that would position the telescope Mike went to school to study
to align with celestial objects by mechanical engineering, though
way of information from the US he attributes much of his skill
aval bservatory. owever, to being a hobbyist. My hobby
upon completing the code, he is making things and Ive been >STEP-03
discovered PyEphem, a Python doing it since I was old enough Getting on the level
package that offered a much larger to hold a screwdriver. He even This large bullseye level allowed for less complication
scope for celestial exploration. converted his home lathe and when aligning the telescope to the desired object,
Though he had the PyEphem router to be CNC, and built his en uring he a al a on a a ur ace
code, he couldnt find anything own 3D printer too.

raspberrypi.org/magpi March 2017 33


Projects SHOWCASE
DANIEL FERNANDEZ
A chemist, blogger, and consultant
A simple case: you can 3D-print Its a very neat setup: a Pi, with a life-long passion for
one or get a pre-existing case a screen, and a Bluetooth electronics and DIY projects.
ha s ppo s a sc een heartbeat monitor github.com/danielfppps

Data is live-plotted but can


be reset at any time, with
he o d da a sa ed o e

Quick
Facts
HEARTBEAT
MONITOR
> It took two days
for Daniel to
develop the
software

> Daniel wants to


make an open-
source voice
assistant
The Raspberry Pi is increasingly being used in health applications
> If you use the
project, make here how one a er ade h own health de e
sure the code
launches
he current surge of smart Daniel Fernandez has decided to then save the data so that you can
at boot

> Daniel is an
T watches, however long
it lasts, probably owes
create his own heartbeat monitor
w th hel ro a a err
wor w th t later urther ore
wanted o e fle l t n how the
old hand with
the Raspberry something to the activity trackers I have always liked to monitor data was plotted and how often the
Pi, using it that are synonymous with anyone my heartbeat while I run on the heartbeat was updated, and to be
to automate
tr n to ee tra o the r tne tread ll an el tell u here able to retrieve the data from the
several projects
These devices track the users is simply no cheap, commercial device in an easy-to-process format
> The case is to
heartbeat and use it to calculate solution that did everything I l e
protect the Pi
from sweat and things like periods of rest, calories wanted: to plot the results in a graph o e an an el u ld e
spilt water urnt and ore ou an tell a thats easy to monitor, so that you selected the Raspberry Pi 3 as it
lot of things from a heartbeat, so can look at them while you run, and wa a ull fled ed o uter w th

34 March 2017 raspberrypi.org/magpi


HEARTBEAT MONITOR Projects
PI AT HEART

>STEP-01
You only need four items to make the monitor how many projects are this simple?
Starting up
When the Pi boots up, it loads up a Python script that
built-in luetooth that could fit o far, the Raspberry Pi has
checks the heartbeat data from the sensor, and a
on his treadmill. He coupled it always worked correctly with my
reePa cal rogram ha lo he a a
with a Polar H7 heart sensor and a heartbeat sensor, aniel says.
. screen, and -printed a little The program has always provided
case to fit it all in. smooth plots and a very responsive
ts not very difficult to build display of my real-time heartbeat.
as most of the project is based I have been able to save my run
on software, e plains aniel. data files and perform some more
f you have the sensor, screen, e tensive mathematical analysis
and software, you could have it to better understand how my heart

If you have the sensor, screen,


and software, you could have it
working in less than a few hours >STEP-02
Beat box
The heartbeat monitor automatically connects to the
working in less than a few hours. reacts to changes in intensity,
Pi and sends heartbeat data to the Python script. Its
I have made the software open cadence, inclination, and so on.
a e oa e le, hich i u e o lo he re ul
source and available via a GitHub I would want to include some
repository [magpi.cc/2kBj0aM . functionality to save my heartbeat
Hes been successfully using it files to my ropbo and even have
for its intended purpose, having run the option to share the data on
2 miles with it since he finished my social media accounts when I
the project. finish each run. was also thinking
about connecting the treadmills
control panel to the Raspberry Pi
so that the treadmill could adjust
intensity automatically to match
a target heartbeat.
Other heartbeat sensors that
follow the same standard as the
Polar H7 should work with the >STEP-03
project if you decide to make Saved
your own. Maybe its a good A reset button on the display resets the plot and
e cuse to keep up with your ew a e he on creen a a o a CS le or anal i
Above The Pi waits patiently until it
gets data from the heartbeat monitor Years resolution? at a later date.

raspberrypi.org/magpi March 2017 35


Tutorial WALKTHROUGH

36 March 2017 raspberrypi.org/magpi


12.99
Tutorial
200 pages of

THE Ocial Raspberry Pi

RASPBERRY PI
PROJECTS BOOK
Amazing hacking and making projects
from the creators of magazine

Inside:
How to get started with Raspberry Pi

The most inspirational community projects


Essential tutorials, guides, and ideas

Expert reviews and buying advice

able
Availw
no
magpi.cc/MagPiStore
plus all good newsagents and:

raspberrypi.org/magpi March 2017 37


Tutorial RASPBERRY PI 101: BUILD AN HTPC MEDIA CENTRE

HOW TO BUILD AN HTPC


MEDIA CENTRE
Build your home theatre media centre with a Raspberry Pi and OSMC

Youll B
uilding a media centre, or HTPC (home
theatre PC) is one of the most rewarding INSTALLING OSMC
Need
projects a newcomer can complete.
Its easy to turn a Raspberry Pi into an HTPC, and ON A RASPBERRY PI
you can quickly hook it up to your television.
> OSMC sing an TP , you can play video and music files, >STEP-01
> Pi Zero or and stream video and audio from online services. And Installation
Raspberry Pi 2/3 unlike proprietary systems, such as Apple TV and First, install the OSMC image to an SD card. Visit
> Keyboard Google Chromecast, you can use it to play just about magpi.cc/2jqbw8R in your web browser and
for setup any media format. download the OSMC disk image for Raspberry Pi Zero
> Smartphone for You can add streaming services to your HTPC, such or Raspberry Pi 2/3. Flash the image to an SD card
remote control as BBC iPlayer and Soma radio stations. These enable using Etcher (etcher.io).
you to play media directly from the internet.
There are several pieces of software available for 01
setting up an TP . Two options youll find on the
Raspberry Pi Foundations Downloads page are OSMC
and LibreELEC. Both are similar and run a media
player called Kodi.
In this guide, were going to opt for OSMC. Its a
free and open-source media centre built on top of
Debian, and is reliable and easy to use.
Setting up OSMC on a Raspberry Pi is
a straightforward and rewarding project.
Lets get started.

dd ons ena e o o s eam


deo and m s c om on ne se ces
s ch as a e o oma

deo and a d o es can e


s n a asp e h ans e ed o he med a cen e s n
o can d sp a deos m s c and a h m d e can p a ac
p c es on o e e s on a de an e o med a es

38 March 2017
xxxx 2016 raspberrypi.org/magpi
BUILD AN HTPC MEDIA CENTRE Tutorial
>STEP-02 >STEP-05
Setup Streaming services
Insert the SD card into your Raspberry Pi. Connect a Select Videos > Video Add-ons > Get More. Scroll
keyboard and use an HDMI cable to connect a display. down the er e to nd a a and ele t n tall
Power up and go through the Welcome section. Its a Press ESC to get back to the main screen and select
good idea to keep SSH enabled (the default option). deo a a hoo e e trea and to
watch the station. For keyboard controls, visit the
02 Kodi wiki (magpi.cc/2jqjK0C).

05

>STEP-03
Video files
To test video playback, weve downloaded a >STEP-06
o r ht ree deo le o a o e alled Return of Remote control
the Kung Fu Dragon (magpi.cc/2jxKryi). Download Open the app store on your phone and search for
the deo er on and then tran er the le al od e ote ore on ndro d en the
to a fla h dr e app, and click Add Host then Find Kodi. It should
nd the a err on our networ l a e
03 ow u e the a a a re ote ontrol

>STEP-04
Play video
onne t the fla h dr e to the a err n the
nter a e ele t deo le and the fla h
dr e ere ou ll ee the deo le ou o ed
across. Select it, and the video will start playing.

04

raspberrypi.org/magpi xxxxx 2016


March 2017 39
Tutorial RASPBERRY PI 101: HOW TO BACK UP YOUR RASPBERRY PI

HOW TO BACK UP
YOUR RASPBERRY PI
a u the le on a a err o ou an u l re tore our le

ne o the reat th n a out u n a a err our o uter h n a t how a e le are

Youll O how ea t to re et the whole te reated n the r t la e

Need o letel
ou re wor n on a ro e t and ou
e o eth n u t onl ta e nute
ower down our a
ard la e t nto an
err and re o e the
ard reader and onne t t to
to re n tall the o erat n te and tart a a n w t our o uter
> Raspberry Pi
re torat on u t one th n that a e the a err en a er nal w ndow on a a or nu
> SD card deal or e er entat on o uter and enter df a e a loo at what dr e
> Flash drive h on tant tate o e n read to re re h an ou ha e on our te ow atta h the ard to
e a dou le ed ed word thou h he a err a our o uter and enter df a a n
u e ul ro o uter ou an et u e a l and u e the ot the newl ounted dr e on a nu a h ne
nternet wr te do u ent n tall and u e od n tool t w ll e o eth n l e de d and on a a t
and wor on all anner o lon ter ro e t w ll a de d he nu er a e d erent
ou u e a a err or a lon t e ou ll want o e ure to he are ull
to th n a out a a u olut on a u ena le n nu
ou to re tore the a an and our le
ortunatel there are e eral d erent wa to o sudo dd bs=4M if=/dev/sdb of=raspbian.img
a out a n u the and our le
na a
Option 1: Copy the SD card image
he le t wa to a u our a err to sudo dd bs=4m if=/dev/rdisk2 of=raspbian.img
o the ent re ard a an a e
h te hn ue the re er e o fla h n our ou an then u e the raspbian.img le to re tore
ard when n tall n an to t n tead o o n our ent re o erat n te n t urrent tate
an a e le ro our o uter to the ard to an ard u n dd n re er e or u n an a
ou o the ent re ard to an a e le on u h a t her etcher.io to fla h the ard

Adding a password to your backup can secure the p s a pop a p o am es ac ed p s n pa e


es s o ed emo e o on an e e na d e sed o sched e ac ps es o ed s n he same p o am

40 March 2017
xxxx 2016 raspberrypi.org/magpi
BACK UP YOUR RASPBERRY PI Tutorial
n ndow ou a u the ard u n n
a er magpi.cc/2bndEsr
en the ro ra and l e to the e ur t alert
w ndow nter C:\raspberrypi.img n the a e le
te t o and l ead he ard w ll e wr tten to
the a e le hen t a ead u e ul ou an
l

Option 2: Back up the Home folder


he hallen e w th turn n the ard nto an a e
le do n t on a re ular a ou ha e to re o e
the ard ro our a err atta h t to
a a or and o lete the whole a u
he e ond a u o t on to a u u t our ow ou ll nd a new ro ra alled a u n o e Files
can be restored
o e older a a o re ed le n o re n the enu e or e individually, or
le ena le ou to row e and re tore nd dual le l on older to a e and he that o e you can restore
the whole of your
and d re tor e e the er nal on our a err l ted older to nore hould n lude u h n Home folder to a
ow l on tora e o at on and han e a on fresh installation
of Raspbian
cd /home/ to our fla h dr e
sudo tar czf pi_home.tar.gz pi o a to er ew and l a ow
u w ll tart the r t a u o our o e older
o the pi_home.tar.gz le to a fla h dr e ou ll e a ed ou want to enter an en r t on
or a e ee n a word h a ood dea or e ur t nter the
a e a word n the n r t on a word and
Option 3: Schedule backups on r a word eld l ont nue
t o le to hedule a u anuall he r t a u a ta e a wh le de end n on the
hedul n the tar o and a a ron o ee e o our o e older
hedul n a w th ron magpi.cc/2kg73Xs hen u ha n hed a n u u e ull
o e a err u er hoo e to u e r n ou an et u a hedule et the utton to n
magpi.cc/2kgchCH n tead o tar e au e th l hedul n and han e ee to a
artl o e u dated le rather than the whole a u w ll now tore the ontent o our o e
te ut ou need to reate an e lude le that older to the fla h dr e on a da l a read to e
nore the ontent o te older a e a loo re tored whene er ou need t
at th ta han e d u on ou re ntere ted
magpi.cc/2kg1qIQ Restoring files
n ea er a roa h to u e a ree ro ra alled ou e had a total te a lure and had to w e
u h auto ate r n and e t a u er our ard ou ll need to re n tall u ollow
r endl nter a e t an ea ro ra to u e and ou the n tru t on earl er
an a u our a err u n a on a e ure our a u fla h dr e atta hed to the
or o n the le d re tl to a fla h dr e a err ow o en e or e a u
ou an d re tor e to n lude and e lude and l e tore to re n tall an n le or
t ea to re tore a u u n talled d re tor e e tore ro here w ndow w ll
de ault on untu and ea to n tall n a an o en ou are n tall n ro a re h a an
a e hoo e our fla h dr e u n the a u
sudo apt-get update && sudo apt-get upgrade o at on l orward
sudo apt-get install deja-dup hoo e the date to a a u ro wh h ou
want to re tore and l orward ou ha e two
o t on re tore le to or nal lo at on and re tore
to a art ular older hoo e to re tore le to the r
or nal lo at on l orward and e tore
ou entered a a word ou ha e to enter t n
the n r t on a word eld l ont nue
ll the le ro the o e older n our
re ou a u w ll now e re tored ou w ll ee
e tore n hed when all our le are a
l lo e ou w ll now nd all the le and
d re tor e ro our o e older re n talled
o e ou can clone our S car o an image le u ing
dd on a Mac or Linux, and Win32 Disk Imager on a PC

raspberrypi.org/magpi xxxxx 2016


March 2017 41
Tutorial TUTORIAL
JOHN COLE
Travelling bearded nerd with a heart
powered with coffee and an unfocused
mind. 2016 Presidential candidate.
Engineer at Dexter Industries.
dexterindustries.com

The speaker will


do the talking
for Alexa

The USB microphone


will do the listening
for Alexa

The GoPiGo will


do the walking
for Alexa

Youll
Need HOW TO MAKE AN
ALEXA-POWERED
ROBOT
> Raspberry Pi 3

> The GoPiGo


magpi.cc/
2hA8f6i

> Raspbian for


Robots
magpi.cc/
2kixPxB

> Speaker for the


Raspberry Pi
magpi.cc/
2hAgCi7

> Microphone
amzn.to/
2g9mm1V Build an Amazon Alexa-controlled robot using the Raspberry Pi,
> A free Amazon
Developer
allowing you to operate it with just your voice
account
inally, a Raspberry Pi robot to do your
> A free IFTTT
account F bidding, controlled only by the sound of
your voice! Amazon Alexa software can be
put on the Raspberry Pi robot, the GoPiGo. In this
project, well create an Alexa-based robot that will
respond to voice commands, as well as answer your
questions. You can ask Alexabot How hot is it in
Dubai? or Whats the weather like in London?.
What makes Alexabot really interesting is that you
can order it around with your voice, using the Alexa
Voice Service (AVS).
The first step towards robot world domination
and building our Amazon Alexa-controlled robot
is to set up AlexaPi.

42 March 2017 raspberrypi.org/magpi


ALEXA POWERED ROBOT Tutorial

Alexabot.py Language
>PYTHON
from flask import Flask
import gopigo DOWNLOAD:
import time magpi.cc/2kiFlZz

app = Flask(__name__)

@app.route('/')
def index():
return 'Hello world'

@app.route('/forward')
def forward():
print("Forward!")
gopigo.fwd() # Send the GoPiGo Forward
time.sleep(1) # for 1 second
gopigo.stop() # then stop the GoPiGo
return 'Alexabot moved forward!'

@app.route('/backward')
def backward():
print("Backward!")
gopigo.bwd() # Send the GoPiGo Backward
time.sleep(1) # for 1 second
gopigo.stop() # then stop the GoPiGo.
return 'Backward!'

@app.route('/left')
def left():
print("Left!")
gopigo.left()
time.sleep(1)
gopigo.stop()
return 'Left!'

@app.route('/right')
def right():
print("Right!")
gopigo.right()
time.sleep(1)
gopigo.stop()
return 'Right!'

@app.route('/dance')
def dance():
Fig 1 An example of how to build your own command print("Dance!")
for each in range(0,5):
There are a few tutorials on how to turn your
gopigo.right()
time.sleep(0.25)
Raspberry Pi into an Amazon Echo using Amazon
gopigo.left()
Alexa. However, AlexaPi (magpi.cc/2kiyOxO) is the
time.sleep(0.25)
easiest way to get Amazon Alexa on your Raspberry gopigo.bwd()
Pi. The project has prepared everything to set up time.sleep(0.25)
Alexa Voice Services on your Pi in a streamlined gopigo.stop()
and simple manner. The hardest part is setting up return 'Dance!'
your Amazon Developer account and gathering your
credentials (and really, thats not that hard!). @app.route('/coffee')
At this point, with your speaker and your def coffee():
microphone plugged into your Pi, you should be able
print("Coffee!")
return 'coffee!'
to run Alexa on your GoPiGo, just as you would on
an Amazon Echo. Ask it for a news update: Alexa,
if __name__ == '__main__':
whats the news? app.run(debug=True, host='0.0.0.0')

raspberrypi.org/magpi March 2017 43


Tutorial TUTORIAL

Fig 2 Your ngrok


readout should
look a bit like this

Next, well set up IFTTT. If This Then That (IFTTT) Fig 1 shows how this is done in more detail. We
TRIGGER is a service that lets us connect different parts of will need to do this for all the moves you want
WORDS the web together. In our case, IFTTT helps us couple your Amazon Alexa-controlled robot to make! In
Alexa together with the Raspberry Pi. IFTTT lets us our project, we made seven: one each for Forward,
Remember
that your bridge the AlexaPi responses back to the Raspberry ackward, Left, top, Right, ance, and offee.
trigger words, Pi. First, youll need to set up an IFTTT account. Next, well connect to the ngrok service. We will
the words (ifttt.com/join). Again, this is free. have IFTTT contact a server on the Pi, but the tricky
that get Alexa
going, start Next, youll need to add the IFTTT service to your part will be setting up a server on the Pi thats visible
with Alexa Ale aPi. You can do this by first installing the Ale a to the world outside our local wireless network. For
trigger. app on your phone or tablet (magpi.cc/2kyIJho); its this, you can use ngrok (ngrok.com), a service that
available for iOS, Android, and Fire OS. With your allows you to connect to your Raspberry Pi through
phone on the same network as your Pi, connect to
your AlexaPi and add the IFTTT service.
Next, in IFTTT, we will need an applet for each A robot that will
respond to voice
command we want to send to the GoPiGo. First,
connect Amazon Alexa to your IFTTT account

commands
(magpi.cc/2kizD9X). Then well do the following to
create an applet that will handle a single command:

01. Create an IFTTT applet (magpi.cc/2jTYYn2 any network. IFTTT needs an internet-based URL
or our r comman e ill crea e to contact, so well use ngrok to make our server
an le a a le accessible to the outside world.
First, set up an account with ngrok. You can get
02. Selec Sa a S eci c Phra e away with a free account, but it will be much easier to
set up Alexabot with a paid account. A paid account
03. Specify the command. Say Backward. will allow you to set up named servers, rather than
ngroks randomly assigned server.
04. e , elec ha Next, install ngrok on your Raspberry Pi using the
directions here: ngrok.com/download.
05. e ll u e he ac ion er ice, a er This should install all the software. You will next
need to get your token, which will authorise your

RUNNING 06. Clic a e a e re ue an eci Raspberry Pi to ngrok. If you log into your account you
THE FLASK hein orma ion will see step 2, with your token already populated. It
SERVER should start with ./ngrok authtoken. Copy the
07. The URL is either your provided ngrok URL or command, and paste it into your command line.
The Flask our cu om omain e ill n hi in our
server
runs in the next step, but for now we can enter ngrok.io. Test out ngrok
background You can type the following into the command line:
and needs
to be set up
08. ur a le ill e oing a me ho , he
in a i eren con en ill e e , an on u an hing in ./ngrok http 80
command- the body.
line window You should then see a server start up, as shown in
from the
ngrok server. 09. Clic Crea e c ion an hen ini h Fig 2. When an IP address appears, try typing that IP
address into your browser. You should see your default

44 March 2017 raspberrypi.org/magpi


ALEXA POWERED ROBOT Tutorial
server on Port 80 come up. We will start our server
with the following command:

./ngrok http -subdomain=dexterindustries 5000

where dexterindustries is a reserved domain set


up with our basic account on ngrok. If you go with the
free account, youll now need to go back and re-enter
the domain name that ngrok gave your Pi into each of
your IFTTT commands.

Set up the Flask server


The final step in getting our Amazon Ale a-controlled
robot working is setting up the Flask server on
the Raspberry Pi.
Well set up a Flask server in Python to listen to
IFTTT. To install Flask on the Raspberry Pi, enter the
following into your command line:

sudo pip install flask

You can try running the Flask server weve AlexaPi


provided in our GitHub code and see what happens:

python alexabot-flask-app.py

You should see the Flask server start!


To get an idea of how the code works on the Flask
server, you can type the following in your web browser:
http://alexabot.ngrok.io/forward. You should get this
response in your browser: Alexabot moved forward!.

ifthisthenthat
This illustrates how the Forward command works;
each command will work this way, with its own
directory and custom code for moving the GoPiGo.
Now, with all the services set up, we should be able
to say a command like Alexa trigger forward; Alexa
will alert IFTTT, which will send an HTTP message
through ngrok back to our GoPiGo and post to the
web server running in Flask. The Flask program will
command the GoPiGo to move forward.
The quick-start method to get running with
Ale abot is to first start Ale aPi

sudo python /opt/AlexaPi/src/main.py

Next, start ngrok in a separate window:

sudo ~/ngrok/ngrok http


-subdomain=dexterindustries -log=stdout
5000 > log.txt &

Finally, start the Flask server:

sudo python alexabot-flask-app.py

Start talking! Remember, your commands need to he o o n o ma on


for getting the
start with Alexa trigger and then the command
Alexabot to respond to
you want the robot to carry out. o command

raspberrypi.org/magpi March 2017 45


Tutorial WALKTHROUGH
SIMON LONG
Works for Raspberry Pi as a software
engineer, specialising in user interface
design. In his spare time he writes apps
for the iPhone and solves crosswords.
raspberrypi.org

fgets is the library


function to read text
from an input stream

stdin is the input


stream associated
with the terminal

SCANF
AN INTRODUCTION TO C PART 09

USER INPUT
Just like sscanf,
scanf returns
an integer
indicating how
many values
it successfully
read, which
you can use
to check for
errors. One
problem is
Reading and interpreting input from the user
that scanf

I
only removes n the previous instalments, weve looked at #include <stdio.h>
matched how to print program output to the terminal,
values from the
in u u er, but in order to interact with the user, this void main (void)
so if a scanf needs to be a two-way process. This instalment looks {
fails to match at how we can read and interpret input that the user char input[256];
anything,
what the user enters in the terminal. int age;
typed will be The printf is the standard way of writing formatted
read again on text output from a program, but how can we read what printf ("What is your name, user?\n");
the next call
to scanf. It the user types in? scanf ("%s", input);
really is easier In the last instalment, we looked at the sscanf
to use fgets function, which reads values from a string. Theres printf ("How old are you, %s?\n", input);
and sscanf!
an equivalent function called scanf, which reads scanf ("%d", &age);
values typed in by the user:
printf ("%s, you're %d?\n", input, age);
GET THE }
NUMBER
RIGHT
scanf works exactly like sscanf, but has one fewer
Remember argument, as it reads from the keyboard rather than
ha he r
item in the argv from a string.
array argv[0] However, its not the best way of getting input, as
is the name it relies on the user doing what you expect, and this
of the program
itself, not the doesnt always happen! (For example, in the code
r arame er above, if the user types in 257 characters when asked
The actual for their name, they will over ow the space allocated
parameters
start at argv[1]. for the input string, and bad things may happen)

A better way
Above The argc and argv arguments to the main function can
be used to access parameters typed on the command line
A better approach is to read each line the user enters
when the program is run into a buffer string, and then use sscanf to read

46 March 2017 raspberrypi.org/magpi


AN INTRODUCTION TO C Tutorial
values from that string. The C library function fgets main returns an integer this is a success or failure
is useful for this. See the following example: code which some operating systems can use for
LEARN TO
CODE WITH C
processing in a shell script or the like. Traditionally,
BOOK
#include <stdio.h> if a program succeeds, main returns 0; if it fails, it
returns a non-zero error code. For programs that run Want to learn
more C? You
void main (void) on their own, you dont need to worry about it! can n he
{ argc is the number of parameters given on the entire series
char input[256], name[256]; command line after the program name. This number and more in
the Learn to
int age; includes the program name itself, so its always 1 or Code with C
more; if parameters are provided, it will be 2 or more. Essentials
printf ("What is your name, user?\n"); char *argv[] is an array of strings, and each string book, available
digitally and
fgets (input, 256, stdin); is one of the parameters. in print now
sscanf (input, "%s", name); Its probably easier to understand that in practice, at magpi.cc/
so heres an example: learn-c-book
printf ("How old are you, %s?\n", name);
while (1) #include <stdio.h>
{
fgets (input, 256, stdin); int main (int argc, char *argv[])
if (sscanf (input, "%d", &age) == 1) {
break; int param = 0;
printf ("Not an age, try again!\n"); while (param < argc)
} {
printf ("%d is %s\n",param,argv[param]);
printf ("%s, you're %d?\n", input, age); param++;
}
STDIN AND
}
STDOUT
return 0;
fgets takes three arguments. The first is the buffer } We talk about
into which it should store the input. The second is stdin in this
article, which is
the maximum number of bytes it will write into that Try running this as before, just by typing its name. the standard
buffer, which is useful to prevent over ow situations Then try typing other things after the name on the input stream
like that mentioned above. The third tells it where to command line and see what it prints. what the
user types at
read from in this case, stdin (short for standard Heres an example of a simple calculator written the console.
input) is the keyboard. using parameters: You may
When we ask the user for input, we use fgets to sometimes see
references to
read up to 256 characters of whatever they type (up #include <stdio.h> stdout, which
to the point at which they press the ENTER key), and is the standard
we then use sscanf to interpret it. When asking for int main (int argc, char *argv[]) output stream
as you might
the users age, we use the value returned by sscanf { expect, this is
to check that the user has entered what you expect, int arg1, arg2; output which
and loop until they give a valid answer. This makes if (argc == 4) is printed to
the console,
it easier to handle the cases where the user types { usually
something unexpected! sscanf (argv[1], "%d", &arg1); ia rin
sscanf (argv[3], "%d", &arg2);
Reading parameters if (*argv[2] == '+') printf ("%d\n", arg1 + arg2);
Theres another way to get input to your program, if (*argv[2] == '-') printf ("%d\n", arg1 - arg2);
which is to supply it as a parameter when you start the if (*argv[2] == 'x') printf ("%d\n", arg1 * arg2);
program from the command line. Weve always shown if (*argv[2] == '/') printf ("%d\n", arg1 / arg2);
the main function as }
return 0;
void main (void) }

This works, as youve seen, but it isnt strictly argv[2] is the second parameter; this is a string,
correct. The strict definition of main looks like this: but were only interested in the first character, so we
use *argv[2] to get this.
int main (int argc, char *argv[]) Make sure you separate the arguments from the
operator with spaces so they are identified as separate
But if youd seen that in instalment 1, youd have parameters <progname> 2 + 2 rather than
run a mile, wouldnt you? <progname> 2+2.

raspberrypi.org/magpi March 2017 47


Tutorial WALKTHROUGH
GERMANO CESARI
CEO and Glise lead developer
at twistednormal ltd. Writes
code for a living, smokes ribs
for pleasure.
twistednormal.com

MODEL A SQUID
WITH GLISE How to get started with 3D modelling and turn your Raspberry Pi
Youll into a personal graphic workstation
Need uring the last few years, 3D applications Set up and install
> Raspbian D have been behind many achievements
in computational and video hardware,
You must first activate the e perimental penGL
drivers find out how on the Raspberry Pi website
> Glise
magpi.cc/ addressing whole new branches of computer graphics. here: magpi.cc/2knRTvS. You might also want to
2kqaIiq Once known as 3D modelling applications, these increase the GPU memory to 128MB.
> Experimental packages are now best described as fully edged Download Glise for Raspberry Pi from
GL drivers modelling suites, with ever-higher hardware twistednormal.com, right-click on the downloaded
magpi.cc/
requirements and steeper learning curves. We want to installer, and select Package Install.
2knRTvS
take a step back and focus on pure 3D modelling using Avoid any L E Glise key binding con ict they
> Three-button
Glise, a new free modeller with minimal hardware both use Alt+mouse drag). You can either edit
mouse
requirements and a painless interface. Built from ~/.config/openbox/lxde-pi-rc.xml and comment
scratch, it turns a Raspberry Pi into a true modelling out the whole <context name="Frame"> section, or
tool. So lets get started and see what your Raspberry simply press the unction Windows key when using
Pi can do! the Alt key to move the camera in Glise.

We will create a coarse sketch,


add ns e es and en ac es Extrude faces and bevel e ne o mode and ad s
then tweak as needed ed es o add e es ns the pose using soft selection
and tentacles and ea mode

48 March 2017 raspberrypi.org/magpi


MODEL A SQUID WITH GLISE Tutorial

Fig 1 Basics of tweaking a face:


a) selection and handle
b) translation
c) scale

What we are going to do gizmo on its lower-right corner. By default, Glise


3D modelling is an iterative process where you push, will use a single, full-screen modelling canvas. If you STICKY
pull, and tweak vertices, edges, and faces. But how do want to change the default layout, check the online
KEYS
you turn simple, geometrical primitives into an alien documentation at Layouts, iewports and ialogs. Start a tool,
spider, a ying mussel, or a panda playing a banjo Creating a cube is straightforward: use a right keeping its
shortcut
As any good artist, you will start by sketching out mouse button R click anywhere in a modelling
pressed, and
the basic proportions of the model using a very coarse canvas to open the pop-up menu, and select Create leave tool
mesh, which has only few components and allows ube. ow that there is an object in the scene, mode by
releasing it.
you to make big changes quickly. As your modelling you can move the camera by pressing the ALT key
No need for a
session progresses, youll work on increasingly and dragging the left mouse button L to rotate, RMB click.
comple details, adding new, smaller components, the middle mouse button to pan, or the R
either locally or by subdividing your whole model.
Were going to draw a squid, since theyre relatively
easy to model, yet comple enough to let us cover
Focus on the modelling
several fundamental concepts.
canvas, which is where all
Modelling basics
Instead of going ahead with an endless list of actions themagic happens
to perform, like click there, open that and the
like, lets go through the fundamental concepts to zoom. Whenever the Alt key is pressed, drag
and procedures needed to sketch the squid head, the mouse to move the camera. Any time you want
which, surprisingly enough, youll be able to model to centre the cube, just press pace and it will be
all by yourself once youve grasped the basics. You framed in the current canvas. Practise with these
might want to check the online documentation at controls: moving the camera and framing things must
magpi.cc/2knLzo2 and you definitely should while become second nature. See Navigation in the online
practicing, to get more in-depth information about documentation for more camera controls. TWEAK
the topics discussed here. All this is fine and dandy, but you wont get very
MODE
Glises main window may contain several far just by rotating a camera around a cube. o were Press Ctrl+Shift
independent viewports, each holding either a scene going to tweak a face, which is, yes, modelling! Left- and LMB/
MMB-drag
manager, a Python console, or a modelling canvas click on a face to select it. As the face turns yellow, a to translate/
an ambient occlusion renderer is also available on -a is handle is placed right on its centre Fig 1-a). scale a
Linu and Windows . ince were not going to deal You can now L -drag any of the arrows to translate preselected
component
with scene management or Python programming, the selection along a direction Fig 1-b , or L - without
we will focus on the modelling canvas, which, as the drag the centre of the handle to move it freely. Try selecting it
name implies, is where all the magic happens. You it! Dragging an arrow with the middle mouse button r an u ing
hehan le
can easily spot a modelling canvas from the little a is will make you scale the selection along a direction.

raspberrypi.org/magpi March 2017 49


Tutorial WALKTHROUGH

single right mouse button click to e it tool mode.


Again, trl Z is your friend if you mess things up.
ongratulations - you know a lot of stuff now!

Sketching the head


So you know how to create a primitive, rotate the
camera, tweak components, and e trude faces. elieve
it or not, you can easily model our target shape in
Fig 2 all by yourself. You can skip this if you managed
to model something close enough. Otherwise, this
is how to proceed in five easy steps create a cube,
e trude a side face slightly outward, scale it smaller,
and e trude it inward. cale the opposite face smaller.
snt modelling awesome
We know what youre thinking: if thats a squid
Fig 2 Coarse head MMB-drag the centre of the handle for a uniform head, what on earth have we been eating ont
sketch reference:
a om he on scale on every a is Fig 1-c . Left-click on an empty worry; let us introduce you to the wonderful world of
om he ac area to clear the selection. Play with the handle subdivision. Subdivision is the process of applying a
and get comfortable with translating and scaling, specific set of rules to generate a more comple mesh
change the type of components you can select and from a simpler object. Glise handles each object as
tweak press A, , , G to switch to points, edges, if composed of two distinct yet entangled entities:
a base mesh and its subdivided surface. When you

When you model a base mesh, model a base mesh, Glise automagically takes care of
its subdivided surface in real time. You may change

Glise automagically takes care the display mode of a modelling canvas by pressing
1 to see only base meshes, 2 to see only subdivided

of its subdivided surface


surfaces and work directly on them the default , or
to see both.
Now press PgUp twice to increase the display
faces, or mi ed , and remember that a simple trl Z appro imation level of the surface of our sketch.
will undo any unwanted change. Check the online snt it starting to look like a s uid eep in mind
documentation at Preselection, Selection & Soft that each level will eat four times more memory and
Selection and Handles & Tweaking to learn more video memory) than the previous, so depending on
about selections and tweaking. the comple ity of your model, you might not want
Now one last, quick step: select a cube face and to go further than a couple of levels. Use PgDn to get
press . Youre currently using the e trude tool back to the previous level. See Introducing Glise and
to perform a face e trusion. ove the mouse left Display in the online documentation to learn more
and right to slide the newly created face and use a about what weve just covered.

Fig 3 dd n ns
a) edge selected
b) after edge bevel
c) during face extrusion

50 March 2017 raspberrypi.org/magpi


Tutorial
Eyes, fins, and tentacles TOOLS AND
Well, were done now with our rough sketch,
PRESELECTION
and its time to proceed to the ne t level. We want
to add a few details. Unfortunately, our base mesh Most tools
also work on
the one you actually model is basically still very
preselection.
close to a simple cube. We cant e trude fins and There is often
tentacles from a cubes face, because we need no need for
a selection
components to work with, and in the middle of a
to operate
face theres only, well, a face. So follow us, and on single
everything will be clear in a minute: press F to components.
switch to object selection mode, select our object,
and press hift Pg p aka Refine . This will replace
Fig 4 Adding tentacles:
our base mesh with the first appro imation level a) vertices selected
of its subdivided surface, which will keep its shape. b) after vertex bevel
c) during face extrusion
Now our model has way more components, and we
can have our fins in the right place. ut wait s uids
have a symmetrical body. Lets work on one side
and have Glise take care of the other! We just have
to properly set up symmetry on our squid: press S
to switch to edge selection mode, and select one
of the edges dividing the left side from the right.
Press Alt ymmetry ompute rom Edges
and thats it. snt symmetry great f instead you
received an error message, check that the edge
you selected really lies on the centre of the model.
There are also other ways to compute symmetry
check Symmetry in the online documentation
to learn more.
ack to the fins now that weve refined our
model and enabled symmetry, select an edge like
Fig 3-a and press B to use the edge bevel tool.
Slide the mouse like in Fig 3-b and right-click to
e it tool mode. ow select the newly created face
and e trude it as in Fig 3-c. Well make something
similar for the tentacles, but we will work with
vertices press A to switch to verte selection
mode, select the vertices as in Fig 4-a, and press
Ctrl+B to use the bevel tool on those. Right-click to
e it tool mode when youre close to Fig 4-b. Then
all we need to do is e trude the newly created faces
as in Fig 4-c. Create the eye by using the bevel tool
on a single verte and deleting the resulting face
with Del.
ow its just a matter of tweaking a bit and
working on a few further e trusions, and your final
result will be very much like the squid in our picture.
t doesnt have to be e actly the same it must be
what you want it to be. LOCAL
PIVOT
What now? Local Pivot
Well, this is uite a comple subject, and this short forces the
tutorial wasnt meant to cover everything. There camera to
are tons of books, online tutorials, and videos on rotate around
the centre
each single topic related to 3D modelling. Still, the of the scene,
tools you used in these pages can be found in any 3D ignoring
software package, and the fact that youre doing this selections.
Press L
on your Raspberry Pi is awesome! Now draw and be o oggle
creative, but above all, have fun!

raspberrypi.org/magpi March 2017 51


Tutorial WALKTHROUGH SAM AARON
Sam is the creator of Sonic Pi. By day hes
a research associate at the University of
Cambridge Computer Laboratory; by night

PART 17 he writes code for people to dance to.


sonic-pi.net

SUBTRACTIVE
SYNTHESIS
&& Learn more ways to design sounds in Sonic Pi thanks to Sam Aaron
Youll
Need T
his is the second in a series of articles on how
to use Sonic Pi for sound design. Last month
the :saw. Its this buzziness and variation from a
pure sine wave that we can play with when we use
we looked at additive synthesis, which we subtractive synthesis.
> Raspberry Pi
running Raspbian discovered was the simple act of playing multiple

> Sonic Pi v2.9+


sounds at the same time to make a new combined Filters
sound. This month well look at a new technique Once we have our raw source signal, the next step is
> Speakers or
commonly called subtractive synthesis, which is to pass it through a filter of some kind, which will
headphones with
a 3.5mm jack simply the act of taking an existing complex sound modify the sound by removing or reducing parts of it.
and removing parts of it to create something new. ne of the most common filters used for subtractive
> Update Sonic Pi:
sudo apt-get This is a technique which is commonly associated synthesis is something called a low-pass filter. This
update && sudo with the sound of analogue synthesizers of the Sixties will allow all the low parts of the sound through, but
apt-get install
and Seventies, but also with the recent renaissance of will reduce or remove the higher parts. Sonic Pi has a
sonic-pi
modular analogue synths through popular standards powerful yet simple-to-use FX system that includes a
such as Eurorack. low-pass filter, called :lpf. Lets play with it:
Despite this sounding like a particularly
complicated and advanced technique, Sonic Pi makes with_fx :lpf, cutoff: 100 do
it surprisingly simple and easy so lets dive right in. synth :saw, note: :e2, release: 4
end
Complex source signal
For a sound to work well with subtractive synthesis, it If you listen carefully, youll hear how some of that
typically needs to be fairly rich and interesting. This buzziness and crispiness has been removed. In fact,
doesnt mean we need something hugely complex in all the frequencies in the sound above note 100 have
fact, just a standard :square or :saw wave will do: been reduced or removed, and only the ones below are
still present in the sound. Try changing that cutoff:
synth :saw, note: :e2, release: 4 point to lower notes, say 70 and then 50, and compare
the sounds.
Notice that this sound is already pretty interesting Of course, the :lpf isnt the only filter you can use
and contains many different fre uencies above :e2 to manipulate the source signal. Another important
(the second E on a piano), which add to create the is the high-pass filter, referred to as :hpf in
timbre. If that didnt make much sense to you, try Sonic Pi. This does the opposite to :lpf in that it lets
comparing it with the :beep: the high parts of the sound through and cuts off the
low parts.
synth :beep, note: :e2, release: 4
with_fx :hpf, cutoff: 90 do
As the :beep synth is just a sine wave, youll synth :saw, note: :e2, release: 4
hear a much purer tone and only at :e2 and none end
of the high crispy/buzzy sounds which you heard in

52 March 2017 raspberrypi.org/magpi


SUBTRACTIVE SYNTHESIS Tutorial
A
Notice how this sounds much more buzzy and raspy
now that all the low-frequency sounds have been
removed. Play around with the cutoff value note
how lower values let more of the original bass parts
of the source signal through and higher values sound B
increasingly tinny and quiet.

Low-pass filter
he low a lter u h an ortant art C
of every subtractive synthesis toolkit that its
worth taking a deeper look at how it works. This
diagram (top right) shows the same sound wave
(the :prophet synth) with varying amounts of
lter n t the to e t on how the aud o

Language
wa e w th no lter n ot e how the wa e or you to directly name and control the running FX
is very pointy and contains lots of sharp edges. It synth. Line 2 does exactly this and controls the FX to
the e hard har an le that rodu e the h h set the cutoff_slide: opt to 3 and the new target >RUBY
crispy/buzzy parts of the sound. Section B shows cutoff: to be 130. The FX will now start sliding the
the low a lter n a t on not e how t le cutoff: opts value from 50 to 130 over a period of
Above How the
pointy and more rounded than the wave form three beats. Finally, we also trigger a source signal waveform alters
above. This means that the sound will have fewer synth so we can hear the effect of the modulated when a low-pass
e s added h
h h re uen e n t a ore ellow rounded low-pass filter. o c o a es
eel e t on how the low a lter w th a
a rl low uto alue th ean that e en ore Bringing it all together
of the high frequencies have been removed from This is just a very basic taster of whats possible when
the nal re ult n n an e en o ter rounder you use filters to modify and change a source sound.
wa e or nall not e how the e o the wa e Try playing with Sonic Pis many built-in FX to see
or wh h re re ent the a l tude de rea e a what crazy sounds you can design. If your sound feels
we o e ro to u tra t e nthe wor too static, remember you can start modulating the
re o n art o the nal wh h ean that options to create some movement.
the overall amplitude is reduced as the amount Lets finish by designing a function which will play
o lter n that ta n la e n rea e a new sound created with subtractive synthesis. See
if you can figure out whats going on here and, for
the advanced Sonic Pi readers out there, see if you can
Filter modulation work out why we wrapped everything inside a call to
So far weve just produced fairly static sounds. In at (please send answers to @samaaron on Twitter).
other words, the sound doesnt change in any way for
the entirety of its duration. Often, you might want define :subt_synth do |note, sus|
some movement in the sound to give the timbre some at do
life. ne way to achieve this is via filter modulation with_fx :lpf, cutoff: 40, amp: 2 do |fx|
changing the filters options through time. Luckily, control fx, cutoff_slide: 6, cutoff: 100
Sonic Pi gives you powerful tools to manipulate an synth :prophet, note: note, sustain: sus
FXs opts through time. For example, you can set a end
slide time to each modulatable opt to specify how long with_fx :hpf, cutoff_slide: 0.01 do |fx|
it should take for the current value to linearly slide to synth :dsaw, note: note + 12, sustain: sus
the target value: (sus * 8).times do
control fx, cutoff: rrand(70, 110)
with_fx :lpf, cutoff: 50 do |fx| sleep 0.125
control fx, cutoff_slide: 3, cutoff: 130 end
synth :prophet, note: :e2, sustain: 3.5 end
end end
end
Lets take a quick look at whats going on here.
Firstly, we start a :lpf FX block as normal with an subt_synth :e1, 8
initial cutoff: of a low 50. owever, the first line sleep 8
also finishes with the strange |fx| at the end. This is subt_synth :e1 - 4, 8
an optional part of the with_fx syntax which allows

raspberrypi.org/magpi March 2017 53


Tutorial WALKTHROUGH
BEN NUTTALL
Raspberry Pis community manager,
creator of the GPIO Zero library, Jam
master, and the Foundations resident
Python expert!
twitter.com/ben_nuttall

BUILD LOGIC GATES WITH


Youll
Need
GPIO ZERO
SOURCE/VALUES
> The latest version
of GPIO Zero
magpi.cc/
2kmDu5I

> Full-size
breadboard

> 3 LEDs
Learn how you can use source/values in GPIO Zero to easily connect
> 3 330 resistors

> 2 push buttons


devices together using a declarative style of programming
> 7 male-
ource/values is a more advanced feature What is source/values?
S
to-female
jumper wires of GPIO Zero, but its incredibly powerful GPIO Zero is more than just a friendly API: it
> 2 male-to-male and much simpler than youd think! You comes with some powerful tools for helping you
jumper wires can do more with less code, and it saves you from program your next project. While you can start
using while loops to keep updating the state of your with simple procedural code, where each line is
devices. This clever concept allows you to describe followed in sequence, you can progress to event-
how devices should behave, making your code driven programming, meaning various events can
more concise. be triggered in any order, or at the same time. And
Source/values is easy to get started with, and takes finally, the darkest of dark arts, source values brings
a keen mind to master. Theres some magic going on forth a third programming paradigm: declarative.
beneath the hood! You will learn how it all works, and This means you describe an objects behaviour in
put it into action by creating logic gates (AND, OR, one line, and it will follow that instruction in the
and NAND), using LEDs and buttons. background. This is really handy if you have lots
of things going on at once!
LEDs represent OUT1, Buttons represent
OUT2, and OUT3 IN1 and IN2
Source/values is the name for the concept
in GPIO Zero for telling a device how it should
behave, or for connecting up multiple devices
together so they act in a particular way. Every
GPIO Zero device has a .value property which
you can read at any time: a button will tell
you if its pressed (True) or released (False),
and an LED will tell you if its lit (True) or not
(False). Output devices (like LEDs) can have their
value set; led.value = True will light the LED,
just like using led.on().
Every device also has a .values property, which
is an iterator constantly yielding the current value.
Output devices have a .source property which
is where you tell the device where it should get
its values from. Commonly, this will be another
devices .values property, which is an easy way of
connecting two devices together. For example,
Each button and LED is connected led.source = button.values means the LED will
to ground (GND) and a GPIO pin be on when the button is pressed.

54 March 2017 raspberrypi.org/magpi


BUILD LOGIC GATES Tutorial

source_values.py
from gpiozero import LED, Button
from gpiozero.tools import all_values, any_values, negated
from signal import pause

in_1 = Button(0)
in_2 = Button(1)

out_1 = LED(2)
out_2 = LED(3)
out_3 = LED(4)

out_1.source = all_values(in_1.values, in_2.values)


out_2.source = any_values(in_1.values, in_2.values)
out_3.source = negated(out_1.values)

pause()

The magic under the hood Programming logic gates Language


This concept was developed by Dave Jones (author Lets begin. First, wire up two buttons and three >PYTHON
of the picamera library and co-developer of GPIO LEDs on a breadboard. Youll need to import the
Zero) based on an idea formed in a GitHub issue gpiozero LED and Button classes, and the all_ DOWNLOAD:
magpi.cc/
(rpf.io/gpz76). The way it works is that when a values, any_values, and negated source tools.
ZeroSourceValues
devices source is set, a background thread is created Create objects representing each of the LEDs and
to constantly set the devices value to the next item buttons, providing the pin numbers theyre wired
Above Read up
in the iterator. If source is set to another device's to. The buttons represent two inputs; the LEDs three on source/values
.values, this is effectively always reading the other outputs. Youre going to program the first LE to in the gpiozero
documentation
devices current value. It doesnt have to be, though: represent the binary AND of the two inputs, the at rpf.io/sv
it can be any iterator, or you can write your own second to represent the OR, and the third the NAND.
function to send values to the device. To define the A of the two buttons, youll need to
A handy thing about GPIO Zero is the fact that use the all_values function from gpiozero.tools;
devices tend to have a standard value range usually all_values yields True if all of the inputs are True,
a sliding scale from 0 to 1 (or True and False, which which is an AND gate:
are effectively just and 1 . This means that you can
pass the values from one device into another: like a out_1.source = all_values(in_1.values, in_2.values)
potentiometer (0-1) into a PWM LED (0-1) to dial up
the brightness. Exceptions include Motor, which goes To define the R of the two buttons, you can use the
from -1 to 1 (-1 being full speed backwards, 1 full speed any_values source tool; any_values yields True if
forwards), and composite devices like Robot, which is any of the inputs are True, like an OR gate:
a tuple (-1, -1) to (1, 1) for left and right motor speeds.
out_2.source = any_values(in_1.values, in_2.values)
Why is it useful?
Using this method of connecting devices is much more You could define the A button using a
concise. Rather than using a while loop five lines to combination of negated and all_values, but since you
constantly check if a button is pressed to turn an LED have already calculated the AND, you can simply read the
on or off, or using an event-driven approach two lines state of the AND LED and negate that:
when_pressed and when_released), one line tells it to
match the button: led.source = button.values. out_3.source = negated(out_1.values)
As well as connecting two devices directly together,
you can process the value in between, using a custom inally, if youre running this code from a file rather than
function. GPIO Zero provides a set of commonly a Python shell, the last line, pause(), will keep your script
used tools for this kind of processing. Importing the running. Run your code and youll see the NAND LED lit up.
negated function from gpiozero.tools allows you to Thats because (with no buttons pressed), its the only gate
specify that an LED should be lit when the button isnt thats active according to the rules. Try pressing the buttons
pressed: led.source = negated(button.values). in different combinations to check your logic! ow try
See more source tools in the docs at rpf.io/st. programming some more logic gates: XOR, NOR, and XNOR.

raspberrypi.org/magpi March 2017 55


Tutorial WALKTHROUGH
CARRIE ANNE PHILBIN
Carrie Anne is the director of education
at the Raspberry Pi Foundation
and also the author of Adventures
in Raspberry Pi.

MAKE A
raspberrypi.org

Youll
Need

WHOOPI
PROJECT
> 2 crocodile clips Enter the Pioneers
> 2 male-to- challenge here:
female jumper
magpi.cc/2iHKIP5

CUSHION
leads

> A speaker

> Cra u
paper plates,
cardboard,
aluminium foil,
glue, scissors,
sponge, bulldog
or paper clips,
sticky tape A Pi-powered retro prank, perfect to get your mind thinking
about a Pioneers project!
n the bad old days before TV and computers, PARP! noise, causing him to jump into the air and
I the most popular form of family entertainment
was the whoopee cushion, a tooty balloon
making his false teeth y out. t was the best thing
ever. This project brings the whoopee cushion up to
originally made from a pigs bladder. The whoopee date: theres no bladder and no need to blow it up.
cushion would be in ated and hidden under Grandads Thanks to the Raspberry Pi, you can also add whatever
chair cushion. When he sat down, it would make a loud noises you want!

Behind the sofa may not


be the best place to hide,
but youll need to see your
prank in action

This look of discontent


is what every prank
should strive for

An electrically
powered trump
machine, ready
to prank

56 March 2017 raspberrypi.org/magpi


MAKE A WHOOPI CUSHION Tutorial
Making the Whoopi cushion
ut a circle from the cardboard to fit the centre of the
eating side of each paper plate. Tape or stick squares
of foil onto the cardboard. These are your contacts:
when they touch, they will complete a circuit. Using
some copper tape, connect the foil to the edge of the
plate. Chop the sponge up into cuboid chunks and
glue them around the foil on one of the plates: this
will stop the foil squares touching each other until
someone sits on the plate. t should look something
like Fig 1.
Put the two plates together so that the foil pieces
are on the inside and facing each other. ffset the
paper plates so that the copper tape sections are
not touching.
You now have a cushion made of two plates. You
can tape the plates together, or you might choose to
use bulldog or paper clips so that you can test that
your cushion works correctly, and easily debug any Test the sound Fig 1 It looks a bit
like some futuristic
hardware problems. Thats the hardware complete. ow for the software! tech. Well use it to
make farting sounds
Were going to use Python. ont worry if you havent
Connect the Whoopi cushion to the Pi used it before: just follow the instructions and youll
Plug one header lead (it doesnt matter which) onto pick it up. Youll be using the command line to enter
a ground G pin on the Pi refer to Fig 2). Plug commands. To do this youll need to open a terminal
the other wire onto GP pin 2 Fig 3, overleaf) and window by clicking on the terminal icon: it looks like a
then clip a crocodile clip cable to one of the paper computer screen, and is found three icons along from
plates copper tape sections. Connect the other end of the Menu button on your desktop.
the crocodile clip cable to the male pin of one of the Connect the speaker to the Raspberry Pi using the
connected jumper wires (Fig 4). Repeat these last two sound jack. Create a new folder called whoopee by
steps to connect the other plate to your Raspberry Pi. typing the following command in the terminal and
Your setup should look similar to Fig 5. pressing Enter on the keyboard:

Fig 2 If you have


an older Raspberry
Pi model you'll
only have 26 pins,
3V3 5V but they have the
GP2 5V same layout
GP3 GND
GP4 GP14
GND GP15
GP17 GP18
GP27 GND 3V3 5V
GP22 GP23
3V3 GP24 GP2 5V
GP10 GND
GP09 GP25
GP11 GP8
GP3 GND
GND GP7
DNC DNC GP4 GP14
GP5 GND
GP6 GP12
GP13 GND
GND GP15
GP19 GP16
GP26 GP20 GP17 GP18
GND GP21

GP27 GND
GP22 GP23
3V3 GP24
GP10 GND
GP09 GP25
GP11 GP8
raspberrypi.org/magpi March 2017 57
Tutorial WALKTHROUGH

Fig 3 a n
this will be the Fig 4Its a very
same pin on any simple step but
Raspberry Pi best to get it right

3V3 5V
GP2 5V
GP3 GND
GP4 GP14
GND GP15
GP17 GP18
GP27 GND
mkdir whoopee To switch audio to the headphone jack, return to the
GP22 GP23
terminal window and type the following command:
e 3V3 GP24
t, use cd whoopee to enter the folder you
have just created. Were going to need a sample amixer cset numid=3 1
GP10 GND
sound file for this project, so well use one from
onicGP09 GP25this burp sample using the
Pi. ownload f your Raspberry Pi is connected to the internet,
following command: you could search for some suitable trumping sounds.
GP11 GP8 They need to be in WAV format to work. Alternatively,
GND
wget GP7
http://rpf.io/burp -O burp.wav download our example sounds here: rpf.io/farts.

DNC
ow, DNC
test that you can play the sound file using Write a program in Python
aplay by typing: pen Python LE from the Programming menu
GP5 GND
and click on ile ew Window. This will open a blank
aplay GP12
GP6burp.wav file. lick on ile ave As, name the file whoopee.py
and then type the following code into your file
GP13 GND
You should hear it from the speakers or headphones
GP19to GP16
connected your Pi. f you cant hear anything, make
sure that your speakers are connected correctly. f import os
GP26 GP20
this still doesnt work, youll need to change your import random
audioGND GP21
configuration. from time import sleep
from gpiozero import Button

This part of the code pulls in all the libraries that


youre going to use to write your program. Youll then
need to use the Button class in your code. Youll have
to tell it that the button is on pin 2. To do this, write
the following code in your new file

button = Button(2)

ow create a list of all your sound effects and store


them inside a variable that you can call later on in
MAKE YOUR OWN PRANKS your code:
AND WIN!
trumps = ['ben-fart.wav', 'ca-fart.wav',
Think you can do better than this? The Raspberry 'marc-fart.wav']
Pi Foundation is running a competition for folks
between 12 and 15, and all you need to do is make n Python, s uare brackets are used to create a list.
them laugh using digital technology. Sound easy? Each item in the list is separated by a comma.
Sound fun? Then check out the website for more Once all the setup needed in the code is complete,
e ail magpi.cc/2iHKIP5 you can move on to writing the part of the program
that will make something happen when the button is

58 March 2017 raspberrypi.org/magpi


MAKE A WHOOPI CUSHION Tutorial

3V3 5V
GP2 5V
GP3 GND
GP4 GP14
GND GP15
GP17 GP18
GP27 GND
GP22 GP23
3V3 GP24
GP10 GND
GP09 GP25
GP11 GP8
GND GP7
DNC DNC
GP5 GND
GP6 GP12
GP13 GND
GP19 GP16
GP26 GP20
GND GP21

Fig 5 Yours may be


considerably tidier
than this. Or messier.
Its all good

Language
pressed. Begin by creating a loop using while True:.
Then, add button.wait_for_press() inside the loop
whoopee.py >PYTHON 3
by indenting by four spaces. Each time around the import os
loop, the computer waits for the button to be pressed. import random DOWNLOAD:
magpi.cc/
On the next line, use the random.choice function from time import sleep
WhoopiCushion
to select a sound at random from the list you created from gpiozero import Button
earlier. That selected sound needs to be stored inside
another variable which you can call parp! Type parp = button = Button(2)
random.choice(trumps). trumps = ['ben-fart.wav', 'ca-fart.wav', 'marc-fart.wav']
The next line will play the sound selected at random
using aplay, as used earlier when testing sounds. while True:
Type os.system("aplay {0}".format(parp)). button.wait_for_press()
Finally, add sleep(2) to pause the program before it parp = random.choice(trumps)
starts the loop again. Your code should look like this: os.system("aplay {0}".format(parp))
sleep(2)
while True:
button.wait_for_press()
parp = random.choice(trumps) Setting it up
os.system("aplay {0}".format(parp)) Carefully place your cushion in a spot where your
sleep(2) victim will sit on it (obviously!), but not under a really
heavy cushion where it will be squashed straight
ave the file by clicking on ile ave. Test that your away. The tricky bit is setting up the Pi so that it
code works by clicking on Run > Run Module. Use your cant be seen: remember, youll need a plug socket to
hand to push the top plate of your Whoopi cushion connect it to the power, unless youre using a battery
down to make a connection between the foil sheets, pack. Run the program, and wait. Heres a hint:
and you should hear a fun sound. f it doesnt work first whistle tunelessly and look around at the ceiling. This
time, dont worry. Check your code through. Have you will make you seem innocent, and will help to attract
typed your code out exactly as you see it here? potential victims.

raspberrypi.org/magpi March 2017 59


Tutorial WALKTHROUGH
JAMIE BAILEY
Jamie is an electrical/system engineer,
integrated circuit designer, and CEO/
founder of Initial State, a data analytics
service for Internet of Things devices.
initialstate.com

See the current status of


each process at a glance

See a history of when processes


exit to spot if theres any patterns

Receive a text message or email


whenever a process exits

REMOTELY MONITOR
YOUR PI PROCESSES Create a web-based dashboard of all your important processes and get
Youll a not at on when one e t
Need f youre using one or more Raspberry Pis to Monitor a process
> Initial State
account
I run a dedicated task (e.g. weather station or
monitoring your beer fridge), you need those
Whenever you run a program or script on your Pi,
you initiate a process. Each running process will
magpi.cc/ processes to run uninterrupted. A task that exits have a unique process ID number (PID). You can see
2kiYp77
unexpectedly may need your immediate attention every process owned by you by typing ps at your Pis
to avoid lost data, project delays, or a system failure. command prompt. You will see a response that looks
Its impractical, though, to manually babysit a bunch something like this:
of Raspberry Pis. A better way to ensure continuous
operation is to be alerted when a process exits, and be PID TTY: 3359 pts/0 3373 pts/0
able to pull up a single dashboard to see the status of TIME CMD: 00:00:01 bash 00:00:00 ps
every important process running on every one of your
deployed Raspberry Pis. f you want to find every running Python process,
you can use the following command:
Initial State
We want to stream the status of each of our processes $ ps -ef | grep py
to a web service and have that service turn our data
into a nice dashboard that we can access from our root 2287 1 0 Dec09 ?
laptop or mobile device. Our data needs a destination, 00:00:00 sudo python /home/pi/weather/
and well use Initial State as that destination. First, go weather.py
to magpi.cc/2kiYp77 and create a new account. Next,
install the Initial State Python module onto your Pi: In the example above, the PID of the weather
Python script is 2287. Once we know the PID of the
cd ~ process we want to monitor, we can pass this number
\curl -sSL https://get.initialstate.com/ as a parameter into a simple Python script that
python -o - | sudo bash will monitor the e istence of this defined process
and send either a Running or Exited response to
Follow the prompts, including the step of creating a our dashboard.
test script to ensure you can successfully stream data We will use the Python script located at
from your Pi. magpi.cc/2kj3BYs. Before we can use this script,

60 March 2017 raspberrypi.org/magpi


REMOTELY MONITOR YOUR PI PROCESSES Tutorial
we need to set each of our user settings at the top for monitoring our processes. However, we need to Language
of the file. consider what happens when we have a power outage. >PYTHON

BUCKET_KEY specifies the data bucket our script Monitor a reboot DOWNLOAD:
magpi.cc/2iUSsAY
will stream into. Make sure you use the same If power drops, our process will instantly die, as will
BUCKET_KEY for each script that should send data our monitoring script and network connection. On
into the same dashboard. reboot, we need to do two things: send an update to
our process dashboard that our process exited, and
ACCESS_KEY is your unique Initial State account key. automatically start our process and process monitor
This key is used to send data into your account from after the reboot completes.
the scripts. You can find your A E EY in the First, lets create a script that will run on reboot to
Streaming Access Keys section of your Initial State send a process exited status to our dashboard. Well
account settings. use the script at magpi.cc/2kiTfIa. The user settings
at the top of this script need to be set just like the
PROCESS_NAME is the name of the specific process other scripts. Make sure you use the same BUCKET_
youre monitoring that you want to display on KEY, ACCESS_KEY, and PROCESS_NAME as in the
your dashboard. For example, PROCESS_NAME = Monitor a process step. Once this script is set up,
"Franklin Weather Station". we need to call it automatically on reboot.

You can run this script as follows: Automatically launch on boot


To automatically launch our scripts on boot, we will
python monitor_process.py <pid> use crontab:

To run this in the background without interruption: crontab -e

nohup python monitor_process.py <pid> & At the end of the file that opens, add the
monitor_reboot script and the launch_process
anually finding the P is cumbersome. Lets script. Specify the full path. For example, youll add
make it a bit easier by creating another simple script a single line that looks something like the following
that will find the P automatically and launch our with your specific paths
monitor_process script.
@reboot python /home/pi/weather/monitor_
Launch a monitored process reboot.py && /home/pi/weather/launch_
We can use a simple Bash script to do three things: process.sh
launch our important task program process, find the
PID of the task/program/process we just launched, Notice the monitor_reboot script is followed by
and pass the PID into our monitor_process script. &&. This specifies that the monitor_reboot script
The Bash script that well modify and use is located should complete before the next command runs. If
at magpi.cc/2kiS23q. theres a power outage, it may take a few minutes
To use this script, simply modify the two user for your network connection to be restored. After the
settings at the top of the file delays specified in the monitor_reboot script expire,
status updates will be sent to your dashboard and
PROCESS2RUN is the process you want to run and your process will be launched.
monitor. Specify the full path. Once this is in place, everything will be automated.
Every time your Pi boots, your process dashboard
MONITOR_SCRIPT is the monitor_process.py script we will update, and your process will launch and INITIAL STATE
just created. Again, specify the full path. be monitored.
Initial State is
an easy-to-
Before you run this script, youll need to make it an Dashboard and notifications use platform
e ecutable file. Run the following Each process that you monitor will add a data tile to for collecting
data from
your dashboard. This can be extremely useful if you connected
chmod u+x launch_process.sh have an application where multiple Pis are deployed devices and
across multiple locations. For example, if a Pi is used turning that
data into
To run the script: to monitor temperature in every room in your office dashboards,
building, you can quickly see the status of every Pi at a waveforms,
./launch_process.sh glance. You can enable and or email notifications no i ca ion ,
and more.
for each process status by going to the Triggers section initialstate.com
We could stop here and have a pretty good solution of your data bucket settings.

raspberrypi.org/magpi March 2017 61


F.A.Q. YOUR QUESTIONS ANSWERED
NEED A
FREQUENTLY PROBLEM
SOLVED?
ASKED QUESTIONS
Email magpi@raspberrypi.org or
find us on raspberrypi.org/forums
to feature in a future issue.

Your technical hardware and software problems solved

RASPBIAN
HOW DO I SWITCH INTERFACE?
Default interface

INTERFACES
You can select which interface to use by default from the
Raspberry Pi onfiguration tool under Preferences in the
program menu. t is set to boot to the desktop by default,
but you can also set it to boot straight into the command
WHAT INTERFACES CAN I USE line if it suits your usage.
ON RASPBIAN?
Switch while running
PIXEL You can switch between the desktop and L while the Pi
The graphical user interface G for Raspbian is the running. rom the command line, using the command
main way to use the Raspberry Pi. rom here you can startx will boot up the desktop. rom the desktop, you
access traditional browsers, office suite apps, and the can uickly switch to a command-line interface using
programming Es. This is the interface most people CTRL+ALT+F2. You can then switch back to the desktop
will use and the one which is recommended. interface with CTRL+ALT+F1.

Command line Custom interfaces


The classic command-line interface L re uires you ost custom interfaces, at least ones running directly
to input te t commands and theres very little in the from the Pi, re uire the desktop be running so it can use
way of graphics outside of A art. You can control the the graphical tools to display them. eep that in mind
Raspberry Pi a bit more directly from here, while still while making something that turns on automatically at
being able to code. boot. heck what is re uired for web interfaces.

Custom interface AUTO LOGIN


You can also create custom interfaces for your Raspberry
Pi weve seen Python-powered phone-style interfaces Defaults
you can use, and there are a few web-based interfaces y default, the Raspberry Pi will log you in whichever
around as well. The latter are very popular in T or way you boot up. or most uses this is fine however
robotics applications. there will always be cases where this is uite insecure.
As education is the main focus of the Raspberry Pi
Right Raspberry Pi
on a on ho ds oundation, though, this is why its turned on.
a he mpo an
asp an se n s
Change it
You can change whether or not the Pi automatically
logs in. Go to the Raspberry Pi onfiguration menu.
nderneath the option to change which desktop it boots
into, youll find the option to turn auto login on and off.

Password
or Raspbian, the default user name is pi and the
password is raspberry, so youll need to remember that
if you turn off auto login. f youre turning it off for
security reasons, its a good idea to change the password
as well. ind out how to do so here magpi.cc/2iqm9pO.

62 March 2017 raspberrypi.org/magpi


YOUR QUESTIONS ANSWERED F.A.Q.

FROM THE RASPBERRY PI FAQ


RASPBERRYPI.ORG/HELP
What size SD card do I need for the Raspberry Pi? Will it run Android?
Whether you want to use the NOOBS installer or a No. While a version of Android can be found in the
standalone distro image, the minimum size SD card we forum, it is not stable enough for everyday use. There
recommend is 8GB. This will give you the free space you are no plans to continue working on it, since Android
need to install extra packages or make programs of your does not provide any enhancement to educational
own. The original Raspberry Pi Model A and Model B require purposes that are not already fulfilled more readily
full-size SD cards. The newer Raspberry Pi Model A+, Pi with existing software: we see it as a platform for
Model B+, Pi 2 Model B, Pi Zero, and Pi 3 Model B require consumption, not for creation.
microSD cards.
Will it run [insert name of program here]?
What size SD cards can it support? In general, you need to look to see whether the program
We have tried cards up to 32GB, and most cards seem you want can be compiled for the ARMv6 (Pi 1) or ARMv7
o or ne ou can al o a ach a S ic or S har (Pi 2/3) architecture. In most cases, the answer will be
drive to provide extra storage. e S eci c rogram are i cu e on our orum, o
you might want to look there for an answer. Ultimately,
What happens if I brick the device? though, nothing beats grabbing a Raspberry Pi and
ou can re ore he e ice re a hing he S car n ing ou he an er hrough irec e ing

raspberrypi.org/magpi February 2017 63


W
Feature PI ZERO W

PI
ZERO
Petite, efficient, and well connected.
Meet the latest member of the Raspberry Pi family

he big news this month is A third of the size of a Raspberry Squeezing wireless networking
T the introduction of a new
computer model from the
Pi 3, the Pi Zero W still has enough
power to run a full operating
onto a Pi Zero board hasnt been
easy, and the way Raspberry
Raspberry Pi Foundation. system like Raspbian. Pi went about it has shown
The Pi Zero W is the same small This update to the Pi Zero considerable ingenuity. The new Pi
revolutionary board that rocked has the same small form Zero case is also a thing of wonder.
the maker community, but it factor, but crams in wireless But its what you can now do
now packs built-in wireless LAN LAN networking too. With the Pi with a Pi Zero W that is going to
networking and Bluetooth. Zero W, you can connect directly make a difference.
It also comes with an incredible to a local wireless network without The Pi Zero W can connect
new case. With switchable lids, having to attach a USB dongle. automatically to a local network.
this enables the Pi Zero W to The Pi Zero W gets the With its small size and low-energy
function as a camera, provides same wireless networking footprint, its ideal as a node for
access to its GPIO pins, or lets it act capabilities first deployed projects around the home, as well
as a secure node. on the Raspberry Pi 3. as IoT and wearable projects.

64 March 2017 raspberrypi.org/magpi


SUBSC
PI ZERO W Feature
TODAY RIBE
A ND GET

FREE
A

PI ZER
OW
AND C , CASE
ABLES
PI ZERO W
!
PAGE 2
8 Technical Specifications
Dimensions:
65mm 30mm 5mm

SoC:
Broadcom BCM2835

CPU:
ARM11 running at 1GHz

RAM:
512MB

Wireless:
2.4GHz 802.11n wireless LAN

Bluetooth:
Bluetooth 4.1 LE

Power:
5V, supplied via micro USB connector

Video & Audio:


1080P HD video & stereo audio
via mini-HDMI connector

Storage:
MicroSD card

Output:
Micro USB

GPIO:
40-pin GPIO, unpopulated

Pins:
Run mode, unpopulated; RCA composite,
unpopulated

Camera Serial Interface (CSI)

Price:
US UK EU

$10 9.60 11
EX-TAX INC VAT INC VAT

raspberrypi.org/magpi March 2017 65


Feature
News PI ZERO W

THE
he technology found in
T the Pi Zero W is similar to
that of the original Pi Zero,
only now everything has had
to make space for an incredibly

BOARD
smart radio antenna. This
design enables the minute
Pi Zero board to pack a complete
wireless LAN and Bluetooth
connection module.
The Pi Zero W contains all of
the technology from the original
Pi Zero, but with a slightly
redesigned board.
The technical surge forward is
thanks to the presence of 2.4GHz
802.11n wireless LAN and Bluetooth
Up close with the technology packed onto a Pi Zero W board

01

06

11

07 04 02

66 March 2017 raspberrypi.org/magpi


PI ZERO W News
Feature
4.1 LE. These make the Pi Zero W To hook up stock cables, youll to the Pi Zero W. Its especially
much more accessible to makers. want a Raspberry Pi Zero Adapter pertinent thanks to the new case.
It reminded us how packed Kit (4, magpi.cc/2kPZNzn) to get The processor remains a
with technology the Pi Zero is. the most from your Pi Zero W. Broadcom BCM2835 containing
It features a full 40-pin GPIO

The Pi Zero W is a full computer,


header (unpopulated, so you will
need to solder the pins on yourself).
Two extra TV pins are used
to connect the Pi Zero W to an
RCA television, while two pins
capable of running Raspbian and
marked RUN can be used to plug
in a reset button.
other Linux operating systems
A single USB On-The-Go
connection allows you to hook up A CSI connection supports an ARM11 running up to 1GHz. The
devices to the Pi Zero W, and the the Camera Module v2 Pi Zero W is a full computer, capable
mini HDMI socket connects the (magpi.cc/28IjIsz). This adds a of running Raspbian and other
board to monitors and TVs. Sony IMX219 8-megapixel camera Linux operating systems.

01. GPIO header 06. MicroSD card


Pi Zero W has the same microS car i u e o
40-pin GPIO header as the provide the storage for the
larger Raspberry Pi models, Pi ero
but its unpopulated. Adding
pins to the Pi Zero W board is 07. Mini HDMI
a grea r ol ering ro ec mini connec ion
i u e o connec he
08 02. Micro USB Pi ero oa or moni or
ingle micro S or i
u e o ro i e connec i i 08. RUN pins
09 Only now you dont need to he o R in can
a a S i i ongle, o be used to wire up a
i ll e ea ier o connec u a reset button.
keyboard and mouse.
09. TV pins
10 03. Micro USB power he in can e u e
he econ micro S or to add an RCA video
is used to provide power connec ion Per ec or
to the board. hooking up a Pi Zero W to
older television sets (for retro
04. Wireless LAN gaming er ec ion
This triangular shape is
used to boost the wireless 10. Camera Module
connec ion he ignal camera or a a e o
05 ounce aroun he riangle he Pi ero an remain
an connec o he oin a on the Pi Zero W. The Camera
the bottom (before being fed o ule i igh l in egra e
up the pipes to the side). with the Pi Zero thanks to the
ne ca e
05. Bluetooth 4.1
he Pi ero al o connec 11. Broadcom BCM2835
o lue oo h hi hi roa com C
connec i i ma e i ea o SoC i he hear o he Pi
03 hoo u irele e ice an ero con ain n R
hare le i h he oar CP running a u o

raspberrypi.org/magpi March 2017 67


Feature
News PI ZERO W

BEHIND THE
PI ZERO W
We chat with Roger Thornton, principal hardware engineer at the Raspberry Pi Foundation

oger Thornton is the but we were getting better at 01. Ground plane
R person in charge of the
Raspberry Pi Zero W
squeezing features onto products,
so we did a little playing around
hi ree ace i u e o
in erac i h he ra io a e
project: developing the new board with the design. According to he re ona e in hi ca i a
has been a labour of love for him. Roger, there was a lot of pushing u he righ re uenc
The first Raspberry Pi product and shoving to fit all the
to gain wireless networking components into a restricted area, 02. Capacitors
was the Raspberry Pi 3 (released and onto one side of the board. At the lower part of the
shortly after the original Zero). The Raspberry Pi 3 layout was ground plane sit two
Developing this product gave based on a two-sided Broadcom ca aci or he e ca ure
Raspberry Pi the experience reference design, with a chip the radio signal.

he e e c e e ns
Its a really neat design
they needed to bring wireless antenna. In contrast, the Zero W
networking to the Zero. uses a single-sided layout
There was no easy way the with a PCB antenna; this is the
wireless layout from the larger trapezoidal shape between the
Raspberry Pi board would fit on mini HDMI and micro USB sockets
the diminutive Zero. We thought on the bottom edge of the board.
it was impossible, muses Roger, The Raspberry Pi 3 antenna is 02 01
a surface-mount component,
explains Roger, whereas the
Zero W antenna is a resonant
cavity which is formed by etching
away copper on each layer of the
PCB structure.
The technology is licensed from
a Swedish company called Proant
(you can see the credit on the
reverse of the Zero W board).
Theyre very clever boffins,
says Roger. Its a really
neat design.

68 March 2017 raspberrypi.org/magpi


PI ZERO W News
Feature

SET UP A PI ZERO W

>STEP 01
The white text is added to the PCB using a silk-screen technique.
These markings are used to provide information and branding for the board
Download Raspbian
Youll need the latest version of Raspbian with PIXEL
from raspberrypi.org/downloads a e ure ou ge
he mo recen u a e, a he la e er ion a Pi
ero u or Pu our Pi ero in i e i ca e

>STEP 02
Set up the Pi Zero W
la h he microS car an in er i in o our Pi
ero ea S n he o a a or o connec
our e oar an mou e o he micro S or
mar e S chain he mou e ia a e oar S i
o i le e a mini o ca le or a a er
o connec he Pi ero o a moni or

The intelligent layout


enables all the circuitry to
be placed on one side of the
PCB, keeping the cost down

>STEP 03
Power on
Connec a o er u l o he micro S or
marked PWR. The Pi Zero W will power up into
Ra ian i h P L Clic on he irele icon in he
o righ o he creen o loca e our local irele
ne or n er our irele a or o connec he
Pi ero o he ne or

raspberrypi.org/magpi March 2017 69


Feature
News PI ZERO W

PI ZERO W
CASE
A whole new way to hold your Raspberry Pi
aunching alongside the Pi
03

L Zero W is a new case.


The design is similar to
01. Pi Zero
he Pi ero oar nugl in i e
the stunning Raspberry Pi 2/3 case. he ca e ole ro i e or acce
The same design team, Kinneir
Dufort, is responsible for creating
the Pi Zero W case. 02. Clips
Its an amazing case which he Pi ero cli in o he ca e
shares a lot of design DNA with the u ing our ro ru ing cli na 04
original. It also comes in the same ecurel o he o om o he ca e
red and white colour scheme.
The case is composed of two
parts: a red base and a white lid.
They clip together to contain the
05
Pi Zero. On the rear of the red case
is a cut-out to allow room for GPIO
pin edges and solder.
02
The white cover is
interesting. You dont
01
get just one lid; three
are available
The first is a solid
cover that keeps
your Pi Zero W
components secure.
The second has a
rectangular slot enabling
you to access the GPIO pins. 04. Camera Cable
The third is the most striking. he Pi ero ca e come i h a Pi ero
This cover contains a holder for camera ca le i h hi , ou connec he
the Camera Module. The camera Camera o ule o he Pi ero oar
clips onto the inside of the lid, and
a perfectly sized gap enables it to 03. Camera Module
take photos through the cover. he Camera o ule i a ache o he 05. GPIO header
Each Pi Zero W case comes with in i e o he camera ca e li Li e he Pi he ca e li are in erchangea le, an one
all three covers, so you can use it ero oar , i na in o lace i h he li ena le irec acce o he P in
whichever way you choose. our la ic ro ru ion on the Pi Zero W.

70 March 2017 raspberrypi.org/magpi


PI ZERO W News
Feature

THREE COVERS

Secure cover GPIO cover Camera cover


he a e co er cli on o he he P co er ha a cu ou ec ion e hin he camera co er i he
Ra err Pi ca e, com le el ha ena le ou o acce he ar a rac ion hol he Camera
sealing up the Raspberry Pi. GPIO pins without removing the lid. o ule in lace an re em le
Per ec l ha e hole on he i e no her cu ou in he a e allo a igi al camera e can ai o
o he ca e ena le ou o acce he room for solder and pin edges (on ee ha Pi ero ro ec he
S an or ma e or he he re er e o he oar , u coul communi ma e i h in egra e
cu e com u er aroun e u e or P acce oo irele an camera unc ionali

raspberrypi.org/magpi March 2017 71


Feature
News PI ZERO W

PI ZERO W
PROJECTS
Five great project ideas for you to build with your new Pi Zero W

AMAZON
ECHO A
mazon Alexa is an
intelligent assistant
making a lot of waves in
Add a speaker to your Pi Zero W
the tech community. Amazon sells using a Speaker pHAT
two Alexa products: the Amazon
Echo and Echo Dot. portable Amazon Alexa device. All USB microphone using the USB to
Amazon has also created a you need are some speakers and USB On-The-Go adapter.
homebrew version of Alexa for a USB microphone. Previously, you also had to
the Raspberry Pi. Pimoronis Speaker pHAT add a button to the Raspberry
Now that the Pi Zero W has (12, magpi.cc/2kXdZsE) is a Pi version of Alexa, but a recent
wireless LAN, its a perfect neat solution. Combine it with a update has added an always on
mode to the Raspberry Pi build.
Alexa now listens for a vocal
cue, such as the word Alexa
and then starts monitoring.
You can change the vocal signal
to any name of your choosing;
computer is a popular choice
for Star Trek fans.
A GitHub repository has all the
information you need to set up
Amazon Alexa on a Raspberry
Pi (magpi.cc/2kXrdW2).
There is a complete guide here
Use a speaker and (magpi.cc/2kXfPcO). Frederick
microphone to turn your Pi Vandenbosch has written a guide
Zero W into a hands-free
Amazon Alexa Echo to installing Alexa on a Raspberry
Pi Zero (magpi.cc/2kXkY4A).

72 March 2017 raspberrypi.org/magpi


PI ZERO W News
Feature

WEARABLE MOTION-
CAMERA SENSING
he Pi ero ca e i h camera
li len i el er ec l o
CAMERA
The low power draw of the Pi Zero
ma ing a mini camera ou coul
W also makes it ideal for use as a
a a u on o he ca e u ing
ecuri camera, or a an ou oor
Sugru o uil a igicam, or u e a
il li e camera oo i u o a
lue oo h camera u on a oun
Zero LiPo (magpi.cc/2kXI8YW)
on el e ic
and youll get a steady stream of
We also like the idea of making
o er Connec he Pi ero camera
a eara le camera a rui ha a
an u e he irele L o en
grea u orial on crea ing hi ro ec
aler hen i e ec mo ion
a rui u e a uni ue rin e
a e a loo a ar e ro ec
ca e, u no ou can im l u e he Pi
(magpi.cc/2kXznhq).
ero ca e magpi.cc/2kXASMw).

FILE
SERVER
The low power draw of the
Pi Zero W and its wireless
connec i i ma e i i eal or
u e a a connec e no e
some storage and turn it into
always-on network storage.
This has always been a great
Ra err Pi ro ec , u i i
e eciall ea i h he ero
uil in irele connec i i

SMART CAR DASH


he Pi ero i ea o moun on a car a h oar u ing a ero ie
mount (magpi.cc/2kXIsa2 ou can u e i a a a h cam o recor
oo age i h he irele L , ou can connec o a er onal ho o
rom our mo ile hone Con i er chec ing ou he o en ource
ri e ro ec or o are magpi.cc/2lnBwjt).

raspberrypi.org/magpi March 2017 73


Review KODI 17.0 KRYPTON

Maker
Says
An award-
winning
free and
open-source
software
media centre
Team Kodi

KODI 17.0
KRYPTON
The premier HTPC software gets an update with a new look
and some new tech behind the scenes
new Kodi release is Bare-bones being pretty much the same means

Related A always cause for a little


celebration. Its one
Skins and interfaces can be changed,
though, so before we delve into that
they did their job. Its a good thing.
One thing we did notice was that
OSMC of the most successful, long- lets talk about the video playback, the video output from the HDMI
OSMC runs a running pieces of open-source as it has had an update. worked a little better with the HDMI
Kodi back end, media software of any type, Long story short, its pretty much switcher in our setup: in earlier
but it uses its
and it powers so many other the same. Additions to the new versions, audio from a Pi using
own interface
and some other popular media centres. The latest video player software include video Kodi would sometimes hiccup as if
optimisations release of Kodi has some minor stream selection the different the audio stream itself just wasnt
that the
improvements behind the scenes, angles button on your old DVD making it to the TV. We didnt
makers believe
or e er with an overhauled video playback remote) and the ability to better come across this issue with Kodi 17.
engine which should benefit these hand off video playback tasks to Theres still a little trouble playing
other media centres in the long add-ons. This isnt something video encoded with 10-bit colour,
run. However, one of the biggest youre going to notice day-to-day, though, with no improvements
things that users of stock Kodi but the real achievement is that the over the previous release. Thats
will notice is that theres a new previous system was completely more of an issue with a lack of
FREE
default skin that replaces the replaced with the new one without hardware decoding for 10-bit on
osmc.tv
venerable on uence. collapsing Kodi in the process: it the Pi than with Kodi.

74 March 2017 raspberrypi.org/magpi


KODI 17.0 KRYPTON Review
kodi.tv

Free

Left Add-ons
can now also
be found in a
dedicated add-
on category,
though some
will still show up
in the relevant
media categories

We also noticed that, while still said, you cant change the order
supposedly supported, AirPlay was in which theyre listed and, for
working worse than ever. Before, a device youre probably mostly
an Apple device could at least see using to play back video, having
the Kodi box although weve never the pure video option last in the
actually seen AirPlay working list is not very useful.
between the two. Now, it simply It runs beautifully on the
doesnt show up. It would be good if Raspberry Pi, though, with smooth
the Kodi guys could get that working transitions between menus and the
consistently, but its a minor issue. same basic structure as other skins.

It runs beautifully on the you prefer). Importantly, it still runs


really well on a Raspberry Pi. We did
o e The new
interface is arranged
much better than

Raspberry Pi, with smooth most of our testing on a Raspberry before, and even
has symbols to
Pi 2, which is more than likely the signify if you have

transitions between menus


backbone for any home theatre watched or are
part-way through
setup, and it worked as well as ever, a video
so theres no worries there.
New look The settings menu is generally ts definitely a worthwhile
That brings us to the new interface, more useful and easier to navigate upgrade over previous versions,
Estuary. Its almost completely as well, although it does mean some so if youre a LibreELEC user
different to the old on uence, extra add-on settings now live away you should be on the lookout for
with a greater focus on using from the settings menu in an all- version 8 when that comes out.
the scraped metadata from your encompassing add-ons field. Other HTPC OSes may be a little
content and optimising the space slower to integrate the new stuff,
to display said content. Inspiration Future-proof so you shouldnt have to worry
has definitely been taken from This new version of Kodi seems about it just yet.
modern smartphone UI and UX like a glimpse of whats to come.
design, which makes sense as With a more robust back end and a Last word
the way we use technology has new front end to go with it, were
changed over the years. You can probably going to start seeing a
A good upgrade to an already great piece of
so a e s o s s ne on he asp e
still have your basic file selection few more noticeable changes in
so he e s no need o o e ha o home
if you prefer, though, and you the next version of Kodi. The new
hea e o e he
actually get more control over interface is great and a welcome
which categories are listed on change over the old on uence one
the home interface. That being (although you can still install it if

raspberrypi.org/magpi March 2017 75


Review PI METRE
bit.ly/pimetre

FREE

Maker
Says
Want
to lose
the Xmas
dinner?
Join Pi Metre
Pi Metre

PI METRE
rat h owered tne a
ow doe t hel ou et t
or the a err

he Pi Metre is a simple repetitive. nce the countdown is runs on cratch, it will use up

Related T fitness app created for


Raspberry Pi in cratch. t
done, it triggers an alarm to let you
know your workout is over.
a lot of resources. ts uite fun,
though, and a nice little project
was designed completely on cratch
MY
FITNESS 2. , so its only recently been able You can create a portable Pi
PAL to work widely on Raspberry Pis

While
thanks to the addition of lash to setup to take it with you to the
hromium. Luke astle, the creator
gym or while running
MyFitnessPal
is great, it of Pi etre, suggests also making a
doesnt run on
portable Pi setup to take it with you
the Raspberry
Pi. The app is to the gym or while running, but it Workout times are then kept in to make so you can create your
available for iOS would work just as well at home. your locker, which can be accessed own portable workout countdown
and Android.
Pi etre works by asking you to with L. nfortunately, theres and tracker.
first start a workout. You do this by no way to differentiate between
pressing E and entering the number different types of workouts, and it
of seconds you plan to work out wont calculate a calorie count for Last word
this does slow down the process cardio. You get an account for the
A very simple workout app
a bit, as you need to transfer the app as well, with the idea that you
which is much better as a
minutes you plan to work out into can save your workouts to refer
full Pi project than just the
seconds. The app will then count back to them youll need to make
software on its own. Youre
down the seconds and play an sure to log off, though, to save the po a e e o ha
appropriate workout mi for you workouts properly. smartphone app, though.
to e ercise to. t lasts just over five ts a very simplistic app
FREE
minutes before looping again, so and could do with a fair few
myfitnesspal.com
for longer workouts it may get a bit e tra components. Also, as it

76 March 2017 raspberrypi.org/magpi


SPEAKER PHAT Review
magpi.cc/2kXdZsE

12 / $15

Maker
Says
Turn
your Pi into
a Lilliputian
ghetto
blaster
Pimoroni

SPEAKER PHAT A tiny speaker board for adding sound to projects


imoronis latest pHAT may up a separate powered speaker. command. It should then work as
P not sound all that phat,
but it does offer a neat
Other use cases include a retro
gaming handheld or by pairing
the default audio output, although
you may need to reboot the Pi first.
way to quickly add audio to your it with a mini microphone a DIY We tested it out with aplay and
projects. This Pi Zero-sized board
manages to cram in a mini speaker,
I2 A , and mono amplifier. We
It is nevertheless a great way
of adding audio to projects
Related
particularly appreciate the 1980s
boombox-style artwork on the
top of the board, complete with a voice assistant based on Amazon mplayer from the command line,
MINI ten-LED bar graph. Alex or the like. as well as Sonic Pi and YouTube
PORTABLE ince the 8 speaker has just The Speaker pHAT comes in kit in the Chromium web browser.
SPEAKER 2W of power, you wont e actly form, requiring about 30 minutes to Theres also a library for manually
Powered or be rocking the neighbourhood. It assemble. First, you need to screw controlling the LEDs if you want.
charged via USB
and connecting sounds more like a tinny transistor the speaker to the rear of the board,
to the audio radio than a ghetto blaster, using tiny spacer nuts, which is a Last word
out port of a offering little in the way of bass little fiddly. Then its time to get
standard Pi (but Not one for audiophiles,
not Zero), this (and obviously no stereo), so its the soldering iron out. Soldering
mini speaker certainly no rival for high-quality the speakers two terminals to the he pea e p o es
packs a punch. audio add-ons from the likes of board contacts with the supplied
rudimentary sound quality
with little power. It is
IQaudIO and JustBoom. But then 24AWG wire is a bit awkward and
nevertheless a great way of
thats not what its intended for; you need to use tweezers to hold
adding audio to projects, with
instead, it should prove suitable for the bare wire as it gets hot! Its
its tiny Zero-size footprint and
projects that require audio output then simply a matter of soldering
no need for a separate power
for notification sounds or speech. on the 40-pin female header and
supply. It looks cute too.
Indeed, it would be ideal for the the pHAT is ready to use.
12 / $15
digital whoopee cushion in this Installation of the software is
magpi.cc/2diQyHq
issue, precluding the need to wire achieved with a single terminal

raspberrypi.org/magpi March 2017 77


Review CLUSTER HAT

Right The Cluster HAT sits on top


of a Raspberry Pi 2/3 board

Maker
Says
Ideal tool
for teaching,
testing or
simulating
small-scale
clusters
pimoroni

CLUSTERHAT Make a cluster computer with a Raspberry Pi and four Pi Zeros


uilding a computer On top of all that, it can be and four official micro cards
B cluster is one of the most
impressive Raspberry
expensive to run multiple full-
sized computers. Energy costs
it comes to 102. Thats by far
the cheapest cluster computer
Pi projects. And being able to quickly ramp up when you're you will find on the market. or

Related
program cluster computers is one running a cluster. those looking to get into cluster
of the most highly valued skills in computing, this is a game-changer.
the world of big data. Hat on it
PICO 5 A cluster is a set of computers The Cluster HAT removes the Getting started
STARTER networked together and used as e pense and effort re uired Setting up the Cluster HAT
KIT a single system. Each computer to create a cluster. This lower hardware was an absolute
PicoCluster
has a range of (or node) is scheduled to work barrier to entry makes it a lot breeze. Screw the four pins on
cluster kits for a on the same task, controlled by a easier to get on with the more to a Raspberry Pi 3 board and
range of boards master computer. important act of learning cluster insert the supplied USB cable,
(including the
Raspberry Knowing how to manage, computing technologies. then attach the HAT (wiring the
Pi). They use and use, clustered computers The HAT sits on top of cable between the board and HAT).
Ethernet and supercomputers is a pretty a Raspberry Pi 2/3 and you slot four Attach the USB power to the HAT
networking
and Raspberry valuable skill. Its also one of the Pi Zero computers on to the HAT and then slot on the four Pi Zero
Pi 2/3 boards, areas at the absolute forefront of (via the USB connection). boards. The whole setup took less
but are more computing technology. A USB cable is run from the than five minutes.
expensive.
ut it has always been difficult Raspberry Pi to the HAT to provide Software is well handled too. A
to get started. Traditionally, cluster power to the four Pi Zero boards. dedicated site (magpi.cc/2jHMeQq)
computing has been an expensive The latter are controlled directly provides image files for the
hobby. You need lots of computers via the GPIO pins. controller (the Pi 2/3) and one
(preferably identical) and a You need a microSD card for each image file for each Pi Zero board.
network controller and the skill to Pi Zero, and one for the controlling The Cluster HAT version
network them all together. This Raspberry Pi. o thats five of Raspbian boots into the
difficulty is before you even start cards in total. command line, but offers a
189 / $239
learning how to manage several We costed up a Raspberry Pi, script for controlling the cluster.
magpi.cc/2kAcJLG
computers working in tandem. Cluster HAT, four Pi Zero boards, or e ample

78 March 2017 raspberrypi.org/magpi


CLUSTER HAT Review
pimoroni.com

28 / $35

clusterhat on all the cluster of four Pi Zero boards Python, Java, SQL (and relational Above Left The
soc e s on
ran at roughly half the speed of database techniques). Youll also the Cluster HAT
This command-line code a single Raspberry Pi 3 board. need a good understanding of p o de connec on
for four Pi
switches on all four Pi Zero The slower speed makes sense the Linux command line. e o oa ds
boards. You can also control them when you think about it. Nick ortunately, starters are
separately, using p1-4. uch as e plains This is partly down not alone. Theres a vibrant Above Right The
Raspberry Pi 3
to the faster individual cores in Cluster HAT Google Groups board board is the only
clusterhat p2 off the Pi 3, but also the node-node (magpi.cc/2jHYqk6). There are de ce s n
he ne e o
clusterhat p2 on communication is obviously lots of resources and projects o e s sed
a great deal faster within the Pi 3 being shared by the community. o hoo p he
Zero boards
It takes a few moments for SoC compared to communicating One book that is recommended
each Pi Zero to power up and load between separate Zeros with reading is Raspberry Pi Super
its software, at which point itll Ethernet-over-USB. Cluster (16.78) by Andrew K
appear in i on . So youre not building a faster Dennis (magpi.cc/2jHZyV8).
Access each node using SSH Raspberry Pi. However, we Whatever resources you choose,
enabled by default dont think this matters. The we think the Cluster HAT is a great
aim for most people will be to resource for starting distributed
ssh pi@p1.local build a low-cost and relatively computing. Its small, cheap, and
easy-to-assemble cluster for easy to set up.
Here you can use i on to educational purposes. You have to leap a lot of hurdles
find the P address luster AT Once created, you can start to to learn cluster computing.
has assigned to the Pi Zero experiment with the concepts But Cluster HAT removes
(under USB Ethernet). behind cluster computing. The the e pensive and difficult
Cluster HAT is ideal for teaching, hardware build. Its then up to
Pi computing learning or developing cluster you to learn the sophisticated
One thing this isnt, though, is a computing ideas. coding techniques.
supercomputer. Theres a good set We suspect it will also appeal to
of benchmarks by Nick Smith on developers who have access to larger Last word
Climbers.net (magpi.cc/2jKlq23). cluster computing systems, but
Nick used iperf to test the not all the time. You can test and A compact, neat and cost-
network-over-USB connection and run code on the Cluster HAT, then e ec e so on o dn
found it comparable to Ethernet. migrate it across to a larger system. a cluster computer. The end-
The slower speed of the Pi Zero p od c m h ac a po e
boards compared to Raspberry Pi 2/3 Distributed computing s pe ec o each n
and ea n n d s ed
boards is much more pronounced. Cluster computing is not a game
comp n concep s
Nick benchmarked the system for beginners. Realistically
using HPC Challenge Benchmark speaking, prospective learners
(magpi.cc/2jKpH5C). He found will need a working knowledge of

raspberrypi.org/magpi March 2017 79


Review BOOKS

TECHNICAL PYTHON, PYGAME


AND RASPBERRY PI
and programming styles who
knew pencils were object-oriented?

BESTSELLERS
GAME
then followed by programming
basics, all with reference to parts
of typical games. The writing style

SEBTEL PRESS and short chapters give a pleasing

Dr James Stones Tutorial books for DEVELOPMENT forward momentum, and were soon
at our first game.
Sebtel make technical, mathematical Author: Sloan Kelly After due recognition to design
subjects easily understandable. Publisher: Apress and testing, theres Bricks, a
Price: 14.99
classic Breakout-style game;
ISBN: 978-1484225165

BAYES RULE: magpi.cc/2lFOdGy


always a good teaching example,
with movement and collision.
A TUTORIAL INTRODUCTION Writing games Building on this example, object-
TO BAYESIAN ANALYSIS remains one of oriented programming is explored
the best ways to fully; theres a lot here, but some
Author: Dr James Stone
motivate learners of it gets reinforced in the next
Publisher: Sebtel Press
Price: 14.95 through some of the challenges game, nake. is introduced
ISBN: 978-0956372840 of learning to code. The Pygame for Robots. Final chapters cover
magpi.cc/2lFLqx5 library provides enough abstraction sound and finite-state machines,
to let the reader produce working wrapping them up with a game of
The revival in interest in Bayes
theorem studying probability games relatively easily, without Invaders. Not always easy going,
based on information we have hiding away anything of real but this well-paced introduction
has found a use in many educational value. arketed at to programming will rapidly carry
el hi i o i l he e
general in ro uc ion o he el Pi users, ellys fine tutorial can newbies a surprisingly long way.
Recommended. be used on any computer where
Pygame is installable.

INFORMATION Hello World is preceded by Score


a useful introduction to data types
THEORY:
A TUTORIAL INTRODUCTION
THE BIG BOOK OF instrument builds. After sewing

MAKERSPACE
circuits, more electronics; the
Author: Dr James Stone
supply listings are localised to US

PROJECTS
Publisher: Sebtel Press
Price: 16.95 suppliers, but it shouldnt take too
ISBN: 978-0956372857 much effort to track things down
magpi.cc/2lFOwRp
wherever you are, locally
Authors: Colleen Graves, as well as through the
An outstanding introduction Aaron Graves
that can pull in the general
internet. Projects are
Publisher: McGraw Hill
reader with dry humour, but Price: 15.99 followed by challenges,
has the textbook rigour needed ISBN: 978-1259644252 suggesting you step beyond
by programmers looking for
magpi.cc/2lFLiNM following instructions and
a fuller understanding of this
essential subject. make projects your own.
Learning programming Every maker needs some

BAYES RULE has well-established


routes, such as Hello World,
of these projects in her
armoury, ready to build with

WITH PYTHON loops, and variables, but whats the


beginner maker to do? The Graves
the next person who asks whats
it all about, then?. If youre new to
Author: Dr James Stone
excellent collection of projects will making, there are plenty of cheap
Publisher: Sebtel Press
Price: 19.95 build up your skills, then challenge and easy projects to build skills and
ISBN: 978-0993367939 you to go further. Hello World confidence. any of these will be
magpi.cc/2lFLqx5 here is the Brushbot Warrior, great to run on makerspace open
repurposing everyday equipment, days. And if youre an old hand, the
The Bayes book, with inline
Python code examples of the
then proceeds via Scribble Bots to challenges and harder projects are
probability problems. Also a host of other moving projects. well worth trying out.
available in R and Matlab After circuits, coding, and
a our er han or hel ing
smartphone projects (DIY
to work through tougher
examples in Jupyter Notebook. projector), were back to non-tech Score
skills, with some great musical

80 March 2017 raspberrypi.org/magpi


BOOKS Review

APACHE SPARK computing, to machine learning ESSENTIAL READING:


R FOR STATS
and message queues. RDDs are

IN 24 HOURS in-memory data structures which


are part of Sparks speed and While Python nips at Rs heels, R remains great
efficiency the park ore for statistics and many general data tasks.
Author: Je re en
API is the other key to
Publisher: SAMS
Price: 27.99 Sparks success, respecting
a strongly functional style
The Book of R
ISBN: 978-0672338519
Author: Tilman M Davies
magpi.cc/2lFUB0t of programming. Publisher: No Starch
R, SparkR with RStudio, Price: 39.99
Apache Spark is and Scala get chapters, and ISBN: 978-1593276515
an essential tool its great to see functional magpi.cc/2lG0Ykf

for tackling big programming in Python Combines a programming tutorial with


data, providing getting treated as well as an introduction to statistical methods,
an API for data in Scala; however, that succeeding well at both tasks. Strongly
recommended for newbies.
processing in Scala, Java, R, or chapter also squeezes in
Python. Avens book focuses IPython and Jupyter Notebooks, A Course in Statistics with R
on Python and, beyond a basic showing the limitation of the Authors: Prabhanjan N Tattar,
comfort in that language, assumes 24 hour-style chapters. Final Suresh Ramaiah,
no particular knowledge on the chapters on administering, B G Manjunath
part of the reader. It introduces extending, monitoring, securing, Publisher: Wiley
Price: 70.00
everything from Scala to Hadoop and improving the performance of
ISBN: 978-1119152729
before tackling a range of Spark Spark give the reader everything magpi.cc/2lFV5Uj
topics with Python examples. she needs to go further a solid
The tools of the trade for big data foundation for Spark with Python. Despite occasionally idiosyncratic
English, this is a wonderful deep dive into
and Spark are introduced one by statistics strongly integrated with R code.
one, from adoop and apReduce,
through Resilient Distributed Score Efficient R Programming
Datasets (RDD) and cloud
Authors: Colin Gillespie, Robin Lovelace
Publisher: OReilly

A BEAUTIFUL u hemin returns to the same


theme from a different angle
Price: 28.50
ISBN: 978-1491950784

ANARCHY you have a creative urge inside magpi.cc/2lFOUzE

you, so stop making excuses, Essential next step in learning R


and start facing up to the e cienc in rogrammer our ime, an
eliminating bottlenecks through deeper
Author: David DuChemin difficult journey to writing
language understanding.
Publisher: Rocky Nook that novel, starting that
Price: 14.99
ISBN: 978-1681982342
business, or painting that Statistical Shape Analysis:
magpi.cc/2lFTBt9
picture Living a great With Applications in R
story is much harder than Authors: an L r en, Kan i ar ia
watching a great story. Publisher: Wiley
A very personal This is a book about Price: 65.00
manifesto, written choices; those we make or ISBN: 978-0470699621
magpi.cc/2lFK1GK
for anyone with a those we abdicate all have
calling to make, an effect on our creations. Statistical methods applied to shape
whether its a It gets the reader to ask analysis. Great for biologists, but strong
mathematical treatment and accompanying
painting or a great business. themselves questions about code expands possible applications.
Were all creative, says the what they want in life. What
author, but weve allowed art dreams do you still hold onto? Categorical Data Analysis
to co-opt the word. any take This call to colour outside by Example
default choices rather than the the lines, and u hemins Author: Graham J G Upton
difficult path of trying to write questioning, have a way of getting Publisher: Wiley
that novel they know they have under your skin and making you Price: 80.50
in them, or set up that business. ask those difficult uestions. ISBN: 978-1119307860
magpi.cc/2lG693O
This is a call to step out of the
comfort zone, and face the fear.
Score
Concise introduction to dealing with
Praising bad ideas, constraints, ca egorical a a i h u or ing R co e
which will help the general data scientist.
and the art of exclusion,

raspberrypi.org/magpi March 2017 81


Community

FOSDEM
FEATURE

EUROPES INCREDIBLY BIG FREE


SOFTWARE DEVELOPERS MEETUP
In medieval times, 10,000 was the population of a major city. For one weekend each
February, its the number of free software developers attending FOSDEM in Brussels

en thousand attendees is in English, and many Americans The project featured in the
T a guesstimate, as FOSDEM
is an entirely free event
y in to attend or speak, the
corridors buzz with geeky chat
design track, as its usability
research was profiled. t was also
with no registration. Its certainly in Flemish and French, and featured in a talk on OpenScore,
very big! Now in its 18th year, Scandinavian and Slavic languages which is crowdsourcing MuseScore
FOSDEM has been referred to as a abound. This is Europes developer digitisation of out-of-copyright
week-long event happening over meetup; it exists because its sheet music to build a vast library
a weekend. Indeed, it feels very important for free and open source of semantic score data, open for
concentrated, with dozens of talks software developers to be able to analysis with tools like MITs
happening at once (610 speakers meet in real life. music21, as well as freely accessible
in total), almost all rooms full to With 55 tracks over 30 rooms of sheet music. Partners for OpenScore
capacity, and busy project stands the Universit Libre de Bruxelles, include the IMSLP public domain
spread over several buildings. youll find not just your favourite sheet music library: imslp.org.
The conference runs on projects, but many new discoveries. Good as it was to see some old-
goodwill, volunteer energy, and This years event included languages school analogue synths in the slides
a modest amount of discreet from GNU Guile to Python, of Python developer Yann Gravrand,
sponsorship plus coffee and technologies from containers to it was even better to hear a live
Belgian beer). While all talks are microkernels, and hardware projects demo of them being controlled via
covering everything from the Python by his old MIDI drum pads,

OPENING
embedded space to chip designers. and the mido and portmidi libraries.
Add in documentation, design, More exotic languages were

THE LEDGER and community management,


and FOSDEM has the entire free
used by Belgian digital artist
Franois Zajga in the Open
software and open hardware Game Development devroom. He
Free software developers dont just pick the ecosystem present. demonstrated sounds from the
un u So are ree om Con er anc Pure Data language, with Ogre3D
was discussing its work on new ledger- Introductory music visuals on the Polymorph video
a e accoun ing o are or no or ro Theres no room on these pages game platform, suitably impressive
organi a ion , ome hing he hir ec or ha to even list the 600+ talks, so visuals and music, dancers, and
een eman ing or man ear heres a tiny avour of all that artists. His presentation is available
n on a glo al cale, an Sch ar a was on offer. Lets start with here: magpi.cc/2l0uvIf.
al ing a ou ac ling he me o incom a i le the arts. Music in particular is There were more visual arts from
igi al a men em ih C n erLe ger often well-represented at techie swarms of lightweight (27 grams
ro ec , an in er ne or ing ro ocol or mone , events, and one outstanding free less than an ounce! razy ie 2.
i h man arallel o he a he in erne software project is MuseScore, drones, painting, climbing, and
i el or which makes it easy to produce commanded by a MIDI glove. Drones
The slides and white paper are available here: great-looking sheet music that can were also ying over the attendees
magpi.cc/2l0vKHy also be played back through the in the GoLang rooms, where
projects soft synthesizer. systems programming included IoT.

82 March 2017 raspberrypi.org/magpi


FOSDEM Community
Thanks to FPGAs, says Philipp
Wagner, we can replace slow
waterfall design processes with FREE CHIPS
(NOT FRITES)
agile methods and rapid iteration

he e en enc o ree o are on ar rom o en


har are ha een a nagging orr ince he earl
a o he mo emen , an ro ec li e Li re oo
are erennial S i i or hi ear e en
saw two highlights for those looking to run on
en irel ree an o en har are
eorg re e, C o Kola an ormer
S re i en , im re e he au ience i h
he o en ial o enP R chi or high
er ormance com u ing an he a a cen re, hile
he le o er ul u er a a a le enR SC
o ere man cu om an o he hel o i ili ie
n a i ion o he e, lime ha rough i
R S la o rom ulgaria, com lemen ing
mo ulari an ree o are i h ree ooling
Pis subtle presence thing of the past. Guile, the Scheme hrough he e ign roce , an o en ource PC
The Raspberry Pi is very well dialect used in many GNU projects C le on i u
established to the point that its and particularly in GUIX, featured
not much talked about. However, many interesting sessions. Of these,
it was quietly working on many MagPi readers may be interested in easy cryptography for the masses.
displays, such as Automotive Natural Script Writing, featuring a The crowded Decentralised Internet
Grade Linux (running on Yocto and Guile dialect with whitespace, which devroom also offered a roadmap
OpenEmbedded), in ports of much of makes the transition from Python for the next few years defence
the software from the Kolab images to Lisp seem a lot less scary. of privacy.
to experimental builds of Haiku Daniel Stenberg, the creator
and Illumos, and in NextClouds Sharing knowledge of the ubiquitous tool curl, gave
Pi 3-based Dropbox replacement. Documentation is a concern for a talk named You know whats
en uttall was there to y the anyone trying to get things done cool? Running on billions of
ag for the Raspberry Pi oundation, with a piece of software. Rich devices, about the unexpected
and talk about HATs. If youre Bowen had some great advice for demands of maintaining code that
interested in building your own HAT, those responsible, stating that everybodys using. There were talks
with entirely free and open-source documentation including IRC on legal issues and community
tools including the board design, channels sets the tone for your development, lightning talks,
watch the video of Leon Anavis talk. project. How welcoming are you to considered keynotes, file formats
And look out for a feature on Anavis new users f you find new users not in open media, and data formats
HAT in these pages soon. sticking with your project, take a in many languages. Some of the
Python got its own full day of listen to his presentation. most interesting talks were in the
lectures: everything from how At the top end of the document- oftware efined Radio devroom.
data structures are implemented handling scale, XWiki was doing a FOSDEM has evolved over the
in CPython, to Python in the sterling job of presenting itself as years, gradually embracing some
cloud. Roberto Colistete Jr talked a useful alternative to Microsoft elements of the upstart maker
about cientific icroPython for Sharepoint. The humble TikiWiki community, as well as embedded
Microcontrollers and IoT. BoF was also present as part of the development (particularly
sessions were held outside the Wiki uite tools, offering secure, Automotive Grade Linux), and
lecture room, and posters revealed self-hosted software for data- even chip design. By far, the best
how much internet giants like driven organisations. of FOSDEM remains the corridor
Facebook use Python. Its a sort of nowledge was on offer conversations, which are a great
mini PyCon, with bonus sidetracks. everywhere: a chance hallway opportunity to meet programmers
Etiene Dalcol spoke about making meeting with Nikita Voloboev and other free software advocates of
wearables with NodeMCU, a Lua- offered the chance to try large all backgrounds. But if you missed
based language. Interesting niche mind maps of scientific knowledge it, you dont have to wait for next
languages were well-represented, magpi.cc/2l0QNcP. Sharing must year take a look at the magnificent
although the regular visit from be balanced with privacy, and pp archive of technical talks at
Belgiums Ada group is sadly a (pretty Easy privacy) was pushing fosdem.org/2017.

raspberrypi.org/magpi March 2017 83


Community FEATURE

THE MONTH IN
RASPBERRY PI
Everything else that happened this month in the world of Raspberry Pi

HELLO,
WORLD! e launched a sister magazine
W last month called Hello World, a
free computing magazine aimed
specifically at educators. The reactions
to it have been fantastic, with attendees
of the Bett Show and other educators
around the UK (and indeed the world)
e cited to get their hands on a copy.
You can find out more info on how to
get one yourself at helloworld.cc, and
help kids and teens learn more about
computing everywhere.

HIDDEN FIGURES
More secret history from behind the scenes of the Apollo missions
You may remember a few issues ago that reader on Twitter pointed out to us.
we did a piece on using the Raspberry Pi Hidden Figures is about these people:
to run the Apollo Guidance Computer the women of colour such as Katherine
code. This was after the code for it had Johnson working behind the scenes as
been uploaded to GitHub in July 2016, a mathematicians, performing orbital
wonderful mixing of old code and new calculations among many other things
tech. One of the things we talked about for NASA. Its been nominated for
extensively was Margaret Hamilton, one three Academy Awards, including Best
of the head coders behind the project. Picture, and shows the struggles these
Its because of her that the concept of women went through, not just because
software engineering exists today, but of their gender but also the colour of
she wasnt the only person breaking their skin. Its an excellent watch and
boundaries at NASA in those days, as a we recommend it.

84 March 2017 raspberrypi.org/magpi


THIS MONTH IN PI Community

CROWDFUND THIS!
The best crowdfunding hits this month for you to check out

MEARM PI PI18650 HAT


BATTERY HAT
kck.st/2kIlKTB

f you cast your minds back a little while, you may kck.st/2l6bwts
remember that we reviewed the excellent MeArm robot
arm its pretty popular in the Pi community, even While not boasting a very descriptive name, the
though you need to do some rejigging to get it working Pi186 AT allows you to plug in 186 rechargeable
with it. ts no surprise, then, that the team behind it Li-ion batteries to power the Raspberry Pi. The
are making a Pi-specific version, and have asked the AT fits on older 26-pin Raspberry Pis as well, and
community to help fund it, which they did in less than offers a new way of enabling portability for the Pi.
12 hours. Theyre currently at , so its a great time Its smashed its funding target, so get on board now
to jump on and get your own kit. to get one to boost your portable projects.

BEST OF THE REST Here are some other great


things we saw this month

magpi.cc/2kQAOfw magpi.cc/2kQJ9jn magpi.cc/2kQp5NT

GBAPI
Weve seen lots of Game Boy conversions and even
RUNMYROBOT GUEST WIFI
We like Lets Robot and
apparently other people in the
community like the idea as well
A makerspace in Santa Barbara,
CA is automating guest WiFi
codes using a Raspberry Pi, a
custom builds (like our modified PiGRRL in the cover theres now an entire website thermal printer, and a big old
feature), but this is possibly the first GBA conversion dedicated to letting people give button. Press it for a 24-hour code
weve seen using RetroPie. Although its missing two random strangers on the internet you can use in the makerspace.
buttons to be able to go full-on SNES, you could access to robots in their home. Its simple and easy. We should
probably mod one a bit further and add buttons, You can add your own if you want, get one for when people come
and the backlight the original lacked. We love it! albeit at your own peril. over and want the WiFi code.

raspberrypi.org/magpi March 2017 85


Community COMMUNITY PROFILE

COMMUNITY
PROFILE

DAVID
PRIDE
A Raspberry Pi maker and student, who plans
to add as many letters as he can after his name

David Pride D
avids experiences in
computer education came
for, head-first. espite a lack of
knowledge in Linu and Python,
slightly later in life. He he experimented and had fun. He
Category: Maker and student
admits to not being a grade-A found a Raspberry am and, with
Day job: Currently getting paid
student: he left school with few it, Pi enthusiasts like ike orne
to study what he loves
ualifications, unable to pursue and Peter Onions. The projects on
Website: piandchips.co.uk further education at university. display at the Jam were enough
twitter.com/davejavupride There was, however, a teacher to push David further into the
who instilled in him a passion for Raspberry Pi rabbit hole and, after
Below David joined computers and coding which would working his way through several
us at the St Jamess stick with him indefinitely. Python books, he began to take
Palace Community
celebration, mingling Twenty years later, back in 2 12, steps into the world of formal
with the likes of the David heard of the Raspberry Pi a higher education.
Duke of York, plus
organisers of Jams soon-to-be released new little With a ualification
and clubs, such as marvel that he instantly fell from Rice University under his
Grace and Femi

86 March 2017 raspberrypi.org/magpi


DAVID PRIDE Community

Above Self-playing xylophones, Wiimote air drums, Lego sorters, Pi Wars robots, Above Davids determination to access and complete further
and more. David is continually hacking toys, giving them new Pi-powered life education in computing has earned him a three-year PhD
studentship. Not bad for a lousy student
belt, he continued to improve is website, the pun-tastic Pi

HIGHLIGHT
upon his self-taught knowledge and hips, is home to the majority
and was fortunate enough to be of his work; David also links to
accepted to study for a masters YouTube videos and walk-throughs
degree in Computer Science at of his projects, and relates his
the University of Hertfordshire. experiences at various events.
With a distinction for his final If youve followed any of the
dissertation, avid completed action across the Raspberry Pi
the course with an overall social media channels or indeed,

Despite a lack of knowledge


in Linux and Python, he
experimented and had fun
distinction for his MSc and was read any previous issues of The
recently awarded a fully funded MagPi magazine youll no doubt
PhD studentship with the have seen a couple of Davids
Knowledge Media Institute. projects. The 4- ot, a robotic
The portfolio of projects second player for the family game
magpi.cc/1XrC3zU
that helped him to achieve his onnect our, allows people to go 4-BOT
many educational successes has head to head with a Pi-powered It seems only fair that we talk about the 4-Bot. Many
provided regular retweet material robotic arm. And believe us when readers will have seen this wonderful build online,
for the Raspberry Pi Twitter we say that its not as easy to beat where it has made its way across various blogs and
account, and various blog entries as youd hope. Then theres his websites, and even made an appearance alongside
have been penned to highlight his more recent air drum kit, which David in a recent Bloomberg interview. Using a Python
fun, imaginative works. uses an old toy found at a car boot imaging library, the 4-Bot splits the game grid into 42
His builds have travelled to sale, plus a Wiimote, to make a squares, and recognises them as being red, yellow, or
a range of Jams and made their functional air drum displaying empty by reading the RGB value of the space. Using
way to the Raspberry Pi and Code Davids toy-hacking abilities the minimax algorithm, 4-Bot is able to play each move
lub stands at ett, as well as and his complete lack of rhythm. within 25 seconds. Considering the trillions of possible
to the birthday celebrations for He does fare much better on his game positions, David made a compromise and, if youre
the tiny microcomputer. home-made laser harp, though! lucky, you may just be able to beat it.

raspberrypi.org/magpi March 2017 87


Community FEATURE

@codeclubworld

CODE CLUB
INTERNATIONAL
Code Club helps get kids coding around the world. Heres how
f you havent yet heard International, magpi.cc/2lfaGNm). most kids coding at a single event.
I about it, Code Club is
a global network of
Code Club partners with local NGOs
not-for-profit organisations .
Coding is the language of the 21st
century, says Kelly Tagalan from
volunteer-led extracurricular coding These share the mission to have a Code Club Australia. Our mission is
clubs for children. Code Club in every community in to make sure every Australian child
ode lub first started in the the world, and support the countrys has the opportunity to learn how to
UK, back in 2012, to help children local Code Club community. code, no matter where they live or
develop coding skills. Since then, Currently there are Code Club what school they go to.
this idea has spread around the partners in ten countries. Code Club
world and there are now over 9,000 Australia, the biggest community Global volunteers
Code Clubs internationally. outside the UK, has over 50,000 Anyone can start an individual
n 2 16, ode lub officially children attending Code Clubs Code Club in their local community,
launched its international (magpi.cc/2lgjyiE). In fact, in 2016 anywhere in the world (see How
programme (Code Club they set a world record for the to Start a Code Club below). There

HOW TO START A CODE CLUB


Code Club is completely free and its very easy to run Once you are ready to go, all you need to do is
your own. All you need is: register on the Code Club International website and
verify that your club is active. Youll get online access
> A venue this could be a local school, oac acco n he e o can nd ee eso ces
library or community centre. to use in your club, such as posters, badges, and
ce ca es nd o e a e o se he ee
> A volunteer thats you! curriculum of Scratch, HTML/CSS, and Python
projects to teach in your Code Club.
> Children to take part in the club. Visit Code Club World: magpi.cc/2kBa6JL.

88 March 2017 raspberrypi.org/magpi


CODE CLUB INTERNATIONAL Community

CODE CLUB
Inspire kids to become the next
generation of digital makers

INTERNATIONAL
IN NUMBERS

are clubs all around the globe, Volunteering is also a good thing
in countries such as Mauritius, to do. I feel really happy when I am
Bermuda, Nigeria, Kazakhstan, volunteering at Code Club because
the Philippines, and Israel. I feel a sense of real achievement,
Code Clubs come in all shapes and says Mizanur Rahman, a Code
sizes and some of the most powerful Club volunteer in Bangladesh.
ode lubs make a big difference for These children do not have big
a very small number of local kids. ambitions and they think of doing
Max Dolgikh runs a Code Club similar jobs as their poor parents,
in Ukraine. Hes been teaching explains Mizanur. At Code Club,
students to use Scratch. One we provide a creative platform.
Ukrainian boy, Vova, wrote a version They can express themselves with
of the classic game Arkanoid. I was confidence and learn skills with
happy all day long, says Max. Its better career prospects.
worth teaching to just a single child Code Club is looking for
to give them a better life. volunteers around the world.
Volunteering at a Code Club is a Anyone can start an individual Code
good way for STEM graduates to pass Club in their local community.
on coding skills while developing Start a Code Club in your local
communication skills. area and youll get to inspire the
I have the opportunity to next generation of digital makers.
share my knowledge with young Visit Code Club International and
people in my community, dont forget to register your club.
says Shohel Rana, a Code Club Class projects are completely free,
volunteer in Bangladesh. At the and available in 25 languages from
same time, these experiences French and Spanish to Korean,
taught me to communicate Arabic, and Hebrew for registered
concepts to a group, skills that will Code Clubs. Visit magpi.cc/2lnuqLL
serve me in the future. to see how you can help.

Code Club students in


Ukraine are learning
computer science skills

raspberrypi.org/magpi March 2017 89


Community EVENTS

RASPBERRY JAM
EVENT CALENDAR 1 3RD ANNUAL HISAR
CODING SUMMIT
Istanbul, Turkey
Find out what community-organised, Raspberry Pi-
themed events are happening near you

3 #PDATTHECOTTAGE
RASPBERRY JAM
Minden, LA, USA

FIND OUT
ABOUT JAMS
Want a Raspberry Jam in your
area? Want to start one?
Email Ben Nuttall about it:
ben@raspberrypi.org

HIGHLIGHTED EVENTS REGULAR EVENTS


3RD ANNUAL HISAR #PDATTHECOTTAGE PRESTON RASPBERRY JAM
CODING SUMMIT RASPBERRY JAM When: Monday 6 March
When: Friday 10 Saturday 11 March When: Saturday 25 March Where: edia nnovation tudio,
Where: isar kullar , stanbul, Where: 61 Elm treet, inden, Preston,
Turkey LA, USA magpi.cc/2lzNExP
magpi.cc/2ktyM3C magpi.cc/2ktjUlM A community of people who meet
haring and spreading essential The inaugural Louisiana Raspberry each month to learn, create,
knowledge of programming and am discover the world of and share the potential of the
algorithmic thinking. Raspberry Pi and what it can do. Raspberry Pi computer.

BLAYDON RASPBERRY JAM DUNDEE MANCHESTER


When: Saturday 11 March RASPBERRY JAM RASPBERRY JAM
Where: Blaydon Library, When: Saturday 25 March When: Saturday 11 March
Blaydon, UK Where: undee aker pace, Where: The hed, anchester,
magpi.cc/2ktAFwS Dundee, UK magpi.cc/2k476Wn
The first laydon am. f youre magpi.cc/2ktAr9f ring your Raspberry Pi along
interested in Raspberry Pi Get along to the undee and take part in the workshops.
computers, join in mingle, aker pace and learn about the Theres also a getting started
learn, share, and enjoy. Raspberry Pi microcomputer! session for newcomers.

90 March 2017 raspberrypi.org/magpi


EVENTS Community
JAM HEAT MAP JAMS
EVERYWHERE!
CAN YOU HELP INCREASE
THE AMOUNT OF JAMS
IN THE AREAS THAT NEED MORE?
4 DUNDEE
RASPBERRY JAM
ndee

BLAYDON
2 RASPBERRY JAM
a don

MANCHESTER
6 RASPBERRY JAM
anches e

COULD USE
MORE JAMS

5 PRESTON
RASPBERRY JAM
es on

STAFFORD
7 RASPBERRY JAM
a od

8 PI WARS
am d e

STAFFORD
RASPBERRY JAM
When: Tuesday 14 arch
MORE WAYS TO LEARN
Where: tafford Library,
tafford,
magpi.cc/2lzwyQu
CODE CLUBS
A big meet-up of Pi enthusiasts The latest figures show there
who all share ideas, help each are over 5,000 Code Club after-
other, and most of all have fun! school or extracurricular clubs
around the UK, any of which
PI WARS you can join to learn more
When: aturday 1 - unday 2 April about computing. That means
Where: omputer Laboratory theres probably one near you.
niversity of ambridge , Code Clubs offer loads of fun
ambridge, ways to learn about computing
magpi.cc/2k48U1D using Scratch, Python, or
Pi Wars is back! The spin-off of the even web-style code. Find out
am am pits Pi-robots against each where your nearest one is at
other in a series of tricky challenges. codeclub.org.uk.

raspberrypi.org/magpi March 2017 91


Community YOUR LETTERS

YOUR LETTERS
Mature users
I am a very senior (more than 50 years Mirror, mirror
experience) computer person from the USA. I am Thank you very much for the
also a physician health surveyor for Medicare, magic mirror guide in the last
so I visit a lot of older folks, most of whom have issue it was incredibly
been bypassed by the computer revolution. My informative and Im getting
experiments with Raspberry Pi indicate that this, the components now to try
in ario orm ac or co ld become a errific and make my own. I liked the
introductory system for seniors who wish to learn way it was laid out, showing
about computing (and many of them do!). each step in detail Im
This is a HUGE potential application. I note sure not everyone reading
that someone has already cobbled together a computer magazine will
a implified er in er ace or enior o g have the necessary carpentry
personally would prefer that this be done at the skills; I sure didnt!
OS level (I know, much easier said than done). On Are you going to continue
e ole e a pberr i i a ing o in e doing these sort of builds at
. o ld be errific i e co ld ge ome ing all in the near future?
going with AARP to promote Raspberry Pi for the Tamara O
elderly, especially if we could produce a really
EXCELLENT simple but capable user interface. If youre this far into the issue, youll probably
Stuart Jones have already noticed that we do indeed have Above A lot of
you liked the big
a similar build this issue with the Pi Zero W
project from last
Thats great that its helping seniors learn retro console. Starting from this issue, were issue and were
de n e p ann n
about computing in America. The Raspberry Pi calling our projects like this MagPi Big Builds
to do more in
Foundations mission does really revolve around while we have had two in a row, were likely the future
children, teens, and other young people, which not going to be doing one every issue, so each
is probably quite apparent in the way a lot of the Big Build will be a bit of an event. Hopefully,
resources are written. However, as youve said, the we can keep making projects as popular as the
community has come together and created some magic mirror!
interfaces more suited to seniors. Theres a very
long list of stuff that the P EL team has to tweak
and add, so you may see something like that one Lost in translation
day, but who knows when? Ive noticed youre doing a few translated editions
Otherwise, it might be an idea to keep an eye on now the German version and the mini mags.
any new Picademy USA courses, so you can learn You seem to have a great range of languages;
better how to educate others about the Raspberry Pi. however, Id love to help you with translating
it into another language. Do you have any plans
for future translated editions?
Marcus

We do have plans for other translated versions of


The MagPi, although we cant really talk about which
ones just yet until were absolutely sure theyre going
to happen. While we do appreciate members of the
community offering their services, its a little tricky
in many ways, because were a magazine and making
sure the te t is different but the design stays similar
requires a lot of extra skills. Do let us know what
languages you would like it translated to, though,
Come along to a Picademy in the USA as we can always try to get that on the plan.
and learn how to teach with Pi

92 March 2017 raspberrypi.org/magpi


YOUR LETTERS Community

FROM THE FORUM: This was a weird one, but thanks to the folks on the
forums, we did realise what happened

WHEN ASCII
To begin with, theyre supposed to say GP and not
. You then wire up the cover to the listed GP

GOES WRONG
ports to get them to light in the right order. Simple
enough. What seems to have happened is that during
the design process, the illustration we used which said
GP was subject to some bug that changed each letter
The Raspberry Pi Forum is a hotbed of to the previous one on the alphabet.
conversations and problem-solving for the Due to the way the articles are checked, it was
community - join in via raspberrypi.org/forums nearly impossible to notice this error. Now we
know its a thing that might happen, though, we
ather late, I know (or early for 2017): Im looking at the can make sure it doesnt again. Were sorry for any
R Christmas tree project. On the image of the back of the tree
card, what do the characters mean next to the lights?
confusion caused!

What does FOHN mean next to the light number? There is also WRITE TO US
FOHN /1, and FOHN 05 appears twice.
Have you got something youd like to say?
Thanks,
Get in touch via magpi@raspberrypi.org or on The MagPi
jonesypeter section of the forum at: raspberrypi.org/forums

raspberrypi.org/magpi March 2017 93


WIN
In association with

ONE OF TEN
KODI EDITION
RASPBERRY PI CASES
This issue weve reviewed
the brand-new version of
Kodi and weve also made a tutorial
on how to make your own HTPC with
it. This Kodi case is the ideal accessory
for your home theatre, blending in
perfectly with your other devices.

What is the codename for Kodi 17.0?

Tell us by 27 March Simply email competition@raspberrypi.org


for your chance to win! with your name, address, and answer!

Terms & Conditions


Com e i ion clo e on arch Pri e i o ere orl i e o ar ici an age or o er, e ce em lo ee o he Ra err Pi oun a ion, he ri e u lier,
heir amilie or rien inner ill e no i e email a er he ra ae en ering he com e i ion, he inner con en o an u lici genera e rom he
com e i ion, in rin an online Par ici an agree o recei e occa ional ne le er rom he agPi maga ine unle o her i e a e u on en r e on li e
am Par ici an e ail ill remain ric l con en ial an on e hare i h hir ar ie Pri e are non nego ia le an no ca h al erna i e ill e o ere

94 March 2017 raspberrypi.org/magpi


Column THE FINAL WORD
MATT RICHARDSON
Matt is Raspberry Pis US-based product evangelist. Before
that, he was co-author of Getting Started with Raspberry Pi
and a contributing editor at Make: magazine.

PI FOR THE
CONNECTED
HOME
Matt Richardson on how the arrival of Zero W is perfectly timed for IoT
ince the original Raspberry Pi Zero came hack with a Raspberry Pi lets you use Amazon
S out, Ive seen many makers using it for
connected home projects. Its size, low price,
Dash buttons to control almost anything you want.
(Dash buttons are usually used to order a particular
low power consumption, and software package product, such as laundry detergent, from Amazon
have made it a great option, even if makers had with just a single press.)
to use a USB peripheral to add connectivity. Now
that wireless LAN and Bluetooth connectivity are Advanced IoT
built into Raspberry Pi Zero W, it makes this mini If you want to go beyond the basics, there are cloud-
computer platform even better suited for home based platforms that let you manage many devices
Internet of Things projects. at once, and create intelligent alerts and actions.
Let me get this out of the way first nternet Many platforms are already Raspberry Pi-friendly,
of Things, or oT, has all the trappings of including the Particle Cloud, Initial State, Cayenne,
an overhyped buzzword. But even if the term and Resin.io. Each has its distinct advantages. For
Internet of Things doesnt stick around very long, example, Initial State makes it really easy for you
the concept of connected devices is here to stay to create custom web-based dashboards to show
for good. ts a clear side effect of increasingly you the state of your own sensors and internet-
affordable wireless connectivity technology. connected devices.
Its not just development boards that are becoming And if youre a beginner, there are platforms that
more connected. The consumer electronics devices make it easy to get started with connected devices.
that we buy for our homes are more likely to have ne in particular is called TTT, which stands for f
wireless capabilities. Even a product as simple as This, Then That. Its an easy-to-use service that lets
a light bulb can be equipped with connectivity, so you connect consumer and maker platforms together
that you can control its intensity and colour with a without needing to write any code. IFTTT can also go
mobile app or home automation platform. I recently beyond your devices it can interact with the news,
connected our Google Home to our WeMo Smart weather, or even local government. n the first
Plugs so that I can control the lights in our home partnership of its kind, the City of Louisville,
using my voice. Last week I was carrying a load of Kentucky recently announced that its now on IFTTT
laundry into a dark bedroom. Being able to say OK and sending real-time air quality data, which you can
Google, turn the bedroom lights on and having it log or use to trigger your own projects. I hope that
instantly do just that was a magical moment. its just the beginning for IoT partnerships like these.
As makers and technology enthusiasts, we have With all the recent developments in the Internet
even more power available to us. We benefit from of Things realm, Raspberry Pi Zero W comes at
affordable connectivity when it arrives on hardware the perfect time to offer affordable, portable, and
platforms like Zero W, and can create the connected connected computing power. The best part is that
devices that we hope to see on store shelves one day. exploring IoT doesnt mean that you need to go too
We also benefit from being able to interface with far into uncharted territory its still the same
consumer-connected devices. For example, a simple Raspberry Pi that you already know and love.

96 March 2017 raspberrypi.org/magpi


Tutorial

ESSENTIALS
LEARN | CODE | MAKE

OUT NOW IN PRINT


ONLY 4/$6 from
raspberrypi.org/magpi

From the makers of the GET THEM


ESSENTIALS
official Raspberry Pi magazine DIGITALLY:
raspberrypi.org/magpi April 2016
March 2017 97
Expand your Pi
Stackable expansion boards for the Raspberry Pi

Serial Pi Plus
RS232 serial communication board.
Control your Raspberry Pi over RS232
or connect to external serial
accessories.

Breakout Pi Plus
The Breakout Pi Plus is a useful
and versatile prototyping expansion
board for the Raspberry Pi

ADC Differential Pi
8 channel 18 bit analogue to digital
converter. I2C address selection
allows you to add up to 32 analogue
inputs to your Raspberry Pi.

IO Pi Plus
32 digital 5V inputs or outputs. I2C
address selection allows you to stack
up to 4 IO Pi Plus boards on your
Raspberry Pi giving you 128 digital
inputs or outputs.

RTC Pi Plus
Real-time clock with battery backup
and 5V I2C level converter for adding
external 5V I2C devices to your
Raspberry Pi. Also
available
1 Wire Pi Plus for the
1-Wire to I2C host interface with ESD
protection diode and I2C address
selection.
Pi Zero

www.abelectronics.co.uk

Das könnte Ihnen auch gefallen