You are on page 1of 102

BUY IN PRINT WORLDWIDE MAGPI.

CC/STORE

+UUWG &GEGODGT OCIRKEE 6JGQHƓEKCN4CURDGTT[2KOCIC\KPG

LD
O

I
0 L E G

U
TOP 1

B
E CT S
PROJ

KE &
M TH ZERO
A 2
W I
E R RY PI
RA SPB AS
RIST M
CH TS
E C
PROJ

LO C K
OV ERC RO 2
PI Z
W
E
R RY
BE
RASP magpi.cc/store

GET STARTED WITH THE BUILD HAT


WELCOME

WELCOME
to The MagPi 112

I
’m a big fan of inquisitive people. Especially when it
comes to messing around inside computers. After all, being
inquisitive about computers is a big part of the Raspberry
Pi experience.
I’ve just spent the last couple of days overclocking the Lucy

EDITOR
Raspberry Pi Zero 2 W computer (page 52). With a cooling case Hattersley
and a couple of lines of code; an intrepid editor can get it running Lucy is editor of
The MagPi and
from 1GHz to 1.4GHz. A pretty nifty upgrade. she’s using hot-
water bottles and a
Zero 2 W is an incredible new computer. We’ve scoured every cat to keep warm.
Not sure either
project from the last couple of years that involved Raspberry Pi ƵŅƚĬÚÆåĹåĀƋüųŅĵ
Zero. The result is 40 incredible projects in our Make & Build with Raspberry Pi Zero 2
W, but she’s open to
Zero 2 (page 34). suggestions.

magpi.cc
The last twelve months have been a wild ride on The MagPi
magazine. We’ve had Raspberry Pi 400, Raspberry Pi Pico, and
Udvsehuu|#Sl#]hur#5#Z1#Doo#lqfuhgleo|#glļhuhqw#dqg#lqwhuhvwlqj#
products that help us understand computers a little better.
GE
As we head into the end of the year, few members of the team RASPBT A
get excited about winter as PI ZER ERRY
O2W
much as Rob. His Raspberry Pi
PAGE
Christmas feature (page 63) is 32
packed with projects for the
festive season.
Merry Christmas and
stay inquisitive.

Lucy Hattersley Editor

magpi.cc 03
CONTENTS

Contents
> Issue 112 > December 2021

Cover Feature

34
34 Make & Build
with Zero 2

Regulars
92 Your Letters
97 Next Month
98 The Final Word

Project Showcases
08 Robot Arm Clock
12 Aston Martin DB5 Junior
16 Droiid
20 Honeycomb Wall Shelf 24
22 Pomelo
24 Automatic Dog Ball Launcher
26 Finn Feeder
28 Live CTA Railway Map

16

Droiid Automatic Dog Ball Launcher

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 ÏŅƴåųĜĹč ĵ±ĹƼ Ņü ƋĘå ƋŅŞĜÏŸ ĜĹ ‰Ęå a±č{Ĝ ĵ±č±DŽĜĹå ±ųå ÚĜüüåųåĹƋ ÆåƋƵååĹ ÏŅƚĹƋųĜåŸØ ±ĹÚ ±ųå ±ĬƵ±ƼŸ ŸƚÆģåÏƋ ƋŅ ÏʱĹčåţ ¥Ņƚ ±ųå ųåŸŞŅĹŸĜÆĬå üŅų ƚĹÚåųŸƋ±ĹÚĜĹč ƋĘå
ųåŧƚĜųåĵåĹƋŸĜĹƼŅƚų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.

magpi.cc 05
CONTENTS

Tutorials 48 56
44 Raspberry Pi Build HAT
48 Sensory world - part 2
52 Overclock Raspberry Pi Zero 2 W
56 Ultimate home server - part 5
60 Touch inputs on Raspberry Pi Pico
Sensory World - part 2 Ultimate home server - part 5

The Big Feature


74
63

Build Christmas Gifts


PicoSystem

Reviews
86
72 Midas display
74 PicoSystem
76 UPS HAT for Zero WH
78 3.7” e-Ink display for Pico
80 Top Ten LEGO® projects
83 Learn: Circuit design

Community
86 Dr Footleg interview
88 This Month in Raspberry Pi Dr Footleg interview

95
RASPBERRY PI ZERO 2 W AND
WIN FLIRC RASPBERRY PI
1 OF 10
ZERO CASE BUNDLES!
06 magpi.cc
Claim your exclusive discount code
 ¦DIY15 at pi-top.com/MagPi

The Ultimate
Holiday Gift Guide
Perfect for experienced Raspberry Pi users
or people just getting started! The pi-top
[4] DIY Edition has everything you need to
begin making, tinkering, and building super
cool projects.

From now until December 31st, our special


.'R2-.%'$2.!)10#×Ûç-o@

Just add Pi!

Build Your Own Build Your Own Computer


Maker Kit Maker Superset Computer Kit and Coding Superset

More than just a case, this Kit The perfect gift for someone No soldering, tools or tech The ultimate gift, and everything you
takes your Pi to the next level. looking to get started with Pi. knowledge needed! This kit need to become a project master.
gives you everything needed
With a 5 hour battery, speaker, This Kit includes the best Pi to build your own computer. Start with the perfect Raspberry
cooling system, and OLED screen case, and an electronics kit full Pi case, Touchscreen Display and
(to name just a few features), of sensors, LEDs, buttons and Use your computer to create Bluetooth Keyboard. Then add
the Maker Kit not only protects potentiometers! Use Further (our fun Pi projects and then simply sensors, lights, and LEDs galore
your Pi, it allows you to take your Online Project Library) and get power it down and take it ,"7-3a0#-o@&#-,*7*'+'2'1
projects with you - anywhere. started coding cool projects. with you! your imagination.

£133.02 / $127.33* £204.02 / $195.29* £341.61 / $327.00* £412.61 / $394.95*

*Raspberry Pi 4 not included. o#003,13,2'*Ù×@×Ø@ØÖØ×@1. #007''120"#+0)-$2&#1. #007' -3,"2'-,@ © CEED Ltd. 2021

Raspberry Pi made simple, robust and modular. pi-top.com/MagPi


PROJECT SHOWCASE

Robot
Arm Clock
A deliberately over-engineered timepiece
provided a satisfying distraction for a busy
software engineer, learns Rosie Hattersley

L
ike many of us, 33-year-old software engineer
Hendrik Ohrens likes to combine the technical
skills he uses for work with those he’s picked
up through his hobbies, to come up with something
creative. “I love working on projects that involve
electronics, mechanics, and software,” he says of his
enthusiasm for making things. With a background in
vflhqwlĽf#uhvhdufk#dqg#phfkdqlfdo#hqjlqhhulqj#dw#wkh#
Hendrik
MAKER

University of Hannover, plus a few Raspberry Pi builds


Ohrens under his belt, he decided it was time to challenge
klpvhoi#wr#ghvljq#klv#Ľuvw#urerw1#Kh#ghflghg#rq#d#urerw#
Full stack software
developer Hendrik arm, since it seemed relatively simple to design but
enjoys playing ģvwloo#kdv#vrph#ghjuhh#ri#ľh{lelolw|Ĥ1#Zkhq#Khqgulnġv#
lacrosse, and
h{lvwlqj#forfn#vwrsshg#zrunlqj/#wkh#lghd#ri#xvlqj#d#
making things in his
spare time. robot arm to move the dials to the correct position
immediately sprang to mind. View the robot arm clock An Arduino board
magpi.cc/
robotarminsta in action on Instagram: magpi.cc/robotarminsta. attached via a serial cable
communicates with servos
Monitoring every movement
Hendrik began by using inverse kinematics to
zrun#rxw#krz#wr#frqwuro#klv#urerw#dupġv#prwlrq#Ğ#d#
scenario that involves using formulae to determine
zkhuh#wkh#hqg#ri#wkh#dup#zloo#vzlqj#urxqg#wr#Ğ#exw#
vrrq#uhdolvhg#wklv#zdvqġw#wkh#ehvw#dssurdfk1#Lqvwhdg/#
he switched to Raspberry Pi 3B+, with the intention
ri#frqwlqxlqj#wr#h{soruh#lqyhuvh#nlqhpdwlfv#dqg#wkh#
ikpy library alongside AI and computer vision. In the
hqg/#kh#irxqg#wudlqlqj#wkh#urerw#wr#dgrsw#vshflĽf#
poses was the most useful approach for his needs.
“The position teaching feature allows me to move
the arm to a position (with my hands) and then save
that position for further use. This feature turned
out to be very useful for the tasks the robotic arm
shuiruphg#diwhu#wkdw/Ĥ#Khqguln#h{sodlqv1

08 magpi.cc Robot Arm Clock


PROJECT SHOWCASE

Quick FACTS
> Hendrik allows his
projects to take
shape organically

> He says the


charm of making
is to watch things
happen when
they happen
When the clock stopped working,
Hendrik decided to use the robot arm > But remember to
to move its hands to show the time double-check your
3D designs before
printing them!

> Hendrik’s previous


project was also a
robot arm

> He trained
it to chase a
rubber duck

Raspberry Pi 3B+ provides the processing power


needed to issue precise position instructions so
the robot’s arms mimic the hands on the clock

Robot Arm Clock magpi.cc 09


PROJECT SHOWCASE

Adding stick-on googly


eyes was an instant way
Hendrik has not only worked on other Raspberry Pi
of giving the robot arm
clock personality projects, but has accrued enough of them over the years
to possess a dedicated Pi Box to keep them all in
The robot arm moves the “Raspberry Pi is the perfect development tool for
clock’s minute hand to ph1#Lw#lv#srzhuixo/#yhuvdwloh/#dqg#rļhuv#doo#L#qhhg#wr#
update the current time
prototype my projects,” he says. Hendrik has not
only worked on other Raspberry Pi projects, but has
accrued enough of them over the years to possess a
ghglfdwhg#Sl#Er{#wr#nhhs#wkhp#doo#lq1#ģWkh#idfw#wkdw#
I can run modern full stack applications, as well as
talk directly to connected hardware, makes it my
Ľuvw#fkrlfh#zkhq#L#surwrw|sh#d#surmhfw1Ĥ#
He decided on an Arduino to talk to the servos
xvlqj#wkh#pdqxidfwxuhuġv#oleudu|/#dqg#Udvsehuu|#
Pi to handle all the logic, as well as controlling the
Arduino attached via a serial interface and a USB
fdeoh1#Iru#wklv#kh#zurwh#fxvwrp#frgh/#uhĽqhg#ryhu#
time (and still ongoing) to control the arm.

Sketching it out
Hendrik prefers to sketch out plans and adapt
them as needed, rather than starting with a rigid
design. For his robot arm, he started with some
servos and a basic CAD model that would be easy
to 3D-print and add small parts to. Once he was

10 magpi.cc Robot Arm Clock


PROJECT SHOWCASE

Arm yourself

Download and 3D-print the robot arm parts,


01 including a clamp for the table, if needed.
BåĹÚųĜĩƚŸåÚĀƴå%ƼűĵĜƻåĬ£XƐƐLjěaƖííě‰ŸåųƴŅŸØ
±ĬŅĹčƵĜƋʱĹeųÚƚĜĹŅÆŅ±ųÚ±ĹÚ±ŸŞÆåųųƼ{ĜƐť
üŅųĘĜŸƴåųŸĜŅĹţ

eƋƋ±ÏʱĹÚĜĹŸƋ±ĬĬ±%ƼűĵĜƻåĬ„ĘĜåĬÚ±ĹÚ
02 eųÚƚĜĹŅaUØƋĘåĹā±ŸĘÚƼűĵĜƻåĬƣ±ŞĜüųŅĵ
the code/arduinoüŅĬÚåųƋŅƼŅƚųeųÚƚĜĹŅţ¥Ņƚ±ĬŸŅ
ĹååÚƋŅŸåƋƚޱĹÚĜĹŸƋ±ĬĬ{ƼƋĘŅĹƐ±ĹÚĜĩŞƼĬĜÆŅĹ
ƼŅƚų±ŸŞÆåųųƼ{Ĝ±ĹÚ±ƋƋ±ÏʱŞŅƵåųŸƚŞŞĬƼţ

happy with the basic design, he simply duplicated Teaching the robot arm
which position to adopt
it to make additional movable parts and chained involved demonstrating
the servos using a cable. each pose

Wkh#urerwġv#dup#qhhghg#wr#eh#prxqwhg#wr#
prevent it toppling over, so Hendrik 3D-printed
fodpsv#khġg#irxqg#rq#Wklqjlyhuvh/#dqg#fodpshg#
the arm to the table. He then glued the broken
clock (whose dials the robot arm would move) to a
zrrghq#er{/#zklfk#kh#dovr#wkhq#joxhg#wr#wkh#wdeoh#
vr#lw#zrxogqġw#exgjh1#Diwhu#vrph#dgmxvwphqwv#wr#
wkh#dupġv#pryhphqw/#zklfk#vtxhdnhg#ehfdxvh#
ƚĜĬÚƋĘåųŅÆŅƋ±ųĵÆƼŞƚƋƋĜĹč±ŸåųƴŅĜĹ
it slightly overlapped in places, Hendrik began 03 the base; screw the base_element on to it,
the far lengthier process of training the robot
üŅĬĬŅƵåÚƤÆƼƋĘå±ųĵƣåĬåĵåĹƋŸţĬ±ĵŞƋĘåƱŸåƋŅ
which position to adopt when. Having created a table or something solid, otherwise the arm will
wkh#vrphzkdw#h{sdqghg#prwlrq0frqwuro#frgh/#kh# ü±ĬĬţƤ8ŅųÏŅĵŞĬåƋåŸåƋƚŞÚåƋ±ĜĬŸ±ĹÚÏŅÚåØŸåå×
says the robot arm could be used for any sort of github.com/devdrik/robo-arm.
Raspberry Pi project he likes.

Robot Arm Clock magpi.cc 11


PROJECT SHOWCASE

Aston Martin
DB5 Junior A faithful replica of the
Aston Martin DB5, and
ŅüƋĘåĀĬĵŞųŅŞŸ±ŸƵåĬĬ
To make an authentic James Bond-style Aston
Martin, the only choice was a Raspberry Pi.
Rob Zwetsloot casts a GoldenEye over it

O
ne of the most iconic cars in cinema
history, the Aston Martin DB5 remains
extremely cool to this day – even without
the many enhancements that Q installed into
James Bond’s vehicle. A real Aston Martin DB5 will
set you back an unimaginable amount of money,
and won’t even have changing number-plates as
standard. If you’re happy with something a little
Simon
MAKER

smaller, cheaper, and a bit more eco-friendly, The


Richardson
Little Car Company has a solution for you: the Aston
A senior electrical Martin DB5 Junior No Time To Die Edition – which
engineer at The uses some Raspberry Pi magic behind the scenes.
Little Car Company,
“As we needed to control two screens, Raspberry
who learnt Python
on Raspberry Pi. Pi 4 was a logical choice as it has dual HDMI
outputs,” Simon Richardson, Senior Electrical
thelittlecar.co
Engineer at The Little Car Company, tells us.

The smokescreen pours out


ŅüƋĘåŠÚåÏŅų±ƋĜƴåšƤåƻʱƚŸƋ

12 magpi.cc Aston Martin DB5 Junior


PROJECT SHOWCASE

Quick FACTS
> Raspberry Pi is
used to test other
cars at The Little
Car Company

> The DB5 Junior is


powered by four
1.8 kWh batteries

> ‰ĘååƻƋų±ÚųĜƴĜĹč
modes are:
cŅƴĜÏåØ)ƻŞåųƋØ
Competition,
Escape
‰ĘåĹƚĵÆåųěŞĬ±ƋåĜŸ±ÚĜčĜƋ±Ĭ
ŸÏųååĹƋʱƋ±ŸŞÆåųųƼ{ĜϱĹ > There’s an
ŸƵĜƋÏĘƋĘåĹƚĵÆåųŸŅĹ hour’s worth of
smokescreen in
the tank between
top-ups

> A real DB5 will set


you back about
£1 million

BĜÚÚåĹĵĜĹĜčƚĹŸĬƚųĩÆåĘĜĹÚƋĘå
Ęå±ÚĬĜčĘƋŸØųå±ÚƼƋŅÆå±ÏƋĜƴ±ƋåÚ

Aston Martin DB5 Junior magpi.cc 13


PROJECT SHOWCASE

If it weren’t so small, we’d The hidden control switches


swear it was the real thing ±ųå±ÏÏƚų±ƋåƋŅƋĘåĀĬĵŸ

Those two screens? The changeable, digital front


and rear number-plates of the DB5 Junior. Luckily,
it’s not a real car, so you get authentic licence plate
qxpehuv#iurp#wkh#Ľopv1#Udvsehuu|#Sl#dovr#frqwurov#
hidden mini guns behind the headlamps.

Raspberry Pi also controls


Testing the number-plate
screens in daylight to make
hidden mini guns behind
sure they work properly
the headlamps
Small but mighty
Even though it’s not a proper road car, it is still
quite a lot of car. With a 21.5 bhp electric motor,
it can reach top speeds of over 45 mph, and has
an array of driving modes for more advanced
control. There’s even a skid mode for if you want
to do some cool doughnuts or other theatrical
evasive manoeuvres.
As for extra gadgets, there’s a working
smokescreen that can be ejected from the exhaust,
and it’s all controlled by a hidden control panel.
“When the guns are activated, Raspberry Pi
activates relays that control the linear actuators
and monitors the limit switches so that the power
is cut when the actuator reaches the end of its
stroke,” Simon explains. “Raspberry Pi controls
the sequence of movement so that the guns cannot
pryh#xqohvv#lw#lv#frqĽuphg#wkdw#wkh#oljkwv#kdyh#
been lowered. The lights will not raise unless the

14 magpi.cc Aston Martin DB5 Junior


PROJECT SHOWCASE

Alternative number-plate 1

All systems go

When the car’s ignition is switched on, a 555


01 timer creates a pulse that triggers a Witty Pi
board to switch Raspberry Pi on. The program runs
automatically, with the cursor and splash screen
disabled so that the screens remain blank until the
default licence plate image is displayed.

The licence plate images are the same as


02 ƋĘŅŸåƚŸåÚŅĹƋĘåϱųĜĹƋĘåĀĬĵţ‰ĘåĜĵ±čåŸ
jxqv#duh#frqĽuphg#dv#kdylqj#uhwudfwhg1#Udvsehuu|# Alternative number-plate 2 are referenced in an array – when the switch is
Pi also plays the machine gun recording when the pressed, the screen changes to the next image in the
array. When it gets to the last image, it goes back to
jxqv#duh#ĠĽuhgġ/#dqg#dq#OHG#lq#wkh#jxq#oljkwv#xs1Ĥ
ƋĘåĀųŸƋĜĵ±čå±č±ĜĹƵĘåĹƋĘåŸƵĜƋÏĘĜŸŞų域åÚţ

Licence to thrill
It’s a fairly simple setup, requiring a Raspberry
Pi 4, an I/O extender, and some timer chips –
although Raspberry Pi can handle much more
than it’s used for.
“As a demonstration of the system’s
capabilities, I coded it to show the movie trailer
on the front screen when the licence plate button
was pressed and held,” Simon mentions. “This
included playing the audio too. It also played the
audio of a theme tune when another button was
pressed and held.”
The car has appeared on TV in the UK and in
When the gun is activated, the headlights are
the USA, and according to Simon, it’s the most 03 ųåƋų±ÏƋåÚرĹÚƵĘåĹƋʱƋĜŸÏŅĹĀųĵåÚØƋĘå
interest they’ve ever had for a product. relays will activate to present the guns, stopping at the
You can also get a regular version of the DB5 maximum swing. The same happens in reverse, with
Junior if you don’t fancy the extra gadgets, but ƋĘåčƚĹŸÏŅĹĀųĵåÚŸƋŅųåÚÆåüŅųåƋĘåĬĜčĘƋŸųåƋƚųĹţ
where’s the fun in that?

Aston Martin DB5 Junior magpi.cc 15


PROJECT SHOWCASE

Droiid –
A Package
Droiid is equipped with a mic and
speaker for its audio capabilities,
including text-to-speech

Delivery
Robot
Here’s an autonomous, efficient bot who’ll deliver goodies
to your doorstep. Nicola King waits for her order…

I
nspired by the likes of Amazon and Starship, two
companies that have both created six-wheeled
delivery robots (magpi.cc/amazonscout and
starship.xyz), UK-based Eben Kouao wondered if he
could possibly build a similar vehicle. As powerful
mini-computers become more accessible, Eben
started building his own version with a Raspberry Pi
and an Arduino, and the result of his labours is Droiid,
Eben Kouao
MAKER

a clever robot that can be controlled from anywhere in


Eben builds
the world.
DIY prototypes
based on new Direct Droiid
technologies. From
“Droiid came through the inspiration of recent
smart mirrors to
delivery robots, innovations going on within the delivery market,”
ƼŅƚϱĹĀĹÚĵŅųå Eben tells us. “As online consumer demand increases,
of his projects at to keep up with growing demand, the idea of Eben has also attached a Raspberry Pi Camera
smartbuilds.io.
autonomous drones delivering small packages to your Module, a speaker, and a mic module, and so
magpi.cc/ grruvwhs#lvqġw#wrr#idu#rļ#uhdolw|1Ĥ the robot’s view of the world can be streamed
ebenkouao
Furthermore, a Raspberry Pi 4 is central to how this on YouTube or Twitch. Droiid can be controlled
robot operates, as Eben explains: “The robot can be through the livestream chat. For instance, a user
seen as a Raspberry Pi connected to an Arduino attached can write a command (as a message) in the live
to motors. Raspberry Pi acts as the orchestrator behind chat to Droiid, e.g. ‘move? Right’. This command
controlling all components of the robot.” is then sent to a server, and Raspberry Pi receives
In terms of dimensions, Droiid is not huge (330 mm that message from the server. Raspberry Pi then
W × 380 mm H × 340 mm L), but it has a compartment sends the command to the Arduino, and Droiid
big enough to hold small parcels or food deliveries, receives the message and executes the function.
and it can be controlled remotely via a livestream chat In addition, as well as giving the robot a command
from anywhere in the world. to move, users can use TTS (text-to-speech). So,

16 magpi.cc Droiid – A Package Delivery Robot


PROJECT SHOWCASE

A Raspberry Pi Camera Module


enables Droiid to see and relay
the view to the web interface

Droiid runs on six stroller


wheels driven by 12 V high-
torque DC geared motors

Quick FACTS
> 3D-printing the
various parts at a
ĉLjŢĜĹĀĬĬƋŅŅĩ)ÆåĹ
Ņƴåų±Ƶååĩ

> In all, the project


ƋŅŅĩŸåƴåų±Ĭ
using the ‘say?’ command at the start, users could [as possible] from the 12 V geared DC motor to months to create
tell Droiid to say ‘Hello, today is Thursday.’ climb inclines with a payload.”
To aid stability over rougher terrain, such as > Eben is no stranger
The wheel deal grass, an accelerometer was added so the tilt level to project-building
Droiid was built using 3D-printed parts and, due can be monitored. An ultrasonic sensor gives with Raspberry Pi
to the size of the project, the printing had to be Droiid spatial awareness and the ability to detect
> ‰±ĩå±ĬŅŅĩ±Ƌ
broken down into smaller parts in order to be obstacles. Finally, a bottom-mounted WS812B
his Smart CCTV
accommodated on the 3D printer bed. LED strip lights the way for the robot in the dark.
Camera: magpi.cc/
Eben decided to equip Droiid with six wheels
eksmartcctv
pdlqo|#dv#d#wudgh0rļ#ehwzhhq#wkh#urerwġv#frvw#dqg# Exciting possibilities
its power. “An earlier model of Droiid used four The feedback that Eben has received from all > ...Or his Smart Mirror
wheels,” he shares. “However, using six wheels corners has been hugely positive, as there are AI: magpi.cc/
seemed to be the sweet spot to get as much power clearly exciting possibilities regarding how eksmartmirror

Droiid – A Package Delivery Robot magpi.cc 17


PROJECT SHOWCASE

Commands are sent to


the Droid Server, which
relays them as JSON
objects to Raspberry Pi
on board Droiid

The parts list for the project


includes a LiPo battery,
motors and drivers, and an
Arduino Mega

18 magpi.cc Droiid – A Package Delivery Robot


PROJECT SHOWCASE

Controlling Droiid
Using the livestream chat in YouTube or Twitch,
Droiid can be instructed to move or say something.

A user writes a robot command as a message


vxfk#d#urerw#fdq#eh#xvhg1#ģLwġv#ghĽqlwho|#d#  eĘĜčĘěĬåƴåĬÆĬŅÏĩ
diagram showing how
01 in the livestream chat. This is received by the
conversation starter,” he remarks. “From the all the elements of the Droiid Server, parsed as a JSON object, and sent to
ŞųŅģåÏƋƵŅųĩƋŅčåƋĘåų Raspberry Pi.
maker community, it’s also been awesome –
some others are curious how it works and what’s
next. I’m now working to take it out to deliver an
actual package!”

I’m now working to


take it out to deliver an
actual package!
This is just version 1 of Droiid and Eben If it’s a ‘say’ command, Raspberry Pi sends it to
02 a speaker; if it’s a ‘move’ command, it relays it
guarantees that a lot more “features and
to the Arduino that controls the robot’s motors.
intelligence” are on the way. Emboldened by the
success of the build so far, he is intent on making
a number of upgrades. These include improving
Droiid’s latency using Apache Kafka – an event
streaming platform – so that the time taken from a
message being sent to Droiid, to the robot actually
performing the action requested, is improved.
Eben has also created a couple of additional
robot models, including Droiid Mini, which is the
four-wheeled version, and is keen to explore the
concept of widening the cohort of people who can
actually control Droiid’s movements. “The idea Alternatively, Droiid can be controlled
of others controlling the robot over livestream
03 manually using the W, A, S, and D keys via a
to complete tasks [or at] sports events is remote web interface that includes the view from its
on-board camera.
something I’m interested in looking further into,”
Eben enthuses.

Droiid – A Package Delivery Robot magpi.cc 19


PROJECT SHOWCASE

Honeycomb
Wall Shelf
David Crookes discovers how Raspberry Pi can shine a whole
The shelf displaying a Doctor
new light on even the most everyday of household items Who and TARDIS model

H
aving recently married, Jason and Jessie vroxwlrqv#dqg#oleudulhv/#dqg#pdnh#xvh#ri#wkh#JSLRv#
Logan decided it was time to put their zlwkrxw#ohdylqj#wkh#ode/Ĥ#kh#h{sodlqv#ri#wkh#ehqhĽw#
vwdps#rq#wkhlu#Ľuvw#krph1 “We wanted of using this particular model early in the build.
something that would really be unique,” Jason “Then, when it’s all ironed out, you can drop the
says. “And some shelves for the living room to program on to a Raspberry Pi Zero or Raspberry Pi
display our adventures and interests seemed like Slfr#wr#jdlq#hĿflhqf|#dqg#vdyh#vrph#frlq1Ĥ
the right concept.” To get things up and running with a set of 12 V
Rather than opt for basic horizontal shelving, RGB light strips, they used pulse-width modulation,
Jason and
MAKER

however, the newlywed couple settled on which is a common way of controlling the dimming
Jessie Logan a hexagonal design. “Jessie set about with ri#UJE#OHGv1#Lw#phdqw#wkh#surmhfw#frxog#dgmxvw#krz#
construction paper making templates and much red, green, or blue is being displayed.
Jason and
Jessie seek new rearranging them on the wall until we were
experiences with vdwlvĽhg/Ĥ#Mdvrq#frqwlqxhv1#ģL#wkhq#zdqwhg#wkhp#
wanton abandon in
New Hampshire, and
to light up.” We plan to use touchpads
Lw#zdv#wklv#ghflvlrq#wkdw#wrrn#wkh#surmhfw#wr#wkh#
the universe at large.
next level, creating an eye-catching set of shining printed in Gallifreyan
shelves. Although the couple says 3D printing was
perhaps a bit ambitious, outputting the six pieces
for each individual shelf on their Crealty Ender 5 Time to improve
Pro 3D printer put the couple in control. “Printing “Since Raspberry Pi can only control a 3.3 V circuit
them allowed for all of the elements we needed, in this manner, we used three NPN transistors
while not overburdening the drywall.” dqg#wkuhh#LUI]77Q#PRVIHWv#wr#vwhs#lw#xs#wr#8#Y/#
and then to the 12 V that the light strip uses,” says
Pieces of six Mdvrq/#zkr#dggv#wkdw#ohduqlqj#wr#vl}h#wkh#PRVIHWv#
Each of the six pieces incorporates a channel that surshuo|#iru#wkh#mre#zdv#wkh#eljjhvw#fkdoohqjh1#ģLw#
allows the lights to shine and the idea was to glue taught us a lot about gating and output curves.”
each part together to form the hexagonal shapes. The result was worth the perseverance, however,
ģZh#dovr#fuhdwhg#vwdqgrļv/#vrph#ri#zklfk#zhuh# and now the couple want to go even further while
hollow to allow for chasing wires into the wall, and adding an extra-special, personal twist. They are
others that could be used with toggle anchors or both fans of Doctor Who and they want to tap into
wood screws in case of a pesky stud,” Jason says. the Gallifreyan language used by the Time Lords.
Since the couple wanted the lights to dim and “We plan to use touchpads printed in Gallifreyan
change colour, they decided to use a Raspberry coated in conductive ink as controls on the wall,”
Pi 4 computer to control the whole set of shelves. Mdvrq#uhyhdov1#ģZh#mxvw#qhhg#wr#lurq#rxw#vrph#
“You can program, debug, search the internet for sensitivity issues.”

20 magpi.cc Honeycomb Wall Shelf


PROJECT SHOWCASE

I±ŸŅĹűŸŞųŅčų±ĵüŅų±ŸŞÆåųųƼ{Ĝ
ÏƼÏĬåŸƋĘųŅƚčĘƋĘåÏŅĬŅƚųŸŅüƋĘå
ų±ĜĹÆŅƵåƴåųƼƐLjŸåÏŅĹÚŸŅųŸŅ

Quick FACTS
> The shelves took
82 days to print

> More time was


spent painting them

‰ĘåÚåŸĜčĹƵ±ŸĜĹāƚåĹÏåÚÆƼ > The design


ƋĘåŸĜDŽåƋĘåƼÏŅƚĬÚŞųĜĹƋƚŸĜĹč was created in
ƋĘåĜų)ĹÚåųĂ{ųŅƐ%ŞųĜĹƋåų Fusion 360
‰ĘåƵĜųåŸųƚĹ
ƋĘųŅƚčĘƋĘåƵ±ĬĬ
> Each shelf needed
±ĹÚŅƚƋŅü±ĘŅĬĬŅƵ
to be lightweight
±ĹÏĘŅųĜĹƋŅƋĘåŸĘåĬü

> The controller and


PSU are mounted
elsewhere

Although Raspberry Pi 4 was


used, Jason and Jesse intend The 3D-printed shelves are
to switch it out for a less not only lightweight, they
powerful Raspberry Pi model have a channel for the LEDs

Honeycomb Wall Shelf magpi.cc 21


PROJECT SHOWCASE

Pomelo
A robot dog aimed at education for younger kids learning code.
Rob Zwetsloot finds out just how good a doggo it is

R
obot pets have been around for a long
time. Raspberry Pi-powered ones, not so
much though. While there are currently no
Aibo-a-likes walking around people’s houses, that
lv#suredeo|#qrw#wrr#idu#rļ1#Srphor#lv#d#orrn#dw#zkdw#
pljkw#eh/#doehlw#zlwk#dq#hgxfdwlrqdo#ohdqlqj1
ģSrphor#lv#d#grj0vkdshg#hgxfdwlrqdo#wr|#urerw#
wkdw#lv#vxlwdeoh#iru#sulpdu|#vfkrro#fodvvurrpv/#zlwk#
Yoel Nasi wkh#jrdo#ri#surprwlqj#vwurqj#dojrulwkplf#vnloov#lq#
MAKER

younger students,” Yoel Nasi – part of the student


A high school
whdp#wkdw#pdgh#Srphor#Ğ#whoov#xv1#ģSrphor#fdq#
student whose
team share eh#surjudpphg#wr#pryh#lq#ghvluhg#sdwwhuqv#dqg#
Pomelo has been displayed at many conferences,
their passion for gluhfwlrqv#wkurxjk#sk|vlfdo#frgh#eorfnv1#Wkh# with a lot of interest shown
programming and eorfnv#duh#vlplodu#wr#wkh#uhjxodu#ĠDEFġ#eorfnv#
making in their
community. wkdw#fkloguhq#sod|#zlwk#lq#hohphqwdu|#vfkrrov# wkh|ġoo#whoo#Srphor#wr#gr/#dqg#wkh|ġuh#surfhvvhg#
dqg#frqwdlq#frppdqgv#vxfk#dv#pryh#iruzdug/# xvlqj#d#fdphud#dqg#TU0olnh#frghv#rq#wkh#eorfnv1
magpi.cc/
pomelogit wxuq#ohiw/#dqg#wxuq#uljkw1#Whdfkhuv#fdq#fuhdwh#dqg#
dvvljq#sx}}ohv#ru#pd}hv#wr#wkh#vwxghqwv#xvlqj#wkh# Robot peace
diruhphqwlrqhg#frgh#eorfnv1Ĥ ģZhġyh#ehhq#pdnlqj#surmhfwv#iru#txlwh#vrph#wlph/#
Usually when we talk about code blocks in reaching the point where we are able to organize
The MagPi, we’re referring to Scratch or other hyhqwv#vxfk#dv#rxu#dqqxdo#Klvdu#Frglqj#Vxpplw/Ĥ#
odqjxdjhv#wkdw#xvh#eorfnv#ri#frgh1#Srphor#xvhv# \rho#h{sodlqv1#ģ^Khuh`#vwxghqwv#rujdql}h#wkhlu#rzq#
olwhudo/#sk|vlfdo#wr|#eorfnv#iru#lwv#surjudpplqj1# zrunvkrsv#wr#whdfk#vnloov#vxfk#dv#surjudpplqj/#
Kids apparently love
playing with Pomelo Wkhvh#eorfnv#kdyh#d#olwwoh#ghvfulswlrq#ri#zkdw# hohfwurqlfv/#FDG/#hwfĩ#Zh#zhuh#dpd}hg#e|#wkh#
hqylurqphqw#dqg#frppxqlw|#diwhu#dwwhqglqj#wkh#Sl#
Zduv#frpshwlwlrq#lq#Fdpeulgjh#iru#wkh#sdvw#vhyhudo#
|hduv1#Wkxv/#wr#eulqj#wklv#fxowxuh#dqg#frppxqlw|#
wr#Wxunh|#dqg#hqfrxudjh#pruh#vwxghqwv#wr#sxuvxh#
VWHDP/#zh#frqwdfwhg#wkh#rujdql}huv#ri#Sl#Zduv/#
who gladly accepted our proposal and supported us
wkurxjkrxw#rxu#mrxuqh|#^wr#fuhdwh#Sl#Zduv#Wxunh|`1#
Qrz#lq#lwv#wklug#|hdu/#zh#kdyh#uhdfkhg#pruh#wkdq#
733#vwxghqwv#doo#ryhu#Wxunh|1Ĥ
Sl#Zduv#zdv#qrw#wkh#vwxghqwvġ#Ľuvw#irud|#lqwr#
Udvsehuu|#Sl#hlwkhu1
ģZh#xvhg#wkh#Udvsehuu|#Sl#lq#pdq|#surmhfwv#
lqfoxglqj#Srphor/#dv#lw#zdv#d#wrro#wkdw#rshqhg#xs#
pdq|#rssruwxqlwlhv#lq#hohfwurqlfv#dqg#sruwdeoh#
frpsxwlqj/Ĥ#\rho#whoov#xv1#ģZh#ohduqhg#derxw#wkh#
Udvsehuu|#Sl#lqlwldoo|#wkurxjk#rxu#whdfkhuv1#Wkh|#
vkrzhg#xv#wkh#pxowlwxgh#ri#surmhfwv#wkdw#fdq#eh#
grqh#zlwk#wkhp/#vr#zh#vwduwhg#wr#gudz#lqvsludwlrq#
iurp#pxowlsoh#vrxufhv#vxfk#dv#The MagPi/#dqg#pdgh#
pxowlsoh#surmhfwv#lqfoxglqj#Srphor1Ĥ

22 magpi.cc Pomelo
PROJECT SHOWCASE

When activated, Pomelo


shows a range of basic
expressions on its face

Quick FACTS
> The head can move
up and down
The 3D-printable
ĀĬ埱ųå±ƴ±ĜĬ±ÆĬå
> Pomelo is Spanish
for anyone to use
for grapefruit

> It teaches the logic


of code

> Sony’s Aibo has


been around for 22
Pomelo reads the blocks and years...
executes their commands
> ... and the fourth
gen came out in
2018

Children were comfortable


around Pomelo and enjoyed
the toy-like aspects
Not just for Christmas
Wkh#whdp#kdyh#ehhq#deoh#wr#whvw#rxw#Srphor#lq#wkh#
uhdo#zruog/#dqg#vr#idu#lwġv#jrqh#zhoo1
ģSrphor#kdv#prvwo|#uhfhlyhg#srvlwlyh#uhdfwlrqv#
iurp#doo#wkh#frqihuhqfhv#wkdw#zhġyh#ehhq#wr/Ĥ#\rho#
vd|v1#ģRevhuylqj#wkhlu#lqwhudfwlrq#zlwk#Srphor/#
zh#zhuh#deoh#wr#whoo#wkdw#fkloguhq#zhuh#frpiruwdeoh#
durxqg#Srphor#dqg#hqmr|hg#wkh#wr|0olnh#dvshfwv#wr#
lw/#olnh#wkh#hprwlrqv#lw#glvsod|hg#zlwk#lwv#h|hv#dqg#
wkh#jhqhudo#ghvljq#ri#lw1#Wkh|#zhuh#dovr#lqwuljxhg#e|#
wkh#delolw|#wr#frppdqg#wkurxjk#wkh#frgh#eorfnv#dqg#
wulhg#wr#pryh#lw#lq#glļhuhqw#zd|v#iru#wkh#urxwhv#wkh|#
fdph#xs#zlwk1#Wkh|#frooderudwhg#zlwk#hdfk#rwkhu#wr#
vroyh#fkdoohqjhv#olnh#pd}hv#e|#xvlqj#Srphor1Ĥ
Srphor#lv#fxuuhqwo|#dq#rshq0vrxufh#surmhfw/#vr#
|rx#fdq#dfwxdoo|#exlog#rqh#|rxuvhoi#uljkw#qrz$#Khdg#
wr#wkh#JlwKxe#uhsrvlwru|#wr#Ľqg#rxw#pruh=#
magpi.cc/pomelogit1## The electronics for Pomelo are fairly simple

Pomelo magpi.cc 23
PROJECT SHOWCASE

Automatic Dog
Ball Launcher
Are your games of fetch with your pooch leaving you panting?
David Crookes catches up with a Raspberry Pi Pico solution

D
ogs love to play fetch and it’s a wonderful just wanted to try something new,” he says. “I love
way to exercise your pooch. Trouble how simple it is to program.”
is, constant ball throwing isn’t half
exhausting for human arms, which is perhaps Print perfect
why there’s a growing number of automatic ball Before getting down to coding, however, he spent
launchers on the market. time experimenting. “I started with the motor
Rather than buy one of those, however, seasoned mount to test if that would launch the balls,” he
maker Brankly has created one of his own. “My dog explains. “After that, I designed the other parts
Brankly
MAKER

loves to play with blue toy balls and I wanted him and, in the end, the case. I played around with
to have a little more fun,” he tells us. “I also want glļhuhqw#vkdshv#dqg#irxqg#wkdw#d#vskhuh#ghvljq#
Brankly is an inventor
and entrepreneur. He him to be able to play fetch when we are busy by looked the best. It was also small enough for my 3D
grew up in Germany encouraging him to load the balls himself.” printer to print.”
and worked as an IT
While training his dog to do so is still ongoing, The case was designed in Fusion 360. “I like 3D
consultant for years
before following his work on the ball launcher is complete. It makes sulqwlqj#ehfdxvh#|rx#fdq#ghvljq#hyhu|wklqj#Ľuvw/#
passion for inventing use of a Raspberry Pi Pico microcontroller board send it to the printer, and have the part after
full-time. which is something of a departure for Brankly who some hours,” Brankly says. “Most of the time,
magpi.cc/dogball has previously used Arduinos for his projects. “I you have to change small parts, but it’s a pretty
vwudljkwiruzdug#surfhvv1Ĥ#Lqghhg/#kh#uhĽqhg#wkh#
project as he went along, such as the rollers that
accelerate the ball.
ģWkh#Ľuvw#yhuvlrq#kdg#d#surĽoh#sulqwhg#rq#wkhp/#
but the friction was not enough to grab the ball
when it was wet from my dog’s saliva,” Brankly
says. “I also had to change the mount for the
vhqvru#d#frxsoh#ri#wlphv#ehfdxvh#wkh#Ľuvw#wzr#
sensors I tried didn’t work.”

And fetch
So how does the launcher work? When a ball is
placed into its funnel, it is prevented from falling
into the launch channel by a piece of plastic that’s
controlled using an SG90 servo. The ball is then
detected by a sensor, prompting Raspberry Pi Pico to
get ready for launch.
“I used a motor controller to be able to randomise
Brankly says the
limitations of his 3D the speed of the motors with a pulse-width
printer meant the modulation (PWM) signal,” explains Brankly. “For
components had to
be cramped into the each cycle, Raspberry Pi Pico generates a random
case more than he’d
number between 40,000 and 65,000, and this gets
have liked
sent to the controller as a PWM value.

24 magpi.cc Automatic Dog Ball Launcher


PROJECT SHOWCASE

The ball is placed into


the funnel where a servo
blocks its path and a
sensor detects it

Quick FACTS

After one to three seconds, > It’s estimated to have


Raspberry Pi Pico instructs Two DC motors are cost $100 to $150
the servo to release the initiated by Raspberry
ball, which then shoots out Pi Pico and spin at a > Raspberry Pi
random speed Pico controls the
launch time

> It also varies the


motor speed
The motor controller can
I used a motor controller be seen to the left, with the
motors themselves in the > Make sure to use

to be able to randomise
centre of the image soft balls

the speed > {ųĜĹƋĀĬ埱ųå


on Thingiverse:
magpi.cc/
“This will vary the distance of the ball each time
dogballthingiverse
so it’s more fun for my dog. After the motors are
started, the ball releases and gets shot out. The
prwruv#wxuq#rļ/#wkh#vhuyr#eorfnv#wkh#hqwudqfh#
again and the machine is ready for the next ball.”
The approach adds an element of uncertainty
and means a dog won’t know exactly when the ball
is going to launch, or how far it’s going to travel.
“I’m really happy with the end result,” Brankly
says. “I think the design looks pretty cute and
my dog really loves it. He gets all excited when he
hears the machine starting up.”

Automatic Dog Ball Launcher magpi.cc 25


PROJECT SHOWCASE

By determining the servo


angle, it’s possible to
control the amount of food
that ends up in the tank

Finn Feeder
One maker and his son are making sure the fish they buy will never go hungry
with a project that’s going swimmingly well, as David Crookes discovers

W
hen Ryan M Haas’s son asked if he dvvhpeo|/#dqg#sduw0doljqphqw#iru#wkh#Ľwwlqj#ri#
frxog#kdyh#d#Ľvk#wdqn/#lw#txlfno|# wkh#vfuhzv/Ĥ#U|dq#vd|v1
ehfdph#fohdu#wkhuh#zrxog#eh#d#sureohp1 ģL#dovr#ghflghg#wr#xvh#Udvsehuu|#Sl#]hur#Z#
“We’re away from home a lot, so I knew there was ehfdxvh#lw#Ľwv#doo#ri#p|#ghvljq#uhtxluhphqwv1#
d#srvvlelolw|#wkh#Ľvk#zrxog#jr#orqj#shulrgv#zlwkrxw# L#qhhghg#d#zd|#wr#frqwuro#wkh#vhuyr#dqg#wkh#
ehlqj#ihg/Ĥ#U|dq#vd|v1#\hw#kh#glgqġw#zdqw#wr#ghq|# ľh{lelolw|#wr#dgmxvw#wkh#dprxqw#ri#irrg#glvshqvhg#
klv#vrqġv#uhtxhvw1 dv#zh#dgg#pruh#Ľvk#wr#wkh#wdqn1Ĥ
Lqvwhdg/#kh#fdph#xs#zlwk#d#ģĽq0wdvwlfĤ#vroxwlrq1# Dowkrxjk#U|dqġv#vrq#grhvqġw#|hw#kdyh#dq|#
Ryan M Haas ģL#kdg#vhhq#dxwrpdwlf#shw#ihhghuv#lq#wkh#shw# Ľvk/#lghqwli|lqj#wkh#rqhv#wkh|ġg#olnh#wr#nhhs#
vwruhv/#exw#L#nqhz#L#zrxog#eh#kdsslhu#zlwk#p|# sod|hg#d#elj#sduw#lq#wkh#ghvljq1#ģRqfh#zh#jhw#wkh#
MAKER

Ryan is an
electronics and rzq#ghvljq/Ĥ#kh#whoov#xv1#ģP|#vrq#lv#dovr#hqmr|lqj# dtxdulxp#vhw#xs#zlwk#wkh#fruuhfw#zdwhu#txdolw|#dqg#
software hobbyist klv#whfkqrorj|#hgxfdwlrq#fodvvhv#lq#kljk#vfkrro1#L# whpshudwxuh/#dqg#rqfh#zh#kdyh#hvwdeolvkhg#d#vrolg#
from Pennsylvania, wkrxjkw#wklv#surmhfw#zrxog#eh#vrphwklqj#ixq#iru#xv# ohyho#ri#khdowk|#edfwhuld/#zh#sodq#rq#sxufkdvlqj#
USA. He enjoys
time with his family,
wr#zrun#rq#wrjhwkhu1Ĥ d#ydulhw|#ri#gdqlrv/#zklfk#duh#d#ydulhw|#ri#vpdoo#
as well as home Zlwk#wkdw#lq#plqg/#wkh#sdlu#jrw#wr#zrun/#zlwk# wurslfdo#Ľvk/Ĥ#U|dq#uhyhdov1
improvement U|dq#vshqglqj#wzhoyh#krxuv#sodqqlqj#wkh#surmhfwġv#
projects.

magpi.cc/
S|wkrq#frgh/#dqg#zrunlqj#rxw#wkh#gdwdedvh#
vwuxfwxuh#kh#qhhghg#wr#wudfn#wkh#ihhgv1#Kh#xvhg#d#
Ryan’s project calls on the
EYXSƤWLJIIHIV
vlqjoh#VJ<3#vhuyr#dqg#6G0sulqwhg#sduwv/#sxwwlqj#
Udvsehuu|#Sl#]hur#Z#dw#lwv#khduw1
Python script two or three
times each day
Nothing fishy
ģWklv#surmhfw#uhsuhvhqwv#p|#Ľuvw#ghvljq#ri#p|# ģWkh|#uhtxluh#irrg#wzr#wr#wkuhh#wlphv#shu#gd|#
rzq#dqg#wkhuh#zdv#d#ohduqlqj#fxuyh#rq#krz#wr# dqg#wkh#dprxqw#ri#irrg#lv#ghshqghqw#rq#wkh#
ghvljq#sduwv#iru#wkh#ehvw#sulqwlqj#txdolw|/#hdvh#ri# qxpehu#ri#Ľvk#lq#wkh#dtxdulxp1#Lw#lv#uhfrpphqghg#

26 magpi.cc Finn Feeder


PROJECT SHOWCASE

Black and grey Prusament


{XeĀĬ±ĵåĹƋƵ±ŸƚŸåÚüŅų
all of the 3D-printed parts
including the food hopper

A single SG90 9G micro


servo usually used for
remote control cars opens
and closes the feed door

Raspberry Pi Zero W logs feed


times in a database. A camera
ƵĜĬĬÆåÏŅĹĹåÏƋåÚĬ±ƋåųüŅų± Quick FACTS
ĬĜƴåƵåÆϱĵüååÚ
> It took twelve hours
to design

> The Python script


is called three
wkdw#qr#pruh#irrg#eh#sodfhg#lq#wkh#wdqn#wkdq#zkdw# h{sodlqv1#ģE|#orjjlqj#ihhg#wlphv#lq#d#gdwdedvh#iru#
times daily
wkh#Ľvk#fdq#frqvxph#lq#wzr#plqxwhv#ru#ohvv1Ĥ wudfnlqj#sxusrvhv/#Udvsehuu|#Sl#]hur#Z#fdq#dovr#
vhqg#ph#dq#hpdlo#zkhq#wkh#krsshu#lv#qhdu0hpsw|1# > It can work out how
Feeding the fishes Wklv#lv#edvhg#rq#frxqwlqj#wkh#qxpehu#ri#wlphv#irrg# much food to give
Dv#vxfk/#wkh#gdwdedvh#vwruhv#wkh#ihhg#wlphv#dv# kdv#ehhq#glvshqvhg/#dqg#lw#ohwv#ph#nqrz#zkhq#wkh#
zhoo#dv#krz#orqj#wkh#ihhghuġv#grru#qhhgv#wr#rshq/# irrg#krsshu#qhhgv#wr#eh#uhĽoohg1Ĥ > The project cost
dqg#wkh#uhtxluhg#vhuyr#dqjoh1#E|#pdnlqj#xvh#ri# Lq#wkh#ixwxuh/#U|dq#zdqwv#wr#dgg#d#olplw#vzlwfk# $45 to make
vfkhgxohg#frppdqgv#+ru#furq#mrev,/#U|dqġv#surmhfw# wr#wkh#grru#phfkdqlvp#vr#wkh#vfulsw#fdq#ghwhfw#
fdoov#rq#wkh#S|wkrq#vfulsw#wzr#ru#wkuhh#wlphv#hdfk# ixoo#dqg#frpsohwh#grru#rshqlqj#dqg#forvlqj1#ģWklv# > Ryan is working on
gd|/#dffhvvlqj#wkh#gdwdedvh#iru#wkh#prvw#uhfhqw# zrxog#vhqg#ph#dq#hpdlo#li#wkhuh#duh#lvvxhv#ohdglqj# a web interface

ihhg#wlph1#Li#wklv#zdv#pruh#wkdq#vhyhq#krxuv# wr#hlwkhu#qr#irrg#ehlqj#glvshqvhg#ru#dq#hqwluh#
djr/#wkhq#d#fruuhfw#dprxqw#ri#irrg#lv#surpswo|# krsshuġv#zruwk#ri#irrg#ehlqj#gursshg#lqwr#wkh#
glvshqvhg#dqg#d#qhz#wlphvwdps#lv#zulwwhq1 dtxdulxp/Ĥ#kh#vd|v1#ģL#dovr#sodq#wr#dgg#d#olyh#ylghr#
ģDv#Ľvk#duh#dgghg/#wkh#grru#rshq#vl}h#dqg#rshq# vwuhdp#ri#wkh#dtxdulxp#vr#p|#vrq#fdq#zdwfk#klv#
gxudwlrq#ydoxhv#zloo#qhhg#wr#eh#dgmxvwhg/Ĥ#U|dq# kdss|#Ľvk#vzlpplqj#durxqg1Ĥ#

Finn Feeder magpi.cc 27


PROJECT SHOWCASE

Live CTA Each station on the map has an LED that


lights when a train is approaching it; the

Railway Map
live data is fetched using the CTA’s API

This live map of Chicago’s ‘L’ rail system lights up stations


where a train is approaching. Phil King climbs aboard

W
e’ve seen a few railway-themed Raspberry
Pi projects before, including mini
departure boards, but Jordan von Mulert
has gone one step further by creating a whole
railway map – of Chicago’s ‘L’ elevated railway –
lit up with LEDs to show the positions of trains at
stations in real-time.
Jordan von Jordan was inspired to make the map after moving
MAKER

Mulert away from the Chicago, where he’d lived for ten years
with his wife. “Since moving away from the city, we
Jordan is a violin have missed the days of being able to ride the train,”
luthier turned
mechanical he reveals. “Creating this live rail map gives a real
engineer. His passion vhqvh#ri#frqqhfwlrq#wr#wkh#hee#dqg#ľrz#ri#wkh#flw|1#
is learning and I like waking up early in the AM and seeing maybe
making things. When
only a dozen trains running in the city. But as the city
not with his wife
±ĹÚĩĜÚŸØƼŅƚűĬĬĀĹÚ comes alive, more and more trains light up my map.”
him in his workshop
or exploring in
ƋĘåƤƵŅŅÚŸţ
Light up the board
Mounted on a wooden board, the map features no
fewer than 191 LEDs – one for each station – wired
individually to pins on eight 24-channel PWM LED
driver boards controlled by a Raspberry Pi Zero W.
Raspberry Pi is at the heart of the operation, as
Jordan explains. “On startup it runs my Python script
which pulls data from the CTA API about every seven
seconds. I found that more often than that doesn’t approaching station, and also to know when a train
capture any useful changes, but less often than that has left service at the end of the run, otherwise the
and you tend to get lots of changes at once.” last LED in the run would be perpetually lit.
The CTA’s API gives him a complete status of
all the trains operating in the system. “When a Web of wiring
train approaches a station, the API includes an While Raspberry Pi is the brains of the operation,
Ġdssurdfklqj#vwdwlrqġ#ľdj#iru#wkdw#wudlq/Ĥ#vd|v#Mrugdq1# Jordan tells us the eight LED drivers are the brawn
ģP|#frgh#orrnv#iru#wkhvh#ľdjv#dqg#dfwlydwhv#wkh#OHG# of it, as they control each individual LED. “I
mapped to the corresponding station.” debated for a long time as to the best way to obtain
The script will also keep track of each train along independent control of the 191 LEDs needed for
lwv#uxq#vr#wkdw#lw#nqrzv#zkhq#wr#wxuq#rļ#wkh#OHG#iru# the map,” he recounts. “Addressable LEDs were
the last station and illuminate the LED for the new dq#rswlrq/#exw#Ľqglqj#6#pp#glvfuhwh#wkurxjk0kroh#

28 magpi.cc Live CTA Railway Map


PROJECT SHOWCASE

The map features a zoomed-in view Quick FACTS


of The Loop, a 1.79-mile long circuit
Each individual LED is wired separately which is one of the world’s busiest > The railway has 145
to one of eight driver boards stations, but some
controlled by a Raspberry Pi Zero W are on more than
one line

> 191 individual LEDs


were required for
the project
The rear view of the map reveals the incredible feat of
wiring each LED individually. The eight PWM driver boards > Using a custom
are controlled by a Raspberry Pi Zero W on the right PCB would
have been very
expensive

> The physical build


only took 12 hours…

> But Jordan


spent months
brainstorming ways
to ease assembly

Live CTA Railway Map magpi.cc 29


PROJECT SHOWCASE

eÏĬŅŸåěƚŞŅü±ŸŞÆåųųƼ{Ĝ¬åųŅƤœ
mounted on the rear of the
map, showing the wire-wrapped
connections to its GPIO pins

addressable LEDs that could be mounted without a


PCB proved to be a challenge. In the end I stumbled
across these drivers and determined that they
would be workable.”

As the city comes alive,


more and more trains light
up my map
With each LED needing to be connected to
one of the driver boards, the project required
a phenomenal amount of wiring. Rather than
soldering them all, Jordan opted to use wire
wrapping, which he says is a lot quicker. “It’s
so fast and easy with a tool… and they are super
secure! Apparently they used wire wrapping on the
Jordan used a special tool (left) to Saturn V [rocket] – not to suggest that my wraps
connect all the LEDs by wrapping
were as good as NASA, but in principle they can
wire around their legs (right) and
the pins on driver boards take a shocking amount of vibration. The other
ehqhĽw#wr#wkhp#lv#vhuylfhdelolw|1#L#fdq#xqgr#d#zluh#
And so it begins… wire-wrapping
connections to a couple of LEDs on wrap to swap an LED in less than the time it would
one of the eight PWM driver boards take my iron to heat up.”
– only 189 more to go!

In the loop
The zoomed-in view of ‘The Loop’ section of the
CTA railway caused a little extra complication, and
dovr#suhfoxghg#xvlqj#rļ0wkh0vkhoi#dgguhvvdeoh#
RGB LED string lights for the project. “Those have
5 mm LEDs which would have been too big for the
tight spacing required at each train stop,” notes
Mrugdq1#ģL#kdg#frqvlghuhg#xvh#glļhuhqw#OHGv#iru#
that section only, but I wanted the lighting to
be consistent.”
Jordan spent hours debugging code and mapping
each LED channel to the correct stop. “Electrically,
things went pretty smoothly,” he says. “I ended up
dgglqj#vrph#rswlrqdo#Ľowhu#fdsdflwruv#wr#wkh#erdugv#
to keep electrical switching noise down, and I’m
still hunting some gremlins in the SPI data lines.
But you know how it is: the reward is the journey,
not the end product.”

30 magpi.cc Live CTA Railway Map


PROJECT SHOWCASE

Making a map
Creating a railway map with holes for the LEDs to
light it up.

That’s a lot of wiring! 191 LEDs


are connected individually to
Jordan bought a translucent map of the CTA
eight PWM driver boards
01 rail system and traced the position of each
Testing a driver board with an station on a paper template placed over it.
eųÚƚĜĹŅţ‰ĘåĀĹĜŸĘåÚŞųŅģåÏƋ
has a Raspberry Pi Zero W
controlling everything

He then transferred the paper template to the


02 wooden mounting board and punched a hole
Standard through-hole LEDs ±Ƌå±ÏĘŸƋ±ƋĜŅĹüŅų±ƐĵĵX)%ƋŅĀƋĜĹƋŅţ
are used, connected to pins
on a driver board using wire
Ƶų±ŞŞĜĹčĜĹŸƋå±ÚŅüƤŸŅĬÚåųĜĹč

Instead of soldering, wire wrapping was used to


03 connect each individual LED to pins on one of
the eight PWM LED driver boards.

Live CTA Railway Map magpi.cc 31


SUBSCRIPTION

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

Rolling Monthly Subscription


Low monthly cost (from £5)
Cancel at any time
Free delivery to your door
Available worldwide

Subscribe for 12 Months


£55 (UK) £90 (USA)
£80 (EU) £90 (Rest of World)
Free Raspberry Pi Zero 2 W with 12 Month upfront
subscription only (no Raspberry Pi Zero 2 W with
Rolling Monthly Subscription)

Subscribe by phone: 01293 312193


Subscribe online: magpi.cc/subscribe
Email: magpi@subscriptionhelpline.co.uk
32 magpi.cc
SUBSCRIPTION

JOIN FOR 12 MONTHS AND GET A

FREE Raspberry Pi Zero 2 W


WITH YOUR FIRST
12-MONTH SUBSCRIPTION

Subscribe in print
WORTH

$15
today and get a
FREE computer!

A full Raspberry
Pi desktop
computer

Learn to code and


build your own
projects

Make your own


retro games
console, media
player, magic
mirror and much, This is a limited
offer. Not included
much more with renewals. Offer
subject to change or
withdrawal at any time.

Buy now: magpi.cc/subscribe

SUBSCRIBE
on app stores

magpi.cc 33
FEATURE

R E E !
F 2 W S
E R O RI B ER
Z C

D
BS

L
U
FOR S GE 32
S E E P A

& BUI
KE
M TH ZERO
A 2
W I O V ER 4 0 I NC
P
RE
R O
D
J E
I
C
B
T
LE
S .
DIS C 2 W S L E Y
Z ER O T T E R
RY P I I E H A
P B E R R O S
R A S B Y

B
oasting a quad-core processor running
dw#4JK}/dqg#zlwk#xs#wr#Ľyh#wlphv#wkh#
processing power of its predecessor, yet
zlwk#h{dfwo|#wkh#vdph#irrwsulqw/#Udvsehuu|#Sl#
]hur#5#Z#lv#d#juhdw#vlqjoh0erdug#frpsxwhu#wr#
exlog#surmhfwv#zlwk1 The tiny new computer was
given away – worldwide – as a free gift to all print
dqg#vxevfulswlrq#uhdghuv#ri#wklv#Ľqh#sxeolfdwlrq1#
And new subscribers can pick up a free Zero 2 W
with a 12-month subscription to The MagPi
(pdjsl1ff2vxevfuleh,1
The $15 wonder is a new and improved entry-
level Raspberry Pi model, making good on
Raspberry Pi’s continuing aim to get the power of
computing into the hands of just about everyone,
whdulqj#grzq#eduulhuv#ri#frvw#dqg#jhrjudsk|1#
]hur#5#Z#uhsuhvhqwv#d#vljqlĽfdqw#shuirupdqfh#
boost, should you be thinking of simply updating
dq#h{lvwlqj#Udvsehuu|#Sl#]hur#Z#surmhfw1#Iru#prvw#
people, however, the launch of this diminutive but
incredibly able single-board computer is an excuse
wr#ehjlq#d#zkroh#qhz#Udvsehuu|#Sl#surmhfw1#Khuh/#
then, are 40 suggestions of ways to make use of
|rxu#Udvsehuu|#Sl#]hur#5#Z1

34 magpi.cc Make & Build with Raspberry Pi Zero 2 W


FEATURE

ZERO 2 W Solder GPIO Pins


05
Get ready for breadboarding and circuit prototyping by
attaching a pin header to your Zero 2 W. For a detailed
guide to soldering see magpi.cc/zerosoldering.

PROJECTS
STARTER Prepare your
workspace
You’ll need a soldering iron
and either lead-based or
lead-free solder. Declutter
Warning!
Raspberry Pi PC Challenge
your workspace, open a
Hot solder!
01 window to provide ventilation,
and don protective gloves
Soldering irons get very
and goggles. Attach a 2×20- hot, and stay hot for a
Zlwk#d#4JK}#txdg0fruh#surfhvvru/#Udvsehuu|#Sl#]hur#5#Zġv#FSX#lv#hyhu|#
pin header (magpi.cc/ long time after they’re
elw#dv#srzhuixo#dv#d#Udvsehuu|#Sl#6#+doehlw#zlwk#845PE#UDP,1#Sdlu#|rxu# unplugged. Make sure
headers) to the holes on one that you put the iron in
Zero 2 W with a keyboard, mouse, and screen and it can be used as a side of Zero 2 W. You can the stand when you’re
fdsdeoh#krph#frpsxwhu1#Iru#d#frpsohwh#uxqgrzq#ri#krz#wr#xvh#|rxu#wlq|# use putty or insert Zero 2 W not using it and don’t
touch the metal parts –
new Raspberry Pi as a replacement for a much more power- and space- into a breadboard to hold it even after it’s unplugged.
kxqju|#ghvnwrs#frpsxwhu/#fkhfn#rxw#rxu#Udvsehuu|#Sl#6E.#SF#Fkdoohqjh#lq# in place. magpi.cc/soldering

The MagPi lvvxh#&8<1


magpi.cc/59 Step 1. Heat gently
With the soldering iron safely in its cradle, turn on
the power and wait for it to heat up. Tin the tip of the
soldering iron with a blob of solder. It’s important that

Start coding
the pin and the pad are both heated up, so press the
02 iron against both while you count to three.

One big reason many people buy a Raspberry Pi is to pick up some coding
skills. And Raspberry Pi OS is packed with programming languages, tools,
projects, and tips. Beginners should start with Scratch, a visual language
that teaches object-oriented skills. Open Scratch 3 and click on Tutorials
to start. For advanced projects, including Python, click Help > Projects.
magpi.cc/learnscratch
magpi.cc/learnpython
Step 2. Apply the solder
When you’ve reached three, still keeping the iron in

03 Discover electronics place, press the end of your length of solder gently
against both the pin and pad, but on the opposite side
to your iron tip.
Using Raspberry Pi and electronics together opens up a whole world
of educational and creative possibilities (as the project showcases we
feature every issue attest). Armed with a breadboard, jumper leads,
LEDs, buzzers, resistors, and switches, you’ll be well set for a journey
to becoming an inventor. Follow our electronics guide in issue #64.
magpi.cc/64

04 Get retro with RISC OS Step 3. Well-soldered pins


Pull the remaining solder away from the joint, then
afterwards remove the iron. You’re after a neat
D#srsxodu#surmhfw#lv#wr#+uh,glvfryhu#frpsxwhuv#ri#|hvwhugd|1#ULVF#RV# mound looking a little like a volcano.
was introduced with the Acorn Archimedes, which was designed for the
DUP#surfhvvruv#wkdw#srzhu#Udvsehuu|#Sl1#Pdq|#shrsoh#grqġw#nqrz#wkdw#
ULVF#RV#lv#vwloo#durxqg/#lq#wkh#irup#ri#ULVF#RV#Rshq1#Wklv#rshq0vrxufh#
operating system has a tiny footprint and retro feel, but with modern
ihdwxuhv#vxfk#dv#zhe#eurzvlqj#+|rx#zloo#qhhg#dq#Hwkhuqhw#dgdswru,1#Ilqg#
Ulvf#RV#lq#Udvsehuu|#Sl#Lpdjhu#xqghu#Rwkhu#Jhqhudo#Sxusrvh#RV1
magpi.cc/riscos

Make & Build with Raspberry Pi Zero 2 W magpi.cc 35


FEATURE

EASY ZERO 2 W Keybow


08
MINI 3-key
KITS & BUILDS This customisable three-key keypad is ideal
for use as a games controller, as play, stop,
dqg#sdxvh#exwwrqv/#ru#hyhq#wr#vwhhu#d#urerw1#
The keys have programmable RGB LEDs, and

QUICKLY BUILD A PROJECT BY they can also be programmed as shortcut


ru#pdfur#nh|v1
BUYING PARTS AND INSTRUCTIONS magpi.cc/keybowmini

06 Pirate Radio
Pimoroni makes some fantastic audio HATs and kits for Raspberry Pi, and
the Pirate Audio range add audio output and small screens to Raspberry Pi
]hur1#Wkh|#duh#lghdo#vwduwhu#nlwv#iru#h{sorulqj#hohfwurqlfv#dqg#frpsxwlqj#
zlwk#dq#dxglr#ehqw1#Xvh#Udvsehuu|#Sl#]hur#5#Z#wr#frqqhfw#wr#wkh#lqwhuqhw#
and tune into radio stations around the world.
magpi.cc/pirateaudio

09 CamJam EduKits
These £5 electronics kits in a tin are absolutely
fantastic! Developed by the folks at Cambridge
These £5 electronics kits are Raspberry Jam, they include breadboards,
jumper leads, resistors, lights, a buzzer, and
absolutely fantastic worksheets for coding with Python.
magpi.cc/edukit

07 M.A.R.S. Rover Robot


Building a robot is one of the most
10 AZ-Touch Pi Zero
satisfying Raspberry Pi projects. Making everyday aspects of your home smart
The M.A.R.S. Rover Robot gets gives you something to show for your coding
top marks for its resemblance hļruwv1#]lkdwhfġv#zdoo0prxqwdeoh#wrxfkvfuhhq#
to real Mars rovers, with six dashboard provides a means of keeping tabs on
wheels (four are steerable), all those IoT devices that are busy monitoring
terrain-conquering and metering your water, heating, and power
suspension, and a sensor to usage. HWHardsoft provides a GitHub page
alert it to obstacles so it can (pdjsl1ff2kzkdugvriwjlw), with examples
avoid them. such as a weather station and code lock.
magpi.cc/marsroverreview magpi.cc/aztouch

36 magpi.cc Make & Build with Raspberry Pi Zero 2 W


FEATURE

11 Naturebytes 16 Games Console


The world around us is fascinating, with the creatures we coexist
Step 1. RetroFlag GPi Case
dorqjvlgh#surylglqj#dv#pxfk#lqwhuhvw#dv#wkrvh#zh#ohduq#derxw#rq#WY1#
The RetroFlag GPi Case (magpi.cc/gpicase) for
Build your own Naturebytes weatherproof wildlife camera, install Raspberry Pi Zero has a total of eight buttons, plus
Raspberry Pi Zero 2 W, and mount it on a tree or post to covertly capture a digital pad and a 2.8-inch 320×240 colour screen.
zlogolihġv#vhfuhwv1 It’ll run for hours on three AA batteries, and is small
magpi.cc/naturebytes enough to carry in a generously sized coat pocket.

Step 2. Install RetroPie


12 OctoCam Use Raspberry Pi Imager (magpi.cc/imager)
for Windows, Linux, and macOS to download
and write RetroPie (RPI 1/ZERO) on a microSD
Keeping tabs on what’s happening in and card. For a more detailed guide to setting up the
around your home has never been so simple :{ĜƤ±ŸåØƤŸååThe MagPi magazine issue #100:
- or sweet! The 5MP OctoCam has suction magpi.cc/100.
pads so it can be mounted almost anywhere
and provides a wireless webcam stream and
peace of mind. Alternatively, it’s great for Step 3. Get some games
You’ll need some games to play on your handheld
time-lapse photography.
console. Fortunately, there are many homebrew
magpi.cc/octocam games, along with retro games that have been
made publicly available by the original creators.
See magpi.cc/legalroms for a guide to getting
games for your retro gaming console.
13 Unicorn HAT Mini
With 119 separate RGB LEDs the Unicorn
KDW#Plql#wxuqv#Udvsehuu|#Sl#]hur#5#Z#
into a portable lightshow. It’s surprisingly
versatile: create rainbow displays, scrolling
messages, image animations, busy lights,
and more. Four buttons enable you to add
interaction to your projects.
magpi.cc/unicornhatmini

14 Mood Light
Frglqj#vnloov#frph#wr#wkh#iruh#zlwk#wklv#Prrg#Oljkw#nlw#zklfk#fkdoohqjhv#
|rx#wr#fuhdwh#jrujhrxv#frorxu#frpelqdwlrqv#xvlqj#wkh#Xqlfruq#sKDW#dqg#
wkh#65#surjudppdeoh#QhrSl{ho#oljkwv1#Rqfh#vhw#xs/#lw#orrnv#idqwdvwlf#dv#d#
ehgurrp#oljkw/#ru#fdq#eh#xvhg#wr#vhw#wkh#prrg#gxulqj#d#sduw|1#
magpi.cc/moodlight 17Upgrade with
Zero 2 W: OctoPrint
15Pi-hole with OctoPrint is a controller for 3D printers, and

PoE USB Hub HAT OctoPi is a tremendously popular version of it


exlow#iru#Udvsehuu|#Sl1#Udvsehuu|#Sl#]hur#5#Z#
The PoE (Power over Ethernet) USB HAT adds three USB-A ports, RJ45 is a great upgrade for OctoPrint that provides
Hwkhuqhw#iru#urfn0vrolg#qhwzrunlqj/#dorqjvlgh#dq#;35144di#urxwhu1#Lwġv# the computing power that a 3D printer needs.
ideal for building self-powered networked projects. We think it’d be the If you’re new to the world of 3D printing and
perfect arrangement for setting up a Pi-hole (pdjsl1ff2slkroh), which making, check out our feature in The MagPi
will protect your network from unwanted adverts and tracking. magazine issue #97 (pdjsl1ff2<:).
magpi.cc/usbhubhat

Make & Build with Raspberry Pi Zero 2 W magpi.cc 37


FEATURE

ZERO 2 W LAMP
20
Web Server
Mythic Beasts uses Linux and multiple

TUTORIALS
PROJECT
Raspberry Pi 4 computers to host websites.
Using it for a Raspberry Pi-based WordPress
blog or site is really straightforward because
it has the Raspberry Pi OS already installed.
Xvlqj#ODPS#+Olqx{/#Dsdfkh/#P|VTO/#dqg#SKS2
Shuo2S|wkrq,#vhuyhu#vriwzduh/#|rxu#zhevlwh#zloo#
18Wearable Time- be all set to welcome the world.

Lapse Camera
magpi.cc/lamp

This step-by-step walkthrough doesn’t


just result in a camera you can use to 21Do Not
Disturb Sign
create a series of time-lapse images
– it’s a wearable device that you can
attach to glasses or wear around your
neck to automatically capture your If you’re still working or studying from home,
gd|1#\rx#fdq#hlwkhu#vwuhdp#wkhp#rqolqh# interruptions are probably frequent. Combat
zluhohvvo|#ru#fuhdwh#d#idqf|#JLI1# intrusions with a not-so-subtle sign showing
magpi.cc/timelapse you need some alone time. This DIY build
uses brightly coloured LEDs to show your
concentration status, and is a great way to put
coding skills to practical everyday use.
Capture how a plant grows magpi.cc/donotdisturb

over time

19 Time-Lapse Animations
Watching paint dry or grass grow are usually given as examples of
incredibly dull ways to waste time. Time-lapse animations give the lie
wr#wklv=#wudlq#|rxu#Udvsehuu|#Sl#]hur#5#Z#dqg#KT#Fdphud#wr#fdswxuh#krz#
a plant grows over time. Seeds growing, clouds moving, and sunrise to
sunset are all rewarding examples.
magpi.cc/timelapseanimations

Multi-Room
22
Audio System
Learn how to set up the powerful music
server Mopidy, and use Python code to play
tracks from the main streaming services to
hqmr|#dw#|rxu#ohlvxuh1#Wklv#wxwruldo#wkhq#vwhsv#
things up by making the whole shebang a
pxowl0urrp#h{shulhqfh1#
magpi.cc/multiroomaudio

38 magpi.cc Make & Build with Raspberry Pi Zero 2 W


FEATURE

23 Make a 3D Camera
\rxġoo#qhhg#wzr#Udvsehuu|#Sl#]hur#erdugv# 28Build a Low-
Cost Robot
dqg#wzr#Udvsehuu|#Sl#KT#Fdphudv#iru#
this zany tutorial, one for each eye.
Wkh#uhvxowlqj#4516PS#shu#h|hslhfh#
ylhzhu#fuhdwhv#6G#hļhfwv#e|#sodflqj# Step 1. Get the parts
the two cameras 5 cm apart to produce A plastic lunchbox, Raspberry Pi Zero W and an L298
overlapping images that simulate an controller plus some AA batteries form the basis of
lpsuhvvlyh#ghswk#ri#Ľhog1# your DIY robot. Our low-cost robot was built by Danny
„Ƌ±ŞĬå±ĹÚĀųŸƋ±ŞŞå±ųåÚĜĹThe MagPi magazine issue
magpi.cc/3dcamera
#87 (magpi.cc/87).

24 Get started with HQ Camera


Raspberry Pi has its own specially
ghvljqhg#fdphud1#Wkh#lqfuhgleoh#4516PS#
KT#Fdphud#dwwdfkhv#wr#d#FV0#ru#F0prxqw#
camera lens (the latter with a supplied
adapter ring) and via a ribbon cable to a
Raspberry Pi, which you’ll use to trigger
its rolling shutter. Timer delays and video
capture are also possible!
magpi.cc/getstartedhqcam 5VGR%JGEMVJGƓV
%ŅƚÆĬåěÏĘåÏĩŸĩåƋÏĘĵ屟ƚųåĵåĹƋŸţŽŸå±ĀĹå
marker pen to measure and make crosses as hole

Zero Key Ring


guides on the lunchbox. Then drill holes and push the
25 ±ƻåĬŸƋĘųŅƚčĘţ%ųĜĬĬĘŅĬåŸƋŅĀƋƼŅƚų±ŸŞÆåųųƼ{Ĝ¬åųŅ
and motor controller.

Vsrqwdqhrxv#Udvsehuu|#Sl#idqv#zloo#olnh#wkh#frqfhsw#ri#wklv#wdnh0dq|zkhuh#
option in which a Zero 2 W is kept safely inside a 3D-printed case attached
wr#|rxu#nh|#ire/#uhdg|#iru#xvh#zkhqhyhu#wkh#qhhg#dulvhv1#Vlqfh#wkh#Z#
ghqrwhv#zluhohvv/#|rx#pljkw#xvh#lw#pruh#riwhq#wkdq#|rx#h{shfw1#
magpi.cc/zerokeyring

26 NeoPixels
Udvsehuu|#Sl#]hur#5#Z#ohqgv#lwvhoi#wr#zhdudeoh#surmhfwv#+exlogv#wkdw#|rx#fdq#
carry about with you). Our friends over at HackSpace magazine wrote a
whole book on wearable projects, and it’s packed with ideas for things you
can make (pdjsl1ff2zhdudeohsurmhfwv). Lots of projects use NeoPixels as
Step 3. Glue and wire it up
Before gluing and wiring things up, place everything
sruwdeoh#oljkwv/#zklfk#duh#d#juhdw#Ľw#iru#Udvsehuu|#Sl#]hur1#Wdnh#d#orrn#dw# ĜĹŸĜÚåƋĘåĬƚĹÏĘÆŅƻϱŸåƋŅÏŅĹĀųĵĜƋƵĜĬĬĀƋ±ĹÚ
Adafruit’s NeoPixels page for help on getting started. that you have enough leads and jumpers. Follow the
magpi.cc/neopixelspi online guide to complete the setup (magpi.cc/robot).

27 Smart Doorbell
See who’s ringing your bell before deciding whether to answer it (and if a
polite smile is needed) with this smart doorbell and video intercom project.
Zkhq#vrphrqh#duulyhv#dw#|rxu#grru/#|rx#jhw#d#qrwlĽfdwlrq#dqg#vqds#ri#wkh#
caller on your smartphone, so you can choose whether or not to respond.
magpi.cc/smartdoorbell

Make & Build with Raspberry Pi Zero 2 W magpi.cc 39


FEATURE

ADVANCED RASPBERRY 32 RIoT Brick


PI ZERO 2 W MAKES
Smartphone apps and smartwatches can track
|rxu#Ľwqhvv#pryhv#dqg#f|foh#ulghv#wr#phdvxuh#
your performance, but ultra-runner Alan Peaty
lqvlvwhg#rq#d#Udvsehuu|#Sl#]hur#yhuvlrq#wkdw#
records the precise weather conditions of his
mountain runs, and shares his travails with
29 PolaPi Zero friends worldwide.
magpi.cc/riotbrick
Lqvwdqwo|#sulqwlqj#wkh#skrwrv#
you take allows you to share the
memories with those who were in
wkh#slfwxuh#zlwk#|rx1#Wklv#Udvsehuu|#
Pi Zero W build additionally lets you
send a copy of the shots you snap
to an online photo site, so you can
uhwulhyh#wkhp#zkhqhyhu#|rx#zlvk1#
magpi.cc/polapizero

30 Dride Zero Stargazing and


Dashcam footage is now commonplace, providing drivers and cyclists Raspberry Pi go hand
with eye-witness footage if there’s a prang or unexpected incident.
Dride sells ready-made dashcams, but there’s also a build-your-own in hand
rswlrq#li#|rx#suhihu#wr#sxw#|rxu#]hur#wr#jrrg#xvh1#
magpi.cc/dridezero

33 CamChess
Li#The Queen’s Gambit sparked an interest
in chess, this challenger setup may also
sltxh#|rxu#lqwhuhvw=#ghvljqhg#wr#plplf#
the experience of playing against a real
frpshwlwru/#FdpFkhvv#xvhv#wkh#VwrfnĽvk#
chess engine and records moves made on a
vwdqgdug#fkhvverdug1#
magpi.cc/camchess

DIY Hardware
31
Password Keeper
So many sites we visit these days require passwords and personal details,
that it’s tempting to use the same login for them all. A far safer option
is to use a dedicated password keeper to generate and store your logins.
Khuh/#Udvsehuu|#Sl#]hur#Z#dfwv#dv#d#vhsdudwh#SF#surylglqj#wkrvh#ghwdlov#
remotely, where keystrokes can’t be logged.
magpi.cc/passwordkeeper

40 magpi.cc Make & Build with Raspberry Pi Zero 2 W


FEATURE

34 RFID Grow Clock 35 Puitar


Toddlers who can’t yet tell the time can hardly be expected to know Electric guitars can produce some
whether it’s far too early to be up and about. (Hint: yes, kids. It is!) Grow h{wudruglqdu|#vrxqgv1#D#Udvsehuu|#Sl#]hur#Z#
Clock is a fun, visual way of signalling whether it’s time to greet everyone, gave this guitar some smart new tricks
or better to play in your room. frqwuroolqj#d#PLGL#nh|sdg#zlwk#d#pdwul{#ri#55#
magpi.cc/rfidgroclock frets and six strings. It now mimics a piano as
much as a guitar.
magpi.cc/puitar

36 Jazz Champion
D#uhsxusrvhg#Fkhvv#Fkdpslrq#iurp#
the 1970s becomes a musical play-
and-response game based on chord
progressions and the maker’s love of
md}}1#Lwġv#d#zrqghuixo#ghprqvwudwlrq#
of the sort of imaginative builds our
uhdghuv#fuhdwh#zlwk#Udvsehuu|#Sl#]hur#Z1
magpi.cc/jazzchampion

37 Stick PC
USB pen drives are endlessly useful, not least as a carry-with-you backup
ri#Ľohv#|rx#qhhg1#Rqh#Udvsehuu|#Sl#idq#vhw#derxw#wkh#wdvn#ri#dsso|lqj#wkh#
vdph#lghd#wr#klv#Udvsehuu|#Sl#]hur#Z/#wxuqlqj#lw#lqwr#d#XVE#vwlfn#frpsxwhu1#
Jhqlxv$#Slprurql#qrz#vhoo#d#]hur#Grqjoh#+pdjsl1ff2}hurgrqjoh) if you
want a more recent, solder-free solution.
magpi.cc/stickpc

38 Telescope 39 BOSEBerry Pi
Stargazing and Raspberry Pi go hand in hand, Lqwhuqhw#udglrv#riwhq#wdnh#d#edfn#vhdw#wr#
zkhwkhu#xvlqj#dq#KT#Fdphud#ru/#dv#lq#wklv# smart speakers, but these tend to serve up
project, using the free KStars app and a Pi d#qduurz#fkrlfh#ri#vhuylfhv#dqg#vwdwlrqv1#
]hur#Z#wr#hqdeoh#vn|0wudfnlqj#wr#eh#frqwuroohg# Wkh#ERVHEhuu|#Sl#sdluv#dq#rog#lSrg#vshdnhu#
remotely. Follow this build to give an entry-level dock with a Raspberry Pi Zero W to provide
telescope a serious upgrade for a tiny outlay. zluhohvv#frqqhfwlylw|1#Wkh#uhvxowlqj#ghylfh#
magpi.cc/telescope is in daily use and sounds great!
magpi.cc/boseberrypi

40 iPod Classic
If you’re lucky enough to be able to
lay your hands on an old iPod Classic,
xsf|foh#lw#lqwr#d#Udvsehuu|#Sl#]hur#5#Z#
streaming device complete with Spotify
playlists. Streaming your music is
eminently achievable.
magpi.cc/ipodclassic

Make & Build with Raspberry Pi Zero 2 W magpi.cc 41


200 PAGES OF RASPBERRY PI
QuickStart guide to setting up The very best projects built by
your Raspberry Pi computer your Raspberry Pi community

Updated with Raspberry Pi Pico Discover incredible kit and


and all the latest kit tutorials for your projects

Buy online: magpi.cc/store


TUTORIAL

Get started with the


Raspberry Pi Build HAT
Welcome to the world of LEGO® and Raspberry Pi. Discover how the
new Build HAT enables you to build and control brick-based projects

L
Set up Raspberry Pi
ast month we introduced the new
Raspberry Pi Build HAT. This new hardware
01 Start with a fresh installation of
enables you to quickly prototype and build Raspberry Pi OS using Imager (magpi.cc/imager).
Lucy
MAKER

interesting projects with LEGO bricks. The We’re using the latest Bullseye version of the OS
Hattersley sensors and motors in the SPIKE™ portfolio work (magpi.cc/bullseye). While it’s copying the
fantastically well with Raspberry Pi. software to your microSD card, set up the Build
Lucy is editor of The
MagPi and is taking Sitting between the LEGO components and HAT. Attach the 9 mm spaces to the bottom of
a much needed Raspberry Pi is the all new Build HAT. This has the board using four screws. Unlike other HATs,
break from DIY with four connectors used to attach sensors and the chips and components are on the bottom
actual bricks.
motors, bringing your builds to life and enabling of the board (so there is space for more HATs
magpi/cc sensing input and movement. and LEGO components). The spacers protrude
We’re going to be covering LEGO builds in the from the same side as the Build HAT chips and
following editions of The MagPi, and this month components. Connect the Build HAT to the GPIO
we’re going to show you how to get started with pins on Raspberry Pi using the other four screws.
Build HAT and perform basic motor control, sense
position from motors, attach a button, and use a
sensor to detect colour.
Power up and set up
02 Power up your Raspberry Pi using either
the Build HAT Power Supply or a regular Raspberry
You’ll Need Pi power connection. For the setup process, you
should attach a keyboard, mouse, and connect to a
> Raspberry Pi display (you can connect remotely via SSH or VNC
magpi.cc/products once set up). Boot into Raspberry Pi OS and follow
> Raspberry Pi the setup instructions, connecting to your network
Build HAT and providing a custom password.
magpi.cc/buildhat
> Raspberry Pi Build
HAT Power Supply
magpi.cc/ Configuration
buildhatpower 03 When you have completed the Raspberry
> The LEGO Pi OS setup process, and rebooted, open the
Education SPIKE Udvsehuu|#Sl#FrqĽjxudwlrq#Wrro#+Phqx#A#
Prime Set 45678
Suhihuhqfhv#A#Udvsehuu|#Sl#FrqĽjxudwlrq,1#Folfn#
magpi.cc/
 ‰
 ĘĜŸŸŞåÏĜ±ĬĬƼÚåŸĜčĹåÚX):ka±ĩåų{Ĭ±ƋåƕĜŸƋĘåĀųŸƋ
spikeprime the Interfaces tab, and set Serial Port to Enabled
LEGO element designed to connect to something that isn’t
another piece of LEGO. A little bit of history in the making and Serial Console to Disabled.

44 magpi.cc Get started with the Raspberry Pi Build HAT


TUTORIAL

The four grey connectors A DC 5521 centre positive barrel


are used to attach LEGO connector (5.5 mm × 2.1 mm ×
Technic™ motors and sensors 11 mm) will power the Build HAT
from the SPIKE portfolio and an attached Raspberry Pi

Install Build HAT software


04 DOWNLOAD
The Build HAT Python library will enable
you to control the Build HAT (and connected LEGO
motor.py THE FULL CODE:
components) with code. Open a Terminal window
and type: > Language: Python magpi.cc/github

pip3 install buildhat 001. from buildhat import Motor


002. motor_a = Motor('A')
For more information on the Build HAT library, 003. motor_a.run_for_seconds(5)
take a look at magpi.cc/buildhatlibrary.

The spacers protrude from


Connecting a motor the same side as the Build HAT
05 Now that the Build HAT is set up and
connected to Raspberry Pi, we can begin to
experiment with motors and sensors.
chips and components
Connect a motor to Port A on the Build HAT. The
connector needs to be inserted the correct way up.
If the connector doesn’t slide in easily, rotate it by
180 degrees and try again.
position.py
Vwduw#wkh#Wkrqq|#LGH#+Phqx#A#Surjudpplqj#
A#Wkrqq|#LGH,#dqg#hqwhu#wkh#surjudp#frgh#iurp# > Language: Python
motor.py listing.
Click Run. You will be prompted to save the 001. from buildhat import Motor
Ľoh>#fdoo#lw#Ġprwru1s|ġ1#Dv#wklv#lv#wkh#Ľuvw#wlph#|rx# 002.
are running a Build HAT program, there will be 003. motor_a=Motor('A')
d#ihz#vhfrqgv#sdxvh#zkloh#wkh#Ľupzduh#frslhv# 004.
across to the board. When complete, the red LED 005. while True:
rq#wkh#erdug#zloo#wxuq#rļ/#wkh#juhhq#OHG#zloo# 006. print("Position: ", motor_a.get_aposition())
dsshdu/#dqg#wkh#prwru#zloo#wxuq#iru#Ľyh#vhfrqgv1#

Get started with the Raspberry Pi Build HAT magpi.cc 45


TUTORIAL

Congratulations, you have a working Build HAT.


The next time you run your code, it will not pause
for so long.

Spin it around
06 Change line 3 of the motor.py program and
add speed=50 as an argument.

motor_a.run_for_seconds(5, speed=50)

Click Run and the motor will run faster. Now


change the argument to -50:

motor_a.run_for_seconds(5, speed=-50)
The Build HAT Power Supply provides 8 V DC, 6 A output to power both
Raspberry Pi and the Build HAT, along with connected motors and sensors
Click Run again and it will run in reverse.
Credit: Chris Richardson

force_sensor.py Get position


07 LEGO SPIKE Prime motors have a position
> Language: Python sensor included to enable precise position. The
motors can be used in reverse, as position dials.
001. from signal import pause Click New and enter the code from position.py.
002. from buildhat import Motor, ForceSensor Click Run and twist the motor around and you will
003. see the position value in Thonny’s Shell change
004. motor = Motor('A') from 179 to -180.
005. button = ForceSensor('D', threshold_force=1)
006.
007. print("Waiting for button to be pressed fully and
Attach a button
008.
released")
08 Let’s try a button, or Force Sensor™
009. button.wait_until_pressed(100) as it’s known in Brick HAT parlance. With the
010. button.wait_until_released(0) motor still connected to Port A, connect the
011. Force Sensor to Port D. Click New, and enter the
012. motor.run_for_rotations(1) force_sensor.py code.
013.
014. print("Wait for button to be pressed")
015.
016. button.wait_until_pressed()
017. motor.run_for_rotations(2)
018.
019. def handle_pressed(force):
020. print("pressed", force)
021.
022. def handle_released(force):
023. print("released", force)
024.
025. button.when_pressed = handle_pressed
026. button.when_released = handle_released The Build HAT is unique in that the components are placed
027. pause() ƚĹÚåųĹå±ƋĘƋĘåÆŅ±ųÚØåűÆĬĜĹčX):kƋŅĀƋŸ±üåĬƼŅĹ
the top. Look closely to spot Raspberry Pi’s RP2040 chip
introduced with Raspberry Pi Pico

46 magpi.cc Get started with the Raspberry Pi Build HAT


TUTORIAL

Credit: Chris Richardson


color_sensor.py
> Language: Python

001. from buildhat import ColorSensor


002.
003. color = ColorSensor('C')
004.
005. print("HSV", color.get_color_hsv())
006. print("RGBI", color.get_color_rgbi())
007. print("Ambient", color.get_ambient_light())
008. print("Reflected", color.get_reflected_light())
009. print("Color", color.get_color())
010.
The LEGO Technic motors are very powerful, and you’ll
need an external 8 V power supply (such as the Build HAT 011. print("Waiting for color black")
Power Supply) to drive them 012. color.wait_until_color("black")
013. print("Found color black")
Run the code and you’ll see: “Wait for button to 014.
be pressed fully and released”. Press the button 015. print("Waiting for color white")
fully down, and let go. The motor will spin around. 016. color.wait_until_color("white")
The Shell will display “Wait for button to be 017. print("Found color white")
suhvvhgĤ1#Suhvv#wkh#exwwrq#lq#jhqwo|#dqg#ohw#jr>#|rx# 018.
will see a “pressed” value appear. Press and release 019. while True:
the button to varying strengths to test it out. 020. c = color.wait_for_new_color()
021. print("Found new color", c)

Sensing colour Raspberry Pi


09 The Color Sensor™ can sort between eight
ŅĹĀčƚų±ƋĜŅĹ
settings for
Build HAT
glļhuhqw#frorxuv#dqg#fdq#phdvxuh#uhľhfwhg#dqg#
ambient or natural light.
Attach the Color Sensor to Port C on the
Exlog#KDW1#Fuhdwh#d#qhz#Ľoh#dqg#hqwhu#wkh#frgh#
from color_sensor.py.
Point the sensor at the green of the Build HAT
board and click Run. It should display the HSV, RGBI
and other colour values. The code will prompt for

Top Tip wkh#frorxu#eodfn>#pryh#wkh#vhqvru#wr#d#eodfn#remhfw#

Bookmarks (LEGO bricks work well). Then do the same again for Top Tip
a white object. Then the code displays the colour of
Here are some webpages for you to bookmark as the objects you point the Color Sensor towards. Notification
you begin your LEGO journey:
œĘåĹƼŅƚĀųŸƋ
Build HAT documentation attach Build HAT
magpi.cc/buildhatdoc to Raspberry Pi OS
Test out other sensors
Build HAT product brief
10 This is just the start of what you can achieve
Bullseye, you may
čåƋ±ĹŅƋĜĀϱƋĜŅĹ
magpi.cc/buildhatproductbrief with the Build HAT. Over the next few issues we alert that the HAT
will look at some incredible projects and builds isn’t supported.
Build HAT Power Supply product brief that you can make with LEGO and Raspberry Pi. These will vanish
magpi.cc/powersupplyproductbrief ƵĘåĹƋĘåĀųĵƵ±ųå
In the meantime, read the documentation for the
is uploaded to
Build HAT Python library to discover more code to
Build HAT Library Build HAT (during
magpi.cc/buildhatlibrary
test out the components found in the LEGO SPIKE Step 5).
Prime education kit (magpi.cc/buildhatlibrary).

Get started with the Raspberry Pi Build HAT magpi.cc 47


TUTORIAL

Explore the
Part 02

sensory world:
Make an intruder alarm
Catch intruders red-handed with this sound- and laser-triggered alarm

I
n this series, we are exploring some of the Iru#wklv#wxwruldo/#zhġuh#xvlqj#wkh#odvhu#vhqvru#
most commonly available sensors and their iurp#wkh#Zdyhvkduh#Vhqvruv#Sdfn/#dydlodeoh#lq#wkh#
use cases.#Iroorzlqj#odvw#prqwkġv#Ľuh#dqg#jdv# XN#iurp#Wkh#Sl#Kxw#+magpi.cc/wavesensors,/#dqg#
vdihw|#dodup/#wklv#wlph#zhġoo#xvh#vhqvruv#wr#exlog#d# dovr#vrog#vhsdudwho|/#exw#dq|#vlplodu#vhqvru#vkrxog#
Phil King glļhuhqw#nlqg#ri#dodup=#rqh#wr#ghwhfw#lqwuxghuv1 zrun#lq#d#vlplodu#zd|1
MAKER

Zkloh#wkhuh#duh#pdq|#srvvleoh#zd|v#wr#vhqvh# Lw#frqwlqxdoo|#hplwv#d#odvhu#ehdp/#dqg#lwv#uhfhlyhu#
Long-time wkh#suhvhqfh#ri#d#shuvrq#qhdue|/#lqfoxglqj#d#SLU# rqo|#ghwhfwv#d#uhľhfwhg#ehdp#ri#wkh#h{dfw#vdph#
contributor to The
prwlrq#vhqvru#ru#fdphud/#zhġoo#eh#xvlqj#d#odvhu# zdyhohqjwk#+983#qp,/#vr#lw#zrqġw#eh#wuljjhuhg#e|#
MagPi, Phil is a
freelance writer and ehdp#dqg#vrxqg#vhqvru1#Zkhq#hlwkhu#lv#wuljjhuhg/# rwkhu#ylvleoh#oljkw1#Zkhq#lw#ghwhfwv#wkh#ehdp/#lwv#
editor with a focus d#ylvxdo#dqg#dxgleoh#dohuw#zloo#jr#rļ1 gljlwdo#slq#rxwsxwv#4>#zkhq#wkh#ehdp#lv#eurnhq/#lwġv#31
on technology. Zlwk#wkh#srzhu#wxuqhg#rļ/#frqqhfw#wkh#
@philkingeditor odvhu#vhqvru#wr#Udvsehuu|#Sl#dv#lq#Figure 11#
Zhġuh#srzhulqj#lw#iurp#Udvsehuu|#Slġv#6Y6#
Connect laser sensor
Figure 1 The wiring
01 Wklqn#ri#doo#wkrvh#prylhv#zkhuh#d#vhfuhw#
slq/#jurxqglqj#lw#zlwk#d#JQG#slq#+erwk#yld#wkh#
euhdgerdug#vlgh#udlov,/#dqg#wkh#gljlwdo#rxwsxw#
diagram for the
complete alarm
djhqw#ru#wklhi#kdv#wr#jhw#sdvw#vrph#odvhuv#jxduglqj# +pdunhg#GRXW#rq#wkh#vhqvru,#lv#jrlqj#wr#JSLR#541
system, including laser dq#remhfw=#euhdn#wkh#ehdp#dqg#wkh#dodup#zloo#jr#
and sound sensors,
LED, and buzzer rļ1#Wkdwġv#zkdw#zhġoo#eh#grlqj#khuh1

Laser positioning
02 Zlwk#wkh#odvhu#vhqvru#zluhg#xs/#wxuq#rq#
Udvsehuu|#Sl1#\rx#vkrxog#vhh#wkh#vhqvruġv#uhg#
srzhu#OHG#+rq#wkh#uljkw,#oljkw#xs#li#lwġv#frqqhfwhg#
fruuhfwo|1#Lw#vkrxog#dovr#eh#hplwwlqj#d#odvhu#ehdp#
iurp#wkh#phwdo#wxeh/#vr#eh#fduhixo#qhyhu#wr#orrn#
vwudljkw#lqwr#lw1
Dlp#wkh#ehdp#dw#d#qhdue|#zdoo#+xs#wr#418#p#dzd|,#
dqg#fkhfn#wkdw#lwv#ohiw#OHG#+pdunhg#GDW,#lv#olw/#
frqĽuplqj#wkdw#lw#lv#ghwhfwlqj#wkh#odvhu#ehdp1#\rx#
pd|#qhhg#wr#dgmxvw#wkh#yhuwlfdo#dqg#krul}rqwdo#wlow#
ri#wkh#vhqvru/#ru#pryh#lw#forvhu#wr#wkh#zdoo1Iru#wkh#
Ľqlvkhg#dodup/#zh#uhfrpphqg#|rx#sodfh#wkh#odvhu#
vhqvru#idluo|#qhdu#wkh#ľrru#vr#wkdw#dq|rqh#zdonlqj#
wkurxjk#lw#zloo#euhdn#wkh#ehdp#dqg#lw#zrqġw#eh#
dq|zkhuh#qhdu#wkhlu#h|hv1

48 magpi.cc Explore the sensory world: Make an intruder alarm


TUTORIAL

DOWNLOAD
THE FULL CODE:
magpi.cc/github

The laser sensor emits and


detects a laser beam, so
The sound sensor triggers when the
knows when it’s been broken
noise exceeds its threshold, adjustable
with the lower potentiometer screw

Laser test
03 Wr#ehjlq/#zhġoo#fuhdwh#d#vlpsoh#S|wkrq#
wkh#vhqvru1#Hyhq#li#wkh#GDW#OHG#rqo|#ľlfnhuv#rļ#
prphqwdulo|/#wkdw#vkrxog#eh#hqrxjk#wr#wuljjhu#rxu# You’ll Need
surjudp/#dv#lq#wkh#laser_test.py#olvwlqj/#wr#uhdg#wkh# dodup#odwhu1
> Laser sensor
vhqvruġv#gljlwdo#rxwsxw#dqg#sulqw#rxw#d#phvvdjh#wr# magpi.cc/
vkrz#zkhq#wkh#ehdp#lv#eurnhq1#Iurp#wkh#ghvnwrs# lasersensor
phqx/#jr#wr#Surjudpplqj#dqg#rshq#wkh#Wkrqq|#
> Sound sensor
Add a sound sensor
LGH#wr#vwduw#frglqj1
04 Qrz#wkdw#zh#kdyh#rxu#odvhu#vhqvru#zrunlqj/#
magpi.cc/
soundsensor

Try breaking the beam with ohwġv#pdnh#rxu#vhwxs#hyhq#pruh#lqwuxghu0surri#e|#


dgglqj#d#vrxqg#vhqvru1#Zhġuh#xvlqj#d#Zdyhvkduh#
> LED

your hand and see if the vrxqg#vhqvru#iru#wklv/#dv#ihdwxuhg#lq#wkh#Vhqvruv# > Active piezo buzzer
Sdfn/#exw#rwkhu#vlplodu#vhqvruv#duh#dydlodeoh/# > Jumper wires
message changes dorqj#zlwk#XVE#plfv1
Rxu#vhqvru#kdv#slqv#iru#dqdorjxh#dqg#gljlwdo#
Dv#ehiruh/#zhġuh#xvlqj#wkh#JSLR#]hur#oleudu|>#dw# rxwsxwv/#exw#zh#rqo|#qhhg#wkh#gljlwdo#rxwsxw#iru#
wkh#wrs#ri#wkh#frgh/#zh#lpsruw#wkh#Exwwrq#phwkrg# rxu#dodup1#Zlwk#wkh#srzhu#wxuqhg#rļ/#zh#frqqhfw#
iurp#lw1#Zhġoo#xvh#wklv#wr#vhqvh#zkhq#wkh#gljlwdo# wkdw#slq#+GRXW,#wr#JSLR#47/#dqg#wkh#YFF#dqg#JQF#
rxwsxw#iurp#wkh#vhqvru#lv#kljk/#lq#hļhfw#wkh# slqv#wr#6Y6#dqg#JQG#+vkduhg#zlwk#wkh#odvhu#vhqvru#
htxlydohqw#ri#d#sxvk0exwwrq#ehlqj#suhvvhg1#Dv#lwġv# yld#wkh#euhdgerdug#vlgh#udlov,/#dv#lq#Figure 11
frqqhfwhg#wr#JSLR#54/#zh#dvvljq#wkh#odvhu#remhfw#wr# Wxuqlqj#Udvsehuu|#Sl#edfn#rq/#|rxġoo#vhh#wkh#
this with laser = Button(21)1 srzhu#OHG#rq#wkh#ohiw#ri#wkh#vrxqg#vhqvru#lv#olw#xs1#
Lq#dq#lqĽqlwh#while True:#orrs/#zh#fkhfn# Pdnh#d#orxg#qrlvh#dqg#|rx#vkrxog#vhh#wkh#OHG#rq#
zkhwkhu#wkh#slq#lv#orz#+if laser.value == 0,/# wkh#uljkw#oljkw#xs#wr#vkrz#lw#kdv#ehhq#ghwhfwhg1
zklfk#phdqv#wkh#ehdp#kdv#ehhq#eurnhq/#dqg#
Danger!
vhw#wkh#phvvdjh#+msg1#yduldeoh,#wkdw#zhġoo#eh#
Laser
sulqwlqj#wr#wkh#Vkhoo#duhd#dffruglqjo|1#Lq#rxu#sulqw#
Sound test
vwdwhphqw/#zh#dgg#wkh#end = "\r"#sdudphwhu#vr#wkh#
phvvdjh#lv#dozd|v#sulqwhg#rq#wkh#vdph#olqh1
05 Ohwġv#fuhdwh#d#vlplodu#surjudp#wr#whvw#wkh#
The laser sensor used
here continually emits
a laser beam. Be very
Uxq#wkh#laser_test.py#frgh#dqg#wkhq#wu|# vhqvru1#Lq#wkh#sound_test.py#frgh#olvwlqj/#zh# careful not to point it
towards anyone’s head
euhdnlqj#wkh#ehdp#zlwk#|rxu#kdqg#dqg#vhh#li#wkh# dvvljq#wkh#sound#remhfw#wr#JSLR47#zlwk#sound = as it could potentially
phvvdjh#fkdqjhv#wr#ĠLqwuxghu$ġ1#\rx#pd|#Ľqg#wkdw# Button(14)1#Djdlq/#zh#xvh#wkh#Exwwrq#phwkrg#wr# damage their eyesight.

lw#zrunv#ehwwhu#zlwk#|rxu#kdqg#pruh#glvwdqw#iurp# ghwhfw#zkhq#wkh#slq#lv#wuljjhuhg1 magpi.cc/lasersafety

Explore the sensory world: Make an intruder alarm magpi.cc 49


TUTORIAL

sound_test.py
Wklv#wlph#lq#rxu#while True:#orrs/#zh#whvw# > Language: Python
Top Tip zkhwkhu#wkh#slq#lv#kljk#+wkhuh#lv#d#orxg#hqrxjk#
qrlvh#wr#wuljjhu#wkh#vrxqg#vhqvru,1#Dv#ehiruh/#wklv# 001. from gpiozero import Button
Off board ghwhuplqhv#zklfk#phvvdjh#+lq#wkh#msg1#yduldeoh,# 002.
lv#sulqwhg#wr#wkh#Vkhoo#duhd1 003. sound = Button(14)
We’ve placed our 004. msg = ""
sensors on the 005.
breadboard, but 006. while True:
you could keep
Make a noise
them separate
from the other
06 Qrz#lwġv#wlph#wr#whvw#rxu#vrxqg#vhqvru#wr#
007.
008.
if sound.value == 1:
msg = "Intruder!"
components and fkhfn#lwġv#zluhg#xs#dqg#zrunlqj#fruuhfwo|1#Uxq#wkh# 009. else:
wire their digital sound_test.py#S|wkrq#frgh#dqg#wkhq#pdgh#d#orxg# 010. msg = "All clear"
outputs directly qrlvh#wr#pdnh#wkh#GDW#OHG#rq#wkh#uljkw#ri#wkh# 011. print(msg, end = "\r")
to the GPIO pins. vhqvru#oljkw#xs1#\rx#pd|#Ľqg#wkdw#|rx#qhhg#wr#eh#
It’s best to keep
qrlv|#iru#d#vhfrqg#ru#vr#dqg#wkdw#wkhuhġv#d#vkruw#
the laser sensor
ghod|#ehiruh#wkh#phvvdjh#fkdqjhv#eulhľ|#iurp#ĠDoo#
vertical, however,
so that its beam fohduġ#wr#ĠLqwuxghu$ġ1 ohjv#lq#glļhuhqw#xqfrqqhfwhg#urzv/#zh#frqqhfw#
stays horizontal. Li#|rxġuh#kdylqj#wurxeoh#wuljjhulqj#lw/#wu|# d#663#đ#uhvlvwru#ehwzhhq#wkh#qhjdwlyh#+vkruwhu,#
dowhulqj#wkh#vhqvlwlylw|#ri#wkh#vrxqg#vhqvru#e|# ohj#dqg#wkh#jurxqg#udlo#ri#wkh#euhdgerdug1#Wkh#
dgmxvwlqj#wkh#orzhu#srwhqwlrphwhu#vfuhz#+pdunhg# srvlwlyh#+ehqw/#orqjhu,#ohj#lv#frqqhfwhg#wr#JSLR#49#
G#iru#gljlwdo,#rq#lw=#wxuqlqj#lw#dqwlforfnzlvh# rq#Udvsehuu|#Sl/#dv#lq#wkh#Figure 1#zlulqj#gldjudp1
lqfuhdvhv#wkh#vhqvlwlylw|/#exw#grqġw#ryhugr#lw#ru#
wkh#GDW#OHG#zloo#eh#olw#xs#frqvwdqwo|1

Sound the alarm


08 Iru#rxu#dxgleoh#dohuw/#zhġoo#xvh#d#vpdoo#
Add a visual alert
07 Li#|rxu#vhqvruv#dqg#frgh#duh#zrunlqj#
dfwlyh#slh}r#ex}}hu#wr#pdnh#d#ehhslqj#qrlvh1#\rx#
frxog#xvh#vrphwklqj#hovh#wr#vrxqg#wkh#dodup1#
fruuhfwo|/#lwġv#wlph#wr#pryh#rq#wr#wkh#qh{w#sduw1#
Sulqwhg#phvvdjhv#duh#doo#yhu|#zhoo/#exw#iru#d#surshu#
dodup#|rx#qhhg#d#ylvxdo#dqg2ru#dxgleoh#dohuw1 This time we’ve kept
Dv#lq#odvw#prqwkġv#jxlgh/#zhġoo#dgg#d#vwdqgdug#
uhg#OHG#iru#d#ylvxdo#dohuw1#Rxuv#lv#8#pp/#exw#|rx#
it simple with a single
Testing the laser
sensor by breaking the
fdq#xvh#d#glļhuhqw#vl}h1#Dv#dozd|v/#d#uhvlvwru#lv#
qhhghg#wr#olplw#wkh#fxuuhqw#wr#wkh#OHG#wr#hqvxuh#
alarm function
beam. Be careful not lw#grhvqġw#uhfhlyh#wrr#pxfk#dqg#srwhqwldoo|#exuq#
to point the laser near
anyone’s head rxw1#Zlwk#wkh#OHG#sodfhg#lq#wkh#euhdgerdug/#zlwk# Wkh#ex}}hu#kdv#d#orqjhu#srvlwlyh#ohj#dqg#d#vkruwhu#
qhjdwlyh#rqh>#wkhlu#srvlwlrqv#pd|#dovr#eh#pdunhg#
rq#lwv#wrs1#Frqqhfw#wkh#qhjdwlyh#slq#wr#wkh#
euhdgerdugġv#jurxqg#udlo#dqg#wkh#srvlwlyh#slq#wr#
JSLR#58#+dv#lq#Figure 1,1

Alarm code
09 Zlwk#hyhu|wklqj#zluhg#xs#dv#lq#Figure 1/#
|rxġuh#qrz#uhdg|#wr#surjudp#|rxu#lqwuxghu#dodup1#Lq#
wkh#Ľqdo#frgh/#intruder_alarm.py/#zh#dgg#OHG#dqg#
Ex}}hu#wr#wkh#jslr}hur#lpsruwv#dw#wkh#wrs1#Zh#dovr#
lpsruw#vohhs#iurp#wkh#wlph#oleudu|/#wr#xvh#dv#d#ghod|1
Li#|rx#zdqwhg/#|rx#frxog#fuhdwh#d#vhsdudwh#
ixqfwlrq#zlwk#d#glļhuhqw#phvvdjh#iru#hdfk#dodup#
+olnh#rxu#Ľuh#dqg#jdv#dodup#odvw#lvvxh,/#exw#wklv#wlph#
zhġyh#nhsw#lw#vlpsoh#zlwk#d#vlqjoh#dodup#ixqfwlrq/#

50 magpi.cc Explore the sensory world: Make an intruder alarm


TUTORIAL

laser_test.py
> Language: Python

001. from gpiozero import Button


002.
003. laser = Button(21)
004. msg = ""
005.
006. while True:
007. if laser.value == 0:
008. msg = "Intruder!" The Waveshare sound

intruder_alarm.py
sensor. Its sensitivity
009. else: can be altered by
adjusting the A
010. msg = "All clear" (analogue) or D (digital)
011. print(msg, end = "\r") potentiometer screw
> Language: Python

dv#zhġuh#qrw#erwkhuhg#krz#dq#lqwuxghu#lv#ghwhfwhg1#
001.
002.
from gpiozero import Button, LED, Buzzer
from time import sleep
Top Tip
Zkhq#wuljjhuhg/#wklv#h{hfxwhv#d#for#orrs#zklfk# 003. Analogue out
wrjjohv#wkh#OHG#dqg#ex}}hu#rq#dqg#rļ#d#vhw#qxpehu# 004. laser = Button(21)
ri#wlphv/#zlwk#d#318#vohhs#ghod|#hdfk#wlph1 005. sound = Button(14) For simplicity,
Lq#d#while True:#orrs/#zh#fkhfn#wkh#slq#ydoxhv# 006. led = LED(16) we’ve used the
iurp#erwk#vhqvruv#dqg#wuljjhu#wkh#dodup#zkhq#wkh# 007. buzzer = Buzzer(25) digital output of
the sound sensor
odvhu#ehdp#lv#eurnhq#+laser.value == 0,#ru#wkh# 008.
to trigger our
vrxqg#wkuhvkrog#lv#h{fhhghg#+sound.value == 1,1#Li# 009. def alarm(): alarm. To use the
qhlwkhu#lv#wuljjhuhg/#zh#vkrz#wkh#ghidxow#phvvdjh# 010. print("Intruder alert!", end = "\r") analogue output,
dqg#hqvxuh#wkh#OHG#dqg#ex}}hu#duh#wxuqhg#rļ1 011. for i in range(10): you’ll need to
012. led.toggle() add an ADC chip
013. buzzer.toggle() (e.g. MCP3008) to
convert its signal
014. sleep(0.5)
to a digital reading.
Test the alarm
10 Qrz#wr#whvw#wkh#dodup#v|vwhp1#Dv#ehiruh/#
015.
016. while True:
We’ll cover how to
use an ADC in the
wu|#euhdnlqj#wkh#odvhu#ehdp=#wkh#OHG#vkrxog#wkhq# 017. if laser.value == 0 or next instalment.
eolqn#dqg#wkh#ex}}hu#zloo#ehhs1#Gr#wkh#vdph#iru#wkh# sound.value == 1:
vrxqg#vhqvru#e|#pdnlqj#d#surorqjhg#orxg#qrlvh>#wkh# 018. alarm()
dodup#zloo#wuljjhu#djdlq1#Hdfk#wlph/#wkh#ĠLqwuxghu$ġ# 019. else:
phvvdjh#zloo#vkrz#lq#wkh#Vkhoo#duhd1 020. print("All clear ",
end = "\r") The Waveshare laser
sensor. The lens for
021. led.off() the receiver is on the
022. buzzer.off() left, with the metal
laser tube just to the
Taking it further right of it
Zh#qrz#kdyh#d#vlpsoh#lqwuxghu#dodup1#Wr#lpsuryh#
lw/#|rx#frxog#dgg#h{wud#vhqvruv#vxfk#dv#d#SLU#ru#
hyhq#d#fdphud#wr#ghwhfw#pryhphqw1#\rx#frxog#
wuljjhu#d#odujhu#oljkw#dqg2ru#sod|#dq#dohuw#vrxqg#
ru#vsrnhq#phvvdjh#rq#d#frqqhfwhg#vshdnhu1#\rx#
frxog#dovr#vhqg#dq#hpdlo#ru#sxvk#qrwlĽfdwlrq#dohuw#
wr#|rxu#skrqh#zkhqhyhu#wkh#dodup#lv#wuljjhuhg1
Qh{w#wlph#zhġoo#fuhdwh#d#zhdwkhu#vwdwlrq#xvlqj#
whpshudwxuh/#kxplglw|/#dqg#xowudylrohw#oljkw#
vhqvruv1#Vhh#|rx#wkhq1#

Explore the sensory world: Make an intruder alarm magpi.cc 51


TUTORIAL

Overclock
Raspberry Pi Zero 2 W
Give Raspberry Pi Zero 2 W a speed boost by setting overclock
settings in the config.txt document

R
Cool your Zero 2 W
dvsehuu|#Sl#]hur#5#Z#kdv#d#srzhuixo#
Fruwh{0D86#txdg0fruh#surfhvvru#uxqqlqj#
01 We’re going to place Raspberry Pi Zero 2 W
dw#d#ghidxow#vshhg#ri#4JK}1#It is possible to inside a FLIRC Raspberry Pi Zero Case (£13/$18,
Lucy
MAKER

give this a boost up to 1.2GHz, or even 1.4GHz. The pdjsl1ff2ľluf}hur). The metal case acts as a
Hattersley extra speed makes Raspberry Pi OS more snappy, heatsink. For a cheaper option, attach a Heatsink
Lucy is editor of The and comes in useful when setting up Zero 2 W for Zero 2 W (£1/$1, pdjsl1ff2}hur5khdwvlqn).
MagPi magazine projects that are a little more demanding and
and eggs her little could use a little push (such as image processing
Raspberry Pi to
or retro gaming). There is a chance, however, that
run at ever faster
Update Raspberry Pi OS
speeds. If only she
could run this fast!
Raspberry Pi Zero 2 W will start to overheat and
throttle back the CPU, keeping it safe but making
02 Make sure you are running the latest version
magpi.cc Raspberry Pi OS slower. of Raspberry Pi OS. Open a Terminal and enter
As with all overclocking projects, it’s important the following:
to consider a cooling solution for Raspberry Pi.
Overclock is fun to experiment with, however. So sudo apt update
let’s give Zero 2 W a bit more zest. sudo apt full-upgrade

