Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PI ZERO W
PROJECTS
YOU MUST MAKE!
Video Jukebox Mini Arcade Cabinet
INCLUDES: AirPlay Speaker Car Dash Cam
THE ONLY MONTHLY MAGAZINE WRITTEN BY AND FOR THE PI COMMUNITY 9 772051 998001
Welcome
WELCOME TO
THE OFFICIAL
MAGAZINE PAGE 2
8
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 September
April 2016
2017 3
Contents
Issue 61 September 2017 raspberrypi.org/magpi
10 PI ZERO PROJECTS
IN THE NEWS
YOU MUST MAKE!
PIONEERS WINNERS
AIY NEEDS YOU 10 MILLION PIS
Photo credit: Raspberry Pi Anna Gordon
97
ARDUINO AND PI 60
A microcontroller and an SBC one unstoppable team
REGULARS
YOUR PROJECTS > NEWS 06
> TECHNICAL FAQ 56
> BOOK REVIEWS 80
> FINAL WORD 98
COMMUNITY
> PROJECT THINGS INTERVIEW 82
We talk to Mozilla about their new IoT project
INTERCOM
> CODE CLUB MEETUP REPORT 88
Educators learn to teach computing to kids
REVIEWS
PI DECK 34
Scratching digital music > STRATO PI CAN 74
> INKY PHAT 75
> HYPER PIXEL 76
ALONSOS ROBOTS 36
Cute robots everywhere! > PI-TOP PULSE 77
> CLEVER CARD KIT 78
raspberrypi.org/magpi September 2017 5
News FEATURE
TEN MILLIONTH
RASPBERRY PI
MADE IN WALES British Raspberry Pi manufacturing proves hugely successful
4M
Above Gareth Jones and Joe Whaley from
Made in Britain Sony with Romain Soreau from RS and
in Japan? Sarah Fawcett from Premier Farnell
MODEL 3B
MODEL 2B
(Models A, A+, Zero,
raspberrypi.org/magpi September
February 2017
September 7
News MINI MAKER FAIRE AT THE INSTITUTE OF IMAGINATION
MINI MAKER
FAIRE AT THE
INSTITUTE OF
IMAGINATION
Fuelling kids imaginations with a full head of STEAM
One child had created a robot that at the IoIs Mini Maker Faire
would pick up all the rubbish from the remote-control instructions and
motors, but also used an Arduino to
ZEROCAM RELEASED
A bespoke Pi Zero camera range a NOIR infrared camera. Despite Jamie explains that the
the modules reduced size of ZeroCams work with the
he Pi Hut (thepihut.com) just 11.411.4 mm (compared to existing camera code. He also
T has released the first full
range of cameras designed
the 2523 mm of the standard
Module), it still packs a 5MP sensor
predicted that well see smaller
camera connectors on future
specifically for the Pi Zero. The (compared to the 8MP of the V2 models of the Pi: There are
cameras are smaller than the Camera Module). already smaller ones out there
standard official Raspberry Pi The Pi Huts Jamie Mann tells itll happen!
Below Camera Modules, and connect us, We sampled a bunch [of The ZeroCam, ZeroCam FishEye
Each ZeroCam
directly to the smaller CSI ports camera modules] from various and ZeroCam NOIR cost 15 each
comes in a metallic
case with magnetic of the Zero boards. manufacturers, found the best from thepihut.com.
clasp sounds like
The range includes a standard factory for the job and created
a body cam case
to us! camera, a fish-eye camera, and the ZeroCam brand.
PIONEERS
WINNERS
ANNOUNCED
The next Pioneers
Who Made it Outdoors the best? challenge will be
set in September
he winners of the second Pioneers organiser Oly Brown explaining all the problems they
T Pioneers challenge,
a digital making projgram
says of HH Squareds project,
We really loved how every
encountered while trying to build
a smart picnic hamper.
for 11-16 year-olds, have member of the team contributed Equally, Uniteams great
been announced. [and] how tech was used to explanation of such a wonderful
The overall theme winner is HH enhance the enjoyment of project earned it the Best
Squareds Pi Spy project. the outdoors. Explanation prize. Watch their
Pioneers challenges young The Pioneers challenge isnt YouTube video, Plantz with a Z
people to work together to create just about making something, (magpi.cc/2vfHueC).
a piece of technology addressing but the process of trying to make Dont miss the next Pioneers
a theme, with this cycles theme something. Coding Doughnuts challenge sign up to the
being Make It Outdoors. won the Inspiring Journey prize by newsletter at magpi.cc/2oMN2rc.
VOICE
flew around the world
MICROSOFTS PI SIMULATOR
magpi.cc/2usunnP
raspberrypi.org/magpi September
February 2017
September 11
News BETTER OIL DRILLING WITH A RASPBERRY PI
USING A PI AS A
PLUG-IN
PROCESSOR
Big data in little Pi
Running the software on the Pi
means you can control it from
any networked device
Plug-in processor
Because the device is so inexpensive, I can see there
being a lot of possibility using it for education Scott
tells us, while the standardised environment saves
headaches such as installing libraries and managing
package repositories.
Scotts project could replace Excel for some tasks,
while Docker allows deployment and management
of a few devices or hundred, without too much extra
work. He says there are a lot of interesting cases I
havent thought of.
The project is on GitHub at magpi.cc/2uh3guV,
and Scott has documented the installation process
at magpi.cc/2fmMPdJ.
PI ZERO W
PROJECTS
YOU MUST MAKE!
The Pi Zero W is a dding wireless internet connectivity
MINI HDMI
Connect to an HDMI display
to create your own media PC
or interactive project
SYSTEM ON A CHIP
This features the same CPU as in
the original Raspberry Pi, although
its clocked a little higher
WIRELESS CHIP
Connect to a wireless network
or Bluetooth with the radio chip
on the Pi Zero W
CAMERA
CONNECTOR
The Raspberry Pi Camera
Module can be added for
photography projects all you
need is an adapter cable
GETTING
hile you can do a lot of things with the Pi
W Zero, its worth sharing a few tips to help
you use it in even more projects. These
STARTED
can be as simple as software tweaks to improve
performance and reduce power requirements, or
adding hardware to make it easier to integrate into
your projects. Here are some of our favourites.
ATTACH A
GPIO HEADER
Add GPIO pins to your Raspberry Pi Zero
YOULL NEED
40-pin male header
Soldering iron and solder
COMPOSITE
Look to the top right-hand corner Slot the jumper wires onto the
of the Pi Zero and youll see two headers, and put the other
holes labelled TV, below the GPIO ends inside the screw terminals
VIDEO OUT
holes and next to two pins labelled of the RCA plug. The Pi Zero
RUN. Put the short ends of the should automatically switch
header through the TV holes, flip to this output when you plug it
the Pi over, and solder them on. into a TV.
Using an old telly? Heres how to use
it as a display for a Pi Zero
YOULL NEED
Two-pin header
2 female-to-male jumper wires
Screw terminal with RCA connector
TOP TIP
If the video looks wrong,
switch the jumper cables
over on the Pi Zero
RASPBERRY PI ZERO
WIRELESS
ACCESS POINT
Extend your routers range or turn your wired hotel internet into a wireless wonderland
YOULL NEED
sudo brctl addbr br0
Youll need to turn off some of the new services # Bridge setup
youve just installed using: auto br0
iface br0 inet dhcp
sudo systemctl stop hostapd bridge_ports eth0 wlan0
interface=wlan0
bridge=br0
ssid=[Network name]
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=[Password]
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
05 FINAL TWEAKS
Save the conf file and open another file with sudo
nano /etc/default/hostapd. In this file we can
WIRELESS CAVEATS
tell the system where to find the configuration file Bridging wireless connections is doable, but it can be tricky. A lot
we edited. Find the line #DAEMON_CONF and replace of wireless networks dont allow auto-connection, or require you to
it with: know the password in the first place. If youre using free WiFi, there
may also be a landing page you have to sign into first, which may
DAEMON_CONF="/etc/hostapd/hostapd.conf" cause problems for the bridged computer.
MAKE A PI
BLUETOOTH
RFID-style technology for automation and more
TAG
01 INSTALL THE SOFTWARE eve seen some great YOULL NEED
W projects that use
Python doesnt come with a built-in Bluetooth Bluetooth tags and larger PyBluez magpi.cc/1VOuGCy
module, so we need to install pybluez to our Raspberry Pis. With the Pi ZeroW,
Bluetooth tag or another
Raspberry Pi. Do a standard sudo apt-get you can create a smaller tag that Bluetooth device
update and sudo apt-get upgrade before you slips easily into your pocket.
start. Once thats done, install the following: There are many applications that
support this, but heres how to get
sudo apt-get install python-pip your tag set up.
import time
02 TAG ADDRESS import bluetooth
You can use specific Bluetooth tags that send tag = "ff:ff:ff:ff:ff:ff"
out asignal and MAC address, or you can set an
existingdevice like a PC or phone to transmit its def search():
Bluetooth signal, which the Pi can detect. If youre devices = bluetooth.discover_devices(duration=5,
using a tag, you could carry it with you and leave lookup_names = True)
your Pi Zero at home. return devices
A tag will usually tell you what its MAC address
is, but Windows, Android, and iOS all use slightly while True:
different methods for other devices. Use Google to results = search()
look up how to find the Bluetooth MAC address for
your device. for addr, name in results:
if addr == tag:
# perform function
03 WRITE YOUR CODE
time.sleep(20)
Now you know your MAC address, you can plug
it into the tag code listed on this page. The code
is simple it scans the surroundings once every
HOW TO USE A
BLUETOOTH TAG
Creative projects for
your Bluetooth tags
ART
PROJECTS
In issue 44 we explored an
amazing art installation
called Lichen Beacons,
which used Bluetooth tags to
create an interactive display.
Its a wonderful idea, and
the concept could be used
to activate specific home
automation tasks as you walk
around your house, or to create
a recorded walking tour for a
museum: magpi.cc/2tPnw7t WAKE-ON-LAN
An old favourite, this project sends a magic WoL
packet signal to a computer to turn it on when
BLUETOOTH
the Bluetooth
is detected. We
UNLOCK
produced a tutorial
on this, way back in
issue 47find it at:
magpi.cc/2vD7e4e
Using an actuator, a bit of
code, and a motor controller
attached to the Pi, you can use
the tag to unlock a door when
you stand near it for a certain
amount of time. One less key
to carry around with you!
10 AMAZING
PI ZERO
PROJECTS
VOICE Need some inspiration to put your Pi Zero to work?
CHANGER Here are some of the best Pi Zero projects out there!
magpi.cc/2vEnZfU
KEY PARTS
Microphone
Speaker
KEY PARTS
Button
Video files
Popularly known as the Simpsons KEY PARTS
Shuffler or Simpsons Button,
this very simple Pi Zero project Storage space
features a selection of Simpsons
episodes. When you press a full Simpsons experience, theres Libraries are great, even in todays digital world.
button, the Pi Zero plays a random a 3D-printed case design you can A quiet workspace and importantly, free books!
episode. Obviously, you could download as well. While we think of traditional libraries as inhabiting
do this with any media (even If you are choosing Simpsons large buildings in town centres, full of resources and
music), and all it requires you to episodes, we suggest limiting slow computers, weve also seen cute little libraries
do is solder a button to a GPIO pin yourself to seasons three to eight. spring up in defunct phone boxes and other locations.
and load a Python script. For the Youll thank us later. This project takes the mini library concept one step
further, and allows for the easy and free sharing of
digital books and other e-publications.
This project comes straight from Adafruit, so
PI ZERO
theres a very thorough guide to creating your own
digital learning repository. Books can be accessed via
magpi.cc/2v5tGRl
KEY PARTS
USB power supply
This is a simple but excellent
idea: attaching a Raspberry Pi
Zero to a USB power adapter
so that the form-factor of the
computer is the same size as a
plug. This can then be used to
run a mini server, or even as a
travel computer. This version of
the project by NODE on YouTube
also includes a USB hub, so you
can easily connect storage and
other peripherals to the Pi Zero.
The video includes a guide on
how to build the power supply.
Be careful youre dealing with
mains power! Dont take any
risks with this project.
KEY PARTS
CABINET magicmirror.builders
The magic mirror project is a popular
magpi.cc/2vx4yFS Raspberry Pi project, and while it is usually made
using a Raspberry Pi 3, theres no reason why
you couldnt use a Pi Zero. Especially now that
KEY PARTS the Pi Zero W has wireless capabilities, so youll
only need power and
Prototype board HDMI connections to
0.96-inch screen get it working.
Laser-cut case If youve not seen
this project before,
Well be honest here: this its actually incredibly
project is more about what easy to make. The
you can do with the available carpentry skills
technology than about making required arent very
a neat, portable arcade sophisticated, and
cabinet. Its so small that its the software part is
not particularly comfortable the oldest of arcade games. The all taken care of. You
to use, but that doesnt mean buttons are soldered to some just need to run the
its not an incredible feat of custom-made prototype boards, specific install script
Raspberry Pi engineering. and the case is a custom design and then customise
The back of the cabinet is the in laser-cut acrylic. Adafruit it to your tastes. Its
same size as the Raspberry Pi themselves say the design also very modular,
Zero, while the front is a little process was more of a challenge so you can add and
deeper than the board. It uses a than anything else but hey, it remove features
tiny 0.96-inch OLED screen, with would be a cool project to break very easily.
a resolution of 9664, perfect for out at a party.
magpi.cc/2vqkTtm
KEY PARTS
Projects like this are surprisingly USB retro controller
easy, and weve covered a couple
like them in the magazine before:
from quick, simple hacks of
NES controllers, to installing a
rechargeable battery system into
a fully enclosed SNES emulator.
All you need to do is find a
way to connect the controllers
USB cable to the Pi Zero. You
can swap the USB connector
for a microUSB connector; you
can solder each individual USB
wire to the Pi Zeros USB port if
youre feeling brave; or solder
them to the GPIO and make
some modifications to the code.
RetroPie lets you very quickly and
easily configure your Pi Zero to
play old games, and from there
its up to you how you use it.
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 three covers
Free Camera Module connector
Free USB and HDMI converter cables
....................................................................................................................................
$69 (USA) *If giving The MagPi as a gift, please complete both your own details (above) and the recipients (below).
Address ........................................................................................................................
80 (EU) Name and full postal address of your bank or building society:
$129 (USA)
Address ...........................................................................................................................
........................................................................................................................................
n n n n n n Account number n n n n n n n n
Branch sort code
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.
$37.50 (US) (quarterly) SUBSCRIPTION PRICING WHEN PAYING BY CHEQUE OR CREDIT/DEBIT CARD
Quick
Facts
GOOGLE PI
INTERCOM
> A set of three
intercoms
originally cost
99.95 in 1986
A CONNECTED HOME
WAVES
Turn the sound of your voice into a printed waveform
m grateful for finishing
Above Two printouts of different responses,
both answering the question on the left
>STEP-01
Press a button
and later learned that Raspberry Pi of the sound waves would mean
Four push-buttons one for each question
would work well for the project. more to the participant.
are placed on a breadboard and connected to the
Meeting for weekly sessions, A Python script converts the
Raspberry Pis GPIO pins. The user holds down
it took the trio two to three recording of the users answer into
a button while recording their response.
months to create the finished a graphical waveform to print.
project. We encountered a fair The programming wasnt too
number of problems during every tricky, since we borrowed a lot
work session, but we managed from open-source Python code,
to overcome them by the end, says Matt. The plots take up the
reveals Matt. same amount of paper, no matter
Having a couple of ground how long the recording is, but
rules set from the beginning really we have to manually adjust the
helped, reckons Eunice. For volume on the microphone, to
Quick
Facts
> Daniel
estimates a
Pi Deck setup
costs $182
> There is no
PI DECK
Digital music cant be scratched or can it? Daniel James and
Chris Obbard go old school with a Pi-based digital vinyl system
soldering or
modification to
ver since he saw is not being released on analogue the position of the stylus from a
E
the turntable
Breakdance: The Movie in vinyl, despite the huge resurgence timecode. This is used to play back a
> Audio Injector
sound cards 1984, Daniel James wanted of interest in the format. digital music file at the same point
cost around 20 to be a DJ. But he soon realised Digital Vinyl Systems (DVS) in time but these systems can be
> A Serato CV02 scratching expensive vinyl or have long provided an alternative. hugely expensive.
control vinyl carting it from venue to venue is They allow you to DJ using digital Not now. Daniel and his colleague
pressing is
far from ideal. Unless you are music files and software while Chris Obbard at 64 Studio put a
recommended
famous enough to have a roadie, letting you benefit from the feel Raspberry Pi 3 alongside a standard
> The FLAC
large boxes of vinyl are heavy and of a turntable. You simply place a vinyl deck, eliminating the hassle
music format
gives the impractical, he tells us. Theres special vinyl record on a standard and expense of hooking digital
bestresults also the problem that a lot of music turntable and the system will read decks to a laptop. They figured that
HEY, MR DJ
The Audio Injector stereo sound card adds line-level audio inputs to the Pi
>STEP-01
Put the record on
all you need is a USB stick packed The greatest challenge was Once Pi Deck is set up, place a control vinyl on the
with music files. As long as there getting the audio interfaces to turntable, power up the Pi, and insert the USB stick.
is low latency in both directions of work with low latency since many Waxed paper under a felt slipmat will reduce friction.
travel, you can make effects such of the known techniques are
as rubbing the kick drum beats, for PC architecture. Interrupt
scratching and backspins sound, tweaking doesnt work the same
feel and look realistic, Daniel says. way on the ARM architecture, for
Motivated by a desire to show instance, Daniel explains, but
that low latency applications switching to newer Linux kernels
could work reliably on small and helped a lot. The majority of
inexpensive ARM devices such the work involved configuring
ALONSOS
Quick
ROBOTS
Alonso Martinez explores the ideas of interaction and individuality in
robots, creating adorable Raspberry Pi-based characters that play and learn
Facts n animator by trade, Mesmerising Mira result of a study into shape science.
> Alonso learnt
the majority
A Alonso Martinez wanted to
take his maker skills to the
Enter Mira. Alonso wanted to
create a character that was not only
Her lack of limbs and sharp edges
creates an instantly accessible and
of his maker
next level. He decided to explore aesthetically pleasing and highly pleasing character. And her eyes,
skills from
internetvideos the idea of interactivity with robot interactive, but also able to explore with their mini LED screens that
characters by creating Gertie, Mira the science behind how we perceive blink with their deep, somewhat
> Mira went
through and Lumens. a character based on its shape and galactic blue orbs, draw us to her
multiple designs With Gertie, he was able to features. Miras round form is the that little bit more.
before her final
explore the idea of the ball bounce
egg shape
a staple in animation school, where
> She charges via
a small port on
students are asked to animate a
her base ball, and the reaction of its surface
> Miras small on-
when it connects with another
board camera object. Where Gertie excelled at
can utilise face bouncing, there was still a lack of
recognition
the emotion and personality that
> Alonsos next Alonso hoped to achieve.
build, Lumens,
doubles as a
night light
Miras blinking eyes are powered
by two small LCD screens that
run constant animations
BRINGING
MIRA TO LIFE
>STEP-01
Design
Mira went through
multiple designs
during the process of
her conception, each
variation collected as
Miras control circuits sit inside her egg-shaped doodles by Alonso.
body, with millimetres of space to spare
But Mira is more than just a Mira and Lumens build their own >STEP-02
pretty face. Inside her body lies code and truly create their own The bare bones
a Raspberry Pi, laden with code. unique identities? Each wire and
Cover your face, for example, component has its
and Mira will recognise the game Millimetre-perfect place inside Mira,
of peekaboo via her on-board Stepping back from the mind- with no space to
camera, offering up a shocked blowing concepts of interactive, spare. Given whats
squeal of excitement when you intelligent robots, the physical under the hood,
say Boo! and reveal yourself. build behind Mira and Lumens is Miras small size is
Sit Mira beside you at a piano equally impressive. As an animator, an incredible feat
and shell sing back to you any Alonso is highly skilled in 3D design of design.
02
38 September
xxxx 2016 2017 raspberrypi.org/magpi
EDIT TEXT DOCUMENTS PROPERLY Tutorial
03 04
>STEP-02 >STEP-04
Using cat Nano
Often youll be working with text files from the You wont always have access to the GUI when
command line. The way to do this is using cat working in the command line, and you should
(shortfor concatenate). Open the Terminal and quickly learn to edit text files without heading to
enter cat release_notes.txt. The text will fly up the GUI. The way to do this is using a text editing
off the top of the screen. To view the text one page app called Nano.
at a time, pipe it through more and press SPACE to
move one page at a time. nano release_notes.txt
05 06
UNCOMPRESSING
FILES ON A
RASPBERRY PI
How to extract just about any file on your Raspberry Pi
iles downloaded from Pretty much everybody is compression techniques and files,
Youll F the internet almost always familiar with the concept of a each requiring its own tool and
The Extract
Files icon opens a
second window with
extraction options
Extract
Files is used to
select a download
location, choose
options (including
a password),
and extract the
original files
40 September
xxxx 2016 2017 raspberrypi.org/magpi
UNCOMPRESSING FILES ON A RASPBERRY PI Tutorial
04 >STEP-04
Extract unzip filename.zip
The Extract Files window is
straightforward. If all you want
File extension: .7z
are the files, then click Extract
and theyll be saved into the same
location (typically Downloads). You sudo apt-get install p7zip-full
can change the Extract To folder, but 7z x filename.7z
you wont have sudo privileges, so
stick to directories inside /home/pi/.
File extension: .rar
You can also enter the password to
access restricted compressed files.
The icon in the bottom-right corner sudo apt-get install unrar-free
of Archiver will flash green and red unrar x filename.rar
while it extracts the files, and solid
green when its done.
MIKES PI BAKERY
Veteran magazine author from the old
days and writer of the Body Build series.
Co-author of Raspberry Pi for Dummies,
Raspberry Pi Projects, and Raspberry Pi
Projects for Dummies.
magpi.cc/259aT3X
BUILD A
POLYRHYTHMIC
SEQUENCER
Youll
Make great polyrhythmic music, generated by your Pi
Need
ack in The MagPi #58 we showed you our sendsmessages between musical devices, which
B Hexome simulator, running on a mobile
device and controlling a sequence. It used
include instruments (like a keyboard), and sound
modules that generate an audio signal. Some devices
> MIDI / USB concentric rings of trigger positions, starting with a can combine the two categories in one device the
interface lead
ring of six with each subsequent ring having six more most popular being sound-generating keyboards.
> MIDI sound
trigger positions. Now we take that basic idea, run Messages consist of two or three bytes, and cover
module
(anytype) with it, fall over, pick up the pieces, and assemble it commands such as Note On and Note Off, as well as
into a universal polyrhythmic sequencer. other controls, including volume, vibrato, echo, and
The basic concepts are the same, but this project pitch bend.
gives us nearly unlimited flexibility. Each ring A MIDI connection can control 16 different
generates only one note, and those notes can be channels, where a channel can range from one voice
changed by mapping. However, almost everything or sound to a totally separate piece of hardware.
else has changed. There are up to six rings in the Often instruments have a switch that determines the
sequence: each ring can have a maximum of 32 trigger channel they transmit on, and most will default to
positions, and can be individually muted. The big channel 1.
change is that each ring can have its own individual MIDI runs at the quirky baud rate of 31,250 baud.
sound and volume, courtesy of MIDI. It is odd by todays standards, but in the old days it
was used because it was simple to generate. A MIDI
MIDI connection device can have an input and an output, and, much
Figure 1 MIDI stands for Musical Interface for Digital to the surprise of younger people, an input must be
A block diagram
Instruments. It is a very old standard, but still connected to an output. There can also be a MIDI
of the complete
hardware setup as popular as ever. MIDI is a serial interface that Thru (through in English), which is simply the
MIDI in Audio in
MIDI out
MIDI Sound module Amplifier & Speakers
Raspberry Pi USB USB / MIDI
Audio out
Figure 2
Learn to control Implementation would need a window measuring at least 1100860
the sequencer To write the code, we are going to use the Processing pixels. Each ring is limited to a maximum of 32 trigger
and make some
great music language. If you havent already, install Processing by points, again due to the physical resolution of the
opening a Terminal window and typing: screen. This is despite using the trick of changing the
ring width depending on the number of trigger points.
curl https://processing.org/download/
install-arm.sh | sudo sh The Code
The code is written in three sections, or tabs: these are
You also need to install two libraries. From the Poly, Controls, and Note_Map. In the Poly tab, the
Sketch menu, go to the import library entry and line at the start:
choose Add Library, then search for and install
controlP5. This deals with the variable controls. MidiBus.list()
Then repeat this and install the themidibus library.
This is the library that will generate and send lists all the MIDI devices that have been recognised by
the MIDI messages. the computer, both as input and output devices. We are
As the code is rather long, you can download it from only interested in output devices, and it is likely that you
magpi.cc/1NqJjmV. It is entirely operated from the will only have one such device plugged in. If so, the line:
keyboard or mouse attached to the Pi.
The number of rings is limited to six in this MidiBus(this, 0, 1)
implementation, simply because the resulting
980720 pixel window is all that will fit on a standard which selects the MIDI device to use, will not need
HD screen. If you want a seven-ring sequencer, you to be changed.
MIDI channel 9
There is something special about MIDI channel 9.
When you use this channel, for each note number
you dont get a change in note pitch, but a different
percussive instrument, including cymbals, drums,
cowbells, blocks, and whistles. With the same
mapping as the pitched notes, it can be pot luck as to
which instrument ends up here.
It is possible that as you change some parameters
on the fly, you can be left with a hanging note. This
is a note where the sound module has received a Note
On message, but no corresponding Note Off message.
If you get a hanging note and want to reset it, click
the Reset control. This sends Note Off messages to
all possible notes on all possible channels, a process
which takes less than two seconds.
WINE SAVER:
The Raspberry Pi installed on the chiller unit using Velcro
A 150 Prusa i3
printer from eBay
3D PRINTING
WITH YOUR RASPBERRY PI
Climb on board the 3D printing bandwagon on a budget, using a cheap
Youll but powerful printer controller with a Raspberry Pi at its core
Need he rise of 3D printers has seen numerous reliability and quality a considerable factor in these
> 3D printer
with updated
T inexpensive models becoming available in
the 100-150 bracket, but what is the best
price differences. In an attempt to keep the cost of
this project low, we opted for a 150 Prusa i3 clone
firmware and
way to interface with them? A Raspberry Pi, of course! new from eBay. The printer came as a kit and required
USB connection
This tutorial will cover the things you need in order a few adjustments, along with some Googling due to
> Spare microSD
to control your already working 3D printer with a Pi, difficult-to-translate instructions.
card
allowing you to have remote access and monitoring Even so, this should be easy enough for a complete
> WiFi connectivity
capabilities for your printer from anywhere in the 3D printing novice.
(USB WiFi dongle
if needed) world; as well as the ability to start printing, cancel, There are many of these clones available at a
> Official
and tweak the settings mid-print, thanks to our similar price online. If you would prefer a branded
touchscreen favourite little credit-card-sized computer. budget printer, you can buy a Startt printer for 99
> Repetier Pro from imakr.com. However, it still requires building
subscription Choosing your printer and adjusting, and has a smaller build volume than
(optional) If you are not already lucky enough to be the proud the Prusa. For larger amounts of money, the official
> USB webcam owner of a 3D printer, then the first step is to choose Prusa 3D printers can be purchased, as well as many
(optional) one to buy. There are many options on the market, others. As this market has grown so rapidly, there are
ranging from 100 to upwards of 1,000, with countless options. When buying a 3D printer for use
LIVE-CODING
ONLINE WITH
SONIC PI
Youll
Need
Share your live-coding performances with listeners anywhere
on the internet using Sonic Pi, some simple Python code, and MQTT
riginally created as an interactive and Sharing Sonic Pi compositions
> Paho MQTT
Python Client
O fun instructional tool for teaching both
programming and music, Sonic Pi is also a
For this project, we will assume that you are at least
somewhat familiar with the Sonic Pi GUI and its
magpi.cc/
very powerful tool for creating sophisticated live coding language, and you have at least tried some
2vB4txx
performances as well as algorithmic compositions, simple code or played with the many examples
> Ruby
all by writing code. Its perfect for people who love included with Sonic Pi. If not, check out the Essentials
ruby-lang.org
to code and love to create music, even if they cant book, Code Music with Sonic Pi, for some excellent
> sonic-pi-cli
play an instrument. Best of all, Sonic Pi is included beginners tutorials: magpi.cc/1VGIOux.
magpi.cc/
2vBhoze in Raspbian, making it easy to get started with Our goal for this project is to give you a way to
coding your own musical creations on your Raspberry go beyond playing your Sonic Pi compositions for
Pi. Wouldnt it be great if you could share those whoever happens to be in the room with you. Well
Below Start the
creations over the internet? In this project, well show how you can share your Sonic Pi coding creations
publisher to send
the Sonic Pi code show you how! with your friends, family, and fans over the internet,
so they can listen to your musical masterpieces
virtually anywhere in the world.
To do that, we have created a couple of simple
Python programs that can interface with Sonic Pi, and
communicate with each other over the internet, using
a lightweight IoT messaging protocol called MQTT.
MQTT is a publish/subscribe messaging transport
protocol (in case you are wondering, MQTT originally
stood for MQ Telemetry Transport, but is no longer
officially an acronym). It was designed to be
very lightweight, simple and easy to implement
and is most commonly used for communication
in machine-to-machine and Internet of
Things applications.
MQTT MQTT
Sonic Pi
MQTT
Subscriber
Internet Python program
receives Sonic
Pi code from the
MQTT broker and
sends to Sonic
Pi CLI
MQTT
Sonic Pi CLI
Sonic Pi CLI connects
to the Sonic Pi server
to play the received
Sonic Pi code
Sonic Pi
MQTT
Publisher
Python program
reads the saved MQTT
Sonic Pi code and
publishes to an
Broker
MQTT broker
Now its time to try a simple Once the buffer is saved to a file, run the sp-mqtt-
publisher.py program from a Terminal window. You
DOWNLOAD:
magpi.cc/2vB5FRx
import paho.mqtt.client as paho
import time, os, sys
topic = sys.argv[1]
filename = sys.argv[2]
host = "iot.eclipse.org"
client = paho.Client()
Above The saved file will be published to the MQTT broker
client.connect(host, 1883)
to the MQTT broker. With each iteration of the loop,
it will check to see if the code file has been updated timestamp1 = -10
and, if so, it will re-read the file before re-publishing, while True:
so that the most recent version of the live-coding timestamp2 = os.path.getmtime(filename)
composition is published to the MQTT broker. if timestamp1 != timestamp2:
Now, of course, this isnt much of a live-coding with open(filename, 'r') as myfile:
performance without listeners, right? If you have filedata=myfile.read()
a couple of friends who want to help, you can have timestamp1 = timestamp2
them install the required components as described client.publish(topic, filedata)
in the Getting started section, and run the Python time.sleep(10)
subscriber program, sp-mqtt-subscriber.py, to
retrieve the published code from the MQTT broker and
play it using Sonic Pi on their own Raspberry Pi. Or, if
rpmqtt-subscriber.py
you like, you can run the subscriber program yourself
on the same Raspberry Pi that you used to publish the
code. To run the subscriber program, first be sure you
have installed the Paho MQTT client and the sonic_pi
Ruby script as described above. Next, open Sonic Pi import paho.mqtt.client as paho
and run the Python subscriber program, being sure to import sys, subprocess
specify the same topic name that was used with the
publisher above as a command-line argument. For def on_message(client, userdata, message):
example, enter the following command: pipe = subprocess.Popen("sonic_pi", stdin=subprocess.
PIPE, shell=True)
python sp-mqtt-subscriber.py saulpimon pipe.communicate(input=message.payload)
print(str(message.payload.decode("UTF-8")))
The subscriber program will connect to the Eclipse
IoT MQTT broker and retrieve messages that are def on_disconnect(client, userdata, rc):
published to the topic named on the command line. subprocess.call("sonic_pi stop", shell=True)
When a message is received, the subscriber program
then calls the sonic_pi Ruby script, passing the topic = sys.argv[1]
retrieved message as data. The sonic_pi Ruby script host = "iot.eclipse.org"
connects to Sonic Pi and sends it the code, which will client = paho.Client()
then be played. Dont worry when you dont see the client.connect(host, 1883)
retrieved code in the Sonic Pi GUI on the Raspberry Pi client.subscribe(topic, 0)
on which youre running the subscriber program. The
sonic_pi Ruby script doesnt interact with the Sonic Pi client.on_message = on_message
GUI at all. Instead, it connects directly to the Sonic Pi client.on_disconnect = on_disconnect
synth server to send the code.
You are now ready to start sharing your live-coding print("Press Ctrl-C to stop...")
masterpieces over the internet. Simply make changes try:
to the Sonic Pi code as you would with any other client.loop_forever()
live-coding performance, and save the buffer to a except KeyboardInterrupt:
file as described above. The simple Python programs client.loop_stop()
and MQTT will handle the rest, for you and your client.disconnect()
faithful listeners!
PIHUE
Youll
Learn how to control Philips Hue lights with a Raspberry Pi
and the Pimoroni Touch pHAT
CONTROL
PHILIPS
HUE LIGHTS
Need ere all guilty of spending too much time Next, we need to download the PiHue code
> Pimoroni
Touch pHAT
W geeking out! GeekyTim is no exception; he
spends his time in Hut 8 (his log cabin in the
from GitHub:
magpi.cc/
garden) tinkering with Raspberry Pis, 3D printing, and git clone https://github.com/GeekyTim/PiHue
2pafoP9
laser cutting. His wife complains when she has to come
> Philips Hue
out in the rain to call him in! The PiHue code is in the PiHue directory:
Bridge and Lights
magpi.cc/ After buying some Hue lights, he wondered whether
2uBNFsK they could be controlled with a Pi. Philips provides APIs, cd PiHue
> phue Python and other Python libraries have been developed to access
library by the Bridge. So, he put them all together and created the
StudioImaginaire
magpi.cc/
PiHue a Raspberry Pi Zero W with Touch pHAT that his Configuring PiHue
2uBWOBF family can use to call him in from play Each of the Touch pHATs six capacitive buttons
will have a different function. The Back (left arrow)
Setting up button turns the lights on and off; four A, B, C and D
We start by connecting our Pimoroni Touch pHAT to buttons flash the lights red, yellow, green, and blue
the Pi, burning the Raspbian Jessie Lite image onto respectively; and Enter (right arrow) makes them
an SD card, booting up, and connecting to the same all bright.
network that the Hue Bridge is on.
We need to install a few prerequisites before There are two versions of the code:
downloading the PiHue code, including Python 3, pip, >P
iHueRoom.py controls a Room as defined
Git, the Touch pHAT library, and the phue library that in the Hue app.
gives us access to the Hue lights from Python: >P
iHueLightList.py controls individual lights in a list.
USING RASPBERRY PIS and another add-ons that enable you to connect a
Raspberry Pi with, and even program, an Arduino.
What is a microcontroller?
A microcontroller is a small piece of electronics
that, while limited in its function, can be powerful
enough to control lights, motors and so on with a bit
of programming. The benefit of a microcontroller
over a Raspberry Pi is that they typically require
less power to run.
Arduino
Popular tools for creating very small computerised
projects, Arduinos are cheap and usually use a lot
less power than a Raspberry Pi. You can find HATs Above Raspberry Pi can play nicely with microcontrollers
AND
Combine the ease and accuracy of Arduino with the advanced capabilities
of a Raspberry Pi for the best in physical computing projects
MICROCONTROLLER CHIP
An ATmega328P microcontroller
is used to control the hardware
on the Arduino board. It
is programmed using the
Arduino IDE (accessed via the
Raspberry Pi)
RESET BUTTON
On one corner of ANALOGUE INPUTS
the Arduino board On the lower half of the Arduino
sits a reset button Uno are six analogue input pins
(female header). These can be
used to read information from
USB TYPE B devices such as potentiometers
The larger USB Type and photoresistors
B connector on the
Arduino is used to draw
power, and provides a
connection between
the Raspberry Pi QUARTZ CRYSTAL
and Arduino A 16MHz quartz crystal
chip is included on the
board. This helps the
Arduino control devices
with precision
USB TYPE A
Use one of the USB Type A ports
on the Raspberry Pi to provide
power to the Arduino. Youll
need a USB Type A to B cable
CLIVE WEBSTER
A professional tinkerer since 2004,
Clive just keeps seeing more uses for
Pi around the house how many Pi
boards is too many?
twitter.com/clivewriting
CONNECT THE
GET THE
RASPBERRY PI
AND ARDUINO
TO CHAT
Now that we can program an
SerialLightsRespond.ino
Arduino IDE | magpi.cc/arduinoandpi Arduino with a Pi, lets get the
/* two talking to each other
* Blinks LEDs when motion detected.
* LED blink repetition determined t is possible to make commands from the Pi
* by amount in serial_respond_pi_side.py
*/
I (automated or human-activated) affect the
sketch loaded onto an Arduino; and for data
collected by the Arduino to be sent automatically to
//variables the Pi to be processed.
int led1 = 5;
By why would you want to? Its a fair question, as
int led2 = 6;
the Pi has plenty of GPIO headers to attach motors,
int motion = 3;
int wait = 500; //500ms = 1/2s sensors, LEDs, and other devices why add the
complication and expense of a second board?
void setup() { The answer lies in the simplicity of an Arduino
// put your setup code here, to run once: board. Its an easily programmable microcontroller
pinMode(led1, OUTPUT); with clearly labelled GPIO pins. An Arduino board
pinMode(led2, OUTPUT); therefore has very little overhead to prevent it from
pinMode(motion,INPUT); taking millisecond-accurate readings, and theres
Serial.begin(9600); nothing much to go wrong and cause an Arduino to
} stall or hang.
The Raspberry Pi, meanwhile, has all kinds
void loop() {
of hardware and software overheads from
// put your main code here, to run repeatedly:
if (digitalRead(motion) == HIGH) { USB controllers and display outputs to wireless
if (Serial.available()) { connections and a full-blown operating system. All of
flash(Serial.read() - '0'); //Converts these can lead to delays or jitters in measurements.
Serial message into a number Most Arduino boards have analogue inputs, and can
} supply a wide range of voltages rather than the 3.3 V
} or 5 V that a Pi offers. This makes it much easier to
delay(5000); connect and code for many electronic components.
}
SERIAL COMMUNICATIONS
void flash(int repetitions) {
The standard method of communication between a Pi
for (int i = 0; i < repetitions; i ++){
and an Arduino is serial: its robust, simple, quick and
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH); easy. Lets start with the Arduino, turning our basic
delay(wait); sketch into an alarm system.
digitalWrite(led1,LOW); First, re-save the PIRBlink file, renaming it
digitalWrite(led2,LOW); SerialFlashLights. Now, we need to enable serial
delay(wait); communication, so we head to the end of the void
} setup() section and add:
}
Serial.begin(9600);
void loop() {
ARDUINO TO PI // put your main code here, to run repeatedly:
Now we can switch to writing a Python script on if (digitalRead(motion) == HIGH) {
the Pi. Well use Thonny, the new Python IDE for Serial.println("Motion detected!");
Raspbian. If you havent got Thonny yet, install it with digitalWrite(led1,HIGH);
this code: digitalWrite(led2,HIGH);
delay(wait);
sudo apt-get update && sudo apt-get install digitalWrite(led1,LOW);
thonny digitalWrite(led2,LOW);
delay(wait);
Once installed, fire up Thonny. Enter the code from }
SerialFlashLights.ino into Arduino IDE and serial_ }
flash_lights_pi_side.py into Thonny. Make sure you
ATMEGA328P
MICROCONTROLLER
The ATmega328P CPU has very
little overhead, so it can take
millisecond-accurate readings.
Theres not much that can go
wrong and cause an Arduino to
stall or hang (and if it does, it
automatically reboots and runs
the program).
MICROCONTROLLER PINS
Because the Arduino has
lower software overheads,
it's a useful add-on tool for
sending precise readings to
the Raspberry Pi.
SERIAL MESSAGING
Serial connections are used to
send and read messages to and
from each device. The messages
are sent via the USB cable that
connects the two devices.
SERIAL CONNECTION
The Raspberry Pi can
communicate with the
Arduino using serial
communication. Open a port
between the Arduino and
the Pi in code (libraries are
available for Python and C).
HDMI OR DSI
The Raspberry Pis HDMI and DSI video
output ports enable it to run a visual
interface. They can therefore be used to
turn the Pi into a controller for the Arduino.
PROJECT IDEAS
INTERNET OF LEGO
An entire city, built from Lego and controlled by
Arduinos, Raspberry Pis, and bundles of sensors.
All the parts interact with each other, with myriad
sensors placed around the blocky cityscape to track
events within the city and in the real world. The whole
connected city is powered by a Raspberry Pi running the
Node-RED Internet of Things manager (nodered.org).
internetoflego.com
SMART JUKEBOX
Tijuana Rick (aka Ricardo Cortez) used an Arduino Mega to
transform a 1969 Wurlitzer 3100 jukebox into a digital retro music
box. He had to go the digital route because, while the jukebox still
worked, the previous owner kept all the vinyl records. The Arduino
monitors the jukebox buttons, sending a serial output to the Pi,
which handles the music playback.
PIANO STAIRS
As part of a HackPrinceton hackathon, Bonnie Eisenman
created stairs that play a tune. Each step is fitted with a
light on one side and a light sensor on the other; when a
foot breaks the beam, an Arduino passes the number of
the step to a Raspberry Pi, triggering a specific note to be
played through a set of speakers.
magpi.cc/2vbAE9T
magpi.cc/2vbTbDl
FLIPFRAME
FlipFrame solves the problem of
showing a slideshow of mixed-
orientation images. Obviously,
black bars are insufferable, so Tim
Giles uses a Raspberry Pi to analyse
his slideshows. If the resolution
indicates a landscape image, the Pi
tells a motor-governing Arduino to
turn the FlipFrames 27-inch screen
from landscape to portrait mode.
It is a sight to behold.
magpi.cc/2vbQO32
Maker
Says
Tiny 4WD
is a small
but powerful
robot that
you build
yourself
Coretec
TINY 4WD
ROBOT KIT
Rob Zwetsloot looks at a tiny robot with a lot of power,
in a kit based on a robot you might remember from the magazine
f you cast your mind back the chassis. However, we tested online, linked from the Pimoroni
I to issue 51 of the magazine,
youll remember a robot
it using a Raspberry Pi 3 and it
worked well.
website: magpi.cc/2pXHCu8.
Online instructions arent ideal
55 / $72
Flexible control
From here you can use the test
scripts to control the robot
using a USB controller, or start
making it more autonomous. The
Pimoroni library for the Explorer
pHAT is easy to understand
so, with the docs open and the
examples to hand, you can easily
start creating your own programs.
Each side of the Tiny 4WD is
powered by one of the motor
outputs on the pHAT. This
means that, for example, both
left wheels will always run at
the same speed and direction as
each other. This makes it easy to
turn on the spot, and gives it full
power when its moving forwards
and backwards.
The Tiny 4WD is easy to
customise. There are extra inputs
and outputs on the board, so
you can start adding additional
sensors. Theres a camera mount
that could be used to attach an
ultrasonic sensor, or a Raspberry Pi
Camera Module like the robots in
the Formula Pi racing series. Thumbs up Unfortunately, supplies are
We do like this robot overall. The limited for this kit, but more
Power choices build quality is great, with a sturdy units are being made all the time.
Choosing a power supply can be chassis made from thick acrylic, If you want one, you may just
tricky. The idea is to house your decent micro motors supplied with have to be patient. We think its
power source between the layers the kit, and the inclusion of a great worth the wait, though.
of the chassis. However, the motor controller in the Explorer
narrow gap, partly blocked by the pHAT. The soldering requirements
Last word
wires to the motors, limits the make it unsuitable for an absolute
size of any power supply. Youll beginner, but itd be great as a step A great little robot kit which could do with some
also need to think about power up for novices. It could even be better build instructions. Once its built, however,
capacity the motors will be used as a base by more advanced you have a lot of options and plenty of ways to
powered from the Pis GPIO pins, robotics users, as you can easily make it your own.
so your Pi will need more power swap out the HAT and use a bigger
than you might expect. Pi to add more functionality.
From 10/$13
Maker
Says
Connect
RGB LED
shapes.
Sculpt your
lights
RasPiO
RASPIO INSPIRING Create impressive illuminations with this dazzling range of light kits
he main selling point of the light strips and shapes to the Indeed, thats what youll
T RasPiO InsPiRing is the
ability to daisy-chain a
Pi, along with a couple of optional
10 k resistors (not needed in most
be doing for the pyramid kit.
After assembling the 3D shape
variety of LED strips and shapes cases). Theres also the option of from three triangles, held
together to create 2D and even a header for analogue inputs, so together using pieces of sticky
3D displays. Now headed for you could control your lights with tape, youll need to solder bare
general sale following a successful potentiometers, for instance. wires between the input/output
Kickstarter, the range comprises Male and female four-pin holes at each vertex, which is
four kits: a strip of eight LEDs connectors are supplied for each fairly fiddly.
(10/13), a circle or triangle LED strip and shape, enabling you Once the hardware is assembled,
of 24 LEDs (20), an NTP Clock to daisy-chain units together. the software is installed on
kit including Pi Zero (30), and Three sets of input/output holes the Pi with a single command
a pyramid kit featuring three are provided at each end, so you and includes a range of Python
24LED triangles (50). can solder your connectors at examples which can easily be
Although the super-bright various angles: 180, 90, or 45. adapted for your own purposes.
Related
APA102c LEDs can be controlled by This offers more flexibility when
other devices including Arduino, connecting units to create custom Last word
ATtiny, and ESP8266 each kit light displays, although you can
MOTE comes with a pHAT-sized driver always just wire directly to the This range of LED lighting
Instead of
board for the Pi, communicating holes if you prefer. kits offers flexible daisy-
daisy-chaining,
each super- via SPI. Assembly takes around 20 chain connectivity that
bright LED strip minutes and involves soldering on enables makers to sculpt
(no shapes) custom arrangements of
is connected a 40-pin header, two small female
separately to a headers, and a socket for a buffer shapes. The end results are
pHAT or USB- chip. The chip translates the Pis impressive: the super-bright
connected host. LEDs creating some dazzling
voltage to 5 V logic to drive the
displays. The pyramid is a
LEDs. The power supplied by the Pi
particularly fun (if fiddly)
alone should be enough for most
project to make, and would
projects, but theres the option
make a great gift.
of boosting it with an external 5V
From 16/$21
power supply if needed. Jumper
magpi.cc/2g9iyLs
wires are supplied for connecting
Subscribe from
Magazine
2.29 26.99
rolling subscription
or
full year subscription
106 / $138
Maker
Says
Makes
Raspberry
Pi more
professional
SferaLabs
22 /$29
Maker
Says
A low-
energy, high-
falutin, red/
black/white
electronic
paper display
for your Pi!
Pimoroni
INKY PHAT
Add a little more colour to your e-Ink display, says Phil King
ith the ability to display text While the Inky pHAT has a partial update, adding text (your
W and images that remain
on screen without using
Zero form factor, itll happily
work with any 40-pin Pi model.
name) to a background image.
The slow refresh rate makes the
a power supply, e-Ink displays are Communicating via SPI, it only Inky pHAT unsuitable for scrolling
ideal for saving precious battery uses six GPIO pins (plus 3 V and text, but static text can easily be
Related
life in portable projects. Theyre 5 V power). If you wanted to displayed in any installed TrueType
also much easier to view in bright locate the screen away from the font, using a simple message
sunlight than conventional screens. Pi, however, youd need to use function in Python. Images are a
PAPIRUS Until now, Pi e-Ink displays something like a Black Hat Hack3r bit trickier, as you need to prepare
ZERO have been black and white but (magpi.cc/2fqGy0D). them in a special indexed colour
Available in a the tri-colour Inky pHAT injects a A single Terminal command mode, and they must also exactly
range of sizes,
bright shade of red into the mix. installs all the software required. match the size of the display
this black-
and-white eInk This certainly adds a dash of extra The Python library comes with a at 212 104 pixels.
display has a far interest to images, such as the logo few helpful examples, including
faster refresh
rate, plus push-
shown on the display when you a calendar and a weather display. Last word
buttons to unpack your pHAT. Theres a lot of flashing and
control whats Unlike the rival PaPiRus Zero, pulsing as the screen refreshes, While the slow refresh rate
shown on
the Inky pHAT comes fully the red parts usually appearing makes the Inky pHAT unsuitable
screen. for some projects, it does look
assembled, with the e-Ink screen last. While the end result looks
far cooler than a standard
already mounted and connected to vibrant, the downside is a much
monochrome eInk display. If
the board via a small ribbon cable. slower refresh time compared
you want a low-power, battery-
This saves fiddling about with a with a monochrome e-Ink screen
saving screen with a little more
thin and fragile screen, although typically around 15 seconds
From pizzazz, this is the one to get.
you still have to take care not to vs 1 second or less. The badge
27 / $35
press on it when mounting the example takes even longer, but
magpi.cc/2ou5KTh
pHAT on the Pis GPIO pins. demonstrates the ability for a
40 /$52
Maker
Says
A high-
resolution,
high-speed
3.5-inch
TFT display
for your
Raspberry Pi
Pimoroni
HYPERPIXEL
Vibrant mini screen packs a lot of pixels into a small space - Phil King
hile most small screens Once its all up and running, syncing and two-point capacitive
W connect to the Pis HDMI
socket, the HyperPixel is
youre sure to be impressed by
the HyperPixel's performance.
touch. I2C and SPI are also
disabled. Naturally, this limits
a HAT that plugs onto the GPIO The 800480 resolution matches the screens usefulness for some
pins. It comes pre-assembled, the official Pi 7-inch touchscreen, projects. In addition, if you want
so no soldering is required. On and with a pixel density of 270 to use PWM for fine control of
a Pi Zero, it mounts straight on ppi, the HyperPixel beats its rival the backlight brightness, you
top for a flush fit. For other Pi 3.5-inch screens. The display wont be able to output audio via
ADAFRUIT so it sits on top of the Pis USB shades) and good viewing angles. Last word
PITFT PLUS ports. A rubber foot (to stick to There is some occasional colour
3.5-INCH the top of the Ethernet port) and banding when displaying While not suitable for
This 480320 a support bolt are also supplied to fine gradients, but its hardly projects requiring GPIO pins,
screen also provide extra stability. noticeable. With a frame rate the HyperPixel is ideal for
plugs into the use in a mini media centre,
GPIO pins, but Before you can use the of 60 fps, videos look superb
only uses eight HyperPixel, youll need to install although we noticed a tiny bit of portable retro games
of them. It has a some software. Fortunately, as with distortion at the right-hand edge console, camcorder (see
resistive, rather magpi.cc/2tjrgNq), or as a
than capacitive, most Pimoroni products, you can when streaming YouTube videos
touchscreen interface. Since
touch interface. use a one-line installer command (but not when playing those
the Raspbian desktop is too
in the Terminal. To enter the stored locally).
fiddly to control in miniature,
command youll need to hook the That frame rate is down to
youll want to create your own
Pi up to another monitor, or access the use of DPI (Display Parallel
custom GUI. Whatever you use
it remotely via SSH. When the Interface). The downside to this
it for, this is a stunning screen.
software has been installed, the Pi is that the 18-bit colour uses
45 / $45
will only display to the HyperPixel, 18 GPIO pins, while the rest are
magpi.cc/2uf3kxq
unless you revert the config.txt file. needed for functions including
40/$50
Maker
Says
pi-top
PULSE brings
the arts
intoSTEAM
pi-top
Related
modules and aimed at educational with Raspbian after installing a that helped us figure out how to
users. Usually these add-ons single piece of software. use everything.
are designed to enhance the Its a very tight fit on the All in all, its one of the most
UNICORN experience of using the pi-top, Pi. The case barely misses the fun HATs weve seen in a while,
HAT HD but thats all changing with their Ethernet port, and the connectors allowing users to explore many
With its
latest and most ambitious add-on, for the pi-top hang over the amazing project ideas.
programmable
1616 RGB LED the pi-topPULSE. board, increasing the footprint
display, this It may be ambitious, but it is of the Pi. As an educational tool
is a great HAT
that is easy to
also very cool. From the top, its it is excellent, with a very robust Last word
code and fun to an unassuming white plastic Python library for creating light
An amazing idea with great
use in a range square. It includes a 77 LED displays and games.
of projects. execution we just wish it
display under the plastic, plus a The microphone and speaker
was slightly easier to program.
microphone and speaker. The PCB give you access to other functions.
With a bit of practice you can
is visible on the underside, but it The PULSE acts as a fully
create some astounding things
is lovely and well designed. integrated speaker for Sonic Pi,
with the PULSE.
On its own, it can be plugged and is even optimised for use with
32 / $41
into a pi-top using the special Amazon Alexa on the Raspberry
magpi.cc/UniHATHD
magnetic rails inside the slide-out Pi. Theres a great demo on the
CLEVER CARD KIT Rob Zwetsloot adds RFID tags to his projects with a set of rewritable
contactless cards and this special add-on
Related
n this issue of The MagPi goodies to help you play with zero soldering although if you
I we have a tutorial on
creating an automation
your new project, including a
push button and an RGB LED. The
want to make something a little
more complex, you can always get
RAINBOW system with Bluetooth tags, using lovely printed booklet that comes your soldering iron out. It doesnt
HAT the Pi Zero Ws built-in Bluetooth with the kit includes instructions require much extra software
STARTER connection to detect Bluetooth for projects that use the extra installation either, so we had the
KIT signals (page 22). This project goodies, and takes you through reader up and running in no time.
This kit doesnt
is based on the concept of key the easy Python code needed to Finally, the inclusion of the cards
use RFID, but
it does allow cards and other contactless RFID set up the reader. and key fob are very welcome
you to interact we already have some ideas for
BESTSELLERS
algorithm is illustrated with a
Authors: Annalyn Ng well-chosen data example, which
& Kenneth Soo
is examined with illustrative
LEARNING OPENCV 3
Data science is giraffes, to PageRank and social
everywhere (as is hype about networks applied to geopolitics
data science), as intelligent analysis and weapons sales, Numsense!s
Authors: Gary Bradski
of petabytes of new data becomes examples illustrate and illuminate,
& Adrian Kaehler
Publisher: OReilly essential to governments, business, but the real clarity comes from the
Price: 59.99 charities, and anyone looking to direct writing style, and the authors
ISBN: 978-1491937990 make intelligent predictions. The understanding of the subject matter.
magpi.cc/2hGVLM4
field requires strong mathematical This book is not just for the non-
skills, but what about people who technical reader - any programmer
Targeting the C++ API, Kaehler
need to make decisions about looking to understand data science
and Bradskis near 1,000-page
work covers every aspect of data, but who are not statisticians and machine learning will quickly
real-time image processing and programmers? gain an appreciation of algorithms
library OpenCV, as well as some
Ng and Soos guide to Data that other works introduce in a far
useful insights into computer
vision in theory and practice. Science for the Layman: No Math less digestible form.
Added is a clear explanation of
ten data analysis algorithms for
VISION AND BRAIN: supervised and unsupervised Score
HOW WE PERCEIVE learning - plus one reinforced
THE WORLD
PYTHON IN
those with a little Python who need
to know more. Coverage is split
A NUTSHELL
Author: Dr James V Stone between the basics (with plenty of
Publisher: MIT Press
detail on alternatives to standard
Price: 29.95
CPython); core Python and
ISBN: 978-0262517737
magpi.cc/2ulRAqA the standard library; and
Authors: Anna Ravenscroft,
Alex Martelli, a mixture of standard and
& Steve Holden extension libraries over topics
A computational theory of
vision. Dr Stones enjoyable Publisher: OReilly such as databases, numeric
and accessible look at the how Price: 55.99 processing, and dealing with
and why of animal and human ISBN: 978-1449392925
testing and debugging.
vision will give you a fresh magpi.cc/2ulYkoE
perspective on the subject. Treatment is always detailed
enough to get the job done.
A long time in the Network and web protocols
RASPBERRY PI making (the second edition make up the penultimate
IMAGE PROCESSING was released more than a decade section; and the book is rounded
KOTLIN
Authors: Matt Butcher & Matt Farina
this very effective guide, but Publisher: Manning
Price: 27.99
non-Java users should wait for a
ISBN: 978-1633430075
IN ACTION
different Kotlin book. Jemerov and
magpi.cc/2vj0JBA
Isakova are Kotlin insiders. They
make a persuasive case Pattern-focused guide to the highly
in the What and Why concurrent language that could solve
your web app problems.
Authors: Dmitry Jemerov chapter, before moving
& Svetlana Isakova
on to the basics of how
Publisher: Manning
Price: F
rom 20 (Amazon emphasising the lack of Refactoring
resellers only in the UK) boilerplate in examples JavaScript
ISBN: 978-1617293290 such as declaring classes, Author: Evan Burchard
magpi.cc/2vgdw9D and showing off the Publisher: OReilly
languages type inference. Price: 39.99
ISBN: 978-1491964927
Kotlin is a JVM language Classes are expanded
magpi.cc/2vC59Gi
from JetBrains, the people behind in a chapter which highlights
the IntelliJ IDEA Java IDE. Not the differences from Java in Refactoring and testing will turn
the first language to attempt to interfaces. Improved function calls, bad code to good. Well-written and
enjoyable read strongly recommended.
fix the problems of Java (hello adding methods to Java classes or
Scala!), but uptake has been swift, interfaces, lambdas, and Kotlins
and weve heard praise for the extensive type system round off the Inclusive
language even from some notable first halfs language introduction. Design Patterns
Pythonistas. Kotlin is touted as The second half gets you building Author: Heydon Pickering
a good replacement for Java in your own APIs, using higher Publisher: Smashing Magazine
Android development something order functions, and using deeper Price: 27.00
ISBN: 978-3945749432
of additional interest here, with features such as DSLs.
magpi.cc/2viJIYp
Android Things running on the Pi 3.
This book is aimed squarely at Best practices for pages accessible to all
Java developers: you dont need Score users, reconceiving web design as code-
not pixel-based. Essential reading.
to be a Java expert to benefit from
THE MONTH IN
RASPBERRY PI
AIY AND PHONES
Everything else that happened this month in the world of Raspberry Pi
INTERCOMS
For some reason, everyones been using their AIY Projects Voice Kits
in phones and intercoms this month
Kids smartphone
magpi.cc/2vMuSty
Above Martin Manders intercom project is retro and lovely
This one is a little mean but honestly, we laughed. This
Fisher-Price phone is a true classic and we love the idea
Another intercom? of giving it a hefty upgrade with AIY, complete with a
magpi.cc/2vMSlL7 massive glowing button in the centre. Would it be creepy
if you made it sing while the eyes moved? Very probably.
Already Martin is inspiring
other makers. Heres another
intercom voice project in
the works, this time using
Amazon Alexa. One day well
have to run a comparison
between the different voice
assistant platforms. Perhaps
we should have a retro intercom
competition to decide it?
JAMS IN PICTURES
Pictures from the past months Pi events around the world
twitter.com/Raspberry_Pi twitter.com/tnmoc
NEW I
t doesnt seem very long ago that Raspbian
Jessie came out. The successor to the original
version of Raspbian, Jessie brought us a lot of
RASPBIAN
minor upgrades and visual overhauls that are now a
normal part of the Raspbian experience.
New Debian releases happen roughly every two years.
Jessie came out in September 2015, so its now time for
STRETCH
Raspbian to upgrade to Stretch. The major upgrades this
time are happening below the surface, so you shouldnt
notice many differences when youre using the desktop.
What you will find is upgraded software, including
OUT NOW!
Chromium, and Bluetooth audio via ALSA, along with
SONIC PI 3.0.1
Sonic Pi 3.0 boasts a lot of new features, including:
Right Debian
SCRATCH 2 SENSE HAT EXTENSION
releases are Scratch was upgraded in the last Jessie release to
named after Toy Scratch 2, and this upgrade gives it the ability to
Story characters.
Stretch is an interact with the Sense HAT. Hopefully this will
octopus toy from introduce Scratch users to Astro Pi!
Toy Story3, about
whom youve
probably forgotten
after your heart
shattered at
the end
KICKSTART THIS!
Raspberry Pi projects you can crowdfund this month
magpi.cc/2w6avKr
CNC WOOD
BURNER
This is amazing. A spinning
BOBOP
wood burner powered by a
Raspberry Pi. Its cool, and
it creates amazing results
everything we like to see in
magpi.cc/2vMzmQU a Raspberry Pi project. It uses
a hot wood burner pen rather
BOBOP is billed as the first smart robot for parents. than a laser, which is probably
It looks a bit like the Mira bot project, featured earlier a lot safer.
in this issue, although this one apparently keeps an
eye on your kids. According to the creators, it was
prototyped heavily with a Raspberry Pi, which is still
being used as one of its main computers. You should JEEP ACCELEROMETER
just have enough time to give it a look before it ends.
magpi.cc/2w5lKCU When you have a big 44,
and you regularly go off-road,
you can experience some
interesting angles while driving.
Reddit user GoHomePortland
made a display to track the
pitch and roll while taking
his Jeep off-road. Pointless?
Probably. Cool? Absolutely.
EVENT REPORT:
CODE CLUB
MEETUP
Educators gather in Cambridge to find out how they can take their Code Clubs further
T
raditionally, Code meeting took place. Volunteers using pi-tops, said Sarah
Clubs are places for and educators who run Code Sheerman-Chase, Participation
educators to teach kids Clubs, along with prospective Manager at Code Club. Peter
about computer science. There Code Club hosts, visited Code Club Onion, who is a volunteer at a club
are thousands of them around (and Raspberry Pi!) HQ to attend in Essex, demonstrated physical
the world and theyve helped some talks, get to know other computing with micro:bits.
countless students improve Code Club volunteers, and find out There was also plenty of time for
their computing skills through how to improve their Code Clubs. networking, and the opportunity to
fun activities. At the event in Cambridge, meet the team, including Mickey
In Cambridge, in late July, everybody had a chance to get Day, the Code Club Coordinator for
a different kind of Code Club hands-on with Code Club projects the East of England, and myself.
Right Peter
Onions demos
drew crowds of
people wanting
to know more!
COMMUNITY PROFILE
DAVE
AKERMAN
High-altitude balloonist and master of
LoRa, Dave likes to send Pis as high as
the atmosphere will allow
Dave
themed payload. The caption reads and many, many more miles to
The Queen, The Duke of York, and assisting with the Foundations
my TARDIS, and sums up Daves Skycademy programme, helping
Category: High-altitude maker career in a heartbeat. to explore HAB with educators
balloonist Though writing software for from across the UK. Using a
industrial automation pays the Raspberry Pi and various other
Day job: HAB enthusiast/
bills, the majority of Daves time pieces of lightweight tech, Dave,
software engineer
is spent in the world of HAB and and Foundation staff member
Website: daveakerman.com the ever-growing community James Robinson, explored the
twitter.com/daveake that encompasses it. And, while incorporation of high-altitude
he makes some money sending ballooning into education. Through
Below Dave continues to help business-themed balloons to near- Skycademy, educators were able
others while breaking records
space for the likes of Aardman to learn new skills and take them
and having a good time
exploring the atmosphere Animations, Confused.com and to the classroom, setting off their
HIGHLIGHTS
own balloons with their students, definitely helped, as Dave went progression. Throw in his coding
and recording the results on on to mention on Twitter a few skills from learning to code on a
Raspberry Pis. days later. Teletype and its no wonder he
But education isnt the only Dave first fell in love with high- was ready and eager to take to the
reason for Daves involvement altitude ballooning after coming skies, so to speak, and capture the
in the HAB community. As across the hobby as a video shared curvature of the Earth. What was
with anyone passionate about a
specific hobby, Dave strives to
break records. The most recent
As with anyone passionate
record-breaking flight took place about a specific hobby, Dave
on 13 August 2017, as Daves
Raspberry Pi Zero HAB sent home strives to break records
the highest images taken by any
amateur high-altitude balloon on a photographic forum. With a so great about using the Raspberry
launch. At 43,014 metres, no other lifelong interest in space thanks Pi was the instant gratification
HAB balloon has provided images to watching the Moon landings as gained when receiving images
from such an altitude, and the a boy, plus a talent for electronics in real-time as they were taken
lightweight nature of the Pi Zero and photography, it seems a natural during the flight. While other
devices could operate a camera
and store the photographs for
later retrieval, Dave was able to
transmit them back down to Earth
and check the progress of his
balloon while attempting to break
records with a flight.
High-altitude ballooning isnt
the only part of Daves life that
incorporates a Raspberry Pi.
Having lost count of how many
Pis he has running tasks, Dave
has also created radio receivers
for APRS (ham radio data), ADS-B
(aircraft tracking), and OGN
(gliders), along with a time-lapse
Daves most recent flight broke a new record. On 13 August 2017, his HAB
payload was able to send back the highest images taken by any amateur flight camera in his garden, and a few
more for tinkering purposes.
RASPBERRY JAM
EVENT CALENDAR
Find out what community-organised, Raspberry Pi-
themed events are happening near you
FIND OUT
ABOUT JAMS
Want a Raspberry Jam in
RASPBERRY
your area? Want to start one?
Email Ben Nuttall about it:
4 JAM JOBURG
Johannesburg,
South Africa
ben@raspberrypi.org
8 RASPBERRY JAM
@ PI TOWERS
Cambridge, UK
JAMMING
3 IN MARLBOROUGH
Marlborough, UK
TECHNO JAM
1 Southport, UK
7 MANCHESTER
RASPBERRY JAM
Manchester, UK
2 GUILDFORD
RASPBERRY JAM
Guildford, UK
MANCHESTER
RASPBERRY JAM RASPBERRY JAM ADVICE
When: Saturday 9 September
Where: The Shed, Manchester, UK
magpi.cc/2wgeAMp FINDING
VOLUNTEERS
A very long-running Jam that
celebrated its fifth birthday in June
of this year, finally back from its
summer hiatus.
Youll find that a lot of the people who
attend your first Jam will become your
RASPBERRY JAM future volunteers
@ PI TOWERS Mike Horne
When: Saturday 16 September
Cambridge Raspberry Jam
Where: Raspberry Pi HQ,
Cambridge, UK
magpi.cc/2wgB0xb Every Raspberry Jam is entitled to apply
A family-friendly event where for a Jam starter kit, which includes
everyone is welcome, providing magazines, printed worksheets, stickers,
coding and digital making activities flyers, and more. Download the book here:
for children and adults. magpi.cc/2q9DHfQ.
have just received the latest The MagPi #60, Is the latest one safe to use? How do I know its safe? WRITE
I and was delighted to find the attached
Raspberry Pi Desktop x86 DVD. Unfortunately
Many thanks,
CraigT
TO US
I then realised I hadnt bothered adding a DVD drive Have you got
to my new computer. My intention was to run it in For future reference, you can easily find the ISO of something youd
VirtualBox, so ideally I just need an ISO image. the latest x86 Raspberry Pi Desktop build by going like to say?
Where would the best place be to download the to rpf.io/x86, set up by Raspberry Pi Community Get in touch via
latest version of the ISO image (happy to do so as Manager Ben Nuttall. The one you pointed to in the magpi@raspberrypi.
a torrent)? forum thread was the latest version. As a general rule, org or on The MagPi
section of the forum
Quite a few blogs from last year point to another if theyre hosted on the Raspberry Pi website, theyre
at: raspberrypi.org/
image but I found a different one that seems to be safe to use. If theyre beta release or some other form forums
more up to date. of non-stable release, they will be labelled as such.
RASPBERRY PI AND
MICROCONTROLLERS:
A POWERFUL PAIRING
Matt Richardsons take on how two popular technologies work together
hen I first joined the maker movement in necessarily mean that youll choose one or the
W 2010, microcontrollers such as Arduino were
already an indispensable tool for making
other. A single-board computer can work well with
a microcontroller in a unified project.
things with technology. I used Arduino in many of A simple serial communications connection
my projects because it was so easy to program, and between a Raspberry Pi and Arduino means that the
there was a ton of easy-to-follow examples and two boards can talk to each other and pass data back
community support available. At the time, some of and forth. For example, if you were making your
my projects involved operations such as saving data own pen plotter, you may have a microcontroller
and hosting a web server, which would push any controlling the stepper motors which move the pen.
microcontroller of that era to its limits. The data could be fed to the microcontroller by a
Therefore, when maker-friendly single-board single-board computer, which shows a user interface
computers like Raspberry Pi came onto the scene, on a screen or via a built-in web server.
I started to think a lot about how their powerful
processors would be useful for more advanced
projects. Coupled with the on-board general-
Their strong
purpose input and output pins, it meant makers had
new tools at their disposal to push the boundaries of interoperability opens
up so many possibilities
whats possible for their projects.
Theres a lot of overlap in the functionality of
a single-board computer and a microcontroller.
Both have the ability to run code and interface with The way that the two platforms work together
electronics. The strength of a single-board computer doesnt stop there. A microcontroller isnt very
lies in its ability to do high-level tasks, such as useful if you dont have a computer to write the code
running web servers, writing to databases, capturing and upload it to the board. Luckily, the Arduinos
photos, executing computer vision algorithms, development environment runs nicely on Raspberry
playing audio and video, and so on. Microcontrollers Pis Raspbian operating system. So even if your
have their strengths as well. For example, theyre project doesnt call for anything more than a
good at sending signals with precise timing, which microcontroller, why not use your Raspberry Pi
is important for controlling some types of motors or to program it?
addressable LEDs. Other advantages include their low Contrary to what some may believe,
energy consumption, their quick start-up time, and microcontrollers and single-board computers arent
often they have built-in analogue input capability. competitors, but partners. While theres a lot of
overlap in the functionality of both types of devices,
Working together theyre both great tools to have in your maker toolbox.
As a maker, having both microcontrollers and single- Their strong interoperability opens up so many
board computers in your toolbox means you can possibilities for rather complex projects. When you
accomplish a broader range of projects. Choosing make with both microcontrollers and single-board
the right type of board based on your projects needs computers, the whole is greater than the sum of the
is an important skill for a maker, but that doesnt parts and that makes them a powerful pair.
ESSENTIALS
LEARN | CODE | MAKE