Professional Documents
Culture Documents
The Magpi Issue 118 June 2022
The Magpi Issue 118 June 2022
CC/STORE
RASPBERRY PI
PHOTOGRAPHY
SETUP • EDITING • PROJECTS
- L A P S E & B A T C H
TIME I A L S
CONV E R T T U T OR
BU IL D Y O U R O W N magpi.cc/store
VECTREX MINI
A F T W E A R A BL E K IT
CR
10 FACE TRACKING
PROJECTS
H́Ɏɟ
H́˱ɿʡʄͽ̿ɟ
P i 4 a nd
˱ǵˍΰφɟ W it h R ye s u p p o rt
B u l l s e
P RO FES S I O N A L CO N T RO L SYS T E M D E V E LO P M E N T TO O L
cdpstudio.com
ƗɟˍմڂֈԊԎڂԐԐԅڂԏԅڂԐԅԅڂڂʡ˱ɿ́ԺɂɎ̵ͮɟɂʎձɂ́˪
HSŴڂƗɟɂʎ˱́ˍ́ʄʡɟ͝ڂƉڂՄՄڂ ͽ˱Ɏ͝ΞȘ̿ʄǵͮǵڂԏհڂԍԅԅԏˍڂɟ͝ͽ˱Ɏհڂĩ́̿ǵΰ
WELCOME
WELCOME
to The MagPi 118
P
hotography is a great way to make use of your
Raspberry Pi single-board computer.
Raspberry Pi’s camera modules provide our small
computer with an eye to the world, enabling sight-based
projects and digital camera creations. Using the newer High
Quality Camera enables you to snap images every bit as
Lucy
EDITOR
impressive as with an expensive camera. Hattersley
But, of course, you can do so much more with a Raspberry Pi Lucy is editor of The
because it’s a fully programmable computer. Raspberry Pi can MagPi magazine
and keeps a beady
perform smart vision sensing tricks – capturing whatever you eye on things. She
is a big fan of art
ask it to. And you can automate shots, taking one every few and photography
computer projects.
minutes to create stunning time-lapse shots. You can even use @LucyHattersley
the images to create your own amazing works of art.
This month we have a superb photography feature (page 32)
that collects everything you need to know about Raspberry Pi
cameras. Plus, Nik Rawlinson has written an excellent time-
lapse tutorial (page 40), and Sean McManus provides us with GET A
wkh#Ľuvw#sduw#ri#DuwHyroyhu#+sdjh#77,#Ğ#d#idqwdvwlf#sulphu#rq# RASPBERRY
batch-converting images with Raspberry Pi. PI ZERO 2 W
Some of my favourite
Raspberry Pi projects involve
PAGE 30
cameras. And this issue
is packed with some of
the greatest image-based
Raspberry Pi projects around.
magpi.cc 03
Raspberry Pi
goes industrial
PWR
USR
232
485
CAN
IONO PI MAX
Contents
> Issue 118 > June 2022
Cover Feature
32 Raspberry Pi 32
Photography
Regulars
28 Case Study: Crux Labs
92 Your Letters
97 Next Month
98 The Final Word
Project Showcases
08 Portsdown 4 TV Transmitter
12 Air raid siren monitor
14 Synch.Live
16 5\GTCƓP//& 22
Mushroom Farm
20 Vectrex Mini
22 NMS Ceefax
24 AI Weather Station
26 (KDTG1RVKE/CVTKZ&KURNC[
16
The MagPi magazine is published monthly by Raspberry Pi Ltd. Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701,
is the mailing agent for copies distributed in the US and Canada. Application to mail at Periodicals prices is pending at Williamsport, PA.
POSTMASTER: Send address changes to The MagPi magazine c/o Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701.
magpi.cc 05
CONTENTS
44 66
Tutorials
40 Time-lapse photography
44 ArtEvolver - part 1
48 5RGE&GEM
52 Learn ARM Assembly - part 3 ArtEvolver - part 1 Wearables and costumes
#KT3WCNKV[&CVCNQIIKPI$QCTF
Community
86 Kevin McAleer interview
88 This Month in Raspberry Pi Kevin McAleer interview
95
WIN A CUTIEPI
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 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
QER]SJXLIXSTMGWMR8LI2EK5MQEKE^MRIEVIHMǺIVIRXFIX[IIRGSYRXVMIWERHEVIEP[E]WWYFNIGXXSGLERKI=SYEVIVIWTSRWMFPIJSVYRHIVWXERHMRKXLIVIUYMVIQIRXWMR]SYVNYVMWHMGXMSR
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.
06 magpi.cc
PROJECT SHOWCASE
Portsdown 4 Digital
TV Transmitter
Fancy running your own digital TV station? Dave Crump did and he
used a Raspberry Pi to do it. PJ Evans takes to the airwaves
D
ave Crump is no couch potato; in fact, he wkh#ehjlqqlqj1#Wkh#Ľuvw#zdv#kdugzduh#K597#
much prefers it on the other side of the encoding. Radio amateurs are limited in the
TV set. Since his early years, he has had a amount of bandwidth and power that they can use
passion for amateur TV. Starting with analogue for communication. The second was easy image
home-built equipment, his projects have raised capture using the camera, which works seamlessly
him up to be a key player in the British Amateur zlwk#wkh#K597#hqfrghu1Ĥ
Television Club. His latest project, Portsdown 4,
brings the new world of digital television Proof of concept
Dave Crump
MAKER
Quick FACTS
> Dave Crump is
GLEMVSJXLI'VMXMWL
&QEXIYV8IPIZMWMSR
(PYF
'&8(
> 8LIGSRGITXGEQI
JVSQE+VIRGLVEHMS
amateur –
Evariste Coujard
eĹŅþÏĜ±Ĭ±ŸŞÆåųųƼ
Pi 7” touchscreen
provides control
ŅƴåųƤŅŞåų±ƋĜŅĹŸ
+SVQSVIEHZIRXYVSYW
XVERWQMWWMSRWXLI
5SVXWHS[RGERFI
XEOIRER][LIVI
&HHEHMWLERH
]SYGERVIGIMZI
XVERWQMWWMSRWJVSQ
amateur satellites
Warning!
Frequency
restrictions
9WISJXLMWTVSNIGX
requires a valid UK
PMGIRGIERHQYWXRSXFI
STIVEXIHMRVIWXVMGXIH
JVIUYIRGMIW)MǺIVIRX
VIWXVMGXMSRWETTP]MR
HMǺIVIRXTEVXWSJXLI
[SVPH)S]SYVVIWIEVGL
MJEXXIQTXMRKXSVIGVIEXI
XLMWTVSNIGX
rsgb.org
Evolution of Portsdown 4
)EZIƶWXSYGLWGVIIR
YWIVMRXIVJEGIMW
TIVJIGXJSVXLINSF.X
MWLMKLGSRXVEWX[MXL
PEVKIFYXXSRWXLEXEVI
GPIEVP]PEFIPPIH
L
ast year, The MagPi featured two projects by ģZkhq#dq#dlu#udlg#ru#vkhoolqj#vwduwv/#zh#xvxdoo|#
Gp|wur#Sdqlq=#klv#Dlu#Txdolw|#WudĿf#Oljkw# khdu#vluhqv#jrlqj#rļ/#vljqdoolqj#wkdw#flwl}hqv#vkrxog#
in issue 108 and his Solar System Display jr#wr#d#erpe#vkhowhu#ru#wdnh#fryhu/Ĥ#kh#h{sodlqv/#ri#
in issue 110. Wkh#Ľuvw#surmhfw#vrxjkw#wr#dgguhvv# klv#prwlydwlrq#wr#fuhdwh#wkh#ghylfh1#ģL#qrwlfhg#wkdw#
frqfhuqv#wkdw#klv#krph#flw|#zdv#rqh#ri#Hxurshġv# p|#idplo|#zrxog#wu|#dqg#jhw#dgglwlrqdo#lqirupdwlrq#
prvw#srooxwhg/#zkloh#wkh#vhfrqg#doorzhg#klp#wr# rq#wkh#suredelolw|#ri#dlu#udlgv#ehiruh#jrlqj#rxw#e|#
jd}h#dw#wkh#vnlhv1#Zkhq#zh#fdxjkw#xs#zlwk#klp# eurzvlqj#wkurxjk#phgld#dqg#rwkhu#fkdqqhov1#L#
uhfhqwo|/#krzhyhu/#kh#zdv#zruulhg#derxw#klv#flw|# wkrxjkw#lw#zrxog#khos#wr#kdyh#d#ghylfh#wkdwġv#dozd|v#
Dmytro Panin
MAKER
dqg#vwdulqj#xszdugv#iru#d#yhu|#glļhuhqw#uhdvrq1 rq#wkdw#frxog#vkrz#wklv#lqirupdwlrq#derxw#dfwlyh#dlu#
Gp|wur#lv#d#Xnudlqldq#iurp#N|ly/#dqg#kh#dqg# udlg#vluhqv#dfurvv#Xnudlqh1Ĥ
Dmytro Panin is a
klv#idplo|#duh#dprqj#ploolrqv#ri#shrsoh#glvsodfhg# Wr#gr#wklv/#kh#wxuqhg#wr#wkh#srsxodu#lqvwdqw#
programmer based
in Ukraine, and dqg#vxļhulqj#vlqfh#Uxvvld#lqydghg#wkhlu#frxqwu|1# phvvdjlqj#sodwirup#Whohjudp1#ģLw#kdv#ihdwxuhv#
LI[VSXILMWǻVWX ģL#zdv#lq#N|ly#zkhq#wkh#Ľuvw#zdyh#ri#h{sorvlrqv# uhvhpeolqj#d#vrfldo#phgld#sodwirup/Ĥ#Gp|wur#vd|v1#
line of code aged vxujhg#dfurvv#Xnudlqh#dqg#zh#ohiw#wkh#flw|#zlwk# ģRqh#ri#wkhvh#lv#ĠFkdqqhovġ#Ğ#suhww|#pxfk#d#rqh0
eight. He works for
a large provider of qrwklqj#exw#rxu#edfnsdfnv/Ĥ#kh#vd|v1#\hw#dprqj# wr0pdq|#lqirupdwlrq#glvwulexwlrq#sodwirup1#\rx#
nearshore software wkh#lwhpv#kh#pdqdjhg#wr#jude#ehiruh#hydfxdwlqj# vxevfuleh#wr#d#fkdqqho#|rxġuh#lqwhuhvwhg#lq#dqg#jhw#
engineering zhuh#d#Udvsehuu|#Sl#]hur#frpsxwhu#dqg#dq#h0lqn# phvvdjhv#zlwk#olqnv/#skrwrv#dqg#ylghrv#iurp#shrsoh#
services.
vfuhhq#Ğ#dq#rgg#ghflvlrq/#kh#dgplwv/#exw#rqh#wkdw#
magpi.cc/ kdv#suryhq#wr#eh#yhu|#xvhixo1
airraidmonitorgit
We left the city with nothing
Getting alerts
E|#xvlqj#wkrvh#wzr#frpsrqhqwv/#Gp|wur#kdv# but our backpacks
fuhdwhg#dq#dlu#udlg#vluhq#prqlwru#wkdw#vkrzv#zklfk#
sduwv#ri#wkh#frxqwu|#duh#ehlqj#vkhoohg1#Kh#vd|v#kh#
qhyhu#lpdjlqhg#wkdw#kh#zrxog#hyhu#pdnh#vxfk#d# zkr#uxq#lw1#Whohjudp#ehfdph#d#zd|#iru#rĿfldov#wr#
ghylfh/#exw#wkh#zdu#kdv#vkliwhg#wkh#sdudgljp#ri# qrwli|#zkhuh#dlu#udlg#vluhqv#vwduw#dqg#vwrs1Ĥ
zkdw#lv#d#pxvw/#d#qhfhvvlw|/#ru#xvhixo1#ģL#nqrz#
zkhuh#doo#wkh#ordg0ehdulqj#zdoov#lq#p|#dsduwphqw# Making predictions
duh/Ĥ#kh#odphqwv/#vd|lqj#kh#qrz#orrnv#dw#rog# Zkhq#Gp|wur#ehjdq#klv#surmhfw/#wkh#h0lqn#vfuhhq#
frqfhswv#lq#frpsohwho|#qhz#zd|v1 zdv#douhdg|#frqqhfwhg#wr#Udvsehuu|#Sl#]hur1#Wkh#
lghd#zdv#wr#frgh#d#surjudp#wkdw#zrxog#prqlwru#dqg#
sduvh#phvvdjhv#lq#Whohjudp#dqg#fuhdwh#d#ylvxdo#
vqdsvkrw#ri#wkh#fxuuhqw#vlwxdwlrq#dfurvv#Xnudlqh1#
ģQrw#rqo|#grhv#lw#vkrz#uhjlrqv#zkhuh#wkh#dlu#udlg#
vluhqv#duh#dfwlyh/#lw#khosv#wr#suhglfw#d#srwhqwldo#dlu#
udlg#e|#orrnlqj#dw#wkh#vsuhdg#dqg#surjuhvvlrq#ri#wkh#
dwwdfn#Ğ#fkdqfhv#duh#wkdw#li#pxowlsoh#uhjlrqv#duh#
klw/#lw#zloo#vsuhdg/Ĥ#Gp|wur#vd|v1
Lw#zdvqġw#doo#sodlq#vdlolqj/#wkrxjk1#ģWkh#sureohp#
zdv#wkdw/#hyhq#wkrxjk#L#kdg#d#suhfrqĽjxuhg#
plfurVG#fdug#lqvwdoohg#lq#Udvsehuu|#Sl#]hur/#L#
Although there are qhhghg#wr#fkdqjh#wkh#frqĽjxudwlrq#lq#wkh#Ġerrwġ#
lots of air raid sirens
across Ukraine, there gulyh#dqg#d#fdug#uhdghu#zdvqġw#vrphwklqj#L#
are still many places
frqvlghuhg#hvvhqwldo#zkhq#sdfnlqj#p|#edj$#
in a city where they
cannot be heard L#hqghg#xs#sxwwlqj#wkh#plfurVG#fdug#lqwr#d#idplo|#
eƋĀųŸƋرŸŞÆåųųƼ{Ĝ¬åųŅƤ
processed Telegram
messages to gather air raid
siren data, but Dmytro has
ŸĜĹÏåÏŅĹĀčƚųåÚ±ÏĬŅƚÚ
Ÿåųƴåų±ĹÚÏųå±ƋåÚ±Ĺe{F Quick FACTS
> It can help predict
the likelihood
of airstrikes
> It monitors
Telegram for
information
Dmytro had already put the screen and > Dmytro’s family
Raspberry Pi Zero W together in a case
before being forced to evacuate Kyiv evacuated with
paperwork, clothes,
food, and laptops
phpehuġv#skrqh#dqg#xvlqj#d#wh{w#hglwru#wr#
frqĽjxuh#wkh#fpgolqh1w{w#dqg#frqĽj1w{w#wr#VVK#lqwr#
Udvsehuu|#Sl#]hur#wkurxjk#wkh#XVE#frqqhfwlrq1Ĥ
Wkh#surmhfw#kdv#dovr#ohg#wr#wkh#fuhdwlrq#ri#d#
preloh0Ľuvw#rqolqh#pds#dw#sirens.in.ua1#ģLwġv#kdug#
wr#jhw#Udvsehuu|#Sl#lq#Xnudlqh#li#|rx#grqġw#douhdg|#
kdyh#rqh/Ĥ#Gp|wur#uhyhdov1#
Vr#idu/#wkh#ghylfh#kdv#suryhq#xvhixo1#ģOdvw#
zhhnhqg/#zh#zhuh#jhwwlqj#uhdg|#wr#jr#wr#wkh#
vkrs#exw/#edvhg#rq#wkh#gdwd#iurp#wkh#ghylfh/#zh#
srvwsrqhg#wklv#dqg#wkh#dlu#udlg#vluhq#zhqw#rļ#whq#
plqxwhv#odwhu/Ĥ#kh#vd|v1#Vlqfh#srvwlqj#derxw#wkh#
prqlwru#rqolqh/#orwv#ri#rwkhu#Xnudlqldqv#kdyh#dovr#
fuhdwhg#wkhlu#rzq#yhuvlrq1#ģL#kdyh#rshq0vrxufhg#
wkh#frgh#dqg#wkh#lqvwuxfwlrqv1#L#krsh#lw#nhhsv#shrsoh#
There’s a macOS widget too, with Linux
vdih#gxulqj#wkhvh#xqwklqndeoh#wlphv1Ĥ# and Windows versions in the works
Synch.Live
Combining art and brain science with
Raspberry Pi? It’s not as strange as you
think. Rob Zwetsloot ponders it
C
reating art with Raspberry Pi is one of our
favourite things to see, which is why we
have been excited about this project during
an email exchange with its creator, Hillary Leone.
“Synch.Live is a joyful, participatory community
art experience and cutting-edge brain science
Construction of the hat system
experiment, designed to spark emergent behaviour
and fortify human connection,” Hillary tells us.
Hillary Leone Idea emerging
MAKER
14 magpi.cc Synch.Live
PROJECT SHOWCASE
Synch.Live magpi.cc 15
PROJECT SHOWCASE
5\GTCƓP//&
Mushroom Farm
Hobbyist farmers Judit and Zsolt used engineering and tech know-how
to expand their mushroom farming business. Rosie Hattersley hears how
W
ith two decades of engineering “The aim is to ensure the automatic operation
experience gained during military of mushroom growing sites, so the characteristics
service, Hungarian Zsolt Pozsár of the growing environment can be monitored
uhvxphg#klv#yrfdwlrqdo#txdolĽfdwlrqv#dqg# dqg#prglĽhg#uhprwho|/Ĥ#vd|v#]vrow1#ģGhylfhv#
began a career maintaining the bottling lines must operate continuously and reliably in a humid
for a multinational company. Meanwhile, his hqylurqphqw#zlwkrxw#xvhu#lqwhuyhqwlrq1Ĥ#Uhprwh#
wife Judit’s small farming concern seemed as management without smart controller devices
wkrxjk#lw#frxog#ehqhĽw#iurp#]vrowġv#nqrzohgjh# such as relays and timers is impossible. “These
of how technology could improve their crops. operations should be user-friendly, with no
The couple have been growing mushrooms for surjudpplqj#nqrzohgjh#uhtxluhg1Ĥ
wkh#sdvw#Ľyh#|hduv1#]vrowġv#PP8G#Udvsehuu|# ]vrow#zdqwhg#d#vpdoo/#orz0srzhu/#Olqx{0edvhg#
Pi-based monitoring system – a four-channel vlqjoh0erdug#frpsxwhu1#Kh#fkrvh#Udvsehuu|#Sl#iru#
programmable control and remote monitoring his mushroom farm on the recommendation of
Zsolt
/#-'4
16 magpi.cc ^IVEǻR22)2YWLVSSQ+EVQ
PROJECT SHOWCASE
Quick (#%65
> >WSPXIRNS]W5
languages: Pascal,
Perl, and Python
Warning!
Mains Electricity
Do not connect 230 V
contacts to the relays
SRXLITVMRXIHGMVGYMX
FSEVHEWXLIMVLMKLGSMP
voltage and current will
also cause the contact to
WTEVOERHMRXIVJIVI[MXL
XLIHMWTPE]ƶWWIVMEPHEXE
XVEǽG9WIPS[ZSPXEKI
and current fast relays
and move them away
from the control unit.
2YWLVSSQWFIRIǻXJVSQXLIMV magpi.cc/
STXMQEPKVS[MRKGSRHMXMSRW electricalsafety
^IVEǻR22)2YWLVSSQ+EVQ magpi.cc 17
PROJECT SHOWCASE
Zsolt’s controller system shows the status of the lights, fans, kh#pdnhv#wkh#lqvwdoohu#vriwzduh#iru#klv#PP8G#
allows the user to
see at a glance the kxplglĽhu/#dqg#zdwhulqj#v|vwhp#Ğ#lqfoxglqj#wkh# plant-monitoring devices available online
WXEXYWSJXLIGVST pressure, and whether or not the tent door is open. (magpi.cc/mm5dgit). He also maintains his own
and the current
environment settings ģPhdvxuhphqw/#wlplqj/#dqg#hohfwulfdo#htxlsphqw# Gheldq#uhsrvlwru|#iru#Udvsehuu|#Sl#RV/#Gheldq/#dqg#
control is done by a Python-language program that Xexqwx#Olqx{#+magpi.cc/pozsi).
18 magpi.cc ^IVEǻR22)2YWLVSSQ+EVQ
PROJECT SHOWCASE
ri#wkhlu#idup#lq#Wlv}diØogyÃu/#forvh#wr#Exgdshvw1#
Their mushrooms, as well as oyster mushroom )TQY[QWTQYP
compost useful for growing other crops, are sold in
hqylurqphqwdoo|#iulhqgo|#sdfndjlqj1
Wkh|ġyh#dovr#h{sdqghg#zlwk#dgglwlrqdo#
mushroom fruiting chambers, as well as
diversifying into other crops. The addition of these
yhjhwdeoh#sorwv#kdv#dovr#jlyhq#]vrow#wkh#h{fxvh#wr#
frph#xs#zlwk#dqrwkhu#prqlwrulqj#surmhfw#dgglqj#
automated irrigation to the whole site, as well as
the mushroom tents. “The water and electrical
system, electrical cabinet, and pump shaft will be Judit and Zsolt’s son
WLS[WSǺXLIPEXIWX
ready by the summer. Tomatoes, eggplants, and QYWLVSSQGVSTKVS[RMR
XLIMVGIPPEVTVSHYGIH[MXL
sxpsnlqv#zloo#jurz#dqg#wkh#hqylurqphqw#zloo#
XLILIPTSJXLISVMKMREP
eh#ehdxwlixo$Ĥ# TVSXSX]TIGSRXVSPPIV
The MM5D controller unit houses Raspberry
01 Pi and sensors and controllers to adjust the
lights, temperature, and humidity sensors. It’s linked
to OpenWeatherMap.org.
^IVEǻR22)2YWLVSSQ+EVQ magpi.cc 19
PROJECT SHOWCASE
Vectrex Mini
A bespoke version of a rare video games console is within your reach... if you’re willing
to make one. Nicola King learns how to ‘mini-fy’ an inimitable console of yesteryear
R
emember the Vectrex video games system?
Maybe not. Launched in 1982, it soon
disappeared. Still, it was one of the most
curious consoles ever made, with an integrated
vector CRT monochrome monitor – colour could be
added with the addition of an acrylic screen overlay
that came with each cartridge-based game. Only
5;#wlwohv#zhuh#rĿfldoo|#uhohdvhg/#lqfoxglqj#wkh#
Brendan
MAKER
Brendan made a
separate controller
Quick FACTS
unit for the project
> It’s powered by a
WXERHEVHSǽGMEP
5.1 V 2.5 A micro-
USB supply
NMS Ceefax
The BBC closed its Ceefax service in 2012 but Nathan Dane is keeping
memories of the iconic blocky service alive, as David Crookes explains
B
efore the internet, there was teletext
– a brightly coloured, blocky-looking
information service built into a huge
number of television sets from the mid-1970s
onwards. It allowed millions of people to read
qhzv#dqg#vsruw#khdgolqhv/#fkhfn#wkh#zhdwkhu/#Ľqg#
travel information, view TV and radio listings, and
even play a quiz or two.
Nathan Dane
MAKER
Rain or shine
Nathan also tweaked the Ceefax page design so that
it would allow headlines longer than 35 characters
dqg#kh#pdgh#klv#QPV#Fhhid{/#dv#kh#fdoov#lw/#gudz#
data from other sources, too. TV listings, for
lqvwdqfh/#frph#gluhfwo|#rļ0dlu#iurp#wkh#Iuhhylhz#
Electronic Programme Guide. Weather, meanwhile,
You can view the lv#wdnhq#iurp#wkh#Phw#RĿfhġv#DSL#Ğ#d#ghflvlrq#wkdw#
pages on Nathan’s
website using overcame a major challenge.
an interactive
ģIru#wkrvh#zkr#grqġw#uhphpehu/#wkh#Fhhid{#
viewer created by
Alistair Cree weather map was essentially a blocky outline of
Quick FACTS
> BBC Ceefax was
XLIǻVWXXIPIXI\X
service in 1974
Raspberry Pi can generate a valid
> Nathan’s version
teletext signal without VBIT-Pi, but
scrapes the BBC
the board allows teletext to be
website for news
added to an existing video signal
Raspi-teletext adds
the teletext signal to
Raspberry Pi’s composite
video output
Dw#Ľuvw/#kh#kdug0frghg#wkh#irxu#XN#frxqwulhv#lq#
glļhuhqw#frorxuv#dqg#lqfoxghg#wkh#gdwd#ehvlgh#hdfk#
ri#wkhp1#E|#wdnlqj#zhdwkhu#iurp#wkh#Phw#RĿfh/#
however, Nathan could download weather data for
the UK’s eleven regions. “Comparison code then
grouped all the areas with similar conditions under
one colour – it’s not perfect, but it’s close enough
to do the job,” Nathan reveals.
Having kept the project for personal use for
a long time, he’s now made his Ceefax publicly
This fuzzy image shows how the teletext signal looks in the Vertical
available online, where it’s gone down well with
Blanking Interval (VBI). “This was made visible by adjusting the
visitors. “I was initially drawn to teletext because V-Hold on a CRT to ‘roll’ the VBI down into view,” Nathan says
AI Weather Station
Forecasting air quality with this Raspberry Pi weather station
and machine learning, Rob Zwetsloot takes a whiff
A
ir quality is a big issue in many parts of
the world – especially in cities and other
built-up areas. While we’ve seen a couple
projects like this before which just show current air
quality readings, this project does something a bit
more special.
“I focused on creating an AI-driven, budget-
Kutluhan Akar friendly device to collect local weather data with
MAKER
Quick FACTS
> If you wish to
replicate this,
Kutluhan says a
Raspberry Pi 3B+
will work too
Good quality
According to Kutluhan, the predictions are at
roughly 92% accuracy for the three quality classes.
“After publishing my project, I received
encouraging comments to keep improving
this weather station as an SDG (Sustainable
Development Goals) project,” he reveals. “[I also
got] questions regarding how to make the station
frpsdwleoh#zlwk#ZlIl#ru#JSUV#e|#xwlolvlqj#glļhuhqw#
development boards.”
Kutluhan is planning to add LoRaWAN and GPS
capabilities to the weather station in the future, for
collecting data in forests and industrial areas. We
look forward to seeing how it goes! Testing the weather station to make sure it all works
Fibre Optic
Matrix Display
This unique Raspberry Pi Pico-powered display produces
some amazing arty effects. Phil King is mesmerised
W
e’ve seen a wide variety of displays
used in projects, but none quite like
this. With a standard 16×16 NeoPixel LED
pdwul{#erdug#frqqhfwhg#e|#rswlf#Ľeuhv#wr#d#julg#ri#
wlq|#krohv#lq#d#vpdoohu#68¹:#iurqw#sodwh/#lw#uhvxowv#
lq#vrph#frro#frorxu#hļhfwv#iurp#wkh#oljkw#ohdnlqj#
iurp#wkh#vlghv#ri#wkh#Ľeuhv1#Wr#jhw#wkh#ixoo#lpsdfw/#
fkhfn#rxw#wkh#ylghr#+pdjsl1ff2Ľeuhrswlf|w) on
ElliotMade
MAKER
HoolrwPdghġv#\rxWxeh#fkdqqho1
Hoolrw#whoov#xv#wkh#frqfhsw#lv#d#qdwxudo#h{whqvlrq#
A technical product
manager for ri#wkh#zrug#forfnv#khġv#pdgh#suhylrxvo|1#Kdylqj#
an online retail ehhq#lqwurgxfhg#wr#Udvsehuu|#Sl#Slfr#rq#d#frxuvh#
company, Elliot at teachmepcb.com/#kh#rswhg#wr#xvh#lw#iru#wklv#
spends his spare
surmhfw=#ģLw#Ľw#wkh#uhtxluhphqwv#iru#wklv#glvsod|/# 1
MKLXPIEOMRKJVSQXLIWMHIWSJXLISTXMGǻFVIW
time on electronics, VIWYPXWMRWTIGXEGYPEVTEXXIVRWERHIǺIGXW
machining, soxv#doo#ri#wkh#rwkhu#jrrg#uhdvrqv=#lwġv#fkhds/#hdv|#
gardening, and wr#jhw/#uxqv#FlufxlwS|wkrq/#uhdoo|#hdv|#wr#
just making things
in general.
xvh/#dqg#kdv#suhww|#juhdw#fryhudjh#lq#wkh# Sandwiched plates
frppxqlw|#rqolqh1Ĥ Wkh#exlog#frpsulvhv#d#qxpehu#ri#sodwhv/#ghvljqhg#
elliotmade.com Diwhu#vshqglqj#d#|hdu#ru#wzr#wklqnlqj#derxw# lq#VrolgZrunv/#vdqgzlfkhg#wrjhwkhu1#Dw#wkh#yhu|#
wkh#lghd#Ğ#lq#zklfk#wlph#kh#ohduqhg#wr#xvh#wkh# iurqw/#khog#e|#wzr#phwdo#urgv/#wkh#pdlq#glvsod|#
VrolgZrunv#FDG#vriwzduh/#zklfk#fdph#lq#xvhixo# julg#kdv#68¹:#wlq|#krohv#frqqhfwhg#zlwk#rswlf#
Ğ#Hoolrw#vhw#derxw#exloglqj#wkh#lqqrydwlyh#glvsod|1# Ľeuhv#yld#d#iurqw#sodwh#wr#wkh#OHG#pdwul{#erdug#
ģL#vshqw#d#zhhn#ri#hyhqlqjv#dqg#rqh#zhhnhqg#wr# ehklqg/#zkrvh#uhdu#lv#vxssruwhg#e|#d#plggoh#
nqrfn#rxw#wkh#phfkdqlfdo#frqvwuxfwlrq#dqg#wr#jhw# sodwh1#Dq#rswlrqdo#edfn#sodwh#lv#xvhg#wr#prxqw#wkh#
vrph#edvlf#frgh#uxqqlqj1Ĥ hohfwurqlfv/#lqfoxglqj#Slfr1
Warning! Rqh#ri#wkh#pdlq#fkdoohqjhv#zdv#soxjjlqj#
CNC Cutter doo#ri#wkh#rswlf#Ľeuhv#lq#sodfh=#ģWkh|#zhuh#qrw#
frpsohwho|#xqlirup#lq#wklfnqhvv/Ĥ#vd|v#Hoolrw/#ģvr#
Be careful when using vrph#Ľw#hdvlo|/#vrph#zhuh#orrvh/#dqg#vrph#glgqġw#
CNC cutters in your
projects. Wear ear
Ľw#dw#doo#Ğ#e|#wkh#hqg#ri#lw/#p|#Ľqjhuwlsv#zhuh#
protection and safety suhww|#vruh#iurp#wkuhdglqj#wkhp#doo#lq1Ĥ
glasses and stand clear
of the machinery as it Dozd|v#xs#iru#d#ixq#fkdoohqjh/#kh#rswhg#wr#pdnh#
works. Understand the wkh#sodwhv#rq#d#FQF#pdfklqh/#ploolqj#wkhlu#vkdsh#
FEWMGWEJIX]JYRGXMSRW
of your machine. dqg#guloolqj#hyhu|#vpdoo#kroh/#zklfk#zdvqġw#zlwkrxw#
lwv#glĿfxowlhv1#ģL#xvhg#wkh#vdph#nlqg#ri#vrolg#
magpi.cc/cncsafety
fduelgh#guloo#elw#wkdw#lv#xvhg#lq#SFE#pdqxidfwxulqj/#
zklfk#lq#klqgvljkw#zdv#suredeo|#qrw#d#juhdw#fkrlfh#
Elliot used a CNC iru#doxplqlxp#Ğ#wkh|#duh#yhu|#hdv|#wr#euhdn/#
machine to mill two
of the panels and sduwlfxoduo|#li#wkh#ľxwhv#Ľoo#xs#zlwk#fklsv#lq#d#kroh1#
drill all the tiny holes,
P|#FQF#ploo#wrsv#rxw#dw#6;33#usp#dv#zhoo/#zklfk#
FYXXLI]GSYPHFI
3D-printed instead lvqġw#wkh#ehvw#iru#vpdoo0gldphwhu#wrrov#olnh#wklv1Ĥ
kŞƋĜÏĀÆųåŸÏŅĹĹåÏƋå±ÏĘ
matrix LED to a tiny hole
in the main display panel
Quick FACTS
> &TVSNIGXFYMPH
guide is on
.RWXVYGXEFPIW
Krzhyhu/#kh#vd|v#wkdw#dq|rqh#zdqwlqj#wr# wkh#rswlf#Ľeuhv1#Wklv#pdnhv#lw#hdv|#wr#dgdsw#wr#
magpi.cc/
uhsolfdwh#wkh#surmhfw#frxog#6G0sulqw#wkh#sodwhv# vkrz#dq|#wh{w#ru#sdwwhuq1#Vr#idu/#Hoolrw#kdv#xvhg# ĀÆųåŅŞƋĜÏÚĜŸŞĬ±Ƽ
lqvwhdg1#ģLq#idfw/#dqrwkhu#xvhu#rq#Lqvwuxfwdeohv# wkh#glvsod|#dv#d#gljlwdo#forfn#+zlwk#dq#UWF,#dqg#
wrrn#p|#Ľohv#dqg#sulqwhg#klv#rzq#yhuvlrq#dqg#lw# iru#vfuroolqj#wh{w2judsklfv#dqg#dqlpdwhg#hļhfwv/# > The code and
orrnv#olnh#lw#wxuqhg#rxw#juhdw$#Wklv#ghvljq#lv#dovr# exw#ģlw#fdq#gr#mxvw#derxw#dq|wklqj#|rx#zdqw/#rqo|# )QSHIPǻPIW
txlwh#hdv|#wr#pdnh#zlwk#d#odvhu#fxwwhu1Ĥ olplwhg#e|#|rxu#lpdjlqdwlrq1Ĥ# GERFIJSYRHSR
,MX-YFmagpi.cc/
CASE STUDY
Crux Labs
digital telephony
Raspberry Pi was this company’s clear choice to enable
seamless home working. By Rosie Hattersley
C
rux Labs’ CEO and founder Rohit Pdq|#Ľupv#zlwk#xqghu#433#hpsor|hhv#odfn#
Gupta noticed that, while home d#vshfldolvw#LW#h{shuw#wr#pdlqwdlq#d#fodvvlf#SE[#
communications technology had become whohskrqh#v|vwhp#dqg#lqwhjudwhg#frppxqlfdwlrqv#
well-integrated, many small businesses were kxe#dqg/#lq#dq|#fdvh/#wkh#frvw#ri#lqvwdoodwlrq#lv#
still using analogue telephony solutions, surklelwlyh#iru#pdq|#exvlqhvvhv#dw#wklv#vfdoh1#
with no means of recording missed calls Jxswd#irxqghg#Vlqjdsruh0edvhg#Fux{#Odev#wr#rļhu#
and following up on the potential business dq#dffhvvleoh#gljlwdo#whohskrq|#vroxwlrq#wr#VPHv/#
opportunities they represent. iurp#vroh#wudghuv#xs#wr#durxqg#583#vwdļ1
THE CHALLENGE
Fux{#Odev#kdg#wr#hqvxuh#wkdw#qhlwkhu#frvw#qru#
frpsoh{lw|#zrxog#eh#d#eduulhu#iru#vpdoo#frpsdqlhv#
vhwwlqj#xs#wkhlu#Ľuvw#gljlwdo#whohskrq|#vroxwlrq1#Lwv#
fxvwrphuv#qhhghg#dq#hdv|0wr0lqvwdoo#surgxfw#wkdw#
zrxog#uhtxluh#plqlpdo#vxssruw/#zkloh#uholdeo|#
gholyhulqj#exvlqhvv0fulwlfdo#ixqfwlrqdolw|1
THE SOLUTION
Fux{#O[/#Fux{#Odevġ#Ľuvw#VPH#surgxfw/#lv#d#gljlwdo#
whohskrq|#vroxwlrq#dlphg#dw#exvlqhvvhv#iurp#vroh#
wudghuv#xs#wr#durxqg#583#vwdļ/#zlwk#d#Udvsehuu|#
Sl#6#dw#lwv#khduw1#Lw#xvhv#VLS#whohskrq|#dqg#d#zlgh# Iru#Fux{ġv#pxowlqdwlrqdo#folhqwv#zlwk#rĿfhv#lq#
duhd#qhwzrun#wr#fuhdwh#d#orz0frvw/#vfdodeoh/# erwk#Pdod|vld#dqg#Vlqjdsruh/#wklv#vrsklvwlfdwhg#
ghylfh0djqrvwlf#dqg#orfdwlrq0djqrvwlf#gljlwdo# Udvsehuu|#Sl0edvhg#v|vwhp#rļhuv#vxevwdqwldo#
whohskrqh#qhwzrun1#Ihdwxuhv#vxfk#dv#fdoo#uh0 vdylqjv#rq#lqwhuqdwlrqdo#fdoov/#dw#d#frvw#wr#
urxwlqj#doorz#wkh#lqwhjudwlrq#ri#whohskrq|#dfurvv#
pxowlsoh#rĿfh#orfdwlrqv/#dv#zhoo#dv#hqdeolqj#
hpsor|hhv#wr#slfn#xs#fdoov#iurp#wkhlu#krph#rĿfhv# The powerful and low-cost
dv#wkrxjk#wkh|#zhuh#lq#wkh#exvlqhvv#edvh1#
Fxvwrphu#ghpdqg#ohg#Fux{#wr#ghyhors#lwv#vhfrqg# Raspberry Pi 3 was ideal
gljlwdo#whohskrq|#surgxfw1#Fux{#Y[/#d#ģfdoo#fhqwuh#
lq#d#er{Ĥ/#wdnhv#doo#wkh#ixqfwlrqdolw|#ri#wkh#Fux{#O[#
for large-scale rollout
dqg#dggv#FUP#dqg#fdoo#pdqdjhphqw#ihdwxuhv1
wkh#folhqw#ri#ohvv#wkdq#d#vl{wk#ri#wkh#sulfh#ri#d#
WHY RASPBERRY PI? frpsdudeoh#hqwhusulvh#v|vwhp1
Fux{#Odev#glg#wkhlu#uhvhdufk=#kdylqj#wuldoohg#qr#
ihzhu#wkdq#hljkw#rwkhu#rswlrqv/#FHR#Urklw#Jxswd# THE RESULTS
vd|v#Udvsehuu|#Sl#zdv#wkh#fohdu#fkrlfh1#Kdg#Fux{# Zkhq#Frylg04<#orfngrzqv#ehjdq#wr#lpsdfw#
fkrvhq#d#vwdqgdug#exvlqhvv#whohskrq|#rswlrq/#kh# vhyhuho|#rq#exvlqhvvhv#dfurvv#wkh#zruog#lq#5353/#
eholhyhv#lw#zrxog#kdyh#frvw#dv#pxfk#dv#633/333# Fux{#Odev#fxvwrphuv#zkr#zhuh#douhdg|#xvlqj#
mxvw#wr#dftxluh#d#surwrw|sh1#Wkh#srzhuixo#dqg#orz0 Fux{#O[#uhsruwhg#wkdw#wkh|#zhuh#deoh#wr#vzlwfk#
frvw#Udvsehuu|#Sl#6#zdv#lghdo#iru#odujh0vfdoh#uroorxw1 wr#uhprwh#zrunlqj#frpiruwdeo|/#zlwk#vwdļ#
Zlwk#Udvsehuu|#Sl/#wkh#vwdeoh#kdugzduh#lv# frqwlqxlqj#wr#zrun#iurp#krph#zlwk#qr#glvfhuqleoh#
vxlwdeoh#iru#wkh#dssur{lpdwho|#;33#vriwzduh# qhjdwlyh#hļhfw#rq#wkh#exvlqhvv1#Fux{#O[#uhsruwv#
sdfndjhv#wkdw#Fux{#O[#frqwdlqv/#iurp#plqru# ryhu#43/333#xvhuv#dfurvv#44#frxqwulhv1#Wkh#PG#ri#
kdqgolqj#ihdwxuhv#wr#XL#ryhuod|v#wkdw#hqvxuh#d# Fux{#Y[#folhqw#Idu#Hdvw#Iorud/#Vlqjdsruhġv#ohdglqj#
frqvxphu0iulhqgo|#lqwhuidfh1#Wkh#uhvxow#lv#d#kljk0 rqolqh#ľrulvw/#qrwhg#wkdw#fkrrvlqj#wkh#Udvsehuu|#
txdolw|#surgxfw#wkdw#fdq#eh#vhw#xs#lq#durxqg#63# Sl0srzhuhg#v|vwhp#zdv#ģrqh#ri#wkh#zlvhvw#
plqxwhv#e|#d#qrq0vshfldolvw1 whfkqrorj|#ghflvlrqv#^zh`#pdgh1Ĥ#
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
Subscribe in print
WORTH
$15
today and get a
FREE computer!
A full Raspberry
Pi desktop
computer
SUBSCRIBE
on app stores
magpi.cc 31
FEATURE
RASPBERRY PI
PHOTOGRAPHY
The Raspberry Pi Camera Module offers a world of creative
and fun digital photo opportunities. By Rosie Hattersley
L
ess than two years after Raspberry Pi
revolutionised the world of personal
computing, the tiny but powerful
Fdphud#Prgxoh#lqwurgxfhg#d#wrwdoo|#glļhuhqw#
approach to digital photography.
The three Raspberry Pi Camera options
open up dozens of fantastic projects to try
that involve little more than adding a tiny-
but-mighty lens and a smattering of code. Try
point-and-shoot photography via a designed-
it-yourself camera, capture superb sports day
action shots and all-day time-lapses; explore
duwlĽfldo#lqwhooljhqfh#xvlqj#lpdjh#uhfrjqlwlrq>#
set up smart surveillance in case of unwelcome
guests; use wildlife cams to enjoy the birds
and the bees; a delivery cam just in case the
postman doesn’t ring twice; encase a camera
in a waterproof housing to explore the world
aquatic; or bolt to a telescope to peer at celestial
realms unknown.
RASPBERRY PI
CAMERA OPTIONS
There are three main camera options
available for Raspberry Pi owners
ASPBERRY PI NOIR
R
8LI7EWTFIVV]5M3S.7(EQIVE2SHYPISǺIVWPS[
PMKLXERHRMKLXXMQITLSXSKVETL]XLEROWXSMXWPEGOSJ
MRJVEVIHǻPXIV
magpi.cc/noir), hence its name, but can
also be used for daytime shots if you’re after some
YRYWYEPIǺIGXW
CONNECTING
AND USING
THE CAMERA
Find out how to connect your High Quality Camera or
Camera Module, enable it, and take your first shots
W
e are going to show you how to connect
the High Quality Camera or Camera
Module to your Raspberry Pi using the
supplied ribbon cable.
Attaching a Camera Module to Raspberry Pi is
easy, using the CSI (camera serial interface) found
on most Raspberry Pi boards.
You’ll need a compatible ribbon cable. The larger
Model A and Model B Raspberry Pi boards use a
standard cable (magpi.cc/cameracable), while
the smaller Zero boards use a Zero Camera Cable
(magpi.cc/zerocameracable).
With a camera attached to Raspberry Pi, you
can then start to capture images and video using
terminal commands
and Python code.
You’ll Need We will then enable
RASPBERRY IPDIE
it in Raspberry Pi
> Raspberry Pi Zero,
OS, before entering
CAMERA GU
Model A, or Model B
magpi.cc/products some commands in a
Terminal window to
> (EQIVE2SHYPI
magpi.cc/camera start shooting photos
and video. Let’s Inspired to try more Raspberry Pi photography?
> (EQIVEGEFPI
magpi.cc/ get started... Download for free ĚåƐkþÏбĮƐ±žŤÆåŹŹDžƐ{ĞƐ±ķåŹ±Ɛ
cameracable :ƣĞÚåERHXV]WXSTQSXMSRZMHISKVETL]PIEVRLS[
XSGETXYVILMKLWTIIHEGXMSRWLSXWHS7EWTFIVV]5M
ǼEWLTLSXSKVETL]ERHQSVI;IƶPPEPWSXIEGL]SYXS
build a photo booth (Minecraft optional), how to shoot
YRHIV[EXIVJSSXEKIERHLS[XSXEOITLSXSWVIQSXIP]
magpi.cc/cameraguide
-SPH7EWTFIVV]5M[MXLXLI
-)2.TSVXWJEGMRKHS[RERH
slide the ribbon cable in so
XLIWMPZIVIHKIWEVIXS]SYV
left and the blue plastic to
your right
Top Tip
Camera
documentation
Take a look
at the High
Quality Camera
documentation
to set up
ƼŅƚųƤϱĵåų±ţ
magpi.cc/hqcam
gettingstarted
8
LI-MKL6YEPMX]
(EQIVE[MXLEWXSGO
6 mm lens enables you
to capture seriously
MQTVIWWMZIWLSXW
I
f you have a Camera Module V2,
or Camera NoIR, you are ready to
connect it directly to Raspberry Pi.
The High Quality Camera will need a
lens mounting on top of the sensor on
the camera board before you can take
photographs. A low-cost 6 mm lens is
available for the High Quality Camera
(magpi.cc/6mmlens). This lens is
suitable for basic photography. It can
also be used for macro photography
because it can focus objects at very
short distances. It does not require the
adaptor ring and connects directly to the
HQ Camera.
Start by screwing your lens onto the
High Quality Camera and adjusting the focus rings.
Follow the High Quality Camera documentation to
set up the lens (magpi.cc/hqcamgettingstarted).
sudo raspi-config
L VS LIBCAMERA
RASPISTIL
raspistill -o test.jpg
INCREDIBLE
CAMERA
PROJECTS
All the incredible things you can make with
Raspberry Pi and a Camera Module
SET UP A PAREN
T TOY CAMERA
DETECTOR 8LI7EWTFIVV]5M-MKL6YEPMX](EQIVEGERFIYWIH
[MXLXLI(QSYRXERHPIRWIWFYXMXƶWRSXXLISRP]
8LMWSRIMWKVIEXJSVOMHWERHMWEWYTIVFMRXVSHYGXMSR STXMSR&WQEOIV:SP^SI\TPEMRWQSYRXPIRWIW
MHIEP
XSYWMRKXLI(EQIVE2SHYPIYWTMGMSYWXLEX JSVQEGLMRIZMWMSRERHMRJVEVIHTLSXSKVETL]GEREPWS
WSQISRIƶWFIIRMR]SYVVSSQERHLEZMRKEKSSHSPH be used, which is what he chose for this Raspberry
RSWI$SYRJEMVVMKLX$8IIRWERHLSYWIWLEVIVWOIIR 5M>IVSFYMPHHIWMKRIHXSEHH^ER]JIEXYVIWERH
to put a hunch to the test can set up a spy cam to alert MRXVSHYGIYRTVIHMGXEFPIIǺIGXWXSHMKMXEPTLSXSKVETL]
XLIQ[LIRIZIVWSQISRIHEVIWIRXIVXLIMVHSQEMR ƳWSQIXLMRKQSVIKIRIVEPP]ORS[REW1SQSKVETL]
8LIIEW]XSJSPPS[XYXSVMEPI\TPEMRWLS[XSWIXYTXLI )ITIRHMRKSR]SYVPIZIPSJQEOIEFMPMX]]SYGERIMXLIV
7EWTFIVV]5M(EQIVE2SHYPIERH5.7QSXMSRWIRWSV YWIERI\MWXMRKSPHGEQIVEFSH]SVERSXLIVZIWWIPXS
XSXVMKKIVZMHISVIGSVHMRKWLSYPHERYRI\TIGXIHZMWMXSV house your camera, or fashion one yourself, for which
FIHIXIGXIHTPYWLS[XSEHNYWXXLIWIRWMXMZMX]WS]SY :SP^STVSZMHIWHIQSWERHPMROWXSEQTPIEPXIVREXMZI
HSRƶXKIXNYQT]IZIV]XMQIXLIHSSVVEXXPIW8LIVIƶW HIWMKRMHIEW-MW)TVMRXIHERH(3(GYXZIVWMSRMW
IZIREWXIEPXLQSHIWSXLIXIPPXEPIVIHVIGSVHMRKPMKLX held together with magnets as well as screws, while
MWWLMIPHIHWLSYPH]SYVLSYWIQEXIWLEZIXLIMVS[R XLIZMI[ǻRHIVMWJVSQETEMVSJRMKLXZMWMSRKSKKPIW
WYWTMGMSRW-IPTJYPP]]SYKIXEREPIVX[LIRERMRXVYHIV *\LSVXMRKSXLIVWXSVIHMWGSZIVXLIUYMVOMRIWWSJ
MWHIXIGXIHERHGERXLIRZMI[XLIJSSXEKIXSGLIGOMX analogue photography, this project shows how much
[EWRƶXNYWXEGLIIO]TYWWTE]MRK]SYEZMWMXFIJSVI]SY fun it can be to experiment when the basic Raspberry Pi
launch in and raise merry hell with the oldies about an camera and other parts are cheap enough to allow you
MRZEWMSRSJTVMZEG] the freedom to do so.
magpi.cc/parentdetector magpi.cc/digitaltoycamera
ION
FACE RECOGNIT
SMART LOCK
HUBBLE PI
A great way to control access to a building is using the
7EWTFIVV]5M-MKL6YEPMX](EQIVEERHEWQEVXTLSRIXS
EWGIVXEMR[LSƶWGEPPMRK;LIREJEQMPMEVJEGITSTWYT
SRWGVIIR]SYGERXLIRKVERXXLEXTIVWSREGGIWW8LMW 4FWIVZIVWSJXLIRMKLXWO][MXLIZIREFEWMGXIPIWGSTI
[SVOWVIEPP][IPPƳEWPSRKEW]SYƶVIEVSYRHXSGLIGO GERYWIMXMRXERHIQ[MXL7EWTFIVV]5MERHXLI-MKL
]SYVTLSRI[LIREZMWMXSVRSXMǻGEXMSRTSTWYT+SV 6YEPMX](EQIVETPYWE(QSYRXXSXIPIWGSTIEHETXIV
scenarios in which you aren’t around, you could train XSGETXYVIMRGVIHMFPIEWXVSRSQMGEPWMKLXW-YFFPI5M
Raspberry Pi 3 or 4 to recognise friends’ faces and allow pairs Raspberry Pi 4 with free astronomy software
XLIQIRXV].RIIIHXYHMSƶW[EPOXLVSYKL]SYXEOI 0XEVW[LMGLHMWTPE]WEPMZIQETSJXLIRMKLXWO]SR
photos of people you want to let in, as per this amusing XLIXIPIWGSTIƶWHMWTPE]2EOIVERXMEKSI\TPSMXIHXLI
JEGIVIGSKRMXMSRWIXYTEPSRK[MXL,VSZIƶW7IPE]8S PEVKIPIRWSJXLI-6(EQIVEERH[VSXI5]XLSRGSHI
18*-&8E[MVIPIWWERXIRREERHSJGSYVWI7EWTFIVV] LIGEPPW&WXVS(EQXSGSRXVSPMXWWLYXXIVWTIIHXLI.4
5M[MXLXLI(EQIVE2SHYPIEXXEGLIH&XI\XQIWWEKI and exposure time. Bonuses include being able to
MWWIRXXSXLIS[RIVWXEXMRK[LS[EWPIXMR[LIRIZIV EYXSQEXMGEPP]XEOIQYPXMTPI7&;TLSXSWERHYWMRKIMXLIV
WSQISRIMWVIGSKRMWIHERHXLIMVHSSVYRPSGOIH VIQSXIHIWOXSTSVEXSYGLWGVIIRXSXVMKKIVEWLSX
magpi.cc/facerecogsmartlock magpi.cc/hubblepi
TURN YOUR
PHOTOS INTO
TIME-LAPSE VIDEOS
Can we get to the good bit? Shooting time-lapse
videos makes drawn-out processes more engaging
G
Enable legacy camera support
ood things are usually worth the wait –
unless they come at the end of a long and
01 The functions we need to use in our
Nik
MAKER
largely repetitive video. In this workshop, Python code will run natively on older versions
Rawlinson we’ll show you how pairing Raspberry Pi with a of Raspberry Pi OS, but require legacy support if
Camera Module 2 and a PIR motion detector lets you’re running Raspberry Pi OS Bullseye or later.
(SǺIIHVMROMRK
X]TI[VMXIVPSZIV you shoot stills only when there’s something To enable support in these versions, open a new
with a penchant for worth watching. Discover how to convert images Terminal window by pressing CTRL+ALT+T (or
pencils and paint.
into a time-lapse video packed with action. We’ve connect to your Raspberry Pi remotely using SSH)
+VIUYIRXP]JSYRH
staring at the sea been using this technique to show how time- dqg#w|sh=
JVSQXLIFEGOSJ frqvxplqj#duwlvwlf#surfhvvhv#uhvxow#lq#d#Ľqlvkhg#
EGEQTIVZER image, but you could also use it to see what your sudo raspi-config
nikrawlinson.com pet does when you’ve left it home alone.
ri#pryhphqw1#Sodfh#|rxu#Udvsehuu|#Sl#rq#d#ľdw#
sudo nano /boot/config.txt surface so the USB ports are to the right and the
GPIO pins are running along the top edge, and hold
Nh|#grzq#wr#wkh#erwwrp#ri#wkh#Ľoh/#dgg#d#qhz# your PIR sensor so that its pins are also running
olqh/#dqg#w|sh= along the top edge and pointing towards you. Use
jumper wires to connect the PIR’s left pin and right
lcd_rotate=2 pins to GPIO pins 6 and 2 respectively, and the
PIR’s middle pin to GPIO pin 7 (magpi.cc/pinout).
Press CTRL+X to quit and press Y when asked if
|rx#zdqw#wr#vdyh/#wkhq#uherrw#e|#w|slqj=
support caused our at the scene we want to capture. Take a test photo
e|#uhwxuqlqj#wr#wkh#Whuplqdo#surpsw#dqg#w|slqj=
saved images are
0kB in size, delete
Top Tip
Running
too slow?
FFmpeg defaults
to a framerate of
ƖĂüŞŸţŅŸƵ±Ş
it for 60 fps, add
‘-framerate 60’
before ‘-pattern_
ƋƼŞåűĜĹƋåŞŎƖţ
uploaded images, as well as a user account that logs removing the # at the start, and adjust the number
straight into that folder. The process for doing this at the end of the line to correct the framing. Our
will vary between providers. Make a note of your camera is positioned with Raspberry Pi’s logo
username, password, and server address. printed on the baseboard in the top left corner,
so we need to rotate the image by 270 degrees to
correct its orientation. However, you may instead
need to make an adjustment of 90 or 180 degrees,
Supply your login details
07 Download the code from GitHub
depending on your setup.
cd timelapse
ArtEvolver:
Part 01
batch-convert
images with
ImageMagick
Prepare to build an ever-evolving artwork using Python
code that merges images endlessly. Start by discovering
ArtEvolver blends
how to bulk process images with ImageMagick the robot with other
pictures, constantly
changing the
B
Sean composite image
WRITER
8
LITSWXIVM^IIǺIGX
mogrify -flip * (here used with a
value of 4) gives your
image the style of a
Ehzduh=#prjuli|#ryhuzulwhv#|rxu#lpdjh#Ľohv1 vintage PC palette
8
LIMQTPSHIIǺIGX montage image_file1.jpg image_file2.jpg mogrify -gravity center -crop 1024x768+0+0 *
here used with a
value of 0.5, distorts -tile 2x1 -geometry +0+0 new_file.jpg
the image
If you have images with unusual dimensions,
This will create a qhzbĽoh1msj#Ľoh#iurp#wkh#wzr# you may need to crop north or south instead. (You
images you supply. can also use a north crop to extract the top of a
portrait-shaped image before you resize it.)
-edge, -paint, and -spread. Experiment with them Using ImageMagick enables you to batch-convert
to transform photographs creatively. Spread gives lpdjhv#lqwr#d#udqjh#ri#glļhuhqw#vw|ohv1#Lq#wkh#qh{w#
|rx#d#iurvwhg#jodvv#hļhfw1#Wkh#ydoxh#iru#fkdufrdo#lv# ArtEvolver tutorial, we will collate these into a
a line thickness. Start here: physical project that uses these transformations.
in one command. They’re carried out in the order 020. echo "$image_file is landscape already [$width x
you list them. Here’s an example that resizes, $height]."
mirrors, and negates an image in a single command: 021. fi
022. done
convert -resize 1024x768^ -flop -negate
Make a SpecDeck:
Digital tape
loader for the
ZX Spectrum
Fed up with ‘R Tape Loading Error’ errors on your classic Speccy?
Load ZX Spectrum software with ease using Raspberry Pi and Pirate Audio
PJ Evans
WRITER
F
Prepare your SD card
PJ has owned a ZX
Spectrum since
orty years ago, Sir Clive Sinclair brought
home computing to the masses with his
02 It’s software time now. We don’t need a
1982. He’s pictured dļrugdeoh#][#Vshfwuxp1#It was soon the full-blown OS, so Raspberry Pi OS Lite is perfect for
here with Richard
Altwasser and Dr
centrepiece of living rooms across the UK as our needs. If you’re building this project headless
Steven Vickers, young gamers and coders battled with parents (with no keyboard or monitor attached), then we
the hardware and for control of the television. As wonderful a recommend the new advanced features in Raspberry
software designers
machine as it still is, the tape loading system Pi Imager (magpi.cc/imager). Run Imager and select
of the ZX Spectrum.
for games and other software was fraught with Raspberry Pi OS (Other) then Raspberry Pi OS Lite as
twitter.com/ errors. Wonky cassettes and unreliable playback the image and your SD card as the storage. Now click
mrpjevans
hardware caused no end of frustration. Now we the cog to set the hostname, enable SSH, create an
can use a Raspberry Pi Zero to emulate a tape onto account, and set wireless LAN credentials. Now you
an original ZX Spectrum with a reliability you can write your image and, on boot, your Raspberry
could only have dreamt of in 1982. Pi will connect to the network and be ready to go.
You’ll Need
This vintage ZX
Spectrum loads games
by listening to tones
from a cassette player
and converting them
into digital information
Save (CTRL+[) then reboot (sudo reboot). After Once complete, you can install all the libraries
reboot, connect the audio out to headphones you need:
(careful of the volume!) and run this command:
sudo apt install git libsdl2-mixer-2.0-0
speaker-test -c 2 python3-rpi.gpio python3-spidev python3-pip
python3-pil python3-numpy libatlas-base-dev
Do you hear static-like white noise? If so, you’re libportaudio2 Top Tip
good to go. Press CTRL+C to stop the racket.
Finally, run sudo raspi-config and under Keep it down
Interfacing Options, enable SPI and I2C.
Please be careful
Will it work? when testing
04 It depends on dependencies playback, ZX
Spectrums
Turn it up to 11
The lines we added to frqĽj1w{w in the previous
step did two things: enable audio output to the
05 What you do next depends on what kind
need it loud,
so please don’t
DAC (digital-to-analogue converter) on the HAT of hardware you are intending to use with this listen directly
and disable any other audio output. However, to project. If it is an emulated ZX Spectrum such as to playback on
get control over the screen, we have to install FUSE or Spectaculator, or a modern recreation such headphones! If
you need to test
libraries that will help us write and display data. as Harlequin, you can skip this. However, if you
hold them away
These are known as dependencies. Start by want to load to an original ZX Spectrum, including from you, you’ll be
making sure you have updated everything already later variants such as the 128+, you’ll need further able to hear!
installed to the latest version: dpsolĽfdwlrq1#Zkdw#zloo#gr#wkh#wulfn#lv#d#vwdqgdug#
specdeck_1.py DOWNLOAD
THE FULL CODE:
> Language: Python 3 magpi.cc/specdeck1py
cd ~/specdeck
sudo python3 specdeck.py
Here we can see a
healthy loading tone:
After a few seconds, ‘SpecDeck!’ will be XLIIUYEPFEVWMRXLI
displayed on the screen and then Raspberry Pi’s FSVHIVWLS[XLEX
we have the levels
logo. This means all is working. Pressing button just right
A on the HAT will start conversion of the TZX to
WAV. This takes a little time on the Raspberry Pi Finally, test it with a reboot:
Zero, but the resulting WAV will be kept so it will
be instant next time. You can pause playback by sudo reboot
pressing button A again and rewind by pressing
B. On the right-hand side, X and Y will scroll On startup, you should see the ‘SpecDeck!’
through all the TZXs available. Press CTRL+C to dqqrxqfhphqw#dqg#wkhq#rxu#whvw#Ľoh1#\rx#fdq#
stop the program. shut down your Raspberry Pi safely by pressing
dqg#kroglqj#exwwrq#E#iru#Ľyh#vhfrqgv1
Spectrum service
11 We don’t want to have to log in via SSH
Add some files
every time we want to use our SpecDeck, so let’s
start everything up on boot by installing the
12 Our SpecDeck is a little exposed and Top Tip
program as a system-level service. wkhuhġv#orwv#ri#gholfdwh#vwxļ#wkdw#qhhgv#
Iluvw/#fuhdwh#d#qhz#Ľoh= protecting. Fortunately, there are a lot of cases Legal ROMs
that people have designed for the Pirate Audio
sudo nano /usr/lib/systemd/specdeck.service HAT that can be 3D printed. Our favourite, by Looking for
Yasuhiro Wabiko, can be downloaded here: content for your
Now add the text in the vshfghfn1vhuylfh listing pdjsl1ff2sludwhdxglrfdvh. This can add that SpecDeck? The
ZX Spectrum
and use CTRL+[ to save and exit. Now we have our all-important protection and make the SpecDeck
homebrew scene
vhuylfh#Ľoh/#zh#fdq#hqdeoh#lw#wr#uxq#rq#errw= truly portable. Other improvements could be to is as busy as ever.
add a battery to make it truly portable, or add See magpi.cc/
sudo systemctl enable /usr/lib/systemd/ support for other computers such as the ZX81 or legalroms.
specdeck.service Commodore 64. As ever, it’s over to you.
Learn ARM
Part 03
assembly:
Raspberry Pi Pico
Learn how to code a small assembly language OpenOCD providing a
link between gdb and
program for Raspberry Pi Pico the Raspberry Pi Pico
Stephen
MAKER
Smith
R
aspberry Pi Pico is a low-cost
Stephen is a retired microcontroller board built around
software developer
who has written
Raspberry Pi’s custom RP2040 system-
three books on on-a-chip (SoC) containing dual-core 32-bit
ARM Assembly ARM processor cores. The RP2040 uses ARM’s
Language
microcontroller M-series instruction set,
Programming.
He is a member sometimes referred to as the ‘thumb’ instruction
of Sunshine set, which is based on the 32-bit instruction set,
Coast Search except most instructions use 16 bits of memory.
and Rescue and Single-stepping
enjoys mountain This makes programs compact and allows you to do through the
biking, hiking, and quite a lot in the RP2040’s 264kB of memory. program in gdb
running. He is also There is no operating system on Pico, and just
a member of the
one program running, which is your program.
Sunshine Coast
Writers and Editors However, there is an SDK that you link into your
The output from our
Society (scwes.ca). program to provide useful function libraries, program in minicom
magpi.cc/ including those to initialise the processor. The
stephensmith SDK is open-source, and you can browse the
processor initialisation assembly language code in
src/rp2_common/pico_standard_link/crt0.S. your home folder by Raspberry Pi Pico SDK’s
setup script. The source code for this tutorial is in
You’ll Need HelloMagPi.S and CMakeLists.txt1#Frs|#wkh#Ľoh#
pico_sdk_import.cmake from the SDK’s external
> Raspberry Pi
Create the program
> Raspberry Pi OS 01 Start by setting up Raspberry Pi Pico and
folder to the tutorial3 folder. In this folder, create a
new folder called build. The tutorial3 folder should
32-bit
install Pico’s SDK on your Raspberry Pi. Connect now look like:
> Raspberry Pi Pico your Pico to Raspberry Pi via the Serial Wire Debug
> Raspberry Pi Pico
(SWD) pins using jumper leads. Follow Chapter 5 in pi@raspberrypi:~/pico/tutorial3 $ ls -l
SDK the Getting Started with Pico documentation if you total 16
need a refresher (magpi.cc/getstartedpico). drwxr-xr-x 6 pi pi 4096 Apr 9 10:39 build
> Serial and debug
connectors In Raspberry Pi OS, create a folder named -rw-r--r-- 1 pi pi 412 Apr 9 10:37
tutorial3 in the pico folder that was created in CMakeLists.txt
openocd -f interface/raspberrypi-swd.cfg -f
target/rp2040.cfg
gdb-multiarch HelloMagPi.elf
(gdb) load
(gdb) i r r7
r7 0x0 0
CMakeLists.txt DOWNLOAD
THE FULL CODE:
The next statement calls the SDK routine
stdio_init_all, which initialises Pico’s SDK to > Language: CMake magpi.cc/learnassembly3
either send text output to the serial port or the USB
sruw1#Wklv#lv#frqĽjxuhg#lq#wkh#CMakeLists.txt#Ľoh# 001. cmake_minimum_required(VERSION 3.13)
by the following two lines: 002.
003. include(pico_sdk_import.cmake)
pico_enable_stdio_uart(HelloMagPi 1) 004. project(HelloMagPi C CXX ASM)
pico_enable_stdio_usb(HelloMagPi 0) 005.
006. set(CMAKE_C_STANDARD 11)
Khuh/#zh#frqĽjxuh#rxwsxw#wr#wkh#vhuldo#sruw1#Li# 007. set(CMAKE_CXX_STANDARD 17)
zh#zdqw#wr#vhh#rxu#rxwsxw#Ľoh#ghexjjlqj/#zh#pxvw# 008.
use this option. When gdb stops Pico’s processor, 009. pico_sdk_init()
it stops everything since our program is the only 010.
thing running. This stops and disconnects the USB 011. include_directories(${CMAKE_SOURCE_DIR})
connection, preventing it from working. The serial 012.
port doesn’t require continuous attention, so it 013. add_executable(HelloMagPi
doesn’t mind. 014. HelloMagPi.S
This routine contains a lot of code, and it will 015. )
take quite a long time to step through it all. So, we 016.
will set a breakpoint at the next statement which 017. pico_enable_stdio_uart(HelloMagPi 1)
happens to have a label, namely loop. Then we 018. pico_enable_stdio_usb(HelloMagPi 0)
will continue, so we stop at the loop label after 019.
stdio_init_all. 020. pico_add_extra_outputs(HelloMagPi)
021.
(gdb) b loop 022. target_link_libraries(HelloMagPi pico_stdlib)
Breakpoint 2 at 0x10000362: file /home/pi/
pico/tutorial3/HelloMagPi.S, line 17.
(gdb) c 18 ADD R7, #1 @ Increment counter
Continuing.
target halted due to debug-request, current The ADD R7, #1 instruction increments our
mode: Thread counter that is printed out. Again, we step through
xPSR: 0x01000000 pc: 0x0000012a msp: this instruction.
0x20041f00
(gdb) s
Thread 1 hit Breakpoint 2, loop () at /home/ 19 MOV R1, R7 @ Move the counter to second
pi/pico/tutorial3/HelloMagPi.S:17 parameter
17 LDR R0, =hellomagpi @ load address of
hellomagpi string Perform MOV R1, R7, which moves the counter
from register 7 to register 1. This is since R1
The next instruction is LDR R0, =hellomagpi holds the second parameter to printf. We can’t
which loads the address of the hellomagpi string use R1 as our counter, since printf will not
into the register R01#Wklv#zloo#eh#wkh#Ľuvw#dujxphqw# preserve the value of this register. Step through
to printf which we call in a few steps. We step this instruction.
through this instruction.
(gdb) s
(gdb) s 20 BL printf @ Call pico_printf
The BL printf instruction will call Pico command to execute this instruction without
SDK’s printf function. This isn’t the printf debugging into it.
function from the C runtime, but part of the SDK.
It is a good implementation of printf and helpful (gdb) n
to use from any programming system using the target halted due to debug-request, current
SDK. If we step, it will take a lot of step calls to mode: Thread
get through this function, so we use the next xPSR: 0x01000000 pc: 0x0000012a msp:
0x20041f00
21 B loop @ loop forever
Part 1
AUTHOR Download
EDWIN JONES the code
from GitHub:
Edwin Jones is a senior software engineer at Mediatonic wfmag.cc/
who’s been working in the games industry for around 17
wfmag62
years. edwinjones.me.uk
H
ow can you make your own game &&ZL]\RXȇOOSUREDEO\ȴQGWKLVHDVLHUWKDQ
for a handheld console that came previous projects, but the Game Boy still has some
out in the 1980s? It’s actually quite quirks you may be unfamiliar with. If you want to
easy, thanks to a few factors. jump ahead, I can recommend this primer from
Because the Game Boy is so old, IUHH&RGH&DPSwfmag.cc/c-begin.
it’s simple to program. And, thanks to the open- 2XUȴUVWVWHSLVWRFRQȴJXUHRXUWRROVWRDOORZXV
source community, its tools are better now to write some code, compile it, and deploy it. First,
than they’ve ever been. If you have a desktop you’ll need a Game Boy or another compatible
computer, you can write code and run it on a console such as the Game Boy Advance or DS.
Game Boy. <RXȇOODOVRQHHGDȵDVKFDUWWRFRS\520VRQWR
One of the simplest ways to get started is such as an EZ Flash: ZIPDJFFH]ȵDVK. If you
with the Game Boy Development Kit, or GBDK. don’t have access to a Game Boy, you can just
:HbFDQXVHWKLVWRZULWH&FRGHDQGFRPSLOHLW run your code on an emulator. I’m using BGB
into a Game Boy program, also known as a ROM. (wfmag.cc/BGB), which has excellent tools for
There are a few versions of software around, visualising what our code’s doing as it runs.
INCLUDES but we’re using the modern version on GitHub: Once you have these tools, you’ll need to
You’ve probably twigged that wfmag.cc/gbdk2020. install GBDK. Follow the instructions on GitHub
our ’main’ function is the code There’s quite a bit of code required for this for your preferred operating system to get it
that our program executes at project – too much to print here in full, but you running. Follow the README to get started
run time. Those lines above FDQGRZQORDGWKHȴOHV\RXȇOOQHHGIURPRXU*LW+XE (wfmag.cc/GBDK). Download the latest release
that which start with a ‘#’ are at wfmag.cc/wfmag62. We’ll be going over all DQGXQ]LSLWWRWKHGLUHFWRU\RI\RXUFKRLFH2QFH
includes. These tell the compiler the code you need step by step, so don’t worry you’ve got that set up, we need to write some
to add some code in place of
LI\RXGRQȇWXQGHUVWDQGLWDOODWȴUVWΖI\RXȇUHD code. Open your editor of choice (my favourite
these lines when compiled.
is VS code: ZIPDJFFYVFRGHDQGFUHDWHDȴOH
We’re using this to import the
called main.c$GGWKHIROORZLQJWH[WWRWKLVȴOH
GBDK code we’ll need to make
our code talk to the Game Boy
hardware directly. #include <gb/gb.h>
#include <stdio.h>
void main()
j Figure 1: This is what your
Hello World should look {
like. Notice how a Game printf(“hello world!”);
Boy-compatible font has
automatically loaded. }
items are drawn to the window layer. can also draw onto two layers: the background could draw – that’s 128 bits.
layer and what’s called a window layer. This is Divide that by 8 bits per byte
XVHGIRU8ΖHOHPHQWVVXFKDVWKHSOD\HU+8'RU and you get 16 bytes.
Now run the following commands in a terminal health bars. If you go back and play some of your
IURPWKHGLUHFWRU\\RXVDYHGWKLVȴOHLQ favourite Game Boy titles, like The Legend of Zelda:
Link’s Awakening (Figure 2), you can see where the
“{path where you installed the GBDK}/bin/lcc” layer’s been placed.
-c -o ./main.o ./main.c The Game Boy lets us scroll the background
“{path where you installed the GBDK}/bin/lcc” and move sprites freely, so we don’t need to
-o ./main.gb ./main.o worry about clearing any previously used pixels.
It even handles wrapping for us – if a background
ΖI\RXRSHQWKDWIROGHU\RXVKRXOGVHHDQHZȴOH or sprite moves too far in one direction, it will
in there called main.gb. Open this in your Game appear on the other side of the screen.
Boy emulator and you Now you understand a
should see the output in “You’ve written and bit more about how the Wireframe
Figure 1. Game Boy works, let’s get 1YZruvufqZEbqruEnnREqRP
ǁljɥȢɁʰljǁʰɁʍɨˎɨɰɽ in Wireframe, our sister
&RQJUDWXODWLRQV<RXȇYH started with our own game:
magazine that lifts the
written and deployed your Game Boy program” DVLPSOHLQȴQLWHUXQQHU lid on the world of video
ȴUVW*DPH%R\SURJUDP called Drop Bear. A bear’s games. Every issue
)HHOIUHHWRPRYHWKLVRQWRDȵDVKFDUWDQGUXQLW falling from the sky, dropping coins; how many includes tutorials and
in-depth interviews, along
on your own hardware. can he collect before the time runs out?
with news and reviews
First, we’ll need to create some sprites using of the latest indie and
HELLO WORLD a browser-based tool called the Game Boy Tile triple-A games.
Now our tools work, let’s look at the Game Boy’s Data Generator (wfmag.cc/gbtdg). Open the 1fdPfvucfqRŧ{ZrZuuYRZq
specs in more detail so we can understand how it folder the project has downloaded to, then open website at wfmag.cc.
works before we make a real game: the LQGH[KWPOȴOHLQ\RXUEURZVHUDQG\RX Check out their
should see something like Figure 3. subscription offers at
wfmag.cc/subscribe.
• $SL[HOIRXUFRORXU/&'VFUHHQ
DGGUHVVDEOHFDQGUDZRVFUHHQ
• four-way direction pad and four buttons
A
(start, select, A, B) for a total of eight inputs
• $QELW6KDUS/5&38
• 8kB of working RAM
• 8kB of graphics memory
• At least 32kB of ROM memory from the game
carts themselves
Let’s move on to input. Most games have We’re loading this new tilemap to the background
multiple ‘states’. Here, we’ll keep it simple by only layer as we did with the logo – you’ll see each
using three – the game splash screen, the game tilemap entry is adjusted by 0×80, so we
play screen, and a game over screen. We can get don’t interact with the loaded font as before.
the Game Boy to wait for our input with another &RPSLOHb\RXUSURJUDPDJDLQDQGORDGLWLQWR%*%
command. Add the following lines to the end of You should now see Figure 7 (overleaf).
your main function: Now, at the end of your main program, add the
following code to the end of your main function:
waitpadup();
waitpad(J_START); // scroll the background forever
cls(); while(1)
{
These functions wait for all buttons to be scroll_bkg(0, 3);
released, just in case the user has any depressed. // Wait until VBLANK to keep time Figure 6: You can see
j
When the Start button is pressed, the screen wait_vbl_done(); the sprites that make
up each letter in this
is cleared. Try it yourself in the BGB emulator: } view. This is the same
font we used for our
press the RETURN key, and the screen should Hello World program.
FOHDU:HFDQȵHVKRXWWKHJDPHSOD\E\DGGLQJ
a background that loads when we move to the
second stage. As our game involves a dropping
bear, a simple trick is to load a background we
can then scroll vertically to generate the feeling
of movement. You can make a striped tile via
the tools mentioned above, but for now, copy
If you compile and run your game again, then // set game timer
press Start, you’ll see the background scrolls. game_time = 600;
SHORTHAND We’ve used an ļŝǙŝļƢĕ loop that scrolls the while(game_time)
You might have noticed we background up three pixels and then waits for {
used a new type here called
a vertical blank. This ensures the code only // scroll the background
‘UINT16’. This is a ‘typedef’:
runs once a frame. The Game Boy has a frame scroll_bkg(0, 3);
a way C programs can use
rate of ~60 fps, which means we’re moving the
their own shorthand to refer
to existing types. The GBDK background at roughly ~180 pixels a second. //decrement the game timer
PRdRruYRrRWfqvrrf|R game_time--;
YE{RE|E~ufPRdRvdrZXdRP FALLING DOWN
integers by size instead of Next, let’s add a little code to allow the main // Wait until VBLANK to avoid
using byte for UINT8 etc. game to run for a while, then stop. We can then corrupting memory and keep time
add some code that resets us back to the main wait_vbl_done();
splash screen, creating a basic game loop. We }
know that each refresh of our loop happens
roughly 60 times a second, so if we want to create //jump back to the start of the
a quick ten-second cycle, we can start a counter program
at 600, decrement it each loop, and exit when goto start;
LWȴQLVKHV$GGWKHIROORZLQJFRGHWRWKHDERYH
main function: Recompile and run the game again. The screen
should fall for ten seconds then you should come
UINT16 game_time = 0; back to the start screen.
Next up, let’s add a player character with
This lets us store a value of 16 bits, more than sprites. I’ve prepared the bear sprite data
enough for number 600. Next, add this at the PHQWLRQHGHDUOLHUZKLFK\RXFDQȴQGLQWKHȴOH
very top of your main function: SOD\HUFKDUDFWHUFRGHF. Just copy this code and
paste it outside of the main function (as you have
start: previously) for now.
)LUVWZHQHHGWRGHȴQHVRPHYDULDEOHVWR
This is a label for a goto statement which we’ll control the position of our player character. Add
use in a minute. Next, update the loop statement this code before your main function like so:
like so:
UINT8 player_x = 72;
UINT8 player_y = 32;
<RXPD\KDYHQRWLFHGDGLHUHQFHLQWKHQDPHRI
the command from before – this is because we’re
setting sprite data, not background data. As we
need more than one 8×8 tile to draw an image, Figure 9: Here you can see
j
we also need to set multiple sprite tiles at a time, the bear sprite in VRAM.
Note how some tiles are
hence the loop. We then invoke a macro to make Here, we write some loops to go over every tile of repeated to save memory.
VSULWHVYLVLEOH3RVLWLRQLQJWKHVSULWHVLVDOLWWOH our sprite and move them around based on the
trickier – add a new block inside your for loop FXUUHQWSOD\HU[DQGSOD\HU\YDOXHVZHFRQȴJXUH
before the wait_vbl_done() call like this: We then wait for player input to see if the sprite’s
x position should move. If you’re wondering
// move player DERXWZKDWȆȇDQGȆȇPHDQWKHȆȇLVWKHVL]HRID
for (UINT8 y = 0; y < BEAR_TILE_MAP_WIDTH; tile in pixels and the ‘2’ how many pixels we want
y++) to move per update.
{
UINT8 yOffset = y * 8; BEAR NECESSITIES
If you recompile your game and load it in an
for (UINT8 x = 0; x < BEAR_TILE_MAP_ emulator, you should see Figure 8 if you press
HEIGHT; x++) Start on the splash screen, and if you press the
{ OHIWDQGULJKWNH\VEXWWRQVWKHEHDUZLOOPRYH
UINT8 xOffset = x * 8; around the screen.
move_sprite(tileCounter++, player_x If you load up the VRAM debugger view again,
+ xOffset, player_y + yOffset); you’ll see that our bear sprite has overwritten
} some of the Nintendo logo in that memory area
} (Figure 9).
// update input If you’re wondering why some tiles are
GOTO JAIL
// LEFT highlighted in this view, it’s just BGB’s way of GOTO is a simple C command
that lets you move execution
if (joypad() & J_LEFT) telling you what’s currently being drawn on
to any other part of the code
{ screen. The other tiles represent that state of
PRdRPM~EbEMRbŬuƆrWEbbRdfvu
player_x -= 2; VRAM for things not currently being drawn. This of favour in modern times as
} FDQEHKDQG\IRUȴJXULQJRXWZK\WKLQJV\RXORDG it’s considered risky, but it still
// RIGHT in aren’t being drawn – usually because their has uses now and then as you
if (joypad() & J_RIGHT) positions haven’t been correctly set. can see in our code – as long
{ And that’s it for now. In the second part of the as you keep an eye on exactly
player_x += 2; guide, we’ll add objectives, a timer, and end game where your labels are!
} states. See you next issue.
RASPBERRY PI 2 ND E D I T I O N
Retro Gaming with Raspberry Pi shows you how to set up a
Raspberry Pi to play classic games. Build your own games console or
full-size arcade cabinet, install emulation software and download classic
arcade games with our step-by-step guides. Want to make games? Learn
how to code your own with Python and Pygame Zero.
WEARABLES
&
COSTUMES
Make your clothes Raspberry
Pi-powered masterpieces
with Rob Zwetsloot
C
ostumes and cosplay aren’t just about
sewing. Crafting armour from foam or
thermoplastics, or turning some PVC
piping into a spear is all part of it these days.
So are electronic add-ons like screens, LEDs, or
moving parts.
Raspberry Pi Zero and Raspberry Pi Pico are
perfect devices to use with more interactive
costumes. With their small size, low power
requirements, and ease in which to program,
they’re a great choice for your Iron Man costume.
Time to make some plans and try to get your
frvwxph#Ľqlvkhg#ehiruh#wkh#frq1
r e s o u r c e s
Co s p l a y
t o f yo u r b u i ld
e p a r
he c o s t um
He lp w i t h t
ft a ny
o s c r a sells m
C k s a n d fabric,
at s to c
th igs to
ro m w s.
A s to r e rials, f plastic
p l a y m a t e
a n d t hermo
cos foam
n c ra f t
t o ev e
k
ft.co.u
Cosplay photography co s c ra
If you want to take decent
selfies or other shots of your
own cosplay, this guide is a Wearable
great start to getting into that. Tech Projects
d
From Sophy Wong, an
at
magpi.cc/costog our colleagues over
e ma ga zin e,
HackSpac
ea t bo ok
comes this gr
ble
full of excellent weara
projects and ideas
beyond Raspberry Pi.
book
magpi.cc/wearable
KamuiCosplayd
s, an
Tutorials, book
te your
patterns to crea
costumes
own incredible
from Kamui.
m
kamuicosplay.co
Alysson Ta
Alyson has
bb itha
incredible
up tutorials make-
, something
is an expert she
on, being a
transform h b le to
erself into
different ch m a ny
aracters.
magpi.cc/
tabbitha
LIGHTING UP
LEDs and displays
W
ant to really make your costume eye-
catching? Install lights and displays on it
so that you instantly light up the room.
y l i g h t s
C o spl a
Maker
01 Build the circuit
Freya and For this project, a round NeoPixel board
Rob Zwetsloot was used. NeoPixel lights require power, a data
input, and ground. While there are not many lights
Web in this setup, they usually require more power than
magpi.cc/cosplayeyes a Raspberry Pi can deliver, so you’ll need a battery
pack as well. A button is also added, which acts as
Project wkh#wuljjhu#iru#wkh#glļhuhqw#oljkw#hļhfwv1
Using NeoPixel LEDS,
these lights were
programmed to recreate
colour patterns for the 02 Coding
NeoPixels require special libraries to
character Sans from
work with Python and MicroPython, including
Undertale. Using
a button press Adafruit_Blinka (magpi.cc/blinka) and the
cycled through CircuitPyhon libraries, like so:
FKHHGTGPVǭUGVVKPIU
sudo pip3 install rpi_ws281x adafruit-
circuitpython-neopixel
03 Installing into the costume the inside. With everything in place, she just had
In this build, Freya glued the NeoPixel ring to press the button in her pocket to change the
to some frosted acrylic in the eye, allowing the code sequence.
68 magpi.cc Raspberry Pi
Wearables & high-end
Costumesaudio
FEATURE
Project
02 Build the prosthetic Inspired by The
Walking Dead, Luis
Luis went the extra mile and created a
decided to make a
latex stomach wound attached to the front of Halloween costume
the display, and connected to a harness he could where you could see
wear under his T-shirt. It’s coloured with make- through him. In TV
up to look skin-coloured, and paint for the blood and movies, there’s
and ‘insides’. green screen magic
involved during
editing. In real life, it’s
as simple as using a
e h a r n e s s
Wi t h t h
h e T - s h i r t
on and t
Q \ ¼[ \ Q U M \ W
W ^M ZQ \
n i t a l l o n
t ur
MOVING
MOTORS
and servos
R
obots and robotic armour are cool costumes
to make. And sometimes, you need some
fake eyes to blink. Using servos and motors,
you can really make a costume come alive.
Te nt ac le hat
Maker
01 Electrical components
Derek The hat uses eight servos, two for each
Woodroffe tentacle, which are hooked up to a Raspberry Pi
Zero. A sine wave is sent to each servo – an X and
Y movement – to try and emulate a more natural
Web
pryhphqw#lq#wkh#Ľqlvkhg#surgxfw1#Wklv#exlog#
magpi.cc/tentaclehat
uses an eight-port I2C PWM controller so that
everything can be connected properly.
Project
This writhing and
wiggling hat is
more of a passive
02 Make the tentacles
accessory. Just turn it The build of the tentacles is very smart;
on and the tentacles the core is made from the spring of a net curtain are slotted over it to give the whole thing some
will move of their
vr#lwġv#ľh{leoh#dqg#pryhv#lq#fxuyhv1#Dfu|olf#glvfv# structure, before stockings are applied on top.
own accord.
Vrph#odwh{#lv#dssolhg#rq#wrs/#dqg#vrph#odvhu0fxw#
2 mm MDF suckers are glued on. Wonderful.
Warning!
Projectiles
Wear goggles when
working with face
tracking weapons,
however soft the
darts are
magpi.cc/nerfsafety
Maker
Engineering
After Hours
Project
01 Creating a model 03 Wearing a gun Taking inspiration
Using a Raspberry Pi connected to an Edge The mount in this project is quite simple from the predators
TPU, you can start training the model for your – a few pieces of wood are cut to length and of… Predator, this
AI face tracker. Feeding it with pictures of faces attached to a series of straps that keep the gun shoulder-mounted
NERF gun uses AI to
allows it to learn what they look like, although you counterbalanced while wearing it on his back. The
track faces and aim
fdq#dozd|v#Ľqg#h{lvwlqj#prghov#wkdw#zloo#kdyh#idfhv# whole thing is powered by a series of batteries
a NERF gun in that
already built in. The more it’s used, the better it dqg/#xvlqj#d#vlpsoh#zluhohvv#uhprwh/#fdq#eh#Ľuhg# direction. Good thing
becomes as well. at the person it’s tracking. Be careful, even with there are no laser
foam darts. pointers attached.
02 Tracking
A Pan-Tilt HAT from Pimoroni was used,
with the code manipulating the motors to turn the
pan and tilt portions of the setup. This is usually
used in robots for object tracking, but is perfect
for anything that requires a camera to move and
track at the same time. The NERF gun needs to
be mounted to the Pan-Tilt HAT and the camera
mounted to the gun.
I N S TA L L I N G
inputs and sound
Y
our costume moves? It lights up? Great.
Grhv#lw#kdyh#vrxqg#hļhfwv#dqg#lqwhudfwlyh#
elements on the outside? Time to add them.
o u t t h e i n t e r n e t
S o c ia l me dia w i t h
Maker
01 Components galore
Tuang Wkhuh#duh#vhyhudo#sduwv#wr#wklv#rxwĽw/#
Thongborisute controlled by a Raspberry Pi and several Arduino
frqwuroohuv1#Frqgxfwlyh#ulqjv#rq#wkh#Ľqjhuv#wrxfk#
Web during a handshake, a button is used to unfriend
tuangstudio.com dqg#lv#wlhg#wr#dq#OHG#glvsod|/#d#olnh#lv#d#kljk#Ľyh#
which activates a force-sensitive resistor (FSR),
Project dislike is via a touchscreen, and microswitches and
This social interaction pressure-conductive resistors (PCR) are used for
project has a lot of follow/following. It’s a lot to connect, but very cool.
buttons and lights and
displays everywhere,
which the general
public can interact 02 Jacket attachment
with, just like Rqfh#doo#ri#wkh#frpsolfdwhg#flufxlw#vwxļ#lv#
Twitter, Facebook, completed, it’s time to attach it to a jacket. This
QTǭ+PUVCITCO can be done with conductive thread to reduce
wire usage, along with tape to attach things and
glue and whatever else you have. The locations
are important for the experiment – the unfollow
button is over the heart you could break, and the
PCR is on the shoulder.
03 Socially interact
The experiment can now begin – go out into
wkh#zruog#dqg#Ľqg#rxw#zkdw#shrsoh#wklqn#derxw#
you. Tuang’s experience showed that people react
glļhuhqwo|=#ģVrph#pd|#khvlwdwh#wr#dvn#ru#lqwhudfw/#
but some partake in face-to-face conversation.”
R ob ot co st ume
01 Hardware setup
The display on the chest uses Instagram
likes to create an electrocardiogram heartbeat, and
the buttons control the LED colours, play random
sounds, and start playing videos on the display.
The voice changer uses Arduino parts as well, and
employs a microphone inside the head. The speech
dfwlydwhv#wkh#vhuyr#wkdw#ľdsv#wkh#urerw#mdz1
02 Cardboard construction
One of the best things about this costume
is how much cheap and recycled material it uses.
Cardboard boxes, googly eyes, aluminium foil, and
air conditioner hoses, among many other things.
Be careful when cutting and gluing to make sure
|rx#kdyh#hqrxjk#vsdfh#wr#dfwxdoo|#Ľw#lqvlgh1
M a everything we’ve
covered so far –
lights, displays,
a h a n d le r, a s yo u
buttons, and a
moving mouth using
servos. There’s also
y n o t b e a b le t o a voice changer
s e e ve r y we l l
Xå±ŹĻƐĚŇƾƐƒŇƐÏŇÚåƐDžŇƣŹƐŇƾĻƐ
ď±ķåžƐƾЃĚƐ{Džď±ķåƐ¬åŹŇ
Available now
magpi.cc/codetheclassics
REVIEW
StackyPi
SB Components magpi.cc/stackypi £14 / $18
SPECS
CONNECTORS:
40-pin GPIO An RP2040 microcontroller compatible with standard HATs. By Phil King
header, 6-pin
W
debug header,
micro-USB ell is it a Raspberry Pi Zero? Is it a
Pico?… No, it’s StackyPi. While there
STORAGE: are a few dedicated add-ons for Pico, if
8MB on-
board flash, you’re a Raspberry Pi fan then you probably have
plus microSD some HATs kicking around that you might like to
card slot xvh#zlwk#lw1#Gxh#wr#Slfrġv#glļhuhqw#duudqjhphqw#ri#
GPIO pins (in two separate rows), however, it’s not
FEATURES:
Boot and reset possible to simply plug in a HAT.
buttons, status Step forward StackyPi. Based on the same
The size of a Raspberry Pi Zero, the StackyPi is an RP2040-
LED, 4 × 12-bit Raspberry Pi RP2040 microcontroller chip as based microcontroller with a 40-pin GPIO header
ADC channels,
Slfr/#lw#rļhuv#wkh#vdph#ixqfwlrqdolw|/#exw#zlwk#d#
PIO, I2C,
SPI, UART pre-soldered 40-pin (2×20) GPIO header. It has Plug and play?
a very similar form factor to a Raspberry Pi Zero, That standard 40-pin GPIO header means you can
DIMENSIONS: including four mounting holes. There’s even a connect any standard Raspberry Pi HAT, pHAT, or
65 × 30 × 10 mm
microSD card slot for extra storage, although other compatible add-on board. The downside is
Vwdfn|Sl#douhdg|#kdv#;PE#ri#rq0erdug#ľdvk# that it’s not a case of plug and play. You will need
(compared to Pico’s 2MB).
Other features include a standard micro-USB
port (for 5 V power or connecting to a computer),
You will need to adapt any
two tiny push-buttons (including a handy reset), existing software for your
an on-board status LED, and six debug pins.
HAT to make it work
to adapt any existing software for your HAT to
make it work.
SB Components has adapted software for several
Verdict of its own HATs for StackyPi, available in a GitHub
repo (magpi.cc/stackpigh), which also features a
Not a plug-and- handy GPIO pinout comparison chart – it’s very
play solution for similar to that on a Raspberry Pi, although some
HATs, as you’ll JSLR#slq#qxpehuv#duh#glļhuhqw1
need to do some
As with Pico, you need to connect the board
software tinkering,
yld#plfur0XVE#wr#d#frpsxwhu#wr#ľdvk#wkh#XI5#
but still a neat
little Pico-style Ľupzduh#dqg#surjudp#lw#Ğ#xvlqj#PlfurS|wkrq/#
board with some CircuitPython, or C++.
bonus features. Why use this over a Raspberry Pi Zero? Well,
7
lw#grhv#rļhu#idu#orzhu#srzhu#frqvxpswlrq#dqg#
four ADC channels. Alternatively, you could use
/10
a Raspberry Pi Pico with a Red Robotics Pico 2 Pi
adapter for standard HATs.
76 magpi.cc StackyPi
SUBSCRIBE AND
SAVE UP
TO
35%
on the cover price
ISSUE #55
OUT NOW
hsmag.cc
REVIEW
SENSOR: Much more than an air quality monitor for your Pico. By Phil King
BME688 –
A
temperature,
humidity, ir pollution is an ongoing issue in many Ľuvw#xvhg/#exw#wklv#d#rqh0rļ#surfhvv#dqg#hqvxuhv#
pressure, gases parts of the world, so the Air Quality greater accuracy for future readings.
Datalogging Board for Pico may well come All in all, this is a well-thought-out board backed
CONNECTORS:
Dual female in very useful for monitoring purposes. A fair up by some top-notch documentation and software.
header for Pico, bit larger than a Raspberry Pi Pico (not supplied) Multiple online tutorials cover its various functions
3 × ADC inputs, which plugs into its dual female headers, this
ZIP LED socket,
square board surprised us with just how many
servo output,
2 × high-power features have been crammed in. A well-thought-out board
For starters, there’s a mini OLED screen (128×64
outputs, 5 V
power input, monochrome) to show sensor readings, plus two backed up by some top-
plus extra
solder pads
small push-buttons, a piezo buzzer, and three ZIP
(WS2812B) RGB LEDs along one edge.
notch documentation
FEATURES:
128×64
Then there’s a host of input and output options,
including three analogue inputs (connected to
and software
monochrome Pico’s ADC channels) for connecting external
OLED, 2 × push-
sensors, a ZIP socket to add more LEDs, a three- in detail, including data logging and analogue
buttons, piezo
buzzer, 3 × ZIP pin servo connector, and two high-power outputs input/output control. The GitHub repo includes a
(WS2812B) RGB (screw terminals) with a max draw of 1 A. In comprehensive MicroPython library for the board
LEDs, 3 × AA addition, there are solder pads for 3V3 power, GND, and numerous code examples to try out.
battery holder
digital pins, SPI, and UART.
DIMENSIONS: Power-wise, there’s a handy switch in one
74×72×27.1 mm corner and a 3 × AA battery holder on the rear. Verdict
There’s even a 5 V input if you want to charge up
the batteries with a solar panel. A fully-featured
Pico add-on with
What a gas plentiful input/
output options,
The key feature of the board is its BME688 sensor, ŅýåųĜĹč±ĘŅŸƋŅü
located in one corner. As well as measuring possibilities for
temperature, humidity, and atmospheric pressure projects. Excellent
(as on a BME680), it features an AI-enhanced documentation too.
9
gas sensor that detects volatile compounds and
The BME688 sensor So many inputs and
is at the top left of the gases to determine IAQ (Index of Air Quality) outputs! Hook it up to a
board; its readings can
/10
and estimated CO2#ohyhov1#Lw#wdnhv#Ľyh#plqxwhv# servo, water pump, heating
be shown on a small pad, or even a solar panel
OLED in the middle to calculate the baseline for the gas sensor when to recharge the batteries
10 Amazing:
Facial Pan / tilt face tracking
recognition
Simple movement
eŸĜĵŞĬåƵ±ƼƋŅƚŸåü±ÏåƋų±ÏĩĜĹčôĬĜƋåų±ĬĬƼģƚŸƋƋų±ÏĩƋĘåü±ÏåƵĜƋĘ
±Ï±ĵåų±ţĘĜŸÏ±ĹÆåƚŸåüƚĬüŅųųŅÆŅƋŞųŅģåÏƋŸŅųĵŅƋĜŅĹƋų±ÏĩŸØŅų
projects
åƴåĹţ
magpi.cc/pantilt
EmpathyBot
Make faces at your Raspberry Pi
Emotional robot
with these incredible builds This Dexter Industries project
ƵĜĬĬųåŸŞŅĹÚÚĜýåųåĹƋĬƼƋŅ
W
ÚĜýåųåĹƋåĵŅƋĜŅĹŸô±üƚĹĬĜƋƋĬå
ith software like OpenCV, it’s easy to create ųŅÆŅƋƋʱƋĘŅŞåüƚĬĬƼƵĜĬĬĹŅƋ
Raspberry Pi projects that can both recognise and ÆåƚŸåÚÚƚųĜĹčƋĘåĜĹåƴĜƋ±ÆĬå
track faces from a camera. Here are some of our ±ƚƋŅĵ±ƋŅĹƚŞųĜŸĜĹčţ
favourite uses of this kind of smart vision.
magpi.cc/empathybot
Object-tracking robot
Archimedes
Follow the ball
Handsome owl
:åƋƋĜĹčųŅÆŅƋŸƋŅüŅĬĬŅƵŸŞåÏĜĀÏƋĘĜĹčŸĜŸ±čųå±ƋƵ±ƼƋŅĜĵŞĬåĵåĹƋ
ŸĜĹčƋĘåeF¥ĜŸĜŅĹĩĜƋØƋĘĜŸųŅÆŅěŅƵĬĬŅŅĩŸ±ųŅƚĹÚüŅųĘ±ŞŞƼŞåŅŞĬå±ĹÚ ±ƚƋŅĵ±ƋĜŅĹƋ±ŸĩŸôĜƋűŸ±ĬŸŅĘŅƵųŅÆŅƋų±ÏĜĹčĬå±čƚå8ŅųĵƚĬ±{Ĝ
±ĬĬŅƵƼŅƚƋŅƋ±ĩ屟ƋĜÏĩåųţåųƼÏƚƋåţ ƚŸåÚƋŅƵŅųĩţ
magpi.cc/archimedes magpi.cc/objecttrack
magpi.cc/creepyportrait magpi.cc/facelock
Face-tracking
robot mannequin
head
Nightmare fuel
eޱĹě±ĹÚěƋĜĬƋŸƋƼĬåŞųŅģåÏƋرĬƋĘŅƚčĘƋĘĜŸ
ƋĜĵå±ƋƋ±ÏĘåÚƋŅ±ųŅÆŅƋƋʱƋ±ÏƋŸ
±Ÿ±Ĺ±Ĭ±ųĵŸƼŸƋåĵôĹŅƋ±ƴåųƼčŅŅÚ
ŅĹåƋĘŅƚčĘţ
magpi.cc/robothead
Face mask detector
Don’t spread it
ĘĜŸÏĬåƴåųü±ÏĜ±ĬųåÏŅčĹĜƋĜŅĹĵŅÚåĬĩĹŅƵŸĜüƼŅƚűųåƵå±ųĜĹč±ü±Ïå
ĵ±ŸĩŅųĹŅƋţFƋűŸĜĹŸŞĜųåÚÆƼ±ŸĘŅŞŞĜĹčÏåĹƋųåĜĹʱĜĬ±ĹÚƋʱƋ
ƵŅƚĬÚŅĹĬƼĬåƋƼŅƚĜĹƵĘĜĬåƵå±ųĜĹč±ĵ±Ÿĩţ
magpi.cc/facemask
Face recognition
Face landmark tracking Who’s there?
Expression tracking ĜƋĘƋĘåųĜčĘƋƋų±ĜĹĜĹčĵŅÚåĬØĜƋűŸ
ü±ĜųĬƼ屟ƼƋŅƋå±Ïʱ±ŸŞÆåųųƼ{ĜƋŅ
ŸĜĹčƋĘ埱ĵåƋåÏʱŸƋĘŅŸåÏųååŞƼ±ĹĜĵ±ƋåÚĵåĵŅģĜƋĘĜĹčŸØ±ĹÚĬ域ÏųååŞƼ ųåÏŅčĹĜŸåŞåŅŞĬå±ĹÚŅÆģåÏƋŸţĜƋĘ
ϱųƋŅŅĹƚÆåųŸØƋĘĜŸĜŸ±ÏŅŅĬ±ĹÚŞŅƵåųüƚĬƚŸåŅü±ŸŞÆåųųƼ{Ĝü±ÏåƋų±ÏĩĜĹčţ ƋĘĜŸØƼŅƚϱĹčåƋŸƋ±ųƋåÚƵĜƋĘƋʱƋţ
magpi.cc/landmarktrack magpi.cc/recognition
Learn Terminal
with Raspberry Pi
Unleash the power of the Linux command
line with these resources. By Phil King
Raspberry Pi OS has a user- command right through to Part three covers common tasks
Price: friendly graphical user interface, writing programs in Bash and essential tools, including
£34 / $40 (Free PDF
but opening up a terminal shell script. Part one covers package management and
version)
window enables you get under topics such as navigating the regular expressions. Finally,
magpi.cc/linuxclbook
the hood. Its command-line Ľoh#v|vwhp/#pdqlsxodwlqj# part four is all about writing
interface can often prove quicker Ľohv#dqg#gluhfwrulhv/#dgydqfhg# shell scripts.
dqg#pruh#hĿflhqw#wkdq#d#JXL#Ğ# keyboard tricks, permissions, The book is also available
once you get to know it and learn and processes. The second as a free PDF download from
a few useful commands. part introduces text editors, linuxcommand.org, where
Over 500+ pages, The with a detailed section on vi, there’s also a stripped-back
Linux Command Line takes and prompt customisation. online guide to get you started.
Websites
Useful web resources COMMAND LINE FU
This searchable repository of basics of how to use it on Raspberry
for the command line terminal commands is a goldmine Pi, including a selection of
of information. Users share their useful commands.
most useful commands, as can magpi.cc/terminaldocs
you. It can also be used to store
your personal favourites. BASH REFERENCE MANUAL
commandlinefu.com Bash is the standard shell, or
command language interpreter,
RASPBERRY PI used in Linux. This comprehensive
DOCUMENTATION resource covers a wide range of
This section of the Raspberry Pi features and functions beyond the
online documentation gives an entry-level commands.
overview of the terminal and the magpi.cc/bashref
Conquer the
you how to create your own
custom commands.
magpi.cc/udemyclbasics
Kevin
McAleer
A master of robotics, Kevin has built many kinds and can
also teach you how to make your own, all with Raspberry Pi
O
ne of our most “I’ve always been into computing; I bought an Arduino
passionate readers is making things as far back as from Maplins and made
Kevin. He always has I remember,” Kevin tells us. some LEDs blink. However,
something to share with us on “From making things with I’ve always been passionate
#MagPiMonday, and notices cereal boxes (the best source of about computing and making
little bits and pieces we put robust and available cardboard) things, so building robots is
in the magazine, including to creating robots and futuristic the ultimate Venn diagram,
accidental patterns in the zruogv#lq#Ohjr/#dw#djh#hljkw$# with my happy place right in
Kevin getting his colour of the spine. He’s also an There was probably a gap of the middle.”
original Raspberry Pi
excellent maker and teacher of about 30 years before I got
signed by Eben during
the tenth anniversary robotics on YouTube. back into making and practical What is your history
with making?
When I was growing up, our
house always had electronics
and disassembled TVs and
things as my father was a TV
repair engineer. He had a lab
full of repair equipment such
as an oscilloscope, spectrum
analyser, and a soldering
station. So, understanding how
electronic things work and how
to repair them when they don’t
lv#sduw#ri#p|#GQD1#L#vshflĽfdoo|#
remember reading a book on
superheterodyne receiver
theory from his room during
high school and following along
with it.
Zkhq#glg#|rx#Ľuvw#ohduq#
about Raspberry Pi?
Early 2012 - I checked my inbox
and can see that I ordered my
Ľuvw#Udvsehuu|#Sl#edfn#lq#Mxqh#
5345#iurp#UV#Frpsrqhqwv$#
MagPi 01
Monday
Amazing projects direct from our Twitter!
E
very Monday we ask the question: have you
made something with a Raspberry Pi over
the weekend? Every Monday, our followers
send us amazing photos and videos of the things
they’ve made. 02
Here’s a selection of some of the awesome things
we got sent this month – and remember to follow
along at the hashtag #MagPiMonday!!
05
06
04
08 09
07
11
10
13
12
14
16
15
17
PicoBricks
SQ1 case
”Pico Bricks is an electronic development board + software
which is designed for use in maker projects. With ten “SQ1 is a Raspberry Pi case you want to put right beside your
detachable modules included, Pico Bricks can be used to create headamp, DAC, and media centre. The elegant design is
a wide variety of projects. It also includes a protoboard that you meant to be seen but not be distracting. Great for Raspberry Pi
can use to add your own modules.” ±ĀÏĜŅűÚŅŸ±ĹÚ±ƚÚĜŅŞĘĜĬåŸţŰ
kck.st/3M9Q036 kck.st/3MGQHRl
RadSense
“The WeatherSense RadSense is built around a Geiger counter
that counts the number of energetic particles hitting the gas
inside the tube. Software on the Grove Mini Pro Plus board reads
these counts and produces a CPM count. The computer then
encodes the data and sends it via a 433MHz radio signal (no
radio license required!) to your Raspberry Pi.”
kck.st/3LG5USK
YOUR LETTERS
Your
Letters Model B query
I recently purchased a Raspberry Pi 4
Model B to show announcement slides
rq#d#ľdw0vfuhhq#WY#lq#wkh#ir|hu#ri#rxu#
church. I was curious about how to get
lw#vwduwhg#iuhvk#iurp#wkh#er{B#Dovr/#L#
zdv#zrqghulqj#li#Udvsehuu|#Sl#zdv#
Parts unknown xqqhfhvvdulo|#vrsklvwlfdwhg#iru#p|#
surmhfw/#dqg#zdqwhg#wr#nqrz#li#|rx#
L#qrwlfhg#lq#lvvxh#44:#wkh#duwlfoh#FGS#Vwxglr#0#dssduhqwo|#wklv#lv#sduw#wzr#exw/#iru#wkh# wkrxjkw#d#vlpsoh#wkxpe#gulyh/#zlwk#whq#
olih#ri#ph/#L#fdqqrw#Ľqg#zklfk#lvvxh#sduw#rqh#zdv#lqB#Lġyh#vshqw#derxw#63#plqv# volghv#grzqordghg#iurp#SrzhuSrlqw/#
orrnlqj#dw#wkh#frqwhqwv#ri#hdfk#lvvxh#rq#wkh#zhevlwh#jrlqj#edfn#derxw#d#|hdu#exw# zrxog#eh#deoh#wr#orrs#rq#d#vpduw#WY#
fdqġw#Ľqg#lw111#fdq#|rx#jlyh#ph#d#foxh#dv#wr#zklfk#lvvxh#lwġv#lqB zlwkrxw#wkh#whfk#ri#Udvsehuu|#SlB
Zkhq#|rx#folfn#rq#ĠGrzqordg#iuhh#SGIġ#iurp#rxu#zhevlwh#dqg#
on the back issues page (magpi.cc/issues), it will come up Subscribe by phone:
01293 312193
with a screen asking if you’d like to make a contribution to the
magazine. If you’ve done this before and want to do it again,
you may need to clear your browser’s cache for our website.
You can also make a recurring contribution if you wish. You
Subscribe online:
can also just continue on and get the PDF for free.
WIN A
CUTIEPI
We reviewed this
excellent Compute
Module-powered tablet
last issue. It’s powerful,
very user-friendly, and
even has a neat handle
that can be used to prop
it up. Now is your chance
to win one.
Competition magpi.cc 95
HELP! MY COMPUTER
IS BROKEN
,S[HS-Ƥ\MX#
E
Sub Editor
B L
Nicola King
A R K A ADVERTISING
REM
S!
Charlotte Milligan
T
charlotte.milligan@raspberrypi.com
O
+44 (0)7725 368887
OB
DESIGN
R
criticalmedia.co.uk
Head of Design
Lee Allen
Designers
Olivia Mitchell, Sam Ribbits
Illustrator
Sam Alder
CONTRIBUTORS
David Crookes, PJ Evans,
Rosemary Hattersley, Edwin
Jones, Nicola King, Phil King,
Sean McManus, Nik Rawlinson,
Stephen Smith
PUBLISHING
Publishing Director
Russell Barnes
russell@raspberrypi.com
Director of Communications
Liz Upton
CEO
Eben Upton
DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000
SUBSCRIPTIONS
Unit 6 The Enterprise Centre
Kelvin Lane, Manor Royal,
Crawley, West Sussex, RH10 9PE
+44 (0)1293 312193
magpi.cc/subscribe
magpi@subscriptionhelpline.co.uk
Everybody needs
a hobby(ist)
The Raspberry Pi community makes it all worthwhile. By Lucy Hattersley
O
ne of the big talking points at I’m talking about. Which often makes The big tech-chat at the moment is
the moment is Raspberry Pi two of us. But he appreciates a the supply chain. Last issue we
for hobbyists and Raspberry Pi detailed-orientated chat, especially if I mentioned a website called RPI
for industrial experts. include some historical connection to Locator (magpi.cc/rpilocator) that
Of course, these two things are the pre-digital era that he can more provides alerts for when stores have
rarely separate. My father-in-law, easily connect with. Raspberry Pi in stock. We’re happy to
Richard, is a practical sort that likes I suspect a few years younger and see it joined by Hardware Locator
to have all kinds of projects he’d have been into computing and (magpi.cc/hwlocator).
around the house. Sure, they may Raspberry Pi. As it stands, his hobby is It’s something of a relief to note
qrw#eh#doo#Ľqlvkhg#|hw/#exw#wkh|# steam trains. So much so, he rescued a that Raspberry Pi isn’t the only
are interesting. long-disused Belgian Cockerill Steam company with more customers than it
He’s built an incredible garage with Tram with a fellow rail enthusiast can supply. On the other hand, it’s
a dual-action sliding door, and (magpi.cc/cockerill), and brought it disheartening to hear of our readers’
renovated an old wooden canoe with over to the UK by sea and road on the struggle to pick up, for example, Coral
his daughter Rosie, who is insistent we back of a lorry for renovation. USB Accelerator kits to go with their
will eventually bring it down to our new Raspberry Pi computers.
terraced house in London. There’s no Practical people do I hope this situation picks up soon.
space; unless we put it on the roof! In the meantime, you can get a
He has a stone dragon gargoyle on practical things Raspberry Pi by signing up with RPI
his roof and a train layout, for which Locator for an alert. Or, of course, by
he built several landmark buildings It’s currently powering up and down subscribing to The MagPi magazine
from scratch. wkh#Plg0Vxļron#Oljkw#Udlozd|# (magpi.cc/subscribe).
In his younger days, he inspected teaching a younger generation about Zh#zloo#frqwlqxh#wr#pdnh#wkh#Ľqhvw#
and reported on nuclear power the steam age. We showed Richard a magazine for the best hobbyist
stations and MOD nuclear recent YouTube video of it in action on computer around. The hobbyists make
installations, a very important job Easter Weekend (magpi.cc/mslrYT). Raspberry Pi what it is. More than just
that required extreme focus to keep Practical people do practical things. a useful tool, but a loved computer.
his nation safe. These power stations Long may they tinker.
are handy, and I suspect we could use a Full steam ahead
few more of those at the moment. Somebody who is wholly into a hobby
Lucy Hattersley
AUTHOR
He is also one of the few people I watches the business side of things.
know who will listen to me when I Steam train fans are railway fans, and Lucy is back in “that there” London after a
start talking about NAND gates and the industrial and consumer network brief stint visiting family in the North. She’s
Z80 and ARM Assembly and Raspberry is something they know an awful lot torn between home and hearth.
Pi. He hasn’t the faintest idea what about. I chat chips; he chats coal. magpi.cc
"DPTUFŗFDUJWFTPMVUJPOGPSEBUBDFOUFST
*5EFQBSUNFOUTPSSFNPUFNBDIJOFT
1J,7.)"5
GPS%*:BOEDVTUPNQSPKFDUT 1SF"TTFNCMFEWFSTJPO
3FBMUJNFDMPDLXJUISFDIBSHFBCMFTVQFSDBQBDJUPS0-&%%JTQMBZ#PPUBCMFWJSUVBM$%30.
ŚBTIESJWF4FSJBMDPOTPMF0QFOTPVSDF"1*JOUFHSBUJPO0QFOTPVSDFTPGUXBSF
$YDLODEOHDWWKHPDLQ5DVSEHUU\3LUHVHOOHUV
3FTFMMFSTVHHFTUJPOTBOEJORVJSJFT
XIPMFTBMF!IJQJJP