We put our Raspberry Now reboot the system:


Pi Zero 2 W inside
a FLIRC Raspberry
Pi Zero Case, which sudo reboot
dissipates excess heat
across the metal

Watch your speed


03 Before we start overclocking, take a look at
the default CPU speed. Open a Terminal window
and enter:

vcgencmd measure_clock arm

Terminal will most likely return 600000. Divide this


result by 1000 and you’ll get the speed in MHz. This
is the base speed: 600MHz (or 0.6GHz). This is the
speed requested by the kernel. If your Raspberry
Pi is being throttled due to low voltage or over-
temperature, the actual CPU speed may be lower.

52 magpi.cc Overclock Raspberry Pi Zero 2 W


TUTORIAL

The cpu_freq and


ŅƴåųƣƴŅĬƋ±čåÏŅĵĵ±ĹÚŸ±ųå
used to supply more power,
and speed, to Raspberry Pi OS

Use Nano in a Terminal window


ƋŅåÚĜƋƋĘåÏŅĹĀčţƋƻƋĀĬå

Update config Restart your Raspberry Pi.


04 We’re going to use the frqĽj1w{w#Ľoh#wr#vhw#
05 Restart your system to run under the
You’ll Need
a new upper limit for the clock frequency. Open qhz#frqĽjxudwlrq= > Raspberry Pi
another Terminal window and enter: Zero 2 W
sudo reboot magpi.cc/zero2w
sudo nano /boot/config.txt > Raspberry Pi OS
When the system starts up again, watch vcgendcmd magpi.cc/
Scroll down to the section marked: again to see your new, faster clock speed in action: raspberrypios
> ÏŅĹĀčţƋƻƋ
#uncomment to overclock the arm. 700 MHz is watch -n 1 vcgencmd measure_clock arm magpi.cc/configtxt
the default.
#arm_freq=800 Browse a few webpages and you’ll see speeds of
around 1200000000 (or 1.20GHz).
And change the settings to:

# Overclock settings
# over_voltage=6
Top Tip
arm_freq=1200
Monitoring voltage
The over_voltage command adjusts the core CPU/ It is essential to keep the supply voltage above 4.8 V for reliable performance. Note
JSX#yrowdjh/#dqg#dffhswv#Ľjxuhv#ehwzhhq#049#dqg# that the voltage from some USB chargers/power supplies can fall as low as 4.2 V.
;1#Wkh#ghidxow#ydoxh#lv#31#Wkh#odwhvw#Ľupzduh#lq# This is because they are usually designed to charge a 3.7 V LiPo battery, not to
Exoovh|h#zloo#gr#lwv#ehvw#wr#Ľjxuh#rxw#wkh#fruuhfw# supply 5 V to a computer.
voltage for an overclock, so we have left over_ To monitor Raspberry Pi’s PSU voltage, you will need to use a multimeter
to measure between the VCC (5 V) and GND pins on the GPIO. More
voltage commented out for now (more info at
information on power requirements is available on the Raspberry Pi
pdjsl1ff2exoovh|herqxv,1#Vdyh#wkh#Ľoh#zlwk# ƵåÆŸĜƋå×Ƥmagpi.cc/powersupply.
CTRL+O (press RETURN) and use CTRL+X to exit.

Overclock Raspberry Pi Zero 2 W magpi.cc 53


TUTORIAL

A heatsink attached to Raspberry


Pi Zero 2 W’s CPU keeps the
device cool during overclocking

Top Tip
Crank it up Overclocking problems
06 Let’s try taking things a little faster. Set the
Most overclocking issues show up immediately with a
ARM CPU to 1.4GHz. We managed to get our Zero
failure to boot. If this occurs, hold down the SHIFT key
2 W to run at this speed, but only by including the during the next boot. This will temporarily disable all
over_voltage setting. Edit the frqĽj1w{w#Ľoh= overclocking, allowing you to boot successfully and then
Warning! edit your settings.
Crash likely! over_voltage=6 Alternatively, remove the microSD card from your
arm_freq=1400 Raspberry Pi and insert it into another computer. You
Experimenting with will be able to access the ÏŅĹĀčţƋƻƋĀĬå±ĹÚ±ÚģƚŸƋƋĘå
# gpu_freq=700
overclocking may settings from there. If all else fails, use Raspberry Pi
crash your Raspberry Imager to install a fresh copy of Raspberry Pi OS to the
Pi. There is a chance of
This is as high as we’re going to take over_voltage. microSD card.
corrupting the microSD
card. Experiment with Reboot the Raspberry Pi and you’ll be running at
a clean Raspberry Pi
OS installation and 1.4GHz. Run watch -n 1 vcgencmd measure_clock
ensure no important arm again to see the new upper limit. You can also
data is at risk.
magpi.cc/overclock
try uncommenting the gpu_freq. The gpu_freq The gpu_freq setting
oversees a range of settings: core_freq, h264_freq,
isp_freq, and v3d_freq. All the Zero 2 Ws we tested
should be removed if a
failed to boot with faster gpu_freq settings.
Raspberry Pi fails to boot
Recover from black screen
07
config.txt We think arm_freq=1200 is a good speed
boost. Our engineering team told us that the
ehqhĽwv#iurp#gpu_freq are marginal at best,
> Language: Bash and the gpu_freq setting should be removed if
a Raspberry Pi fails to boot. Your Raspberry Pi
001. # Overclock settings is likely to fail to boot at some point during
002. over_voltage=6 overclocking. See ‘Overclocking problems’ (above)
003. arm_freq=1400 for more information on recovery. Otherwise,
004. #gpu_freq=700 have fun and enjoy squeezing the most out of your
Raspberry Pi Zero 2 W computer.

54 magpi.cc Overclock Raspberry Pi Zero 2 W


HDMI TFT Displays

Midas first introduced the HDMI TFT range in 2018, and have continued to develop this range over the
past 3 years. These displays are ideal ‘plug & play’ devices for a Raspberry Pi SBC.

With the addition of a Raspberry Pi SBC, the Midas Displays HDMI TFT modules become a fully func-
tional, easy-to-use displays. The integrated PCB has a 40-pin GPIO interface and a standard 19-pin
type-A HDMI connector, enabling direct connection of a Raspberry Pi SBC. The HDMI TFT modules
can also easily be used with many other single board computers. These key features enable the
HDMI TFT displays to be used with any external HDMI input source.

Key Features
• 4.3”, 5.0”, 7.0”, 10.1”, & 5.2” bar-type, sizes
available
• IPS all-round viewing options
• ‘Plug & play’ with Raspberry Pi
• HDMI interface
• Capacitive, resistive, and non, touch options
available
• Up to 1100cd/m ² brightness

The products within the Midas HDMI TFT


range are available to order direct, and www.midasdisplays.com
through our distribution partners: Farnell, +44 (0)1493 602602
RS Components, and Digi-Key Electronics. sales@midasdisplays.com
TUTORIAL

Ultimate home
Part 05

server: Backup
and UPS
Now you have the ultimate server, let’s keep your
data safe with an uninterruptable power supply
PJ Evans
MAKER

I
{IĜŸ±ƵųĜƋåųØ f you’ve been following our home server Zhġuh#jrlqj#wr#fryhu#wkh#wkuhh#nh|#slooduv#ri#
ŸŅüƋƵ±ųåÚåƴåĬŅŞåų
tutorials over the past months, you should vhuyhu#pdqdjhphqw=#Edfnxs/#Uholdelolw|/#dqg#
±ĹÚƋĜĹĩåųåųţBå
ĩååŞŸŸåƴåų±ĬÏĬŅĹåŸ now have a pretty sweet Raspberry Pi- Prqlwrulqj1#Oxfnlo|/#wkhvh#duh#qrw#kdug#wr#dfklhyh/#
ŅüĘĜĵŸåĬüĜĹŸƋŅų±čå srzhuhg#vhuyhu#xs#dqg#uxqqlqj/#zlwk#Ľoh# hyhq#iru#d#krph#vhwxs/#dqg#|rx#qhyhu#nqrz=#wkhuh#
ģƚŸƋĜĹϱŸåţ sharing, media streaming, remote access, pd|#frph#d#gd|#zkhq#|rxġuh#uhdoo|#jodg#|rx#wrrn#
twitter.com/ and more.#Lq#wklv#Ľqdo#sduw#ri#rxu#Xowlpdwh# wkh#wlph#wr#surwhfw#|rxu#lqyhvwphqw1
mrpjevans Vhuyhu#wxwruldo/#zhġuh#jrlqj#wr#orrn#dw#surwhfwlqj#
erwk#|rxu#kdug#zrun#dqg#doo#wkdw#gdwd#|rx#kdyh#
hqwuxvwhg#wr#rxu#idyrxulwh#olwwoh#frpsxwhu1#
Don’t be that person
RAID systems,
01 Zkhq#|rxġyh#frpsohwhg#d#surmhfw#olnh#wklv/#
like this RAID 10
lwġv#whpswlqj#wr#vwrs#qrz#dqg#hqmr|#wkh#iuxlwv#ri#
ÏŅĹĀčƚų±ƋĜŅĹØ
ŞųŅƋåÏƋ±č±ĜĹŸƋÚĜŸĩ |rxu#oderxu1#Vdgo|/#wkh#dqqdov#ri#frpsxwhu#klvwru|#
ü±ĜĬƚųå±ĹÚŸåųƴĜÏå
ĜĹƋåųųƚŞƋĜŅĹÆƼ duh#Ľoohg#zlwk#vwrulhv#ri#wkrvh#zkr#glg#qrw#khhg#wkh#
ÚƚŞĬĜϱƋĜĹčÚ±Ƌ±Ņƴåų zduqlqjv#dqg#glgqġw#edfn#xs1#Lwġv#fdxvhg#khduweuhdn#
ĵƚĬƋĜŞĬåÚĜŸĩŸ
zkhq#idplolhv#kdyh#orvw#wkhlu#skrwr#oleudulhv#
dqg#edqnuxswf|#zkhq#frpsdqlhv#kdyh#orvw#wkhlu#
suhflrxv#fxvwrphu#gdwd1#Qhyhu#wuxvw#|rxu#gdwd#wr#rqh#
vlqjoh#vrxufh/#qr#pdwwhu#krz#pxfk#|rxġyh#vshqw/#ru#
wkh#uhsxwdwlrq#ri#wkh#vxssolhu1#Wklqn#fduhixoo|#derxw#
krz#wr#nhhs#|rxu#gdwd#vdih/#qrw#rqo|#iurp#kdugzduh#
ru#vriwzduh#idloxuh/#exw#dovr#wkhiw#dqg#glvdvwhu1

Three is the magic number


02 Wkhuhġv#d#orqj0khog#pdqwud#dprqjvw#v|vwhp#
dgplqlvwudwruv#nqrzq#dv#wkh#60504#uxoh1#\rx#qhhg#
wkuhh#frslhv#ri#|rxu#gdwd/#rq#dw#ohdvw#wzr#glļhuhqw#
phgld#w|shv#zlwk#rqh#rļ0vlwh1#Rqo|#wkhq#grhv#
|rxu#gdwd#vdiho|#Ġh{lvwġ1#Wklv#sulqflsoh#surwhfwv#|rx#
djdlqvw#kdugzduh#idloxuh#dqg#sk|vlfdo#sureohpv#vxfk#
dv#Ľuh1#Dowkrxjk#wklv#vrxqgv#lqlwldoo|#frpsolfdwhg#
ru#dw#ohdvw#d#idļ#wr#vhw#xs/#grqġw#zruu|1#Prghuq#wrrov#
kdyh#pdgh#wklv#hdvlhu#wkdq#hyhu#ehiruh1#Zh#fdq#jhw#
|rxu#gdwd#wr#d#khdowk|#edfnhg0xs#vwdwh#zlwkrxw#wrr#

56 magpiţÏÏ Ultimate home server: Backup and UPS


TUTORIAL

A simple way to keep data safe is


to have a second copy ready to go

You can theoretically add up to 256 disk


drives, but don’t forget a powered USB hub
even with just two, or you risk data loss

You need three copies of dfflghqw/#|rxġoo#eh#kroglqj#d#sdudgh#wkurxjk#wkh#


You’ll Need
vwuhhwv#zkhq#|rx#uhdolvh#|rxġyh#jrw#wkdw#gdwd#vdih#
your data, on at least two dqg#vrxqg#rq#wkh#vhfrqg#gulyh1#Doo#|rx#qhhg#wr#
> ±ŸŞÆåųųƼ{Ĝ
gr#lv#vhw#xs#d#uhjxodu#edfnxs#urxwlqh#wr#frs|#wkh#
different media types frqwhqwv#ri#|rxu#Ľuvw#gulyh#wr#wkh#vhfrqg1
ŽĬƋĜĵ±Ƌå„åųƴåų
(The MagPiĜŸŸƚå
#107 to #110)
pxfk#zrun1#Zkdw#qhhgv#wr#eh#grqh#lv#wzrirog=#pdnh# magpi.cc/issues

vxuh#wkh#gdwd#lv#dydlodeoh#hovhzkhuh#dqg#wkdw#li#|rx# > ŽĹĜĹƋåųųƚŞƋĜÆĬå


Quick and easy backup
04
ghohwh#d#Ľoh/#|rx#fdq#jhw#lw#edfn1 ŞŅƵåųŸƚŞŞĬƼ
Dvvxplqj#|rxġuh#dgglqj#dq#lghqwlfdo#XVE# ŠŅŞƋĜŅűĬš

gulyh#wr#|rxu#vhuyhu/#pdnh#vxuh#|rxġyh#sduwlwlrqhg# > eÚÚĜƋĜŅűĬŽ„ƐţLj


dqg#irupdwwhg#wkh#gulyh#lghqwlfdoo|#wr#wkh#ruljlqdo1# åƻƋåųűĬʱųÚÚĜŸĩŸ
A local drive for local data ŠŅŞƋĜŅűĬš
03 Ohwġv#vwduw#zlwk#d#yhu|#vlpsoh#zd|#ri#
Vhh#wxwruldo#sduw#4#lq#The MagPi#&43:#+magpi.cc/107)
iru#ghwdlov#rq#krz#wr#gr#wklv1#Qh{w/#gr#dq#lqlwldo#
edfnlqj#xs#|rxu#gdwd1#Zh#frqqhfwhg#d#7WE#gulyh# edfnxs#wr#hqvxuh#hyhu|wklqj#lv#RN1#Wklv#pd|#wdnh#
wr#rxu#xowlpdwh#vhuyhu#iru#doo#rxu#oryho|#Ľohv1# vrph#wlph/#ghshqglqj#rq#krz#pxfk#gdwd#|rx#kdyh1#
Wkh#hdvlhvw#wklqj#wr#gr#lv#wr#grxeoh#lw#vr#zh#fdq# Li#|rxu#Ľuvw#glvn#lv#prxqwhg#wr#/mnt/huge#dqg#|rxu#
pluuru#wkdw#gdwd1#Dgglqj#d#vhfrqg#7WE#gulyh#pd|# qhz#glvn#lv#/mnt/backup/#wkh#frppdqg#zrxog#eh=
vrxqg#h{shqvlyh#iru#olwwoh#ehqhĽw/#exw#zkhq#|rxu#
ruljlqdo#gulyh#idlov#ru#|rx#ghohwh#d#fulwlfdo#Ľoh#e|# sudo rsync -av /mnt/huge /mnt/backup

Ultimate home server: Backup and UPS magpiţÏÏ 57


TUTORIAL

 ‰
 Ęåųå±ųåĵ±ĹƼ
Let’s go offsite
ƚĹĜĹƋåųųƚŞƋĜÆĬåŞŅƵåų
ŸƚŞŞĬƼŠŽ{„šĵŅÚåĬŸ 05 D#fhqwudo#sulqflsoh#ri#d#jrrg#edfnxs#srolf|#
±ƴ±ĜĬ±ÆĬåƋʱƋŞųŅƴĜÚå
±Ÿĵ±ĬĬüŅŅƋŞųĜĹƋ±ĹÚ lv#wkdw#dw#ohdvw#rqh#frs|#lv#qrzkhuh#qhdu#|rx1#Wklv#
±Úåŧƚ±ƋåƋĜĵåüŅų
lv#wr#surwhfw#djdlqvw#doo#wkrvh#wklqjv#zh#uhdoo|#grqġw#
±ÏĬå±ĹŸĘƚƋÚŅƵĹØ
ŞåųüåÏƋüŅųĘŅĵåƚŸå zdqw#wr#wklqn#derxw#vxfk#dv#Ľuh/#ľrrg/#wkhiw/#ru#
rwkhu#w|shv#ri#gdpdjh1#D#zlgh#udqjh#ri#vhuylfhv#
h{lvw#wr#vhfxuho|#vwruh#|rxu#gdwd#iru#|rx#iru#d#
uhdvrqdeoh#ihh1#Li#wkh#zruvw#kdsshqv/#d#frs|#ri#doo#
|rxu#suhflrxv#gdwd#zloo#eh#dydlodeoh#wr#uhwulhyh1#
Vrph#hyhq#rļhu#d#kdug0gulyh0e|0srvw#vhuylfh1#
Wkhuh#duh#wrr#pdq|#vhuylfhv#wr#fryhu#khuh/#exw#
vrph#wulhg#dqg#whvwhg#vroxwlrqv#iru#Udvsehuu|#Sl#RV#
Top Tip lqfoxgh#lGulyh/#Dpd}rq#V6/#dqg#EdfnEod}h#E51

Time Machine

Introducing iDrive
Not only can you
back up your 06 Li#|rx#zdqw#wr#nhhs#wklqjv#hdv|/#zh#fdq#
ultimate server, but
uhfrpphqg#lGulyh#+idrive.com,#dv#d#frqwhqghu1#Qrw#
it can back up your
rqo|#gr#wkh|#rļhu#yhu|#dwwudfwlyh#Ľuvw0|hdu#whupv=#
Mac as well. Make
ƼŅƚųĀĬåŸĘ±ųåŸ wkh|#duh#rqh#ri#wkh#ihz#rļ0vlwh#edfnxs#frpsdqlhv#
‰Ĝĵåa±ÏĘĜĹåě wr#rļhu#ixoo#Olqx{#+l1h1#Udvsehuu|#Sl#RV,#vxssruw1#
compatible by Dowkrxjk#|rxġoo#qhhg#wr#gr#vrph#qdyljdwlrq#ri#
üŅĬĬŅƵĜĹčƋĘåŸå Uv|qf#zloo#rqo|#frs|#fkdqjhv/#vr#lwġv#idvwhu#diwhu# wkh#frppdqg#olqh/#|rx#fdq#lqvwdoo#wkh#lGulyh#wrrov#
instructions:
wkh#lqlwldo#edfnxs1#Wr#uxq#wklv#rq#d#uhjxodu#edvlv/# dqg#fuhdwh#d#ghvwlqdwlrq#dqg#d#edfnxs0vhw#lq#d#
magpi.cc/
dgg#lw#wr#furqwde#+d#vfkhgxoh#ri#uhjxodu#mrev,= vxusulvlqjo|#vkruw#dprxqw#ri#wlph1#Li#|rx#kdyh#d#
timemachinegit
orw#ri#gdwd/#wkh#Ľuvw#edfnxs#pd|#wdnh#vrph#wlph/#
sudo nano /etc/crontab exw#lGulyh#fdq#wkurwwoh#wkh#edqgzlgwk#xvhg1#Rqfh#
xsordghg/#d#uhjxodu#lqfuhphqwdo#edfnxs#nhhsv#|rx#
Dgg#wklv#olqh#dw#wkh#hqg= xs#wr#gdwh1#Ehvw#ri#doo/#ghohwhg#Ľohv#dqg#glļhuhqw#
yhuvlrqv#ri#Ľohv#fdq#eh#dufklyhg1
1 12 * * * root rsync -av /mnt/huge /mnt/
backup > /var/log/backup.txt 2>&1

 BŅĵåeŸŸĜŸƋ±ĹƋ
The amazing rclone
ϱĹĵŅĹĜƋŅųƼŅƚų
Ÿåųƴåų±ĹÚƼŅƚųŽ{„Ø
Wklv#zloo#uxq#wkh#edfnxs#hyhu|#qljkw#dw#rqh#plqxwh#
sdvw#wzhoyh1#\rx#fdq#fkdqjh#lw#wr#dq|#wlph#ru#wr#eh#
07 Wkhuh#duh#pdq|#vhuylfhv#dydlodeoh#wkdw#
ƋųĜččåųĜĹč±ĬåųƋŸ
ƵĘåĹĹåÏ域±ųƼ dv#+lq,iuhtxhqw#dv#|rx#olnh1 rļhu#vrph#irup#ri#Ġeorfnġ#ru#Ġexfnhwġ#vwrudjh1#
Prvw#srsxodu#lv#Dpd}rq#V6/#exw#wkhuh#duh#d#
jurzlqj#qxpehu#ri#frqwhqghuv#vxfk#dv#EdfnEod}h#
E5/#Er{/#ru#Gljlwdo#Rfhdq#Vsdfhv1#Zrunlqj#rxw#
krz#wr#frppxqlfdwh#zlwk#doo#wkhvh#fdq#eh#d#
fkdoohqjh/#exw#oxfnlo|#uForqh#+rclone.org,#nqrzv#
krz#wr#wdon#wr#ryhu#73#glļhuhqw#vhuylfhv1#Vljq#xs#
iru#wkh#vhuylfh#|rx#zdqw/#jhw#|rxu#fuhghqwldov/#
dqg#frqĽjxuh#uForqh#xvlqj#lwv#phqxv1#Dowkrxjk#
wulfnlhu#wr#frqĽjxuh#wkdq#lGulyh/#wklv#fdq#eh#d#
yhu|#fkhds#zd|#ri#edfnlqj#xs#lq#wkh#orqj#whup1

Let’s get physical


08 Lq#wkh#prghuq#djh#ri#wkh#forxg/#wklv#pd|#
vhhp#olnh#dq#xqqhfhvvdu|#vwhs/#exw#khdu#xv#rxw1#
Krz#idu#|rx#jr#zlwk#edfnxs#lv#ghshqghqw#rq#krz#

58 magpiţÏÏ Ultimate home server: Backup and UPS


TUTORIAL

ydoxdeoh#|rx#shufhlyh#|rxu#gdwd#wr#eh1#W|slfdoo|/#
skrwrjudskv#idoo#lqwr#wklv#fdwhjru|=#phprulhv#
wkdw#duh#luuhsodfhdeoh1#Wklv#lv#zkhuh#wkh#Ġwzr#
w|shv#ri#phgldġ#uxoh#fdq#frph#lqwr#sod|1#Li#|rx#
devroxwho|#qhhg#wkdw#h{wud#shdfh#ri#plqg/#frqvlghu#
hlwkhu#exuqlqj#wkh#gdwd#wr#jrrg0txdolw|#GYG#ru#
Eox0ud|#URPv#ru/#dv#pdq|#skrwrjudskhuv#gr/#
qhyhu#uhxvlqj#dq#VG#fdug#dqg#dufklylqj#wkhp#
dv#|rx#jr1#Pdq|#edqnv#rļhu#d#fkhds#vdihw|0er{#
vhuylfh#zkhuh#|rx#fdq#vwruh#sk|vlfdo#phgld1

As for off-site data storage,


there really are no
practical limits

Please don’t interrupt


09 Qrz#edfnxsv#duh#vruwhg/#ohwġv#orrn#dw#
pdnlqj#vxuh#|rx#grqġw#qhhg#wkhp1#Rqh#ri#wkh#
Two heads are better than one
11
fodvvlf#fdxvhv#ri#gdwd#orvv#lv#d#vxgghq#srzhu#fxw1#  ŅĵޱĹĜåŸĬĜĩå
±ÏĩĬ±DŽå±ĹÚĜ%ųĜƴå
Wklv#lv#gxh#wr#wkh#rshudwlqj#v|vwhp#frqvwdqwo|# Vhuyhu#uholdelolw|#fdq#riwhq#wxuq#lqwr#d# ŅüüåųÏĘå±ŞŅüüěŸĜƋå
ƱÏĩƚŞŸåųƴĜÏ域Ņ
zulwlqj#dqg#uhdglqj#lwv#vwrudjh#dqg#vrphwlphv# udeelw#kroh=#zkhq#gr#|rx#vwrsB#Wkh#sulqflsohv#ri#
ƼŅƚĩĹŅƵƼŅƚųÚ±Ƌ±
fdfklqj#uhdgv#dqg#zulwhv#lq#phpru|#+nqrzq#dv# kljk#dydlodelolw|#+KD,#zloo#nhhs#d#vhuyhu#uxqqlqj# ĜŸŸ±üå
Ġmrxuqdolqjġ,1#Dq#lqrssruwxqh#srzhu#fxw#fdq#xvh# qr#pdwwhu#zkdw1#Li#|rx#uhdoo|#qhhg#wr#nhhs#wklqjv#
Ľoh#v|vwhp#fruuxswlrq#dqg#wkh#orvv#ri#gdwd1#Dq# wlfnlqj#dorqj/#|rx#qhhg#wr#hudglfdwh#hyhu|#vlqjoh#
xqlqwhuuxswleoh#srzhu#vxsso|#+XSV,#lv#d#edwwhu|# srlqw#ri#idloxuh/#dqg#wkdw#lqfoxghv#wkh#vhuyhu#
wkdw#fdq#nhhs#|rxu#vhuyhu#jrlqj#gxulqj#d#srzhu#fxw1# lwvhoi1#Lq#wkh#odvw#vwhs/#zh#uhpryhg#d#vlqjoh#kdug#
Lq#wkh#fdvh#ri#d#Udvsehuu|#Sl#frpsxwhu/#vrphwlphv# gulyh#dv#d#srlqw#ri#idloxuh1#Xvlqj#wkh#sulqflsoh#
iru#krxuv1#Ehvw#ri#doo/#wkh|#fdq#frppxqlfdwh#zlwk# ri#ordg#edodqflqj/#zh#fdq#uhpryh#wkh#vhuyhu#dv#
|rxu#vhuyhu#ryhu#XVE#dqg#lqyrnh#d#vdih#vkxwgrzq# zhoo1#Vriwzduh#vxfk#dv#Yduqlvk#fdq#vsolw#wkh#ordg#
zkhq#wkh#edwwhu|#jhwv#orz/#surwhfwlqj#|rxu#gdwd1# ehwzhhq#wzr#ru#pruh#Udvsehuu|#Sl#vhuyhuv#dqg#li#
Jrrg#XSVv#iru#krph#xvh#vwduw#dw#durxqg#†;31 rqh#idlov/#hyhu|wklqj#nhhsv#rq#zrunlqj1#Pdjlf$

Top Tip
Redundancy is a good thing Let it grow Remote
10 Dqrwkhu#dvshfw#ri#jrrg#vhuyhu#pdqdjhphqw#
12 Qrwklqj#zh#kdyh#glvfxvvhg#khuh#suhyhqwv# Monitoring
lv#dydlodelolw|1#Li#|rx#kdyh#doo#|rxu#frro#gdwd#rq#wkh# |rxu#vhuyhu#iurp#jurzlqj#lq#wkh#ixwxuh1#Prghuq#
If you want to
vhuyhu/#|rx#zdqw#wr#pdnh#vxuh#lw#fdq#kdqgoh#idloxuh# UDLG#v|vwhpv#vxfk#dv#]5#doorz#|rx#wr#lqfuhdvh#
monitor your
dqg#nhhs#jrlqj1#Dowkrxjk#wkh#wzr0gulyh#v|vwhp# glvn#fdsdflw|#zlwk#qr#grzqwlph1#Xvlqj#ordg0 server from afar
zloo#suhyhqw#gdwd#orvv/#lwġv#jrlqj#wr#eh#d#sdlq#wr# edodqflqj#vriwzduh#vxfk#dv#Yduqlvk#phdqv# ±ĹÚʱƴååƻŞŅŸåÚ
uhfrqĽjxuh#hyhu|wklqj1#Iru#d#wuxo|#urexvw#v|vwhp/# |rx#fdq#dgg#lq#pruh#vhuyhuv/#ru#uhsodfh#idlohg# a web server
|rx#qhhg#d#uhgxqgdqw#duud|#ri#lqh{shqvlyh#glvnv# kdugzduh/#zlwkrxw#dq|rqh#qrwlflqj1#\rxġuh#iuhh# ƋŅƋĘåĜĹƋåųĹåƋØ
+UDLG,1#Wklv#lv#d#Ľoh#v|vwhp#wkdw#doorzv#d#qxpehu# wr#dgg#pruh#vriwzduh#dqg#ihdwxuhv#zkhqhyhu#|rx# ŸåųƴĜÏ域ƚÏʱŸ
uptimerobot.com
ri#glvnv#wr#rshudwh#dv#rqh#dqg#fdq#wrohudwh#dw# zdqw1#Dv#iru#rļ0vlwh#gdwd#vwrudjh/#wkhuh#uhdoo|#
will alert you if
ohdvw#rqh#gulyh#idloxuh1#\rx#fdq#wkhq#uhsodfh#wkh# duh#qr#sudfwlfdo#olplwv1#Dq|#wlph#|rx#qhhg#wr#
ƋĘåƼϱĹ
gulyh#dqg#kdyh#wkh#gdwd#surwhfwhg#djdlq#zlwk#qr# errvw#|rxu#kdugzduh/#lwġv#srvvleoh#wr#gr#lw#zlwk#qr# ĹŅĬŅĹčåųųå±ÏĘ
grzqwlph#dw#doo1#Wkh#]IV#Ľoh#v|vwhp#lv#hvshfldoo|# lqwhuuxswlrq/#djdlq#dqg#djdlq/#wuxo|#pdnlqj#lw#wkh# your site.
jrrg#dw#wklv1 xowlpdwh#vhuyhu1#

Ultimate home server: Backup and UPS magpiţÏÏ 59


TUTORIAL

Touch inputs with


Raspberry Pi Pico
Poke data into Pico – no buttons needed

more electrical charge than it would if you weren’t


holding the end of it. The question is, how do you
Below read the value of this charge?
A bit of exposed wire
can function as a The easiest way is to discharge it and see how
touch sensor long it takes to discharge. For this, we need a way
of discharging the touchpad – basically, a resistor
connected to ground. As the amount of capacitance
in the wire plus a person is very low, we want a
very large resistor to slow down the discharge to
a speed we can measure. We use a 1 M1 resistor
for this.

The pseudo-code to tell if a pad is currently


touched is:
• Set pad to output and drive it high
• Turn pad to an input
• Continue to read pad state until the pad
goes low
• Return the amount of time this took

The higher the capacitance of whatever is attached

R
to the pad, the longer this will take (though it should
aspberry Pi Pico doesn’t have only be a tiny fraction of a second). If it’s above a
capacitive touch hardware on board. certain threshold, then we consider the pad touched.
However, that doesn’t mean we can’t If not, then we don’t.
use capacitive touch. To understand The good news is that CircuitPython can do all of
how, we first need to learn a little about this for us. All we need to do is attach the external
how capacitive touch works. 1 M1 resistor between a pad and ground.
Ben Everard All electrical conductors have some amount of We can then read the state of the touch sensor with:
capacitance – basically, this is an ability to store
import time
@ben_everard electrical charge. If you put one end of a wire into
import board
a circuit without the other end attached, you might
import touchio
Ben's house is slowly think that no electricity flows, but actually, a little
being taken over by 3D
printers. He plans to
does. It charges the wire and this small charge will
touch_pad = board.GP9
solve this by printing an remain stored in the wire until it’s discharged. How
extension, once he gets much charge it stores depends on the size of the
enough printers. touch = touchio.TouchIn(touch_pad)
wire, what it’s made from, etc.
Capacitive touch sensing works because your body
while True:
is a conductor. If you connect a wire to a circuit that
if touch.value:
you’re holding the end of, it’ll be able to store slightly

60 magpi.cc Touch inputs with Raspberry Pi Pico


TUTORIAL

print("Touched!")
time.sleep(0.05)

The touchio module is built into CircuitPython, so


you don’t need to add it. It should work on all boards,
though on some, you won’t need the external pull-
down, and on others, it will only work on some pins;
so if you have trouble, look at the documentation for
your board. On Pico, you can use it on any pin as long
as you add the resistor. We’ve used GP9, but change
this to something different if that works for you.

MAKING A GAME
Let’s make a simple reaction game. In this, we’ll light
up an LED, then the aim is to touch the touchpad as
soon as possible after the LED lights up.
This is done with the following code:

import time
import board
import touchio
import digitalio
import random
THRESHOLDS
We mentioned at the start that this is just reading the Above
touch_pad = board.GP9 The touch inputs on
capacitance of the pad and whatever it’s connected this games controller
led_pin = board.GP25 are a bit messy, but
to. However, how does CircuitPython know if a
led = digitalio.DigitalInOut(led_pin) they work well
capacitance is enough to be a touch? After all, if
led.direction = digitalio.Direction.OUTPUT
you’re attaching different hardware to Pico, you might
get different capacitances.
touch = touchio.TouchIn(touch_pad)
It’s done with a simple thresholding. You can see
led.value = False
the actual value returned by the touch sensing with:

time.sleep(random.randint(5,10)) import time


led.value=True import board
import touchio
start = time.monotonic()
touch_pad = board.GP9
while not touch.value:
pass touch = touchio.TouchIn(touch_pad)

score = time.monotonic() - start while True:


print(score) print(touch.raw_value)
time.sleep(0.05)
We’re using the internal LED on Pico, so there’s no
need to add extra hardware. When you first create a touch input, CircuitPython
We use the following line to pause the execution checks the raw value and sets the threshold to
for a random amount between five and ten seconds: that value plus 100. However, in some cases, that This tutorial is from
HackSpace magazine.
might be too sensitive or not sensitive enough.
time.sleep(random.randint(5,10)) Each issue includes a
You can manually adjust the threshold with the huge variety of maker
There’s then a while loop that does nothing but touch.threshold(value) function. projects inside and
pause until touch.value becomes true. That’s all you need to know to start creating your outside of the sphere
This code is a bit simplistic because it just finishes own touch-sensitive projects. A touch sensor can of Raspberry Pi, and
at the end of the game. You could get it to loop be absolutely anything that’s conductive. It can be a also has amazing
tutorials. Find out
around again if you wanted to make a game that bare wire, a pad on a PCB, or something made out of
more at hsmag.cc.
played over and over. tinfoil. You can be as artistic as you like.

Touch inputs with Raspberry Pi Pico magpi.cc 61


FEATURE

M a k
n
e
gif ts with
your
s p
ow
b e r r y Pi
Ra
r so n al
mate pe
e u l ti es
Build th r your loved on
gift fo

O
ne of the goals of the magazine is to
inspire people to build things using
Raspberry Pi. There’s so much you can
do with the various Raspberry Pi computers and
Raspberry Pi Pico, and we hope that just one idea
lights a spark.
Lots of people get a new Raspberry Pi for
Christmas, but what if they got some inspiration
too? Building something unique and amazing
might just be the way to get someone interested,
and it makes for an incredibly personal gift as well
– especially if they can start using it day-to-day.
So, grab some wrapping paper in one hand and
awkwardly balance a 3D printer in the other, and
let’s get festive.

Make your own gifts with Raspberry Pi magpi.cc 63


pb erry P i
Ra s
gift g uid e
w h o m ight
s fo r those m se lves
Kit ild it the
r to bu
prefe

a dio
G row K it
rb pac k Pir a te R
with he
radio
c/ p irate
pi.c ro
URL:
mag
$ 5 4 rry Pi Ze
rbs / e
rowkithe : £4 8 aspb
pi.cc/g
PRICE ing R
URL: mag art-l
o o k
0 / $4 5 plant A sm kit
PRICE: £4 style with this et radio
in n
me basil inter
Grow so em
ing syst
monitor

Picad
URL: e Rock
yBor
mag
PRIC pi.cc
E: £1 /pic
6 ade URL

g
Buil 5/$ :m
d-it- 225 PRIC agpi.cc
your E: £9 /roc
self
mini Thr 9/ kyb
arca ee- $ 135 org
de bud w hee
get led
, bu f
t ex un with
cell this
ent
, rob
ot k
it

64 magpi.cc
FEATURE

DMG
Pi Boy pi.cc / p iboy
dmg
mag 0 eld
URL: 6 / $13 te handh
E: £ 9 a
PRIC h e ultim ne
te t achi
Crea ing m
gam
retro

Monst
PRICE
e
URL: m
agpi.c
: £210
c/mo rBorg
nsterb
Serio / $286 org
us ro
botic
s for
seriou
s raci
ng

irr or
o n K it a gic m
AIY Vi si ” m
URL: magp
i.cc/aiyvis
/ $93
ion
13.3 m a g pi.cc
/ma
g ic mirrork
it

uick
er
PRICE: £83 h a came
ra for URL: 2 08 r or q
w it 5/$ mir
Machine
lea rning
RI CE : £18 n s mart
P ur ow
cognition e yo
image re Mak

Make your own gifts with Raspberry Pi magpi.cc 65


a ller gi f ts
Sm
a b u dg e t
on
Ra spb e rry Pi
Recycle a ple r pro jects
sim
with these

Retro games box


URL: retropie.org.uk
MAKER: RetroPie
COST: £20 / $20 and a spare Raspberry Pi

Setting up a RetroPie box is incredibly easy, and


we cover the process in our Ultimate Media Centre
feature in The MagPi issue 102 (magpi.cc/102). All
you need for your spare Raspberry Pi is a case and a
controller or two. A Raspberry Pi 4 would be best, but

Media centre you can still make an excellent retro gaming machine
with a Raspberry Pi 3 or newer.
URL: magpi.cc/102 You can also preload it with new games that are
MAKER: Rob Zwetsloot ĵ±ÚåƋŅÆåųƚűŸkaŸŅĹåĵƚĬ±ƋŅųŸôĀĹÚŅƚƋ
COST: £10 / $10 minimum, and a spare Raspberry Pi about them on magpi.cc/legalroms.

Media centres are mostly software-based, and the


simplest ones only require a Raspberry Pi and a
case to put them in. The guide we wrote in issue 102
allows you to play retro games, watch movies and
TV, and stream shows all in one little box. The cost
of parts for that build is around £50 / $60; however,
you don’t need everything we used, so pick and
choose as your budget allows.
For an extra-special treat, make sure it has the info
for the recipient’s WiFi network so they can get using
it straight away.

66 magpi.cc
FEATURE

This cost of a digital frame


like this depends a lot on the
size of the display

Digital photo frame


URL: magpi.cc/photoframe
MAKER: Caroline Dunn
COST: £30-£70 / $40-$95, and a spare Raspberry Pi

This cost of a digital frame like this depends a lot on


the size of the display you plan to use, if you’re not
reusing an old one, as well as whether you plan to
frame it with wood or a 3D-printed case. Once again,
it’s very software-orientated, and loading it with
pictures the recipient will like (along with a way to
change them) should go down well.
You can always switch out the use of Google Photos
Security camera
üŅųXĜÆųå)X)±ĹÚŸƋŅųåƋĘåŞĘŅƋŅŸŅÿĜĹ屟ƵåĬĬţ URL: magpi.cc/camerabook
MAKER: Phil King
COST: £34 / $40 and a spare Raspberry Pi

Whether you have a security-conscious friend, or


someone that likes to watch their garden wildlife,
Raspberry Pi can work great as a security camera.
œåʱƴå±čųå±ƋƋƚƋŅųĜ±ĬĜĹÏʱŞƋåųŎƅŅüƋĘåŅþÏĜ±Ĭ
Raspberry Pi Camera Guide (magpi.cc/camerabook)
using the powerful and free motionEyeOS. There’s
±ĬŸŅ±ŸŞåÏĜĀÏƵĜĬÚĬĜüåűƋƚųåϱĵåų±ƋƚƋŅųĜ±ĬĜĹ
there as well if you fancy doing something a bit
ĵŅųåƤ±Úƴ±ĹÏåÚţ
The price here takes into account a regular Camera
Module. However, if you have the budget, it can easily
be upgraded to a HQ Camera.

TOP MAGPI WRAPPING TIPS:


easy to open
Washi tape is a kind of sticky tape that has printed
designs on it – it’s also a little less adhesive than
regular tape. Get some Christmas-themed tape and
use it on your gifts to make them a bit easier to open,
and much more festive.

Make your own gifts with Raspberry Pi magpi.cc 67


ol p ro je cts
C o
to in sp ir e
for tech lovers
s
Go-to build
RadioGlobe
URL: magpi.cc/radioglobebuild
MAKER: Jude Pullen
COST: £230 / $300 plus, 3D-printed materials

This is a very cool build that requires a decent toolbox

Handheld console
and a bit of maker experience. Basically, you spin the
globe and then move the reticule up and down, and
the nearest radio station to wherever in the world
URL: magpi.cc/55 the reticule is over will be played. Jude, the creator,
MAKER: Ruiz Brothers mentions how he’s discovered loads of great music
COST: £50 / $60, plus 3D-printed materials using this. It uses web radio to play the feeds, and
the physical build itself is made up of a variety of
It doesn’t seem that long ago that we made this components to make the whole thing work. You can
Raspberry Pi Zero-powered handheld in the magazine ŞųŅƱÆĬƼÚŅĜƋÏĘå±ŞåųÆƼŸåĬåÏƋĜĹčÚĜýåųåĹƋޱųƋŸØŅų
– the whole thing still works great, though. It’s based ųåÏƼÏĬĜĹčŸŅĵåŸƋƚýüųŅĵƼŅƚųŅƵĹĘŅĵåţ
on a build from Adafruit called PiGRRL 2.0 which used
a full-size Raspberry Pi, and you could swap it out for
a newer Raspberry Pi if you wish – although you may
ĹååÚƋŅåÚĜƋƋĘ儉XĀĬåŸüŅųƋĘåϱŸåĜüƼŅƚƚŸå±
Raspberry Pi 4.
„Şå±ĩĜĹčŅüƐ%ŞųĜĹƋĜĹčƋĘåĀĬåŸØƵåųåÏŅĵĵåĹÚ
using a softer material for the buttons and D-pad. Your
recipient’s thumbs will thank you in the long run.

68 magpi.cc
FEATURE

Weather station
URL: magpi.cc/weatherstation
MAKER: The Raspberry Pi Foundation
COST: Varies

Digital camera
You can do something like this in two ways. You can
either make a screen like a digital photo frame (see
previous page) that displays weather data from the
URL: magpi.cc/beccacam internet. Or, you can build a full-on weather station to
MAKER: Becca Farsace know exactly what the weather is like right now.
COST: £110 / $150 plus an old camera shell This project is a little bit on the large side, and will
need the recipient to mount parts of it outside, so make
We featured this in the magazine last year, where ŸƚųåƋĘåƼϱĹÚŅŸŅĵåƋĘĜĹčĬĜĩåƋĘĜŸĀųŸƋú‰ĘåŅųĜčĜűĬĩĜƋ
Becca used a classic camera shell to create her for the Oracle weather station is sold out now, but you
own, very nice, digital camera using a Raspberry Pi can source parts using the Foundation’s guide.
and a HQ Camera. It also has an LCD screen so you
can get nice previews. It would also work well with
a new Raspberry Pi Zero 2 W if you’d like to save
space elsewhere.
Old and broken cameras can be found on eBay
pretty cheaply, but otherwise you could 3D-print your
own case for this build.

Old and broken TOP MAGPI


cameras can be found on WRAPPING TIPS:
not enough paper
G$C[RTGVV[ǭEJGCRN[
You’ve cut out a square of
wrapping paper and it’s just a bit
too small for the gift? Try turning
the paper 45 degrees – it’s a more
åþÏĜåĹƋƚŸåŅüޱŞåųرĹÚĵ±ƼŸ±ƴå
ƼŅƚÏƚƋƋĜĹčŅý±Ĺ±ƵĩƵ±ųÚåƻƋų±ŸƋųĜŞţ

Make your own gifts with Raspberry Pi magpi.cc 69


ga bu ilds
Me
to im p re ss
under the tree
es won’t fit
These on

Magic Mirror
URL: magicmirror.builders
MAKER: Michael Teeuw
COST: £100-£200 / $150-$300

A classic build for many Raspberry Pi makers, Magic


mirrors can be quite cheap if you have a spare TV lying
around and some basic skills in carpentry. Otherwise,
a cheap IKEA frame is how original maker Michael got
his start with it.
Preload it with nice phrases for the intended recipient,
and make sure they have space for something like this
Arcade machine
near a power socket. Soup it up with voice controls, as URL: magpi.cc/63
seen in The MagPi issue 90 (magpi.cc/90). MAKER: Bob Clagett
COST: £250/$350 or more

A dream gift for many people, this full arcade machine


build from issue 63 includes decals, proper buttons, and
light-up strips. It’s a big build, so you may want to get
ŸƋ±ųƋåÚŅĹĜƋųĜčĘƋĹŅƵĜüƼŅƚƵ±ĹƋƋŅčåƋĀĹĜŸĘåÚĜĹƋĜĵåţ
Some updates we’d suggest are using the Picade X
HAT (magpi.cc/xhat) from Pimoroni, which helps a lot
in connecting all your arcadey bits to a Raspberry Pi – it
even includes left and right speaker connectors. We’ll
leave the wrapping ideas to you – we’re not sure WH
Smith sells gift bags this large.

Preload it with
PKEGǭRJTCUGUǭHQTVJG
intended recipient

70 magpi.cc
FEATURE

Robot sail boat


URL: ubcsailbot.org
MAKER: University of British Columbia
COST: A lot

Automated model sailing competitions are a thing


people do, and we’ve featured a couple of these
projects in the magazine in the past. One of our
favourites is the UBC Sailbot. It’s a 5.5 metre-long
sailboat, complete with a Raspberry Pi controlling it.
We don’t have a price estimate because there’s a lot of
custom and expensive work going into its construction.
You’ll need some serious building and nautical
engineering skills to recreate this. However, you might
just end up being someone’s favourite relative or friend Automated garden
for a long time. URL: magpi.cc/mudpi
MAKER: Eric Davisson
COST: £150 / $200 dependant on size

Automated gardening is very cool we think, and the


MudPi system that we featured in the magazine a
little while ago is a great way to start your own little
robotic farm – and maybe grow it to something larger.
It monitors soil and plant conditions, controls irrigation,
and allows for remote access and reports so even if
you’re not there, your plants get cared for.
We suggest making a little box garden for a gift
recipient that they can then plant in a garden, or put on
a balcony. They can easily add extra modules if they
start getting the hang of it.

TOP MAGPI WRAPPING TIPS:


easy bows
If you want to go extra fancy, use a ribbon on your gifts.
‰ĘåƤ屟ĜåŸƋƵ±ƼƋŅ±ƋƋ±ÏĘƋĘåųĜÆÆŅĹĜŸƋŅĬ±ƼĜƋ±ÏųŅŸŸƋĘå Warning!
top of the gift lengthways. Wrap around the box with both Power Tools
ends of the ribbon, and when they cross in the middle,
twist them around each other 90 degrees clockwise. These projects will
involve the use of
Wrap the rest up to the top and tie a bow for that classic serious tools, so be
Ƶų±ŞŞåÚƤĬŅŅĩţ careful if you plan to
replicate them.

Make your own gifts with Raspberry Pi magpi.cc 71


REVIEW

Midas 5in TFT LCD


Midas Displays magpi.cc/farnellmidas £77 / $105
SPECS

DIMENSIONS
AND
Turn Raspberry Pi into a professional touchscreen
ENVIRONMENT: display system. By Lucy Hattersley
Module size:
120.70 × 75.80

D
× 23.20 mm;
Operating isplays like this Midas 5in TFT LCD are The Midas 5in TFT LCD has the same resolution
temperature: used in a variety of industrial settings. dv#wkh#RĿfldo#Udvsehuu|#Sl#:lq#Wrxfkvfuhhq#
-20°C ~ +70°C; Don’t be surprised if you’ve already used Display (pdjsl1ff2rĿfldoglvsod|). However, this
Logic voltage: 5V
one of these in a vending machine, EV charger, or device uses an HDMI connection for the display,
DISPLAY: information display. and a micro-USB to USB-A cable to provide
Display size: 5.0 Midas sent us a 5in IPS display for touchscreen feedback.
inch; Resolution: testing (part number: MDT0500D2IHC-HDMI, Our test unit came with a U-shaped MCIB-HDMI
800×480;
magpi.cc/midas5in). It is a small screen with a adapter that neatly connected Raspberry Pi 3B+
Orientation:
Landscape; quirky 800×480 resolution and 5:3 aspect ratio. It to the display. We tested it with a Raspberry Pi 4
Brightness: also comes with a ten-point capacitive touchscreen using a Mini-HDMI to HDMI cable and it worked
750 cd/m2 and GPIO integration. mxvw#Ľqh1
The screen is connected to the Raspberry Pi
INPUT/OUTPUT:
Touchscreen: via the GPIO pins. A look at the datasheet Setting up
CTP; Interface: (magpi.cc/midas5indatasheet) shows that GPIO 17 Our test unit came with a Raspberry Pi 3B+
HDMI; Pinout: is used to control the backlight, and power is passed and microSD card, along with some printed
40-pin GPIO through the GPIO pins (it is powered via a standard instructions. It was easy to disassemble and,
5 V supply connected to Raspberry Pi). A GPIO consequently, reassemble. Just attach it to the
breakout on the rear of the device enables you to GPIO pins, insert the HDMI and USB cables, and
attach further electronic components or HATs. away you go.

config.txt
Here we are using
MagicMirror2 to
build a custom
information board

> Language: Bash

001. ### Select Custom Timings


002. hdmi_group=2
003. hdmi_mode=87
004.
005. ## Disable audio over HDMI
006. hdmi_drive=1
007.
008. # HDMI Timings for MCT050HDMI-A series
(800x480)
009. hdmi_cvt=800 480 60 6 0 0 0

72 magpi.cc Midas 5in TFT LCD


REVIEW

The 800×480 display


ĹååÚŸÏŅĹĀčƚųĜĹčƋŅ
show the desktop in
±ŸŞÆåųųƼƤ{ĜƤk„

Raspberry Pi
connects to the
MDT0500D2IHC
board via GPIO pins,
a HDMI connection,
and USB

The 800×480 resolution is non-standard, so


getting the screen to work requires editing the
The visual fidelity is superb
frqĽj1w{w#Ľoh1#Lwġv#qrwklqj#sduwlfxoduo|#kdlu|/#
but you will need to set custom timings. You
and the touchscreen Verdict
fdq#Ľqg#wkh#lqir#|rx#qhhg#rq#Udvsehuu|#Slġv# response is immediate A fantastic display
Documentation site (magpi.cc/custommode). with an excellent
The key part is the timings, which you’ll need Raspberry Pi OS using both Florence and Matchbox touchscreen and
good Raspberry
to set at: ‘hdmi_cvt=800 480 60 6 0 0 0’. We’ve (magpi.cc/onscreenkeyboard).
Pi integration.
included the frqĽj1w{w additions in this review On the whole, this is a great display. The visual
‰ĘåÏŅĹĀčƚų±ƋĜŅĹ
for reference. Ľgholw|#lv#vxshue#dqg#wkh#wrxfkvfuhhq#uhvsrqvh# is easy enough
is immediate. The physical setup couldn’t be any once you have the
What you can do? hdvlhu/#dqg#wkh#frqĽjxudwlrq#lv#hdv|#rqfh#|rx#kdyh# correct timings.
With everything working, we had a lot of fun the correct timings info. While Midas provides a Midas could
provide beginners
turning our MDT0500D2IHC into a variety of detailed datasheet (magpi.cc/midas5indatasheet),
with more
glļhuhqw#surmhfwv1#Zh#wxuqhg#lw#lqwr#d#pdjlf# there is little tutorial support for beginners,
documentation,
mirror (magpi.cc/magicmirror) and created a presumably as a result of its industrial engineering

8
though.
weather information board; we then used Info- background. But if you want a small screen to
Beamer (magpi.cc/infobeamer) to turn it into integrate into a build, or want to experiment with a

/10
a photo display board and play video clips. In small magic mirror or information screen; this is a
addition, we added an on-screen keyboard to great choice.

Midas 5in TFT LCD magpi.cc 73


REVIEW

PicoSystem
Pimoroni magpi.cc/picosystem £59 / $66
SPECS

INTERNALS:
RP2020 chip A handheld console built around RP2040 and with
(dual Arm
Cortex-M0+ game development in mind. Rob Zwetsloot boots it up.
running at up

E
to 133MHz
with 264kB of xtremely tiny handheld consoles have not Udvsehuu|#Sl#Slfr#ru#rwkhu#US53730edvhg#v|vwhpv/#
SRAM), 16MB always had the best track record in the doorzlqj#|rx#wr#hdvlo|#wudqvihu#vnloov#ryhu#iurp#
of QSPI flash
microcomputer space. A few Raspberry Pi hovhzkhuh1#FlufxlwS|wkrq/#zklfk#lv#edvhg#rq#
supporting XiP
]hur#hļruwv#hqghg#xs#ehlqj#mxvw#d#olwwoh#wrr#vpdoo# PlfurS|wkrq#lv#vxssruwhg#dv#zhoo/#dqg#wkhuhġv#hyhq#
DISPLAY: dqg#Ľqqlfn|#iru#dfwxdo#xvh/#dqg#lw#glgqġw#txlwh#khos# d#65eolw#VGN/#doorzlqj#|rx#wr#sruw#ryhu#jdphv#iurp#
ŎţĂĉtÏŅĬŅƚų wkdw#wkh|#riwhq#xvhg#kdug#6G0sulqwhg#exwwrqv#wkdw# Slprurqlġv#65eolw#kdqgkhog#frqvroh1
SPI IPS LCD
zhuh#xqfrpiruwdeoh1#Zhġuh#sohdvhg#wr#vd|#wkdw# Wkh#vwdqgdug#F..#dqg#PlfurS|wkrq#DSL#dggv#
(240×240 pixels)
Slprurqlġv#SlfrV|vwhp/#zkloh#vwloo#vpdoo/#pdqdjhv# ordgv#ri#ixqfwlrqv#wr#pdnh#fuhdwlqj#jdphv#voljkwo|#
FEATURES: wr#dyrlg#wklv1 hdvlhu/#lqfoxglqj#fdphud#frqwuro/#olqnlqj#wr#exwwrqv/#
D-pad and Lwġv#pdgh#iurp#ploohg#doxplqlxp/#kdv#surshu# dqg#sulplwlyhv#iru#gudzlqj#vsulwhv#pruh#hdvlo|#wkdq#
buttons,
exwwrqv/#dqg#d#qlfh#olwwoh#vtxduh#vfuhhq#zlwk# exloglqj#wkhp#sl{ho#e|#sl{ho1#Wkhuh#duh#glļhuhqw#lq0
525 mAh
LiPo battery, 573¹573#sl{hov1#Lw#ihhov#qlfh#wr#krog#Ğ#wkhuhġv#d# hqjlqh#hļhfwv#|rx#fdq#dsso|#wr#wh{w#dqg#vxfk#Ğ#lwġv#
piezo buzzer/ elw#ri#khiw#Ğ#dqg#kroglqj#lw#lv#qrw#xqfrpiruwdeoh1# d#phdw|#DSL#wkdw#|rx#fdq#jhw#d#orw#rxw#ri#iru#mxvw#d#
speaker, Lw#frphv#zlwk#d#jdph#suh0lqvwdoohg=#Vxshu#Vtxduh# vlpsoh#sl{ho#jdph#rq#d#olplwhg#slhfh#ri#kdugzduh1
CNC-milled
Eurv/#d#sodwiruphu1#Krzhyhu/#wkh#pdlq#gudz#uhdoo|# Wkh#fxuuhqw#jdphv#dydlodeoh#iru#SlfrV|vwhp#
aluminium
case, wrist lv#wkdw#|rx#fdq#pdnh#jdphv#iru#lw#|rxuvhoi1 uxq#devroxwho|#Ľqh#dv#zhoo/#dowkrxjk#wkh#odfn#ri#
strap d#surshu#vshdnhu#lv#d#olwwoh#qrwlfhdeoh1#Wkh#slh}r#
Make your own fun ex}}hu#vrxqgv#duh#txlwh#fkduplqj#lq#wkhlu#rzq#
SlfrV|vwhp#xvhv#lwv#rzq#rĿfldo#DSL/#zklfk# zd|/#wkrxjk/#dqg#vpduw#xvh#ri#lw#fdq#fuhdwh#vrph#
zrunv#PlfurS|wkrq#dqg#F..#0#mxvw#olnh#d#vwdqgdug# qlfh#uhwur#eohhsv#dqg#eorrsv1

There are already


some fun games that
have been made for it

74 magpi.cc PicoSystem
REVIEW

The main draw really The PicoSystem is


beautifully designed

is that you can make


and feels premium

It has a charm loop

games for it yourself holder bit which is


extremely important

Pocket games
Vzlwfklqj#rxw#jdphv#lv#d#olwwoh#pruh#wulfn|#wkdq#
fkdqjlqj#fduwulgjhv/#wkrxjk#Ğ#wkhuhġv#olplwhg#
vsdfh#rq#wkh#SlfrV|vwhp/#dqg#|rx#qhhg#wr#frqqhfw# Verdict
lw#wr#d#frpsxwhu#wr#gr#d#txlfn#uh0ľdvklqj#wr#sod|#
An incredibly cool,
d#glļhuhqw#jdph1#Lwġv#qrw#wrr#iuxvwudwlqj/##dv#lwġv#
tiny handheld
suhww|#txlfn/#vr#iru#ghyhorsphqw#|rx#grqġw#kdyh# that you can fairly
wr#zdlw#wrr#orqj1#Li#|rxġuh#rxw#dqg#derxw#zlwk#lw# easily develop
kdqjlqj#iurp#|rxu#zulvw/#wkrxjk#+lw#frphv#zlwk#d# games for. We
frro#odq|dug,/#|rx#zloo#eh#idluo|#olplwhg1 ģƚŸƋƤƵĜŸĘĜƋʱÚ
\hw#wkdw#kdvqġw#uhdoo|#vwrsshg#xv1#Lwġv#oryho|#wr# more storage.

9
wdnh#durxqg#zlwk#|rx/#wkh#edwwhu|#odvwv#iru#djhv#dqg#
fkdujhv#suhww|#txlfno|/#dqg#|rx#fdq#pdnh#vrph#

/10
uhdoo|#ehdxwlixo#vwxļ#iru#lw1#Zh#orrn#iruzdug#wr#vhh#
zkdw#nlqg#ri#jdphv#shrsoh#pdnh#iru#lw1#

PicoSystem magpi.cc 75
REVIEW

UPS HAT For


Raspberry Pi Zero WH
The Pi Hut magpi.cc/upszero From £21 / $24
SPECS

FEATURES:
LiPo battery
Essential battery backup power for your Raspberry Pi Zero. By Phil King

W
recharge
chip, voltage hen you have a Raspberry Pi Zero Note that the UPS HAT will also work with any
boost chip, running constantly for an important Raspberry Pi Zero with a soldered header – so
multiple battery
task, such as to log data from a sensor, long as your soldering isn’t too messy and has
protection
circuits, I2C bus there’s nothing more frustrating than a mains regular peaks to make good connections.
communication power cut. To avoid this, a UPS (uninterruptible
for monitoring power supply) is an essential bit of kit. Battery power
This Waveshare UPS HAT is an interesting Rqfh#Ľwwhg#wr#d#Udvsehuu|#Sl#]hur#zlwk#L5F#
BATTERY:
803040 LiPo option, supplied with a 3.7 V 1000 mAh LiPo enabled, you can power the HAT via its micro USB
battery, battery. Fitting onto a sticky strip on the board, vrfnhw/#wkhq#ľlfn#lwv#rq0erdug#vzlwfk#wr#srzhu#
1000 mAh, 3.7 V the battery has a short cable that plugs into the xs#Udvsehuu|#Sl#Ğ#ru#mxvw#ohdyh#lw#rļ#wr#fkdujh#xs#
board’s mini JST socket. the battery for a while.
CONNECTIVITY:
6 × pogo pins Li#wkh#pdlqv#srzhu#jrhv#rļ/#lwġoo#lqvwdqwo|#
connect to
underside of
You can monitor the switch to battery power. A fully charged battery
should provide power for up to seven hours,
GPIO header
battery level by installing a depending on the Raspberry Pi Zero’s workload.
Naturally, the addition of any connected devices
simple Python program will reduce that time.
You can monitor the battery level by installing
With the battery installed, the board connects d#vlpsoh#S|wkrq#surjudp1#Wklv#vkrzv#wkh#uhdo0
to a Raspberry Pi WH in a novel way: six springy time load voltage, current (negative if battery
pogo pins connect to the solder on the underside power is being used), power, and percentage.
of the GPIO header for power, ground, and While we’ve seen more sophisticated power
I2C pins. This leaves the GPIO header free for management features, such as on the PiJuice, it’s
connecting other HATs on top. a handy tool.

Verdict The battery sticks to


the board and plugs
 ±ŸŞÆåųųƼ{Ĝ¬åųŅĀƋŸŅĹ
top, connected via pogo
into its mini pins and secured with
With a LiPo JST socket ŸƚŞŞĬĜåÚŸƋ±ĹÚŅýŸ
battery included,
it represents
very good value
for money if you
need to keep your
Raspberry Pi Zero
running during a
power outage.

8 /10

76 magpi.cc UPS HAT For Raspberry Pi Zero WH


dip-pi.com

DiP-Pi PICO
Dual In-Line Package Raspberry Pi Pico
Rapid Stackable Raspberry Pi Pico
Add-on Boards
Universal and dedicated metallic cases
for professional as also amateur applications
Plenty of ready-to-use examples written
in MicroPython and C
Just take it, load your software
and the application is ready
Open hardware (schematics)
No need to do any soldering
Extremely easy to use
Ultra-low cost No Cables No Solder No Lost Time

PIoT Power Master Wi-Fi Master

DiP-Pi PICO
Key Feature PIoT Power Master Wi-Fi Master
6-18V Power Input (EPR) Yes Yes -
Battery Power/Charging Yes Yes -
UPS Functionality Yes Yes -
On Board ON/OFF Switch Yes Yes Yes
On Board RESET Switch Yes Yes Yes
On Board ESP8266 Wi-Fi Yes - Yes
MicroSD Slot Yes - Yes
On Board 1-wire Interface Yes Yes Yes
On Board DHT22/21 Interface Yes Yes Yes
Plenty of Informative LEDs Yes Yes Yes

DISTRIBUTORS:
REVIEW

3.7” e-Paper
e-Ink Display for
Raspberry Pi Pico
The Pi Hut magpi.cc/epaperpico From £24 / $28
SPECS

DISPLAY: Pico and e-ink should make the ideal


3.7-inch,
480×280 pixels,
four-level
low-power combination. By Phil King

E
greyscale
-ink displays have long proven useful for
REFRESH: portable Raspberry Pi applications with
3 seconds (full),
low power requirements where the display
0.3 seconds
(partial) doesn’t require rapid updates. Combined with
the lower-power usage and tiny footprint of
DIMENSIONS: Raspberry Pi Pico, an e-ink display makes an ideal
As with all e-ink displays, anything on screen will
95.3×56.9 mm remain there, even with no power
board, combination for projects like a name badge or
47.32×81.12 mm
display area
weather display.
This 3.7-inch Waveshare e-ink display features
It does offer four levels
two female headers on the rear so that you can of greyscale for fairly
simply plug in a Pico (equipped with soldered
male headers). The graphic on the board makes it accurate shading
clear which way round to orientate Pico to avoid
getting the wrong connections. lv#olplwhg#dqg#sulqwv#vrph#wh{w#dqg#d#frxsoh#ri#
The board also features an eight-pin SPI rectangles in portrait mode. The C code – detailed
interface, so can be wired up to a Raspberry Pi in the wiki – uses landscape mode and is more
computer, Arduino, or another microcontroller. h{whqvlyh/#sulqwlqj#wh{w/#gudzlqj#vkdshv/#dqg#
showing a digital clock with seconds counting.
Four shades of grey Wkhuhġv#qr#h{dpsoh#ri#glvsod|lqj#d#elwpds#
While the 480×280 display is monochrome, it does image, however, so you’ll need to perform a bit of
rļhu#irxu#ohyhov#ri#juh|vfdoh#iru#idluo|#dffxudwh# internet trawling to work out how to do it.
Verdict shading. One advantage of the greyscale display
is that it takes less time to do a full refresh than
The rear features female headers to insert a Pico,
plus an SPI interface to connect other boards
The display itself on colour e-ink equivalents (which Waveshare
works well, and also makes): just three seconds. Even better, it’s
is fast to refresh, possible to do a partial refresh of an area of the
but you’ll need to
screen, for instance for updating a digital clock
do some work on
the code to make
display, in a mere 0.3 seconds.
To make the e-ink display work,

7
the most of it.
you’ll need to visit the Waveshare wiki
(magpi.cc/epaperpicowiki), and download a

/10
}ls#Ľoh#frqwdlqlqj#F#dqg#S|wkrq#h{dpsoh#frgh#
dqg#XI5#Ľohv#wr#ľdvk#wr#Slfr1#Wkh#S|wkrq#ghpr#

78 magpi.cc 3.7” e-Paper e-Ink Display for Raspberry Pi Pico


THE BESTSELLING MAG FOR PC HARDWARE, OVERCLOCKING, GAMING & MODDING

PC HARDWARE
ENTHUSIASTS

ISSUE 220 OUT NOW


VISIT CUSTOMPC.CO.UK TO LEARN MORE
RESOURCES

10 Amazing:
Raspberry Pi The Internet of LEGO

LEGO projects Automated LEGO city


‰ĘĜŸĜĹƋåųĹåƋěÏŅĹĹåÏƋåÚÏĜƋƼŸÏ±ŞåʱŸĵ±ĹƼüƚĹÏƋĜŅĹŸÏŅĹƋųŅĬĬåÚÆƼ±ŸŞÆåųųƼ
{ĜØĜĹÏĬƚÚĜĹč±Ƌų±ĜĹØĬĜčĘƋŸØ±ĹÚåƴåű‰üXƋų±ĜĹŸÏĘåÚƚĬåţ

Using LEGO® with Raspberry Pi is QEKTMGGMRXIVRIXSƥIKS

easier than ever – here are some


projects to start with!

L
ast month we reported on the Raspberry Pi
Build HAT, a new add-on that allows you to
connect Raspberry Pi to LEGO systems for more
precise control. People have been interfacing LEGO
with Raspberry Pi for years, though, and here are some
of the best so far...

Hack LEGO Boost


LEGO robotics
8ųŅĵĜŸŸƚåíLjŅüThe MagPiØƵåųåŞųŅčų±ĵĵåÚX):kŅŅŸƋƚŸĜĹčŸŅĵå{ƼƋĘŅĹ
ŞųŅčų±ĵĵĜĹčĜĹƋĘĜŸƋĘųåå쪱ųƋƋƚƋŅųĜ±Ĭţ

QEKTMGGPIKSFSSWX

BrickPi
Bookreader 2
aƚŸĜÏĀč Robotic literature
kĹåŅüƋĘåŅųĜčĜűĬ±ŸŞÆåųųƼ{Ĝ
Toys-to-live X):k±Ú±ŞƋåųŸØƋĘåüŅĬĩŸ±Ƌ%åƻƋåų
ŅĵÆĜĹå8F%Ƌ±čŸØX):kaĜĹĜĀčŸØ±ĹÚ±X):k%ĜĵåĹŸĜŅĹŸƕ FĹÚƚŸƋųĜåŸĵ±Úå±ĬĜƋƋĬåaĜĹÚŸƋŅųĵŸ
ųå±ÚåųرĹÚƼŅƚϱĹųåÏųå±ƋåƼŅƚųü±ƴŅƚųĜƋåƱĹÚŸƵĘŅƵĜĬĬ ųŅÆŅƋƋʱƋŸÏ±ĹĹåÚÆŅŅĩޱčåŸ
ůŞåųüŅųĵűüŅųƼŅƚŅĹƋĘåŸƋ±čåţ ±ƚƋŅĵ±ƋĜϱĬĬƼţ„ĵ±ųƋú

QYWMGƤKGSQ QEKTMGGFSSOVIEHIV

80 ĵ±čŞĜ.cc Raspberry Pi LEGO projects


RESOURCES

LEGO robot face


)ƻŞų域ĜƴåÆĬŅÏĩŸ
‰ĘĜŸ±ĵ±DŽĜĹčŞųŅģåÏƋüųŅĵƋĘ屟ŞÆåųųƼ{Ĝ8ŅƚĹÚ±ƋĜŅĹƚŸåŸ±ŸŞåÏĜĀÏĩĜƋƋŅ
ÆƚĜĬÚ±ųŅÆŅƋü±ÏåƋʱƋĜŸƴåųƼ±ĹĜĵ±ƋåÚ±ĹÚÏƚŸƋŅĵĜŸ±ÆĬåţ

QEKTMGGVSFSXJEGI

X):k±ŸŞÆåųųƼ
{ĜX±ŞƋŅŞ
Retro cool
±ÏĩĜĹƖLjŎƐØƋĘåųåƵ±ŸĹűƋųå±ĬĬƼ±ĹƼ
ĩĜĹÚŅü±ŸŞÆåųųƼ{ĜĬ±ŞƋŅŞŅų±ĬĬěĜĹě
ŅĹ屟ŞÆåųųƼ{ĜÏŅĵŞƚƋåųŸƼŸƋåĵØ
ŸŅ{åƋåųBŅƵĩĜĹŸÆƚĜĬƋĘĜŸŅƵĹŅƚƋ
X):k±ŸŞÆåųųƼ ŅüX):kţ

Pi 3B+ QEKTMGGPIKSTMFSSO X):kc)„±ŸŞÆåųųƼ{ĜϱŸå


Blocky model NES DIY
ŽŸĜĹčŅĹĬƼŞųåěåƻĜŸƋĜĹčX):kޱųƋŸØ ‰ĘĜŸƚŸåÚƋŅÆå±ĩĜƋØÆƚƋĜƋűŸ±ÆĜƋƋųĜÏĩƼƋŅčåƋĘŅĬÚŅüĹŅƵô
ƼŅƚϱĹĵ±ĩåƼŅƚųŅƵűŸŞÆåųųƼ{Ĝ ƼŅƚϱĹŸƋĜĬĬÆƚĜĬÚŅĹåƼŅƚųŸåĬüØƋĘŅƚčĘØĜüƼŅƚÏŅĬĬåÏƋƋĘåųĜčĘƋ
Ɛťô±ĬƋĘŅƚčĘĜƋĵ±ƼĹŅƋŞĬƚčĜĹƋŅ ŸƋ±ĹÚ±ųÚX):kޱųƋŸţ
ƼŅƚųĵŅĹĜƋŅųŸŅ屟ĜĬƼţ
QEKTMGGPIKSRIWTM
QEKTMGGPIKSTM

Robot car
Block chassis
‰ĘĜŸƴåųƼ%F¥ÆƚĜĬÚĜŸ±čųå±ƋŸĘŅƵϱŸåŅüX):kô±ƴåųƼĵŅÚƚĬ±ųϱųƋʱƋƼŅƚ
ϱĹÏʱĹčåƵĜƋĘƼŅƚųĜĵ±čĜűƋĜŅĹţ

QEKTMGGVSFSXGEV

X):kÚ±Ƌ±ŞĬŅƋƋåų
{ŅĬƼčų±ŞĘŅųŸåĜŸĵŅĵåƋåųũ
‰ĘĜŸÏŅŅĬěĬŅŅĩĜĹčŞųŅģåÏƋŞŅųƋų±ƼŸÚ±Ƌ±±ŸƋĘåĬĜĹåŅűčų±ŞĘØüŅų
±čųå±ƋĵŅƴĜåěĬĜĩååýåÏƋţFƋűŸ±ÏƋƚ±ĬĬƼ±ÆĬåƋŅƚŸå±ƴ±ųĜåƋƼŅü
ŸåĹŸŅųĜĹŞƚƋŸţ

QEKTMGGPIKSTPSXXIV

Raspberry Pi LEGO projects ĵ±čŞĜ.cc 81


Join us as we lift the lid
on video games

Visit wfmag.cc to learn more


RESOURCES

Learn crafting and


making with Raspberry Pi
Enhance your crafting and making skills
with these resources. By Phil King

Creativebug
Creativebug Whatever kind of crafting you
AUTHOR

want to try your hand at, this


Price: video-based site is a great place
From $7.95 per month to learn. It comprises a large
creativebug.com collection of craft classes and
workshops on a wide variety of
topics. Crafts covered include
art and design, sewing, quilting, chapters and comes complete class discussion at the bottom of
papercraft, knitting, crochet, with a description and detailed the description page.
food and home (including baking supplies list, downloadable In addition, there’s a pattern
and home décor), and jewellery resources, and even a video library and handy collections of
making. There are also special transcript. So you should have related classes. While there’s a
fodvvhv#iru#fkloguhq#+lq#glļhuhqw# everything needed to start monthly membership fee, you
age ranges) and holiday themes. creating the project, and can can start watching for free to try
Each class is divided into video discuss it with other users in the it out.

Craft on the web


Learn about crafts with these free online resources
CRAFT GAWKER ŞųŅģåÏƋƋƚƋŅųĜ±ĬŸţFüƼŅƚűųå±ÏųŅÏĘåƋ
Like a Pinterest for crafts, this site ĹåƵÆĜåØÏĘåÏĩŅƚƋƋĘåeÆŸŅĬƚƋå
ŅýåųŸ±Ïƚų±ƋåÚŞĘŅƋŅč±ĬĬåųƼŅü åčĜĹĹåų„åųĜåŸŞĬ±ƼĬĜŸƋţ
ŞųŅģåÏƋĜÚ屟ØƵĜƋĘĬĜĹĩŸƋŅƋĘåĜų magpi.cc/blossomcrochet
ŸĜƋåŸüŅųĜĹŸƋųƚÏƋĜŅĹŸŸŅƼŅƚϱĹƋųƼ
ĵ±ĩĜĹčƋĘåĵţ THE SPRUCE CRAFTS
craftgawker.com œĜƋʱƖLjěƼå±ųěŸƋųŅĹčĬĜÆų±ųƼŅüŅƴåų
ĉLjLjLjŞųŅģåÏƋŸüųŅĵ±ƵĜÚåų±ĹčåŅü
BLOSSOM CROCHET Ïų±üƋĜĹčĀåĬÚŸØĜƋűŸ±čųå±ƋŞĬ±ÏåƋŅƴĜŸĜƋ
ŽŞÚ±ƋåÚƋƵĜÏåƵååĩĬƼØƋĘĜŸ¥Ņƚ‰ƚÆå üŅųŸŅĵåĜÚ屟üŅųƵʱƋƋŅĵ±ĩåĹåƻƋţ
ÏʱĹĹåĬĜŸ±Ƌų屟ƚųåěƋųŅƴåŅü thesprucecrafts.com

Learn crafting and making with Raspberry Pi magpi.cc 83


RESOURCES

Maker mine
Wearable
Tech Projects
Useful resources
to improve your
making skills
Sophy Combine sewing skills with
AUTHOR

Wong electronics to create some of


the cool-looking wearable
Price: technology projects featured projects include NFC data
£7 (or free PDF) in this 164-page book from fxļ0olqnv/#d#oljkw0xs#wrwh#edj/#d#
magpi.cc/ Raspberry Pi Press. odvhu0fxw#QhrSl{ho#qhfnodfh/#
wearableprojects
Sophy Wong expertly guides dqg#d#6G0sulqwhg#mdfnhw#prg#
you through the process of with LEDs.
making each item. Starting with Along the way, you’ll discover
the basics of sewable circuits new techniques for working
and LEDs, you’ll work all the zlwk#ideulf/#Ľqg#rxw#derxw#wkh#
way up to building your own best microcontrollers to use for
wearable controller (complete wearable projects, and learn
with feathers!) for an interactive wkh#edvlfv#ri#wkh#FlufxlwS|wkrq# HACKSPACE MAGAZINE
game of Flappy Bird. Other language to program them. kƚųŸĜŸƋåųŞƚÆĬĜϱƋĜŅĹĜŸƋĘå
ŞĬ±ÏåƋŅčŅüŅų±ĵŅĹƋĘĬƼĀƻ
Ņü±ĬĬƋĘĜĹčŸĵ±ĩĜĹčěųåĬ±ƋåÚţ
Xå±ųĹĹåƵƋåÏĘĹĜŧƚåŸüŅų±

The Art of Tinkering ƵĜÚåƴ±ųĜåƋƼŅüƋŅŞĜϟرĹÚ


ÆåĜĹŸŞĜųåÚÆƼƋĘåŞųŅģåÏƋŸ
ŸĘŅƵϱŸåÚåƴåųƼĵŅĹƋĘţ
hsmag.cc
Karen Akin to a Maker Faire in
AUTHOR

Wilkinson, book form, this beautifully


Mike Petrich illustrated tome shares the MAKERSPACE DIRECTORY
magic of the Exploratorium’s a±ĩåųŸŞ±Ï埱ųåčųå±ƋŞĬ±ÏåŸ
Price:
Tinkering Studio in San ƵĘåųåƼŅƚϱĹƚŸå±ų±ĹčåŅü
£24 / $33
Francisco. While it’s more of an ŸŞåÏĜ±ĬĜŸƋĵ±ĩĜĹčåŧƚĜŞĵåĹƋţ
magpi.cc/tinkeringbook
inspiring project sampler than aŅųåĜĵŞŅųƋ±ĹƋĬƼØƼŅƚűĬĬĵååƋ
d#vwhs0e|0vwhs#jxlgh/#lw#vkrxog# ĬĜĩåěĵĜĹÚåÚŞåŅŞĬå±ĹÚĬå±ųĹ
jhw#|rxu#fuhdwlyh#mxlfhv#ľrzlqj1 üųŅĵå±ÏĘŅƋĘåųţ
With insights from over 150 makerspaces.make.co
makers, you’ll learn a lot of
useful tips and techniques,
while being inspired by a HOW TO MAKE
host of impressive projects. EVERYTHING
These include luminous art ‰ĘĜŸƵåĜųÚ±ĹÚƵŅĹÚåųüƚĬ
installations, squishy circuits An amazing bonus is that the ¥Ņƚ‰ƚÆåÏʱĹĹåĬŸĘŅƵŸĘŅƵƋŅ
using conductive dough, book’s cover is printed with ĵ±ĩåƴ±ųĜŅƚŸĘŅƚŸåĘŅĬÚĜƋåĵŸ
electronic poppable papercraft, conductive ink that you can use üųŅĵŸÏų±ƋÏʱĹÚĜĹƴŅĬƴ埱
wearables and textiles, wire to make a circuit for electronics Ęƚčåų±ĹčåŅüĵ±ĩĜĹčŸĩĜĬĬŸţ
work, cardboard craft, and projects, such as adding a FƋűŸüƚűĹÚƼŅƚűĬĬĬå±ųűĬŅƋţ
absurdist automata. battery and LEDs to it. magpi.cc/makeeverything

84 magpi.cc Learn crafting and making with Raspberry Pi


INTERVIEW

Dr Footleg
Hobby maker, father, STEM Ambassador, and… cave
explorer? Dr Footleg has a variety of interests

> Name Paul Fretwell > Occupation Software engineer


> Community role Maker > Twitter @drfootleg

robots, that rekindled my love


of electronics and now I am
designing and making my own
add-ons for Raspberry Pi.”

When did you learn about


Raspberry Pi?
I was quite late discovering
Raspberry Pi. I came across an
article in Computer Shopper
magazine about building a
robot. The article used the
CamJam EduKit 3, and I bought
the kit and a Raspberry Pi
Zero to build a robot with my
kids. That changed my life,
and now I run after-school
robotics clubs and build robots
to show at Raspberry Jams, to
encourage children’s interest in
STEM subjects.

Zkdw#zdv#|rxu#Ľuvw#Udvsehuu|#

L
This chicken coop is ike a lot of great C64,” Footleg tells us. “When I Pi project?
fully automated
nicknames, Dr Footleg graduated, I thought working on A CamJam EduKit 3 robot with
is so named because of computers would be something I a Raspberry Pi Zero. From that
a simple mishearing of his would enjoy, so I bought a ‘teach start, I now have ten Raspberry
surname, resulting in a letter yourself to program in 21 days’ Pi robots, plus several more
addressed to Mr Footleg. After book and started applying for built from kits by children in
getting his PhD in Chemistry, he jobs 21 days later! I’ve always the after-school clubs I’ve run.
upgraded to Dr Footleg. enjoyed designing and making
“I studied science things. It used to be electronics, What’s your favourite thing
academically, but computers before creating designs using you’ve made with Raspberry Pi?
were a hobby right back to computers became a thing. My Mars Rover robot which I
my early teens when we got a After I discovered Raspberry Pi designed for the Pi Wars 2019

86 magpi.cc Dr Footleg
INTERVIEW

The Turbo 4WD was


featured in some of our
#MonthOfMaking coverage

Now I run after-school robotics


clubs and build robots to show at
Raspberry Jams The Sentinel Robot Controller Board was
developed by Footleg for Raspberry Pi robotics

competition. It introduced me to
CAD and laser cutting, which I
had access to having just joined
Makespace Cambridge.

Any other hobbies?


Caving is my main other
passion. I do exploration and
mapping, and underground
Ľoplqj1#L#dp#dovr#d#fdylqj#
leader with the Scouts, and help
run trips to introduce children
to the underground world.

Any other projects you’d like


to highlight?
Other major projects include a
Feather-based lightsaber, and a
chicken coop and run I designed
and built. In the pipeline, I have
an interactive LED cube (based
on a Raspberry Pi 4), several
PCB projects for robotics and
Raspberry Pi power supply, a
3D-printed robot cat, and a
walking spider robot. I am also
building a Raspberry Pi-based
home automation system and
sensors which will put the
chicken coop online so we can
monitor temperature, open and
Rocky Rover is a very
close the door remotely, and see funky robot and was
built for Pi Wars
the chickens from the house.

Dr Footleg magpi.cc 87
THIS MONTH IN RASPBERRY PI

MagPi
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
01
send us amazing photos and videos of the things
they’ve made.
Here’s a selection of some of the awesome things
we got sent this month – and remember to follow
along at the hashtag #MagPiMonday!!

01. This little fake Tamagotchi is probably a lot


more powerful than one of the originals
02. Hedgehogs are Features Ed Rob’s favourite
animal, so he was very excited to see this
03. Raspberry Pi Tower – a place where
Raspberry Pi folk work, and also this cool
tower of Raspberry Pi
04. Flight trackers are a fun way to use
Raspberry Pi
05. This little handheld will be a great way for
students to test their own games
06. An important race but one Zero 2 W
handily wins
07. I wonder if these robots are a little less
creepy in motion
08. We love Raspberry Pi-powered puzzle
boxes, maybe we should make one...

88 magpi.cc MagPi Monday


THIS MONTH IN RASPBERRY PI

02a

02b

03

04

07

05 06

08

MagPi Monday magpi.cc 89


THIS MONTH IN RASPBERRY PI

Halloween 01

projects 2021
Other amazing things from the community
Spooky community builds from
the scariest night of the year
In issue 111, we showed you how to upgrade your
Raspberry Pi projects to be Halloween-ready. Some
02
of our readers already had Halloween plans, and
showed us their morbid makes over on Twitter...

01. Ah! We wouldn’t want that laughing at us


02. Woah! A startling pumpkin indeed
03. Yargh! The spookiest build this year we’ve
seen so far!
04. Eek! This scary project has been put to use
for a good cause 03
05. Oh! A very cool Halloween costume, even if
not very spooky

05

04

90 magpi.cc MondaysProjects
Coolest
Halloween
are
Projects
for Pico
online!
2021
THIS MONTH IN RASPBERRY PI

Crowdfund this! Raspberry Pi projects you


can crowdfund this month
CROWD
A PROFJUNDING
FüƼŅƚ
ECT?
űƴåĬ±ƚĹÏ
Raspb ĘåÚ±
erry P 
projec i-relat
t, let u ed
magp s know
i @rasp !
berryp
i.com

Raspberry Pi Learning Kit Oasis-Grow


This IOT add-on for Raspberry Pi comes with some Node-RED We featured Oasis-Grow in The MagPi ĜĹƋĘåŞųåƴĜŅƚŸĜŸŸƚåرĹÚĹŅƵ
ƋƚƋŅųĜ±ĬŸôƋĘåÆĬŅÏĩxāŅƵÏŅÚåF%)üŅųI±ƴ±„ÏųĜŞƋôŸŅƋʱƋƼŅƚ ƋĘååĹƴĜųŅĹĵåĹƋ±ĬĵŅĹĜƋŅųĜĹčƋŅŅĬĜŸƚŞüŅųÏųŅƵÚüƚĹÚĜĹčúœĘåƋĘåų
can get started with it. It has a serial port, PWM motor control, ƼŅƚʱƴå±ÏŅƚŞĬåŅüĜĹÚŅŅųŞĬ±ĹƋŸŅų±ĵŅųåĵå±ƋƼĵĜĹĜěü±ųĵØk±ŸĜŸě
LEDs, and more! :ųŅƵʱŸŸŅĵåƋĘĜĹčƋŅŅýåųƼŅƚţ

kck.st/3Gp6vG7 kck.st/3mxVDO9
YOUR LETTERS

Your
Letters
‰ų±ƴåĬƋŅÚĜýåųåĹƋĜŸĬ±ĹÚŸ±ĹÚÏųå±ƋåƼŅƚų
ŅƵĹųŅÆŅƋ±ƴ±Ƌ±ųرĬĬƵĘĜĬåĬå±ųĹĜĹčƋŅÏŅÚå

Code Club at home


My child is very interested in
Code Club but can’t actually
attend any of them at the
moment – I also do not have
the skills to actually start one
or help them much. Is there
any kind of 'Code Club at
home' kit that I can get?
‰Ęåk„ƚŸåŸ± Otherwise, is there anything
ŸĜĵŞĬåųĜĹƋåųü±Ïå±ĹÚ
üŅÏƚŸŸåŸŅĹŸƋųŅĹč
else that might help?
ŸŅüƋƵ±ųåŸƚŞŞŅųƋ
Cass via Facebook

More OS Good news, the folks at the


Raspberry Pi Foundation have
Mxvw#iru#|rxu#lqirupdwlrq/#dv#L#frxog#qrw#Ľqg#dq|#phqwlrqlqj#lq#wkh#uhfhqw#^rshudwlqj# opened Code Club World! It’s a
system] article in The MagPi 111, there is yet another Debian derivate for the Raspberry Pi: more online version of Code Club
Q4OS (magpi.cc/q4ospi). zlwk#lwv#rzq#olwwoh#jdplĽfdwlrq#
dfwlylwlhv#wkdw#pdnh#lw#ixq#wr#
Bernhard via email learn, progress, and show what
they’ve made to friends and
Iru#wkrvh#qrw#lq#wkh#nqrz/#T7RV#lv#d#glvwulexwlrq#ri#Olqx{#wkdw#dlpv#wr#rļhu#d#fodvvlf#xvhu# idplo|1#Dqg#lwġv#iuhh$#Fkhfn#lw#rxw#
lqwhuidfh#dqg#rqo|#vlpsoh#dffhvvrulhv#dqg#dssv1#Lwġv#juhdw#iru#forxg#ghyhorsphqw#dv#lw#kdv#orz# at codeclubworld.org.
kdugzduh#uhtxluhphqwv#Ğ#vrphwklqj#Udvsehuu|#Sl#fdq#eh#juhdw#dw1 Doo#Frgh#Foxe#surmhfwv#duh#
Wkhuh#duh#olnho|#rwkhu#Udvsehuu|#Sl#rshudwlqj#v|vwhpv#zh#plvvhg#Ğ#vrph#duh#wulfn|#wr#wudfn# available from the Foundation’s
grzq#dqg#rwkhuv#duhqġw#dlphg#dw#Hqjolvk0vshdnlqj#dxglhqfhv/#vr#duh#pxfk#kdughu#iru#xv#wr# surmhfwv#vlwh#dv#zhoo#li#|rxġg#
review. If there’s an OS or spin for Raspberry Pi you think we should know about, let us know! prefer: magpi.cc/projects.

92 magpiţÏÏ Your Letters


3 ISSUES
‰ĘåĹåƵƵĜĹÚŅƵ
ĵ±Ĺ±čåųÏųå±ƋåŸĹĜÏå
ĬĜƋƋĬåƴĜŸƚ±ĬåýåÏƋŸĜüƼŅƚ
ʱƴå±±ŸŞÆåųųƼ{Ĝ
ƵĜƋĘƖ:ŅųĵŅųå
FOR £5

Bullseye benefits
One of my Raspberry Pi systems has been running for a
while using the Buster version of Raspberry Pi OS. I’ll
ghĽqlwho|#xvh#Exoovh|h#iru#ixwxuh#surmhfwv/#exw#lv#wkhuh#dq|#
real reason to update my other Raspberry Pi? It’s just a
Ľoh#vhuyhu1

Alan via Facebook

With every new version of Raspberry Pi OS – and any


rshudwlqj#v|vwhp#Ğ#frphv#d#orw#ri#olwwoh#vhfxulw|#Ľ{hv#wkdw#duh#
dozd|v#zruwk#jhwwlqj#li#|rxu#Udvsehuu|#Sl#lv#frqqhfwhg#wr#wkh#
lqwhuqhw#lq#dq|#idvklrq1#Iloh#vhuyhuv#hvshfldoo|#duh#pruh#rshq#
wr#dffhvv/#dv#|rx#duh#xvxdoo|#dffhvvlqj#wkhp#ryhu#wkh#lqwhuqhw1
Otherwise, there are loads of updates here and there. GTK+, Subscribe by phone:
01293 312193
zklfk#lv#xvhg#wr#fuhdwh#wkh#xvhu#lqwhuidfh/#kdv#ehhq#xsjudghg#
to GTK+3. There’s also a new window manager, upgraded
qrwlĽfdwlrqv/#dqg#pruh1#Fkhfn#rxw#wkh#ixoo#olvw#ri#xsgdwhv#rq#
the release blog: magpi.cc/bullseye.

Subscribe online:
Contact us! magpi.cc/subscribe
> Twitter @TheMagPi
> Facebook magpi.cc/facebook
> Email magpi@raspberrypi.com
> Online forums.raspberrypi.com Email: magpi@subscriptionhelpline.co.uk
SUBSCRIBE AND

SAVE UP
TO

35%
on the cover price

ISSUE #49

OUT NOW
hsmag.cc
COMPETITION

WIN ONE OF TEN


RASPBERRY PI
<'41ǭ9#0&(.+4%
RASPBERRY PI ZERO
%#5'$70&.'5К
IN ASSOCIATION WITH FLIRC

As seen in our Raspberry Pi Zero


2 W overclocking tutorial on page
52, the FLIRC Raspberry Pi Zero
Case is the perfect case to keep
the processor on Zero 2 cool
while you bump up the power.

Head here to enter: magpi.cc/win Learn more: OCIRKEEƔKTE\GTQ

Terms & Conditions


Competition opens on 25 November 2021 and closes on 16 December 2021ţ {ųĜDŽå ĜŸ ŅýåųåÚ ƋŅ ޱųƋĜÏĜޱĹƋŸƵŅųĬÚƵĜÚå ±čåÚ ŎƐ Ņų ŅƴåųØ åƻÏåŞƋ åĵŞĬŅƼååŸ Ņü ƋĘå ±ŸŞÆåųųƼ {Ĝ
8ŅƚĹÚ±ƋĜŅĹØƋĘåŞųĜDŽåŸƚŞŞĬĜåųØƋĘåĜųü±ĵĜĬĜåŸØŅųüųĜåĹÚŸţœĜĹĹåųŸƵĜĬĬÆåĹŅƋĜĀåÚÆƼåĵ±ĜĬĹŅĵŅųåƋʱĹƐLjÚ±ƼŸ±üƋåųƋĘåÏŅĵŞåƋĜƋĜŅĹÏĬŅŸåŸţƼåĹƋåųĜĹčƋĘåÏŅĵŞåƋĜƋĜŅĹØƋĘåƵĜĹĹåų
ÏŅĹŸåĹƋŸƋŅ±ĹƼŞƚÆĬĜÏĜƋƼčåĹåų±ƋåÚüųŅĵƋĘåÏŅĵŞåƋĜƋĜŅĹØĜĹŞųĜĹƋ±ĹÚŅĹĬĜĹåţ{±ųƋĜÏĜޱĹƋŸ±čųååƋŅųåÏåĜƴåŅÏϱŸĜŅűĬĹåƵŸĬåƋƋåųŸüųŅĵ‰Ęåa±č{Ĝĵ±č±DŽĜĹåţœåÚŅĹűƋĬĜĩåŸŞ±ĵ×
ޱųƋĜÏĜޱĹƋŸűÚåƋ±ĜĬŸƵĜĬĬųåĵ±ĜĹŸƋųĜÏƋĬƼÏŅĹĀÚåĹƋĜ±Ĭ±ĹÚƵŅĹűƋÆåŸĘ±ųåÚƵĜƋĘƋĘĜųÚޱųƋĜåŸţ{ųĜDŽåŸ±ųåĹŅĹěĹåčŅƋĜ±ÆĬå±ĹÚĹŅϱŸĘ±ĬƋåųűƋĜƴåƵĜĬĬÆåŅýåųåÚţœĜĹĹåųŸƵĜĬĬÆåÏŅĹƋ±ÏƋåÚ
ÆƼåĵ±ĜĬƋŅ±ųų±ĹčåÚåĬĜƴåųƼţeĹƼƵĜĹĹåųŸƵĘŅʱƴåĹŅƋųåŸŞŅĹÚåÚƅLjÚ±ƼŸ±üƋåųƋĘåĜĹĜƋĜ±Ĭåĵ±ĜĬĜŸŸåĹƋƵĜĬĬʱƴåƋĘåĜųŞųĜDŽåųåƴŅĩåÚţ‰ĘĜŸŞųŅĵŅƋĜŅĹĜŸĜĹĹŅƵ±ƼŸŞŅĹŸŅųåÚØåĹÚŅųŸåÚ
Ņų±ÚĵĜĹĜŸƋåųåÚÆƼØŅų±ŸŸŅÏĜ±ƋåÚƵĜƋĘØFĹŸƋ±čų±ĵŅų8±ÏåÆŅŅĩţ

Competition magpi.cc 95
ACHTUNG!!!
The MagPi gibt es auch auf deutsch!

Tolles Angebot 10% Discount


und eine Überraschungsbox
Barcode scannen oder auf
www.magpi.de/magpi-deutsch
gehen um mehr zu erfahren.
MagPi112
NEXT MONTH
EDITORIAL
Editor
Lucy Hattersley

GET STARTED WITH


lucy@raspberrypi.com

Features Editor
Rob Zwetsloot

RASPBERRY PI OS
rob@raspberrypi.com

Sub Editor
Nicola King

ADVERTISING

BULLSEYE
Charlotte Milligan
charlotte.milligan@raspberrypi.com
+44 (0)7725 368887

DESIGN
criticalmedia.co.uk

Head of Design
Lee Allen

Designers
Lucy Cowan, Sam Ribbits,
Ty Logan

Illustrator
Sam Alder

CONTRIBUTORS
David Crookes, PJ Evans, Ben
Everard, Rosemary Hattersley,
Nicola King, Phil King

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
BRAN Unit 6 The Enterprise Centre

NEW OD
Kelvin Lane, Manor Royal,
Crawley, West Sussex, RH10 9PE

S
+44 (0)1293 312193
magpi.cc/subscribe

THE MAGPI #113 magpi@subscriptionhelpline.co.uk

ON SALE 16 DECEMBER This magazine is printed on paper sourced


from sustainable forests and the printer
operates an environmental management

Plus!
system which has been assessed as
conforming to ISO 14001.

DON’T MISS OUT! The MagPi magazine is published by


Raspberry Pi Ltd., Maurice Wilkes Building,
Build a weather
magpi.cc/subscribe
St. John’s Innovation Park, Cowley Road,

station
Cambridge, CB4 0DS. The publisher,
editor, and contributors accept no
responsibility in respect of any omissions

Gaming with @TheMagPi


or errors relating to goods, products, or
services referred to or advertised in the

Raspberry Pi magazine. Except where otherwise noted,


content in this magazine is licensed under
fb.com/MagPiMagazine a Creative Commons Attribution-
Build an old school NonCommercial-ShareAlike
3.0 Unported
magpi@raspberrypi.com
Minitel laptop (CC BY-NC-SA 3.0).
ISSN: 2051-9982.
THE FINAL WORD

Bringing it together
Sitting in the middle of a bunch of makers.
By Lucy Hattersley

I
’ve spent the last few days Computer Science platform (funded Ma^FZ`Ibmagazine has always tried
working with the new Raspberry by the DfE’s National Centre for to sit in the middle of this tribe. And
Pi Build HAT and some bumper Computing Education programme.) I’m not wholly convinced they are that
packs of bricks kindly supplied. Like It also makes a huge range of separate. After all, today’s hobbyist
most makers, I loved LEGO® as a kid. educational projects, which you will maker is tomorrow’s professional
Either when following instructions rffdvlrqdoo|#Ľqg#lq#Ma^FZ`Ib. developer. And most people who work
to build Technic trucks or working The Build HAT is one of those with computers enjoy computers on
free-form to build planes, houses, or fantastic products with a foot in both the side. You never stop learning.
‘abstract sculptures’. camps. Raspberry Pi Trading can be The engineering side of Raspberry Pi
LEGO hadn’t quite become the is growing, and we are increasingly
modern iteration: with its movie Twelve-year-old me coming across projects with a
tie-ins and themed sets. And it’s professional bent. I looked at the
been interesting to pick up LEGO would have loved this Midas display screen this month and
again at a later age, and discover just realised just how often I see screens in
how much of it has changed. Mostly rightly proud of developing such a stores, transport hubs, and on the
for the better. fantastic product, and the Raspberry streets. A huge number of them
One thing I love about Build HAT Pi Foundation is using Build HAT to moving forward are going to be
is that it bridges the gap between create incredible learning experiences powered by Raspberry Pi. Modern
Raspberry Pi the computer, and for children (of all ages). Adding the manufacturing facilities, storage
learning to code with Raspberry Pi. computing power of Raspberry Pi to areas, and delivery trucks are packed
This is the intersection where control LEGO with Python is sublime. with sensors feeding back data on
Ma^yFZ`Ibsits. I keep thinking ‘Twelve-year-old me heat, movement, and location. The
Many people don’t know that would have loved this.’ low-cost, low-energy requirements,
Udvsehuu|#Sl#lv#wzr#glļhuhqw# Still, you don’t have to be twelve and stable Linux support of Raspberry
organisations. There’s Raspberry Pi, years old to love LEGO. Frankly, you Pi make it perfect for these uses.
which designs and makes the can improve your coding skills at Wherever you are in your Raspberry
computers, and components like the any age, so why not have fun with Pi journey, you can be sure Ma^FZ`Ib
Build HAT. And there’s the bricks while you’re at it? pdjd}lqh#zloo#pdnh#hyhu|#hļruw#wr#eh#
Raspberry Pi Foundation, the charity there with you.
that works to put physical Engineering success
computing in the hands of people all There’s another intersection at work
Lucy Hattersley
AUTHOR

over the world. It runs the network in Ma^FZ`Ib. On the one side of a
of clubs and events and provides Venn diagram are the learners, the Lucy is editor of The MagPi and
computer science courses and makers, and hobbyists; and on the is hassling her cat with various
curriculum materials to students other the engineers, developers, and ÆųĜÏĩěƋĘåĵåÚƤåĹÚå±ƴŅƚųŸţ

and teachers, and the Isaac professional ‘doers’. magpi.cc

98 magpi.cc Bringing it together


Sɟ͝ʡʄ˱

H́Ɏɟ

H́˱ɿʡʄͽ̿ɟ

˱ǵˍΰφɟ

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 TOO L

Home projects made easy.


CDP Studio, a great software development tool for your home projects. Build
͝ΰͮ͝ɟ˪͝‫ڂ‬ɿ́̿‫ڂ‬żǵ̵͝Ȼɟ̿̿ΰ‫ڂ‬Ŵʡհ‫͝ͽڂ‬ɟ‫ڂ‬H֕֕‫ڂ̿́ڂ‬ĩ́H́Ɏɟ‫̵́̿ڂ‬ʄ̿ǵ˪˪ʡ˱ʄհ‫̵́ڂ‬ɟ˱‫̿ͽ́͝ڂ‬ɂɟ‫ˍڂ‬ʡȻ̿ǵ̿ʡɟ͝հ‫ڂ‬
out of the box support for GPIO, I2C, MQTT, OPC UA and more. Create beautiful user
interfaces. Built for industrial control system development, FREE for home projects.

cdpstudio.com
Ɨɟˍմ‫ڂ‬ֈԊԎ‫ڂ‬ԐԐԅ‫ڂ‬ԏԅ‫ڂ‬Ԑԅԅ‫ڂ‬՘‫ڂ‬ʡ˱ɿ́ԺɂɎ̵ͮɟɂʎձɂ́˪
HSŴ‫ڂ‬Ɨɟɂʎ˱́ˍ́ʄʡɟ͝‫ڂ‬Ɖ‫ڂ‬ՄՄ‫˱ͽ ڂ‬Ɏ͝ΞȘ̿ʄǵͮǵ‫ڂ‬ԏհ‫ڂ‬ԍԅԅԏ‫ˍڂ‬ɟ͝ͽ˱Ɏհ‫ڂ‬ĩ́̿΢ǵΰ
HIGHPI PRO
The new case from the HiPi.io team

Rapid tool-free assembly and disassembly Secure microSD card cover


Large internal volume for HATs VESA mount support
Compatible with Pi 2/3/4 Molding-configurable output ports
Multiple lid options customizable for volume orders
Passive & Active Cooling options Printed logo for your branding

Available at these great Pi stores:

Contact your favorite Pi store if it’s not listed here

You might also like