Revista Raspberry Pi
Revista Raspberry Pi
Revista Raspberry Pi
CC/STORE
RETRO
Issue 88 December 2019 magpi.cc The official Raspberry Pi magazine
ZX Spectrum
Next
Plus! British icon
reborn
Build the best
Christmas projects
Thermal
Assemble a Testing
low-cost camera bot Raspberry Pi firmware
turns down the heat
Capture the stars with
astrophotography
£5.99
WELCOME
to The MagPi 88
R
etro Computing is always close to our hearts here at Raspberry
Pi Towers. We grew up with all the greats: BBC Micro, Sinclair
Spectrum, Commodore 64 and Amiga.
No matter which classic system you prefer, we can all agree that retro
computing on Raspberry Pi has never been better. Lucy
EDITOR
With its faster processor and increased RAM, Raspberry Pi 4 can Hattersley
become virtually any 8- or 16-bit computer, enabling you to relive those Lucy is Editor of
The MagPi. Her first
glory years, rediscover classic programs, and learn computer science computer was a
ZX Spectrum, but
from the source. See our wonderful Retro Computing feature (page 24). it was Commodore
that stole her heart.
Raspberry Pi 4 is a powerful computer – more power needs more First with the C64,
energy, and that means more heat. The engineering team have been then the Amiga.
magpi.cc
hard at work bringing down the heat, through clever tweaks that keep
the speed levels up, but the heat demands down.
We’ve expanded our heat tests for Raspberry Pi 4 and the result is
a sublime Thermal Testing the Raspberry Pi 4 feature (page 66). It’s
packed with insider information about how computers are made. GET A
Finally: Merry Christmas! Rob starts Christmas around October RASPBERRY
and has been working up to a big ZERO W KIT
Christmas Lights tutorial (page 40)
and the Top 10 Christmas Projects PAGE 22
(page 80). Both are cracking features.
I hope you all have a great holiday
season, and make lots of amazing
things. Don’t forget to share your
projects with us!
magpi.cc 03
CONTENTS
Contents
> Issue 88 > December 2019
Cover Feature
24 Retro computing
Regulars
06 World of Raspberry Pi
92 Your letters
97 Next Month
98 The Final Word
Project Showcases
10 ZX Spectrum Next
14 The Swirl Machine
18 Astrophotography Autoguider 24
10 18
DISCLAIMER: Some of the tools and techniques shown in The MagPi magazine are dangerous unless used with skill, experience, and appropriate personal protection equipment. While
we attempt to guide the reader, ultimately you are responsible for your own safety and understanding the limits of yourself and your equipment. Children should be supervised. Raspberry
Pi (Trading) Ltd does not accept responsibility for any injuries, damage to equipment, or costs incurred from projects, tutorials or suggestions in The MagPi magazine. Laws and regulations
covering many of the topics in The MagPi magazine are different between countries, and are always subject to change. You are responsible for understanding the requirements in your
jurisdiction and ensuring that you comply with them. Some manufacturers place limits on the use of their hardware which some projects or suggestions in The MagPi magazine may go
beyond. It is your responsibility to understand the manufacturer’s limits.
04 magpi.cc
CONTENTS
40 62
Tutorials
Reviews
79 GPIO Xmas Tree
80 Top 10 Christmas projects
82 Learn computing systems
Community
84 Liz Clark interview
86 This month in Raspberry Pi
Liz Clark interview 90 Events calendar
PIARM ROBOT 95
WIN ARM KIT!
magpi.cc 05
THE WORLD OF RASPBERRY PI
Gender Balance
in Computing
programme opens
Raspberry Pi Foundation rolls out scheme to study why young women
don’t choose to study computing. By Rosie Hattersley
T
he Raspberry Pi Foundation has announced “We are drawing on existing research which
a UK-wide rollout of the Gender Balance in points to a variety of influencing factors, including
Computing (GBIC) programme. The GBIC girls feeling like they don’t belong in the subject or
programme launched in April to understand its community, a lack of sustained encouragement,
why many young women don’t choose to study and a lack of role models in computing when
computing-related subjects. “We are working making career choices,” she explains.
with schools to understand which particular The series of rigorously evaluated pilot
Many young women initiatives to address gender balance are most interventions involving 15,000 pupils and 550
don’t choose to
effective,” says Sue Sentance, Chief Learning schools will be the largest national research effort
study computing-
related subjects Officer at the Raspberry Pi Foundation. to tackle gender balance in computing to date.
You can read more about the Gender Balance in
Computing programme on the Raspberry Pi blog
(magpi.cc/QbBrQ6). Schools can register for the
scheme at magpi.cc/gbic.
ZX Spectrum
Next
An iconic 8-bit computer is set to enjoy a
retro revival with the help of a Raspberry Pi
Zero, as David Crookes explains
I
n the 1980s, the ZX Spectrum range of 8-bit
computers quickly became legendary. It
boasted no more than 128kB of RAM (16kB
on the original model), a Zilog Z80 CPU running
at just 3.5MHz, and a palette of up to 16 colours,
two of which were black. Yet the humble
‘Speccy’ encouraged a generation of bedroom
programmers and underpinned a flourishing
Jim Although a tape deck can be plugged
MAKER
Quick
A Raspberry Pi Zero fits FACTS
inside
the Next’s case, connects to the
main computer’s XXXXXand
> board,
works as a slave co-accelerator,
> Xto
allowing the Next XXXX
make use
of its memory, CPU, and GPU
> XXXXX
> XXXXX
> XXXXX
Raspberry Pi loading
A
rt comes in many forms, and for this
project it takes the form of an interactive
wine art creator called The Swirl
Machine. It’s a lot more complicated than it
might sound, though.
“The Swirl Machine is an interactive, digital-
meets-the-real-world machine that swirls Santa
Maria Valley wine and turns it into a digital piece
of art,” say the team from KPS3, the marketing
agency behind The Swirl Machine. “It was created
and developed by KPS3 for Visit Santa Maria Valley.
The machine allows users to select their ‘Fill Level’
and ‘Swirl Speed’. In real-time, the user can watch
the glass fill, swirl, and splash the wine onto a
Rob Gaedtke,
MAKER
magpi.cc/9yrkJW
Warning!
Spinning glass
If you choose to recreate
this project, please fix
glass on a spinning
turntable carefully (and
at your own risk).
Thousands of pieces
of art have been
created – is your
piece on display?
In real-time, the user can > The queue lets you
watch the swirls
fact that it was a spill fit perfectly into the vibe > Art is very cool,
of Santa Maria Valley’s wine experience… if you however you
spill a little, no one really cares. And because of make it
who KPS3 is as a company, it clearly had to push
technical boundaries.”
Making a splash
At the time of writing, there have been around
2000 ‘swirls’ on The Swirl Machine’s website
We love the arm with
(magpi.cc/9yrkJW), and the machine has been
an air compressor
made possible thanks to a Raspberry Pi. that sucks up paper
200 PAGES OF
RASPBERRY PI
Use Raspberry Pi 4 as a desktop
PC and 4K home media centre
Be inspired by incredible
projects made by other people
Astrophotography
Joe
Autoguider
MAKER
Kutner
The awe-inspiring wonders of the night sky encouraged a keen stargazer to
Joe Kutner (aka
Codefinger) is a find a better way to capture their beauty. Rosie Hattersley gets inspired
software architect
at Salesforce.com,
C
where he works reating stunning photographs of the out of observing. It served an important function,
primarily with
Java and other night sky requires planning, patience, though: controlling both my camera and my
open-source and reliable star-tracking equipment. A mount. Without it I would only be able to take very
technologies. He’s desire to travel a little lighter led keen amateur short exposures of the moon and planets.”
published several
astronomer Joe Kutner to embark on his first Joe considered using an iPad or a Microsoft
books about
programming with Raspberry Pi project. Surface instead, but both were far too expensive.
Ruby and Java. He Joe says there’s nothing worse than taking hours He wanted to keep the build cost below $100, and
enjoys amateur
of astrophotography images only to find out your neither worked well with his chosen software.
astronomy, mostly
observationally, but telescope was drifting, causing the stars to look Instead Joe picked up a Raspberry Pi, a case, and
he also dabbles in more like lines than points. To protect against this a touchscreen for less than $100, and added a red
astrophotography. kind of misalignment, he needed an autoguider: plastic cover so he was still able to use the setup
@codefinger a computer and camera that track a star in the in night-vision mode. These work alongside the
telescope’s field of view to ensure that it stays in various bits of astronomy kit Joe uses regularly on
the same position throughout the session. his stargazing missions.
“The main goal of my project was to get rid of
the laptop,” Joe tells us. “I needed to control my Under open skies
telescope in the field. I spend enough time in front Joe made extensive use of general purpose open-
of a computer at work, and the laptop took the fun source software such as Raspbian Stretch and Git,
Quick FACTS
> Raspberry Pi
The Horsehead Nebula and Flame Nebula, records over
photographed from Joe’s Alabama driveway with
the help of his Raspberry Pi-controlled autoguider several hours
while Joe sleeps in
Raspberry Pi in a case his tent
with a red plastic overlay
so it can be used at night
> Joe recommends
Lacerta MGEN II
(magpi.cc/3XGdSW)
if you don’t want to
build your own
Build an autoguider
International expansion
Now that Joe has successfully built a fairly portable
astrophotography rig, he sees its potential for
explorations further afield. He’s keen to try out his
autoguider with other types of astrophotography
kit such as the ultra-compact Sky-Watcher Star
Adventurer series of mounts. “When combined
with my Raspberry Pi,” he says, “I could take the
whole rig on an airplane as carry-on. That would
give me access to some very dark skies.”
SUBSCRIBE TODAY
FROM ONLY £5
Subscriber Benefits
FREE Delivery
Get it fast and for FREE
Exclusive Offers
Great gifts, offers, and discounts
Great Savings
Save up to 35% compared to stores
FREE Raspberry Pi
Zero W Starter Kit
WITH YOUR SUBSCRIPTION
Subscribe in print
for 12 months today
and you’ll receive:
Raspberry Pi Zero W
Raspberry Pi
Zero W case with
three covers
USB and HDMI
converter cables
Camera Module
connector
Offer subject to change or
withdrawal at any time
SUBSCRIBE
on app stores
magpi.cc 23
RETRO
COMPUTING with
RASPBERRY PI 4
Want to rediscover the golden years of computing and enjoy
a bit of classic gaming? Go old-school with PJ Evans
M
odern computers like Raspberry Pi 4 are
amazing, but sometimes we yearn for an
earlier time with 8-bit processors, and either
BASIC language or machine code. A time when computers
were stripped back, with simpler architecture that required
deep understanding.
Quite possibly it is this, rather than straightforward
nostalgia, that fuels the healthy retro computing scene.
Retro computing is also a playground for makers,
providing endless inspiration for projects and supported by
a wealth of open-source software. Over the next few pages
we’ll fire your imagination by looking at building your own
retro computer, whether it’s revitalising old tech or coming
up with a new design. We’ll also try to answer that age-old
question: what to do next?
In this feature, we’re going to look at upcycling vintage
computers, building retro games consoles, playing retro
games, and classic programming. Let’s go back in time.
26 28 30 32
Upcycle a vintage Build a DIY Great gaming Get hold
computer arcade console essentials of games
UPCYCLE A
VINTAGE COMPUTER
Don’t bin an old computer – give it a new lease of life with Raspberry Pi
S
adly, not all tech is built to last and it’s the sourcing of two Molex connectors (relatively
quite easy to pick up an expired 1980s easy to source online – see magpi.cc/molex)
home computer. You may not be able to and some pieces of stripboard to solder in the
save the circuitry, but if the case and keyboard connectors, and some wiring to connect to the
are good, you might just have a great project for GPIO. The column side (KB2) will need diodes on
a Raspberry Pi computer. Add some emulation each line to avoid short-circuiting.
software and you’ve got a modern take on a classic.
VINTAGE TECH
The ZX Spectrum was a mainstay
of the 1980s home computer
revolution and sold millions of units
BUILD A DIY
ARCADE CONSOLE
How one young maker built a retro games console
S
ome amazing projects come out of after-
MAKER
READ CLASSIC
MAGAZINES
Vintage computer magazines often
carried code alongside news and
reviews of the latest technology. You
can read many classic magazines on
archive.org and other websites. Here
are a few of our favourites:
Jamie’s Raspberry
Pi computer uses
Pimoroni’s Picade X HAT
to connect the joystick, Your Spectrum
buttons, and audio (and Your Sinclair)
There’s some great code to play around
with in Your Spectrum magazine and
the early issues of Your Sinclair.
magpi.cc/yoursinclair
A clever alternative
to 3D printing or
laser-cutting, this
case is made from
picture frames
Ahoy!
“ THE BIGGEST
Focused mainly on Commodore
Emulate retro computers, Ahoy! had a range of high-
games with Lakka
CHALLENGE WAS
quality tutorials for Commodore 64 and
Amiga machines.
We look at the hardware
here, but what about
software? We’ve chosen
CUTTING THE magpi.cc/ahoy
TEN GREAT
GAMING ESSENTIALS
For the proper experience you need the proper equipment.
Here’s some of our favourite retro computing kit
Picade
From £150 | magpi.cc/picade
For the ultimate retro experience, this bar-
top cabinet is hard to beat. Picade was one of
the original flagship Raspberry Pi projects,
and this revised unit is everything you could
want for your own personal arcade. A suite
of professional-grade switches and joystick,
LCD monitor, Picade X HAT, and a cool
customisable cabinet, all in one kit. If you
don’t need a keyboard (and you could always
use a wireless one), Picade is a great choice.
Clear Deluxe Arcade any original equipment you’ve managed to acquire. Regardless, for any DIY
project, you’re going to want that original button-mashing sensation.
Controller Kit
£100 | monsterjoysticks.com
This arcade-stick-style kit allows you to build
LACK Table £6 | magpi.cc/UAtraY
an arcade machine right into the stick, and It’s one of IKEA’s most famous pieces of furniture. The LACK table
the clear version enables you to see Raspberry is cheap, cheerful, and available in a range of colours. Best of all, it’s
Pi at work inside. It comes with high-quality hollow and that means we can put stuff in it. It wasn’t long after the
Sanwa arcade parts and a Monster Joysticks original Raspberry Pi devices appeared that various projects started to
GPIO Interface to hook them up to Raspberry centre around this ubiquitous table. This particular project, from Matt
Pi. There are a few different design options, (aka Raspberry Pi Spy), is a beauty, featuring two-player support and
in case you don’t want the clear version, and a an attractive bezel. LACK is perfect if you’re considering a ‘cocktail’-
slightly cheaper plywood variation. style build. Read more at magpi.cc/9RG6SD.
GET HOLD
OF GAMES
You’ve got the kit, but what to play?
Welcome to the world of homebrew
I Nohzdyve
f you think retro gaming is just about old
games, then we’ve got some great news.
Thanks to the ‘homebrew’ scene, new Free | magpi.cc/nohzdyve
games for old systems are appearing all the time.
PLATFORM: ZX Spectrum
Original games rub shoulders with ‘demakes’,
modern games on old systems. We’ve picked Charlie Brooker’s Black Mirror episode
a few of our favourites and provided links for ‘Bandersnatch‘ made headlines with its
finding out more. innovative ‘choose your own adventure’
format. It’s riddled with references to the
home computer scene of the 1980s,‘Tuckersoft’
being based on Liverpool powerhouse Imagine.
ZX Spectrum enthusiast Matt Westcott was
commissioned to bring one of the featured
games to life.
Halo 2600
Hibernated One Free | magpi.cc/halo2600
PLATFORM: Atari 2600
Free / Name your price | magpi.cc/hibernated1
Yes, you read that correctly and yes we are talking
PLATFORM: ZX Spectrum / Commodore 64 / Amstrad CPC
about Microsoft’s legendary Halo franchise.
In Stefan Vogt’s adventure you play Olivia, awakened from hibernation Remarkably, unlike many demakes that can
when an alien spacecraft traps her ship, Polaris-7, in a tractor beam. infringe copyright, this version was written by Ed
With no communication from the other craft and surrounded by death Fries, leader of the original Xbox project and has
and decay, can she escape? This is a text adventure in the classic style been given Microsoft’s blessing. Some cartridges
and the opening chapter in an ongoing series. were manufactured by AtariAge, although you can
download the game for free.
HOMEBREW
DESTINATIONS
Need more games for your console?
These sites are full of homebrew
and legal downloads Warning!
It is illegal to download
copyrighted ROMs from
the internet. The MagPi
does not endorse video
game piracy and strongly
recommends you stick
to emulators that do
not use any protected
software, such as BIOS
Teeter Torture files, and stick to game
downloads that are
offered with the consent
Free | magpi.cc/teetertorture of the rights holder.
PLATFORM: MAME
This game is an original from 1982 which has now
been released free of charge for non-commercial
use by Exidy. It has mysterious origins and only
one cabinet is known to exist, which luckily still World of Spectrum
works! You control a cannon on a trolley that The admins of this site have been thorough in
balances on a barrel of TNT. Shoot the aliens or getting clearance to host the many thousands of
they’ll topple you over, triggering the detonator. games available.
worldofspectrum.org
Relentless 64
Free | magpi.cc/relentless64
PLATFORM: Commodore 64 Vintage Is The New Old
Relentless 64 is a homebrew of a homebrew. A massive collection of homebrew software for
many different platforms.
Originally, the Amstrad CPC version was the
winner of a 16kB cartridge competition in 2013 vintageisthenewold.com
RASPBERRY PI
Retro Gaming with Raspberry Pi shows you
how to set up a Raspberry Pi to play classic games.
Build your own portable console, full-size arcade
cabinet, and pinball machine with our step-by-step
guides. And learn how to program your own games,
using Python and Pygame Zero.
Add a camera to
Part 05
A
camera is an exciting accessory to give At the horizontal middle of this line, draw the
to a robot. First, you will be able to see 8 mm square hole for the lens, with mounting
the world from the point of view from the screws either side by 10 mm. These have a 2 mm
robot, creating a mobile periscope or debugging diameter. Two screws are enough for the camera.
your code from this view. However, a camera also
Danny Staple
MAKER
Connecting
the camera to
Raspberry Pi
After drilling, the camera mount area should look like a bit
like this. It may need filing to remove rough edges
Gently slide the clip from the camera. Gently push the cable in
straight. The contacts should be facing into the camera board
sudo raspi-config
Smart Christmas
tree lights
Bored of normal Christmas lights? Hack your Christmas tree
with a Raspberry Pi and make it festively voice-controlled!
C
hristmas is here, and that means it’s time sudo pip3 install pyaudio
to decorate. Over the years, we’ve made sudo apt install flac
Rob Christmas tree stars, normal tree lights,
MAKER
Zwetsloot and even a light-up card you can make out of the Plug a microphone in, and make sure that Raspbian
cover of issue 52! is using it as an input device (you may need to
Rob is amazing. This year, we’re heading back to the tree lights right-click on the volume icon in the top right to
He’s also the to give them an extra ability: voice-controlled do so). Then run the test script:
Features Editor
of The MagPi, a lights! We’ll be doing this using a slightly
hobbyist maker, easier method than other audio services, so you python3 -m speech_recognition
cosplayer, comic won’t need to sign up to any Amazon or Google
book writer, and
developer accounts. Let’s get festive! It will ask you to speak a word and it should return
extremely modest.
what you said.
magpi.cc
Finally, install the NeoPixel libraries with:
Figure 1
Top Tip
Speech
recognition
troubleshooting
If you’re having
trouble with
the test for the
SpeechRecognition
library, head here igure 1 The circuit is fairly
F
to troubleshoot: simple – make sure you
connect the DIN side of the
magpi.cc/RgpLyc. NeoPixels to your Raspberry Pi
Top Tip
Adding trigger phrases
RGBW code 07 Install your lights
We’ve tried to keep this very simple,
including trigger words as part of if statements.
09 Once you’ve perfected your lights and voice
With RGB
To add one, all you need to do is add an extra if control, it’s time to put the lights up! We like to
NeoPixels, you
only need to statement to the loop. Say you want to add the wrap ours around the tree, making sure there’s
program three term ‘happy holidays’, you’d do so like this: easy access to change any batteries. You may need
variables: red, to add some clips to the tree as well.
green, and blue. if value == 'happy holidays': If you plan to stick them to other furniture,
With RGBW ones,
strip.fill((255,0,0) you may need to make sure you have a temporary
you’ll need to
strip.show() solution, like Velcro with sticky backs, so you can
add a fourth, e.g.
(255,0,255,255). easily add and remove them at the start and end of
In this example, we make the lights turn bright red. the festive season.
smartlights.py DOWNLOAD
THE FULL CODE:
> Language: Python magpi.cc/SmartXmas
001. import speech_recognition as sr
002. import time
003.
004. from gpiozero import Button
005.
006. import board
007. import neopixel
008.
009. button = Button(21)
010.
011. # speech recognition settings
012. r = sr.Recognizer()
013. m = sr.Microphone()
014.
015. # LED strip configuration:
We’ve seen people install lights in bookcases for fun effects 016. LED_COUNT = 90 # Number of LED pixels.
017. LED_PIN = board.D18 # GPIO pin
018. LED_BRIGHTNESS = 0.2 # LED brightness
Light up your tree!
10 It’s time to do the final test of your lights
019. LED_ORDER = neopixel.GRB
# order of LED colours. May also be GRB, GRBW, or RGBW
and turn them on! Test out the voice control, and 020.
maybe think of moving the microphone position 021. # Create NeoPixel object with appropriate configuration.
022. strip = neopixel.NeoPixel(LED_PIN, LED_COUNT, brightness = LED_
around. With some really long wires, you can also
BRIGHTNESS, auto_write=False, pixel_order = LED_ORDER)
put the button to activate the speech recognition in 023.
a place that’s easy to reach. 024. # Setting variables for a specific sequence
At the end of the day, you don’t have to turn the 025. red = (255,0,0)
lights off, either: you just need to say ‘lights off’.
026. green = (0,255,0)
027. flip = 0
028.
029. # Function to make an alternating series of lights
T he speech recognition 030. def merrychristmas():
031. global flip
part of the code is 032. for i in range(90):
033. if flip == 0:
remarkably simple 034. strip[i] = red
035. flip = 1
036. else:
Adding sound and more 037. strip[i] = green
11 One extra feature you might consider is
038. flip = 0
039. strip.show()
sound output, which can be handled with Pygame. 040.
For some voice keywords, you could have lights 041. while True:
sync up to classic Christmas songs, carols, or 042. button.wait_for_press()
043. button.wait_for_release()
whatever you choose.
044.
We suggest making it so the song only plays 045. # set the audio source
through once before going back to normal, though, 046.
to avoid incurring the wrath of the people you live 047. with m as source: audio = r.listen(source)
with. Last year we create a tree-topper star – you
048.
049. # recognize speech using Google Speech Recognition
can easily add some NeoPixels to a 3D-printed star 050. value = r.recognize_google(audio)
like this and have the system control it as well! 051.
052. # check the speech against trigger words
053. if value == 'lights on':
054. strip.fill((255,255,255))
055. strip.show()
Happy Holidays!
12 We really hope you enjoy making this
056.
057. if value == 'lights off':
project and, even if you don’t celebrate Christmas, 058. strip.fill((0,0,0))
we hope you think of it as a great introduction to
059. strip.show()
060.
voice control with Python. 061. if value == 'Merry Christmas':
From all of us at The MagPi, Happy Holidays and a 062. merrychristmas()
Happy New Year!
Hack GraviTrax
Part 02
with Raspberry Pi
Make your GraviTrax layout trigger LEDs for a
dazzling light show to enhance your layouts
L
The WS2812B
ast month we saw several ways of detecting
the balls as they passed by in a GraviTrax
02 The WS2812B (aka NeoPixel) LED is available
layout. We used this to trigger sound samples in a number of different configurations, ranging
to accompany your ball’s run through your layout. from individual LEDs to arrays. We will concentrate
Mike
MAKER
Cook This month we look at how to use those triggers here on just using the LED strips and LED rings. The
to fire LED patterns. We are going to use both I2C- aim is to make them fit into the GraviTrax system
Veteran magazine controlled displays and the ubiquitous WS2812B like an extension component, as we did with the
author from the old LEDs, sometimes called NeoPixels. detectors last month. For the strips, we used the
days, writer of the
Body Build series,
highest LED density we could find at 144 LEDs per
plus co-author of metre, although you could use others. Making a
Raspberry Pi for strip to run under a track is simple. We mounted
Dummies, Raspberry
What sort of LED?
Pi Projects,
and Raspberry
01 We will look at two sorts of LED here: the
a small section of LED strip on 13 mm wide, 3 mm
plywood. The length of track determines how many
Pi Projects WS2812 and the I2C-controlled type, based on LEDs you can fit underneath them.
for Dummies. the 31FL3731 LED matrix driver. This last type has
magpi.cc/TPaUfT become more popular lately as it lends itself to
controlling a lot of LEDs from a very small package.
LED strips
As the I2C protocol is a bus, each 31FL3731 you
have on a bus needs to have a different address.
03 For the three lengths of track used in the
This chip is capable of being set to four different starter pack, we made 8-, 14-, and 20-LED strips.
addresses, depending on what signal you connect We glued a three-pin connector on the end and
to an external address line pin on the chip. There wired it up to the strip. Then we glued a cardboard
are techniques you can use with the I2C bus to get hexagon to the middle of the strip, so the strip
You’ll Need more, but we won’t go into these here. went across the flats of the hexagon. For the 8-
and 20-LED strips, the hexagon was glued in the
> Pimoroni LED SHIM middle of the strip. But for the 14-LED strip, we
magpi.cc/9962nm
glued the hexagon 10 mm from one end because it
> Pimoroni 11×7 LED only spans two hexagon positions – see Figure 1.
Matrix Breakout
magpi.cc/JdMBNi
> W
S2812 LED strip,
144 per metre
LED rings
magpi.cc/BfaifB 04 There are two sizes of LED ring we found
useful, the 12-LED ring and the 16-LED ring.
We mounted the 16-LED ring horizontally on
a 71 mm round disc of 3 mm plywood, and cut a
6 mm hexagonal hole in, to push-fit a large height
tile into it. You can do this with a fret-saw if you
haven’t got access to a laser cutter. If your cutting
is not so accurate and the tile pushes through,
Figure 1 Three
lengths of LED strip
Figure 1 you can always fix it with a dab of hot-melt glue.
Timer display
A Stargate
LED ring
The Stargate
06 We used a 12-LED ring for this, mounted
on a half plate. This time we used only two of
the mounting holes to fix the ring on the plate,
including nuts on the back of the board. We cut
one cardboard hexagon in half across the points,
Figure 4
Figure 7
11×7 matrix
11 This is a white LED matrix and we can
mount it in the GraviTrax system in two ways –
horizontally or vertically. Horizontal mounting uses
45 mm by 24 mm piece of 3 mm plywood, mounted
on a stack of three cardboard hexagons (Figure 11).
Vertically uses a 25 mm length of 32 mm right-angle
wood moulding on a single hexagon. We used a long
header and pushed the pins to one end of the plastic
strip to give us an even longer header length of
9 mm. By using M2.5 screws and 3 mm nylon stand- Figure 8
off tubes, we mounted the matrix with the holes
provided on it, as can be seen in Figure 12.
LED animations
12 The sorts of animations you can get the
LEDs to do are almost limitless. The long LED
strips can programmed so a single LED follows the
path of the ball underneath it, with careful timing.
Figure 7 Physical
Or a strip can be placed across the track so that the Figure 9 layout of WS2812
ball triggers an effect like it is breaking through a driver board
Figure 10
WS2812 software
13 Most animations can be used with a large
number of variation of colour, speed, and effects,
so we need to have software that will allow
animations to be called with a large number of
Figure 10 Mounted
LED SHIM
variations. We have chosen to use threads to make
Figure 11 Horizontally
this simpler. neo_thread.py shows what we came mounted matrix
up with for the WS2812 strips. We appreciate that
Figure 12 Vertically
a thread can be timed out at any time and, if this mounted matrix
happens between the setting of the strip address
and the showing of that strip, the animations Figure 11 Figure 12
might be wrong. In practice this rarely happens
and is not very noticeable when it does.
31FL3731 software
14 We separated this from the WS2812 software
because it’s easer to leave out if you don’t have
any of that sort of display, but it follows the same
format as the other code (see FL3731_thread.py)
You first need to install the libraries for the SHIM
neo_thread.py
> Language: Python
pattern_trigger.py DOWNLOAD
THE FULL CODE:
> Language: Python magpi.cc/Et6Qnt
068. def flash(add, repeats, delay, direction, frontCol, 099. for j in range(0, repeats):
backCol, wipe): 100. strip[add].fill(backCol)
069. strip[add].fill(backCol) 101. for i in range(0, len(seqToLight)):
070. for i in range(0, repeats): 102. for k in range(0, len(seqToLight[i])) :
071. strip[add].fill(frontCol) 103. strip[add][seqToLight[i][k]] = frontCol
072. setAdd(add) ; strip[add].show() 104. setAdd(add) ; strip[add].show()
073. time.sleep(delay) 105. time.sleep(delay)
074. strip[add].fill(backCol) 106. if not wipe :
075. setAdd(add) ; strip[add].show() 107. for k in range(0, len(seqToLight[i])) :
076. time.sleep(delay) 108. strip[add][seqToLight[i][k]] = backCol
077. if not wipe : 109. setAdd(add) ; strip[add].show()
078. strip[add].fill((0, 0, 0)) 110.
079. setAdd(add) ; strip[add].show() 111. def initIO():
080. 112. global muxAdd, strip
081. def push(add, numLed, delay, direction, frontCol, 113. io.setwarnings(False)
backCol, wipe): 114. io.setmode(io.BCM)
082. strip[add].fill(backCol) 115. muxAdd = [11, 9, 10]
083. k = numLed // 2 116. io.setup(muxAdd, io.OUT), # set pins as outputs
084. for i in range(numLed // 2, numLed): 117. pixel_pin = board.D18
085. j = i ; k -= 1 118. num_pixels = 20 # maximum LEDs in biggest strip
086. strip[add][j] = frontCol 119. ORDER = [neopixel.GRB] * 8
087. strip[add][k] = frontCol 120. strip = []
088. setAdd(add) ; strip[add].show() 121. for i in range(0, 8):
089. time.sleep(delay) 122. pixels = neopixel.NeoPixel(
090. if not wipe : 123. pixel_pin, num_pixels, brightness = 0.1,
091. strip[add][j] = backCol 124. auto_write = False, pixel_order =
092. strip[add][k] = backCol ORDER[i])
093. setAdd(add) ; strip[add].show() 125. strip.append(pixels)
094. 126.
095. def seq(add, repeats, delay, direction, frontCol, 127. def setAdd(add):
backCol, wipe): 128. for i in range(0, 3) : io.output(muxAdd[i], 0)
096. seqToLight = ( [3], [2, 4], [1, 5], [0, 6], 129. if add & 1 : io.output(muxAdd[0], 1)
097. [11, 7], [10, 8], [9], [10, 8], [11, 7], 130. if add & 2 : io.output(muxAdd[1], 1)
098. [0, 6], [1, 5], [2, 4], [3]) 131. if add & 4 : io.output(muxAdd[2], 1)
FL3731_thread.py
> Language: Python
Set up a Raspberry Pi
retro games console
Lakka lets you relive the games of the past by enabling your
Raspberry Pi to emulate a host of retro computers and consoles
W
hether you are nostalgic for the games Some features help you organise your growing
of yesteryear or you’re simply dying gaming collection and take screenshots of the
Lucy to discover gaming’s rich history, all in-game action. For now, though, we’re looking
MAKER
Hattersley you ultimately need to get stuck in is a bunch of solely at getting you up and running with a classic
emulators and a stack of gaming ROMs. homebrew video game.
Lucy is editor of The In the past, however, this has also entailed
MagPi magazine.
finding and downloading the BIOSes of various
She enjoys retro
gaming; especially machines and a fair bit of configuration.
Get SD Card Formatter
making retro games.
magpi.cc
Fortunately, with the software platform Lakka
installed on your Raspberry Pi 4, the path to
01 We’re going to install Lakka RPI4 to
gaming glory is much smoother these days. a blank microSD card using the OS installer
Lakka allows you to emulate arcade games as NOOBS (magpi.cc/noobs).
well as titles originally released on a host of 8-bit, In this tutorial, we’re using a Windows PC
16-bit, and even 32- and 64-bit systems. to format a microSD card and copy the NOOBS
Lakka is a Linux operating system (OS) based files to the card (the process is identical for Mac
on RetroArch (retroarch.com). Lakka is designed computers). We will then use the NOOBS card
to run games, and it turns a Raspberry Pi into a with our Raspberry Pi 4 and set up Lakka. From
powerful games system. then on, our Raspberry Pi 4 will boot straight to
You can hook up a gamepad and even make use Lakka and let us run games.
of wireless controllers (there’s more about those First, download SD Formatter on a computer from
You’ll Need at magpi.cc/HpPSSV). It has an interface that will magpi.cc/sdcardformatter. Click ‘For Windows’ or
be very familiar to anyone who has used modern ‘For Mac’ depending on your machine.
> Raspberry Pi 4 games consoles and because it is open-source, it
is constantly being improved.
> USB or wireless
game controller, You can run Lakka on any Raspberry Pi,
Format the card
e.g. magpi.cc/
vilrosgamepad
although Raspberry Pi 4 enables smoother
emulation of more recent consoles.
02 We’re now going to format the microSD card
> Windows PC or that you will use to boot Lakka on a Raspberry Pi.
Mac computer Note that this completely wipes the card, so make
for setup sure it contains nothing you need.
> Blank microSD card Insert the microSD card into your Windows
(8GB or larger) or Mac computer. You will need to use either
> SD Formatter
a USB SD card adapter or microSD card to SD
magpi.cc/ card adapter.
sdcardformatter Close any alert windows that appear, and open
> NOOBS image file the SD Card Formatter app. Accept the terms and
magpi.cc/downloads conditions and launch the program. On a Windows
PC, click Yes to ‘Do you want to allow this app to
> A game ROM, e.g.
magpi.cc/bladebuster make changes to your device’ (you won’t see this
NOOBS (New Out Of Box Software) is used to install
operating systems such as Lakka on Raspberry Pi on a Mac; the approval comes later).
Boot to NOOBS
The card should be assigned a letter under Select
Card. It is ‘D’ on our system. Check the Capacity
04 Now set up your Raspberry Pi 4. You’ll
and other details to ensure you have the correct need to connect a USB keyboard and HDMI display
card. Now click Format and Yes. On a Mac, you’ll be for the installation process (you can remove the
asked to enter your Admin password. keyboard later and use just a game controller).
The display does not have to be the television
you intend to use. It’s best to use Raspberry Pi 4’s
HDMI 0 port. We’re going to use a wireless LAN
Download NOOBS
03 Now visit magpi.cc/downloads and click the
network to connect to the internet, but you can
connect an Ethernet cable attached directly to
NOOBS icon. Select ‘Download ZIP’ next to NOOBS. your modem/router.
The latest version of the NOOBS zip file Insert the microSD card into your Raspberry Pi
(currently NOOBS_v3_2_1.zip) will be saved to and attach the USB-C power supply to power up.
your Downloads folder.
Extract the files from the NOOBS zip file (right-
click and choose Extract All and Extract). Now
T o get further installation options on
open the extracted NOOBS folder (it’s important the NOOBS screen, you will need to be
to ensure you are using the extracted files and not
looking at the files inside the zip file. Make sure connected to the internet
you have opened the NOOBS_v3_2_1 folder and
Connect to wireless LAN
not the NOOBS_v3_2_1.zip file.
You should see three folders – defaults, os, and
05 The NOOBS screen will appear, displaying
overlays – followed by many files beginning with two installation options: Raspbian Full and
‘bcm2708...’. It is these folders or files you need to LibreELEC. To get further installation options, you
copy to the microSD card. will need to be connected to the internet.
Select all of the files inside the NOOBS folder Connect Raspberry Pi directly to your modem/
and copy them to the microSD card. When the files router using an Ethernet cable; or click the ‘Wifi
have copied, eject and remove the microSD card networks (w)’ icon. The WiFi network selection
from your PC or Mac. window appears; wait until it displays the local
Get a game
08 Now it’s time to find and play a game.
Games are downloaded as ROM files and added to
Blade Buster, a
homebrew shoot- networks. Select your wireless network and enter Lakka. These ROM files need a compatible core to
’em-up, running on a the password for it in the Password field. Then run (most but not all ROM files will run correctly).
Raspberry Pi 4
click OK. We’ll use a Japanese homebrew ROM called
With Raspberry Pi connected to a network, you Blade Buster. Download it on your PC or Mac from
get a much broader range of installation options. magpi.cc/bladebuster – click the ‘Blade Buster
Near the bottom will be Lakka_RPi4. Download’ link.
Use the arrow keys on your keyboard to select A file called BB_20120301.zip will appear in
Lakka and press the SPACE bar to add a cross to its your Downloads folder. Unlike NOOBS, you do not
selection box (or use a connected mouse to select extract the contents of this file – ROMs are run as
the Lakka option). compressed zip files. You now need to transfer this
Click Install and answer Yes to the Confirm file from your computer to your Raspberry Pi.
Warning! window. NOOBS will download and extract the
It is illegal to download
Lakka file system to the microSD card. Sit back and
copyrighted game ROMs wait for the system to be installed.
from the internet. Please
Turn on Samba
respect the original maker
and seek a legal source
When it has finished, NOOBS will display ‘OS(es)
Installed Successfully’. Press ENTER on the
09 With your Raspberry Pi and PC on the same
for retro gaming instead.
We use homebrew ROMs keyboard (or click OK with the mouse). network, go to the Settings menu in Lakka on your
made by modern makers Raspberry Pi and select Services. Highlight Samba
for classic systems.
and turn it on by pressing X (or using right arrow).
magpi.cc/legalroms
Samba is installed by default on macOS and used
Starting Lakka
06 Raspberry Pi will restart and this time it will
to be installed by default in Windows, but it has
recently become an optional installation.
Top Tip boot into the Lakka operating system. You will see In Windows 10, click on the Search bar and type
a blue screen with a series of windows and ‘Load ‘Control Panel’. Click on Control Panel in the
SSH Core’ will be highlighted. You can use the arrow search results. Now click ‘Programs’ and ‘Turn
keys on the keyboard to navigate the menu, and X Windows features on or off’. Scroll down to find
You can also to select a menu option, then Z to back up. ‘SMB 1.0/CIFS File Sharing Support’ and click the
use SSH to copy Highlight Load Core and press X to select it. Here ‘+’ expand icon to reveal its options. Place a check
files from your you will find a list of ‘cores’. These are the engines in the box marked ‘SMB 1.0/CIFS Client’. Click
computer to
that emulate different retro consoles and computers. OK. This will enable Samba client support on your
Raspberry Pi. In
Lakka, enable SSH To test the system is working, highlight 2048 and Windows 10 PC so it can access Raspberry Pi.
in Services. You press X again. You’ll be returned to the main menu,
can use a program but this time you’ll see ‘Start Core’. Press X to start
such as FileZilla to the core and you’ll be presented with a classic game
copy files across. Transfer the ROM
See magpi.cc/ssh
called 2048. Use the arrow keys to slide the blocks
together. Matching numbers double in size, and
10 Lakka may appear in the left-hand column
for more
information.
the aim is to make a 2048 block. Press ESC and ESC of your other computer’s file browser (File Explorer
again to return to the main Lakka menu. on a PC or Finder on a Mac).
If not, select Lakka’s main menu on your instructions to press the buttons and move the
Raspberry Pi, then choose Information and analogue sticks on the gamepad. You may have to Top Tip
Network Information. go through it a few times to get the process right.
Take note of the IP address. Enter that into the You can also set each button individually using Ask for help
File Explorer using the format: the options. Once everything is set up correctly,
\\insert.full.ip.address\ you’ll be able to use the gamepad to control your It’s worth heading
Raspberry Pi console. over the Lakka
forums for friendly
Ours, for example, is:
help and advice:
\\192.168.0.13\
magpi.cc/
lakkaforum
Move to the television
Copy the Blade Buster zipped game to the ROMS
folder on Lakka.
12 Your Raspberry Pi games console is now
Back on your Raspberry Pi, go to Load Content ready to be moved to your television. You will be
> Start Directory in the Lakka menu and find the able to control the games console using your USB
BB_20120301.zip file. Click it before selecting or wireless controller and move ROM files directly
Load Archive. Choose FCEUmm as the core to to it from your Windows PC or Mac computer.
play it on. There’s a lot more to Lakka to discover, but for now
Match the buttons
Press ENTER to start the game. Use the arrow keys we hope you enjoy playing retro games on your and sticks on a
gamepad to the
to move and X to fire. Enjoy playing the game. Press Raspberry Pi console.
controls used in
ESC twice when you’re done, to return to Lakka. each core
Set up a controller
11 Video game consoles rarely come with
keyboards. And no doubt you’ll want to attach a
controller to your console.
If using a wireless gamepad, insert its dongle
into one of Raspberry Pi’s USB ports, insert the
batteries, and turn it on. Press the Start button on
the gamepad and it will light up.
Use the arrow keys to choose Input and User
1 Binds. If it is connected correctly, you will see
‘RetroPad’ next to User 1 Device Type. Scroll down
and choose User 1 Bind All. Follow the on-screen
Dialogs
Part 08
I
f we want to ask the user a question, or to void open_dialog (GtkWidget *wid,
inform them of something, the best way to do gpointer ptr)
this is with a dialog box. GTK makes it easy to {
Simon
MAKER
Programming Figure 1
Figure 2
Figure 5
the button will update to show the selected file, and Figure 6 A
GtkColorButton
the full file path of the selected file will be printed
to the terminal window from which you launched
the application.
You can use a GtkFileChooserButton to open a
browser which will select an existing file or folder,
but the designers of GTK decided that you can’t
use this method to choose the location to which a
new file can be saved. For that, you need to create a
GtkFileChooser dialog yourself.
Modify the code above as follows:
Figure 7
fc_btn, TRUE, TRUE, 0); NULL‑terminated list of pairs of labels and return
gtk_box_pack_start (GTK_BOX (vbox), btn, values for the buttons at the bottom of the dialog.
TRUE, TRUE, 0); We create the dialog and call gtk_dialog_run
gtk_widget_show_all (win); when the button is pressed; the button handler
gtk_main (); then waits for the dialog to return. We then
} read the file path back from the file chooser using
gtk_file_chooser_get_filename, as we did for the
In this case, we create a button to open the dialog, file open dialog.
and then have to manually create and open the If you run this code and press the ‘Save file’
dialog in the button handler. button, you’ll see that a file save chooser is slightly
The dialog is created by calling different from a file open chooser, in that it has a
gtk_file_chooser_dialog_new, whose box to allow a new file name to be entered (Figure 5,
arguments are very similar to those for previous page).
gtk_dialog_new_with_buttons that we saw in the Enter a new file name and select a location for the
previous chapter. First, the title of the dialog new file; when you press ‘OK’, the path to the new
is provided, followed by a pointer to the parent file will be printed to the terminal.
window and then a flag which determines the There are several other predefined dialogs which
behaviour of the dialog – in this case, it is set up can be added to an application just by including a
to provide a file name and path to which a file button. Two of the more useful ones are the colour
can be saved. The remaining arguments are a picker and the font chooser.
Figure 9
T
his final tutorial is about the most valuable with titles such as Nuclear Throne and Luftrausers.
skill in all of game development, actually Luckily for us, it is a relatively simple effect and
finishing something. It’s the skill that easy to implement.
Dan
MAKER
We would have
said ‘insert coin’,
but there isn’t
a coin slot on
Raspberry Pi (yet)
Complete your
game project with
a retro arcade
splash screen
part6code.p8 DOWNLOAD
THE FULL CODE:
> Language: Lua magpi.cc/JbTKkP
THERMAL
TESTING
RASPBERRY PI 4
Raspberry Pi 4 just got a lot cooler! The last four months of
firmware updates have taken over half a watt out of idle power
and nearly a watt out of fully loaded power. By Gareth Halfacree
Raspberry
Pi firmware
timeline
Launch firmware
(June 2019)
Finalised prior to production,
the launch firmware is how
every Raspberry Pi 4 rolled
off the factory floor – fully
functional, but not
fully optimised.
VLI firmware
(July 2019)
Released as an early beta,
then withdrawn following
the discovery of a bug, the
VLI firmware enabled power
management in the USB 3.0
controller chip.
BASELINE TEST:
RASPBERRY PI 3B+
Already well established, Raspberry Pi 3
Model B+ was the device to beat
B
efore Raspberry Pi 4 came on the
scene, Raspberry Pi 3 Model B+ was the
must-have single-board computer.
Benefiting from all the work that had gone into
the earlier Raspberry Pi 3 Model B alongside
improved hardware, Raspberry Pi 3B+ was –
and still is – a popular device. Let’s see how
well it performs before testing Raspberry Pi 4.
Raspberry Pi 3B+ heat distribution (Idle) Raspberry Pi 3B+ heat distribution (Load)
Thermal Imaging
A thermal camera shows where the power
goes. At idle, the system-on-chip is
relatively cool while the combined USB
and Ethernet controller to the middle-
right is a noticeable hot spot; at load,
measured after 60 seconds of a CPU-
intensive synthetic workload, the SoC is
by far the hottest component at 58.1 °C.
1600 85
Testing Period Cooldown
This chart measures Raspberry Pi 3B+
CPU speed and temperature during a 75
Temperature (Degrees Celsius)
1350
ten-minute power-intensive synthetic
Frequency (MHz)
RASPBERRY PI 4
LAUNCH FIRMWARE
The fastest Raspberry Pi ever made
demanded the most power
R
aspberry Pi 4 Model B launched with a
range of improvements over Raspberry
Pi 3B+, including a considerably more
powerful CPU, a new GPU, up to four times
the memory, and USB 3.0 ports. All that new
hardware came at a cost: higher power draw
and heat output. So let’s see how Raspberry
Pi 4 performed at launch.
Pi 3 B+ Load (W)
There’s no denying it, Raspberry Pi 4 was a 5.77
Lower is better
hungry beast at launch. Even idling at the
Raspbian desktop, the board draws 2.89 W, 2.89
Raspberry
hitting a peak of 7.28 W under a worst-case Pi 4 Launch
Firmware 7.28
synthetic CPU and GPU workload – a hefty
increase over Raspberry Pi 3 B+.
Thermal Imaging
Thermal imaging shows that Raspberry
Pi 4, using the launch-day firmware,
runs hot even at idle, with hot spots
at the USB controller to the middle-
right and power-management circuitry
to the bottom-left. Under a heavy
synthetic load, the SoC hits 72.1 °C by the
60-second mark.
1600 85
1350
workload causes it to throttle; but
Frequency (MHz)
magpi.cc 69
FEATURE
RASPBERRY PI 4
VLI FIRMWARE
USB power management brings some relief for Raspberry Pi heat
T
he first major firmware update
developed for Raspberry Pi 4 Idle (W)
1.91
brought power management Load (W)
Raspberry
features to the Via Labs Inc. (VLI) Pi 3 B+ Lower is better
USB controller. The VLI controller is 5.77
Thermal Imaging
The biggest impact on heat is seen,
unsurprisingly, on the VLI chip to the
middle-right, the VLI firmware helps
keep the SoC in the centre and the power-
management circuitry at the bottom-left
cooler than the launch firmware. The SoC
reached 71.4 °C under load – a small, but
measurable, improvement.
1600 85
1350
performance in the worst-case synthetic
Frequency (MHz)
RASPBERRY PI 4
VLI, SDRAM FIRMWARE
With VLI tamed, it’s the memory’s turn now
T
he next firmware update, Idle (W)
designed to be used alongside the 1.91 Load (W)
VLI power management features, Raspberry
Pi 3 B+ Lower is better
changes how Raspberry Pi 4’s memory 5.77
– LPDDR4 SDRAM – operates. While
having no impact on performance, it
2.89
helps to push the power draw down still Raspberry
Pi 4 Launch
further at both idle and load. Firmware
7.28
7.01
As with the VLI update, the SDRAM update
brings a welcome drop in power draw at
both idle and load. Raspberry Pi 4 now 2.47
Raspberry
Pi 4 VLI,
draws 2.47 W at idle and 6.79 W running SDRAM
6.79
a worst-case synthetic load – a real
improvement from the 7.28 W at launch.
Thermal Imaging
Thermal imaging shows the biggest
improvement yet, with both the SoC
and the power-management circuitry
running considerably cooler at idle after
the installation of this update. After 60
seconds of load, the SoC is noticeably
cooler at 68.8 °C – a drop of nearly 3 °C
over the VLI firmware alone.
1600 85
1350
synthetic workload is pushed back to
Frequency (MHz)
magpi.cc 71
FEATURE
S
eptember 2019’s firmware update
Idle (W)
includes several changes, while 1.91
Raspberry
bringing with it the VLI power Pi 3 B+ Load (W)
5.77
management and SDRAM firmware Lower is better
updates. The biggest change is how
2.89
Raspberry
the BCM2711B0 SoC on Raspberry Pi 4 Pi 4 Launch
increases and decreases its clock-speed Firmware 7.28
Raspberry Pi 4 VLI, SDRAM, Clocking firmware (Idle) Raspberry Pi 4 VLI, SDRAM, Clocking firmware (Load)
Thermal Imaging
Improved processor clocking brings
a noticeable drop in idle temperature
throughout the circuit board. At load,
everything’s improved – the SoC peaked
at 65 °C after 60 seconds of the synthetic
workload, while both the VLI chip and the
power-management circuitry are clearly
cooler than under previous firmwares.
1600 85
1350
synthetic workload is pushed back all the
Frequency (MHz)
RASPBERRY PI 4
To upgrade your Raspberry Pi to the latest
firmware, open a Terminal window and enter:
N
obody at Raspberry Pi is resting
1.91 Idle (W)
on their laurels. Beta firmware Raspberry
Pi 3 B+
is in testing and due for public 5.77 Load (W)
release soon. It brings with it many Lower is better
Raspberry 2.89
improvements, including finer-grained Pi 4 Launch
Firmware 7.28
control over SoC operating voltages and
optimised clocking for the HDMI video
2.62
state machines. Raspberry
Pi 4 VLI
7.01
Raspberry 2.47
Raspberry
The beta firmware decreases power draw Pi 4 VLI,
2.36
Thermal Imaging
The improvements made at idle are clear
to see on thermal imaging: the majority
of Raspberry Pi 4’s circuit board is below
the bottom 35 °C measurement point for
the first time. After 60 seconds of load,
there’s a smaller but still measurable
improvement, with a peak measured
temperature of 64.8 °C.
1600 85
1350
the heavy demands of the synthetic
Frequency (MHz)
magpi.cc 73
FEATURE
W
hile running the latest firmware
will result in considerable
power draw and heat
management improvements, there’s
a trick to unlock even greater gains:
adjusting the orientation of Raspberry Pi.
For this test, Raspberry Pi 4 with the beta
firmware installed was stood upright with
the GPIO header at the bottom and the
power and HDMI ports at the top.
Thermal Throttling
Simply moving Raspberry Pi 4 into a
CPU Temperature CPU Clock CPU Clock (Moving Average)
vertical orientation has an immediate
1600 85
impact: the SoC idles around 2 °C lower
than the previous best and heats a lot
more slowly - allowing it to run the 75
Raspberry Pi 4 65
This chart shows how long it took to Launch Firmware
L
ooking at the previous pages, it’s hard kernel from its source code. It’s a good example
to get a real idea of the difference in of a CPU-heavy workload which occurs in the
performance between Raspberry Pi 3B+ and real world, and is much more realistic than
Raspberry Pi 4. The synthetic benchmark chosen the deliberately taxing synthetic workload of
for the thermal throttle tests performs power- earlier tests.
hungry operations which are rarely seen in real With this workload, Raspberry Pi 4 easily
world workloads, and repeats them over and over emerges the victor. Despite its CPU running only
again with no end. 100MHz faster than Raspberry Pi 3B+ at its full
speed, it’s considerably more efficient – and,
Compiling Linux combined with the ability to run without hitting
In this test, both Raspberry Pi 3B+ and Raspberry its thermal throttle point, completes the task in
Pi 4 are given the task of compiling the Linux nearly half the time.
Kernel compile:
1600 CPU Temperature CPU Clock CPU Clock (Moving Average) 85
Raspberry Pi 3B+ 75
Raspberry Pi 4 75
Temperature (Degrees Celsius)
1350
The difference between the synthetic
Frequency (MHz)
TIM GOVER ON
FIRMWARE DEVELOPMENT
Bridging the worlds of hardware and software, Tim Gover focuses on the firmware
BCM2711B0 SoC
The September 2019 firmware increases
and decreases the BCM2711B0 SoC
circuitry’s clock-speed in response to both
demand and temperature. The power-
management circuitry also responds to
sudden changes in demand for current.
VLI
The VLI chip is responsible for the blue
USB 3.0 ports. The July firmware update
enabled it to run cooler. Deployment of
this firmware took longer than expected
e’ve already committed to supporting USB
W after early testing revealed a bug, since
resolved, with selected USB 3.0 devices.
mass storage boot and IPv6 network boot
replaced with Gigabit Ethernet plus USB 3.0 over users who only use the USB-C connection
PCI Express. These driver interfaces are much for power.”
more complicated, and also tend to require DMA
access to SDRAM.” What else should we know?
“Dynamic HDMI clocking – the HDMI state
What’s the beta’s secret? machine clock is now dynamically changed to
“The new DVFS code adds more operating points match the resolution requirements using the
for Arm [CPU] frequencies,” says Tim, “and picks updated firmware clock infrastructure. This
the best voltage according to the operating point. makes it better at reducing the idle power to
The voltage also has to be suitable for all the other the minimum required for the current display
blocks on the chip – e.g. V3D – so this is a fairly configuration – e.g. a single high-definition
complicated change.” display should have lower idle power consumption
There are other, more minor changes, too, than a 4Kp30 or dual-display configuration.”
including a more sensible default for Raspberry
Pi 4’s USB On-The-Go (OTG) functionality. “By What’s next on the to-do list?
default the USB OTG controller is not enabled “We’ve already committed to supporting USB
unless dtoverlay=dwc-otg is added to config.txt,” mass storage boot and IPv6 network boot, so that
explains Tim. “This saves about 35 mW for most will keep me busy for a while!”
www.UniPiCase.com
PROGRAMMING Scratch and Python. Rob Zwetsloot decks his Raspberry Pi with one
LANGUAGES:
W
Scratch, Python
e love all the GPIO Christmas little festive flair to your Raspberry Pi, while still
TIME TO FINISH: decorations that you can get for working on other projects that require the use of
Roughly five Raspberry Pi, and while we also really some GPIO pins.
minutes
enjoy putting stuff together like those Christmas
kits, we sometimes just like to plug something in Easy coding
and see it go. One of the unique things about this tree is that you
The GPIO Xmas Tree is something like that – can program it with Scratch! Scratch on Raspberry
and probably the easiest one to code yet! It’s also Pi has a built-in GPIO library, allowing you to code
nice and small, sitting over six GPIO pins rather physical objects, including this tree’s five LEDs.
than taking up all 40. This way, you can add a This is one of the few cases, though, where
something so simple is much easier to do via
ne of the unique things
O Python, especially thanks to the GPIO Zero library,
requiring less than ten lines of code to create a
about this tree is that wonderful twinkling effect!
We quite adore this little tree – it’s cheap and
you can program it cheerful and could be someone’s first Raspberry
Pi project on Christmas morning, with a quick and
with Scratch! very cool result.
While there’s
nowhere to hang
your baubles, this
tiny tree is fun
to program
Verdict
This fun little
project will make
your Raspberry Pi
work desk festive,
or make a young
maker’s first steps
at Christmas
9
wonderful.
/10
GPIO Xmas Tree magpi.cc 79
REVIEW
10 Best:
Christmas
projects
Smart Gingerbread House
Edible electronics, sorta
Gingerbread is delicious, and houses made from it are a staple decoration in
some homes. Estefannie takes it a step further and gives hers lights and motors.
Liven up your living room with these Honestly, ours wouldn’t last long enough for us to do that.
W
e love seeing people make their own festive
projects at this time of year, and we always
try to make sure we include one of our own Raspberry Pi
every December issue. Check out page 40 for this Christmas Tree
year’s smart lights. If you’re still feeling a bit humbug
about it all, here are ten other incredible Christmas Light Show
projects to get you in the spirit.
Advanced tree lights
We quite like the lights we made
earlier in the mag, but if you want to
do some serious tree hacking, we
suggest taking a look at this amazing
project on Instructables.
magpi.cc/irP5Nh
Secret Santa
Minecraft-controlled Babbage
Christmas tree Upgrade your office
If you find fishing names out of a hat
VR to RL
a bit old-fashioned, you can always
Minecraft can be hacked with a bit of code so that you can make have Babbage Bear choose for you.
it do as you wish. But this also means that, via more code, it can Squeeze his hand and he’ll print out a
interact with reality. So, David Stevens has made it so changes to piece of paper showing who you need
the Christmas tree in the game alter the lights outside. Clever! to buy for. £5 limit, though.
magpi.cc/DdipTY magpi.cc/Hbaw2t
Raspberry Pi
Christmas
Light Display
Home light automation
This is a serious amount of lights all
over this house to be controlled by
a Raspberry Pi. David does so using
a phone to connect to Raspbian
via VNC.
magpi.cc/jAtBw3 Pireplace
Raspberry Pi fireplace
Some people like to turn on the
fireplace video on Netflix; others
prefer to create digital fires of
their own. This one also does the
impossible and can cycle through
different colours of flame.
magpi.cc/cyyW58
The MagPi
Christmas Card Cover
Hack the magazine
A couple years ago, we made a little
project that allowed you to turn a copy
of The MagPi into a light-up Christmas
card. Grab the PDF, print the cover on
card, and give it a go!
magpi.cc/52
Websites
Computer Architecture
David
CREATOR
Wentzlaff
Price: Books
Free
magpi.cc/ikxjQd
Add these titles to your
computing bookshelf
Computer Organization
HARDWARE AND
SOFTWARE
This book is famous for
Parrot explaining complex concepts
CREATOR
to non-technical people. It
Price: doesn’t teach anything about
£100 / $130 programming, but is a great
magpi.cc/kx2Cr7 place for absolute beginners.
magpi.cc/BVUnby
Liz Clark
aka Blitz City DIY
The creator of Blitz City DIY talks to us about making amazing
YouTube videos of cool builds
> Day job Vlogger > Community role YouTuber > URL magpi.cc/FDpqSi
N
ot everyone has been late to learn something new),” about four years ago that I really
tinkering with electronics Liz tells us – and we completely got serious about it and now
for decades. Some are agree. “I was in college and I’m doing a bit of everything:
new to the hobby, and it’s easy decided that I should try and CircuitPython, 3D printing and
to figure out why: information learn some coding without really design, PCB design, and of course
on the internet is easier to obtain knowing what that meant. I was a hearty portion of Raspberry Pi.
than ever, and the low cost majoring in music technology, so Outside of hardware, though,
of Raspberry Pi has helped to I began my search in the music I am a long-time avid knitter,
further make it accessible. Liz is arena and learned about Arduino cross-stitcher, and sewer.”
one of those newcomers. and all of the MIDI projects that We’d also argue that textile
Designing a PCB is no
simple feat, and this “I actually got a bit of a ‘late’ people were beginning to make arts are a form of making as well,
one really makes the
start to making (although I’m a with them. I dabbled a bit off just a bit more low-tech.
thermal camera project
a bit easier for Liz firm believer that it’s never too and on with it, but it wasn’t until
Why did you start your channel?
Related to my ‘late’ start in
making, I had been out of
college for about two years
and was starting to feel a little
stuck. I really wasn’t working
on any creative projects and I
was worried that I was going to
permanently fall into that rut
working full-time. I also have a
video background and I hadn’t
filmed and edited anything for
fun at that point since school, so
my channel was basically born
from a place of worry and/or
quarter-life crisis. It was a very
surreal and odd thing for me to
do because I definitely lean more
toward the introverted side, so
the idea of me talking on camera
about things was completely
outside of my comfort zone.
However, I’ve become a lot better
This Month in
Raspberry Pi
Coolest Projects 2020!
Next year’s Coolest Projects events are coming together
W
e love the Coolest Projects – it’s
amazing to see the imagination and
ingenuity of young makers in multiple
fields. More details about the upcoming 2020
events in the USA and UK were revealed – as well
as the opening of registration – as we were going to
print, so we’ve squeezed them in here!
The event is both a celebration and an exhibition
to inspire and enable innovation, creativity,
entrepreneurship, and technology skills in young
Coolest Projects USA
makers. Join us to support hundreds of young
7 March 2020
innovators and celebrate their accomplishments.
Discovery Cube Orange County, CA, USA
Participants and visitors will also get the
coolestprojects.org/usa
chance to take part in exciting hands-on tech
magpi.cc/fKpgFA
activities, see inspirational speakers and leading
technology experts, and join a global community of
digital makers.
All projects are welcome in any programming
language or using whatever hardware you like,
whether you’re a beginner or a seasoned creator.
You can work as an individual or as part of a team
of up to five. Coolest Projects events are open
to all levels of skill; the focus is on creativity,
participation and, most of all, having fun!
Coolest Projects UK
4 April 2020
The Sharp Project, Manchester UK
coolestprojects.org/uk
Christmas
comes early!
Some makers have been getting their Christmas projects sorted well in advance
W
e often get messages and emails from
readers who would love us to feature
their project – and usually we do in our
project showcase feature! Unfortunately, when it
comes to seasonal projects, we don’t always have
time or space – so here’s a couple we were sent this
year that we’d love to show off a bit of!
MagPi Monday
Amazing projects direct from our Twitter
E
very Monday we ask the question: have you
made something with a Raspberry Pi over 01
the weekend? Every Monday, our followers
send us amazing photos and videos of the things
they’ve made. Here is a small fraction of them.
Follow along at the hashtag #MagPiMonday.
02
05
CROWD
A PROFJUNDING
Low-Latency Real- If you
’ve
ECT?
time Robot Control
Raspb launc
hed a
erry P
projec i-relate
t, let u d
Less of a product and more documentation, this will give This case designed for a Raspberry Pi 4 does a bit more
you some direction on how to remotely control a robot in than just keep a Raspberry Pi protected – it also extends
real time over WiFi. We’ve done tutorials on stuff like this, out the I/O (USB, Ethernet, etc.) to a more classic
but this plans to go a bit more in-depth. configuration along the ‘rear’ of the case.
kck.st/2WrbPlH kck.st/2peSisq
EVENTS
01
Raspberry Jam
Event Calendar
Find out what community-organised Raspberry
Pi-themed events are happening near you…
08
FIND OUT
ABOUT JAMS
Want a Raspberry Jam
in your area? Want to
start one?
jam@raspberrypi.org
Checking in
“W
e use the Eventbrite app to check in
attendees where possible. However,
people tend to arrive all at once and we
don’t like a queue. If it’s not possible to scan the
tickets, we just check them as they come in.
It means our numbers are a little off, but it
02 keeps people happier.”
04
Michael Horne – Cambridge Raspberry Jam
Your
Letters
Project submission
If I’ve created a project that I
want to submit to you, what is
the best way to go about it?
Cluster of fun
I like the look of the cluster computing project you did in
The MagPi, but I do have to ask… what is the point of it? You
A MagPi Christmas can’t really do much real computing with it.
WIN
A PIARM
ROBOT
ARM
KIT! Grab a PiArm, the 6 DoF
robotic arm for Raspberry Pi,
and get started with robotics
We reviewed the PiArm in
at your fingertips
issue 87 of The MagPi and
found it an impressive piece
of hardware – now it’s your
chance to win one.
In association with
SB Components
Competition magpi.cc 95
NEXT MONTH EDITORIAL
Editor
Lucy Hattersley
lucy@raspberrypi.org
Features Editor
Rob Zwetsloot
rob.zwetsloot@raspberrypi.org
Sub Editors
Phil King and Nicola King
ADVERTISING
Charlotte Milligan
charlotte.milligan@raspberrypi.org
+44 (0)7725 368887
DESIGN
criticalmedia.co.uk
Head of Design
Lee Allen
Designer
Sam Ribbits
Illustrator
Sam Alder
CONTRIBUTORS
Mike Cook, David Crookes,
PJ Evans, Gareth Halfacree,
Rosemary Hattersley, Daniel
TOOLS
Lambton-Howard, Simon Long,
Danny Staple
PUBLISHING
Publishing Director
FOR BETTER
Russell Barnes
russell@raspberrypi.org
Director of Communications
Liz Upton
MAKING
CEO
Eben Upton
DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000
Plus!
conforming to ISO 14001.
Sail a solar-powered
magpi.cc/subscribe
Building, St. John’s Innovation Park, Cowley
Road, Cambridge, CB4 0DS. The publisher,
A lifelong obsession
Lucy Hattersley has spent a long time learning to code
A
t the base physical level, As with most ZX81 games, you could hands of young makers, and they can
a computer is ground-up only write a couple of screens of code make anything they want with it.
rocks that we’ve tricked into before running out of the 1kB RAM. Computers are more than just
thinking. It’s the most remarkable This turns out to be a bonus when games consoles with keyboards. A
achievement of the human race; one you’re six years old and would prefer good computer has an ecosystem
that teaches us what it means to to go outside and play. of development and making that
be human. As I grew older, I moved on to springs up naturally, both from
I believe that learning to code is BBC Micro at school and begged the availability of tools and the
one of the most profound things my parents for a Sinclair Spectrum community that grows up around it.
you can do as a human on the planet
today. Not just because you can get
a cushy job doing something you
e get to work with the best computer
W
enjoy; or even because computers company in the world
run the world, so you might as well
understand how they work (although at home. I loved making animated That community is important. We
that is important). stories, simple games, and text bring together the best people we
It’s because teaching a machine to adventures. Like most children from can find and write about the fun stuff
think helps you contemplate what you that era, I’ve paid my parents back they’re making, or the cool events
are. And learning to code (especially with a lifetime of free tech support. they’re putting on. We get to work
on a modern computer) means taking with the best computer company in
gigantic, otherworldly concepts and School days the world; on the best computer ever
breaking them down into small, I remember controlling robotic turtles made. We have a lot of fun!
manageable parts. Learn to do that at school, developing my own version So thank you for putting up with
with a computer and you can do it all of Ceefax, and acid-dipping printed me as editor of The MagPi magazine. I
kinds of parts of life. Coding makes circuit boards. hope you’ve enjoyed 2019, and 2020 is
you a better person. Computing was often mayhem and going to be even better.
even if things rarely worked, I never
Learning the BASICs found the lessons dull. This is one
Lucy Hattersley
AUTHOR
All of this was lost to me when I reason why I support Raspberry Pi’s
first encountered a ZX81 at infant low-cost endeavours.
Lucy is editor of The MagPi. She works
school. I remember programming ‘It’s not a toy’ is perhaps the with Rob, Phil, Sam, and lots of writers
a platform game where a 0 had to worst thing a child can hear about every month to put together this
jump up through a moving gap in the a computer. But an incredibly well- magazine and hopes you enjoy it.
platform above. engineered toy can get itself into the @lucyhattersley