Mag Pi 142

Download as pdf or txt
Download as pdf or txt
You are on page 1of 100

YOUR OFFICIAL RASPBERRY PI MAGAZINE

Issue 142 June 2024 magpi.cc The official Raspberry Pi magazine

BUILD A
R ASPBE RRY PI 5
ME DIA PL AYE R
 High-quality audio  Massive M.2 storage  Stream anything

£5.99

Building an Code a budget tracker TOP 10


RC plane display in Python gaming accessories

HOW RASPBERRY PI BUILT A SILICON DESIGN TEAM


Industrial Raspberry Pi
ComfilePi
WELCOME

WELCOME
to The MagPi 142

T
his month the sun is shining on a couple of new
Raspberry Pi productions. We’ve got Raspberry Pi
Connect (page 12) and new Compute Module 4S
boards with up to 8GB of SDRAM and 16GB eMMC
storage (page 14). Lucy

EDITOR
Raspberry Pi 5 now has super-fast SSD storage, and PJ has Hattersley
celebrated by making an all-new media player (page 36). Lucy is the editor
of The MagPi come
This one is much faster than its predecessor, and is perfect rain or shine.

for video streaming, movie file playback, and high-quality magpi.cc

audio. It truly is the best media player you can build.


Because the sun has got its hat on, we’ve got a range of
summer projects to share with you (page 72). Everything from
bird smart bird feeders, machine learning cameras and tide
and weather trackers, to portable computer backpacks. There’s
even a rain detector that – with any luck – we won’t need.
Have great fun with these projects. There’s a lot going on in
GET A
the world of Raspberry Pi, and we can’t wait to see what you
RASPBERRY PI
build with it all.
PICO W
Lucy Hattersley Editor
PAGE 34

magpi.cc 03
CONTENTS

Contents
> Issue 142 > June 2024

Cover Feature

36 Build a Raspberry 36
Pi 5 media player
Regulars

08 World of Raspberry Pi
30 Case Study: EpiSensor
90 Your Letters
92 Community events calendar
97 Next month
98 The Final Word

Project Showcases
16 sprinklR irrigation
28
20 Audiophile Pi
22 Mini Dexed
26 Cat TV
28 RC plane OSD

26

Cat TV RC plane OSD

The MagPi is published monthly by Raspberry Pi Ltd, 194 Cambridge Science Park, Milton Road, Cambridge, England, CB4 0AB. Publishers
Service Associates, 2406 Reach Road, Williamsport, PA, 17701, is the mailing agent for copies distributed in the US and Canada. Application to
mail at Periodicals prices is pending at Williamsport, PA. POSTMASTER: Send address changes to The MagPi, c/o Publishers Service Associates,
2406 Reach Road, Williamsport, PA, 17701.

magpi.cc 05
CONTENTS

Tutorials 56 60
42 Learn Python data structures
48 Program in Scratch
56 Motion control a robot arm
60 Rescue your old backups
64 Build a KiCad RP2040 Controller Motion control a robot arm Rescue your
Xxxxxxxxxxxx
old backups

The Big Feature 78


72

CrowVi display

84
Summer projects

Reviews
78 CrowVi display
80 Ten amazing gaming accessories
82 Learn networking
Community
84 What’s Ken Making interview
86 This Month in Raspberry Pi What’s Ken Making interview

WIN M.2 HAT+ 94

1 OF 10
DISCLAIMER: Some of the tools and techniques shown in The MagPi magazine are dangerous unless used with skill, experience, and appropriate personal protection equipment. While
we attempt to guide the reader, ultimately you are responsible for your own safety and understanding the limits of yourself and your equipment. Children should be supervised. Raspberry
Pi Ltd does not accept responsibility for any injuries, damage to equipment, or costs incurred from projects, tutorials or suggestions in The MagPi magazine. Laws and regulations covering
many of the topics in The MagPi magazine are different between countries, and are always subject to change. You are responsible for understanding the requirements in your jurisdiction
and ensuring that you comply with them. Some manufacturers place limits on the use of their hardware which some projects or suggestions in The MagPi magazine may go beyond. It is
your responsibility to understand the manufacturer’s limits.

06 magpi.cc
Design

Code

Configure

Analyze

PR O FES S I O N A L CO N T R O L SYS T E M D E V E LO PM E N T TOO L

Home projects made easy.


CDP Studio, a great software development tool for your home projects. Build
systems for Raspberry Pi, use C++ or NoCode programming, open source libraries,
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
Tel: +47 990 80 900 • info@cdptech.com
CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
THE WORLD OF RASPBERRY PI

How Raspberry Pi built


a silicon design team
We meet Raspberry Pi’s ASIC design team
to talk about chip design. By Lucy Hattersley

A longside building single-board


computers and microcontroller boards,
Raspberry Pi is heavily involved in silicon
design. For nearly ten years now Raspberry Pi
has been building an ASIC (application-specific
making it ideal for controlling electrical current. It
is turned into silicon wafers, which have patterns
etched onto them to create integrated circuits.
An integrated circuit (IC) also known as a
silicon chip, microchip, microelectronic circuit or
integrated circuit) team in Cambridge to design computer chip, is an integrated system of multiple
and produce custom silicon chips for its products miniaturised and interconnected components
Tammy This intricate process involves designing embedded into a thin substrate of semiconductor
Julyan integrated circuits on a silicon wafer. We sat down material. ICs are made up of millions of tiny
with Tammy Julyan, ASIC Engineering Director and transistors. They have many different functions,
ASIC Engineering
Director Nick Francis, ASIC Technical Director to chat about and can be found in products ranging from
Tammy has worked Raspberry Pi’s ASIC team, and how they go about automotive, computing, and medical equipment.
with Raspberry Pi designing silicon chips. It’s a fascinating deep dive Silicon design is specifying, designing and
for nine years and is
into bare metal computing. testing an IC. It also involves creating the physical
responsible for the
tiny Raspberry Pi Raspberry Pi makes computers using layout of the chips’ circuits. This consists of a
logo on the silicon. components like the Broadcom BCM2712 team of skilled engineers working together using
System-on-Chip, Renesas DA9091 power their expertise to ensure the final design meets the
management unit, and Infineon CYW43455 original requirements.
Bluetooth and Wi-Fi chip. The first step is the specification. Requirements
However, for the last 10 years Raspberry Pi has can come from several sources, an innovative
also been designing its own chips, such as the new idea, customers, internal product needs,
RP2040 microcontroller found in Raspberry Pi Pico and marketing forecasts. For example: RP1 was
and the RP1 I/O controller found in Raspberry Pi 5. designed to hang off the main processor as a
These contain smaller blocks, often referred to as southbridge, handling most input and output
IP (intellectual property) designed by Raspberry Pi capabilities for Raspberry Pi 5. It controls the
Nick or bought in from elsewhere and integrated into camera, display, Ethernet, USB, and GPIO (see
Francis Raspberry Pi’s chips. magpi.cc/rp1doc).
“We start with a team of people from across
ASIC Technical
Director Integrated circuits the different groups including software, hardware
Nick has been with Silicon is basically sand, which is the world’s and management to discuss a new chip: ‘let’s
Raspberry Pi for most abundant element after oxygen. Silicon is make X to do Y’,” says Tammy. Architecting a
seven years and
has worked on a semiconductor, which means it can conduct new chip is an iterative process, and the whole
RP1 and RP-2040. electricity under some conditions but not others, team will meet multiple times to discuss what the

08 magpi.cc How Raspberry Pi built a silicon design team


THE WORLD OF RASPBERRY PI

S RP1 is a 12×12mm,
“shape and feel of the thing” needs to be. Many Verilog” explains Nick. It is a bit like C but “it 0.65mm-pitch BGA
factors are considered: performance, timescales, doesn’t execute in order; it executes all at once”. southbridge, which
provides the majority
make vs. buy, interfaces, features, power, board- Verilog is a hardware description language (HDL), of the I/O capabilities
level design, and software. that describes in code how the circuit functions. for Raspberry Pi 5

Most devices are system-on-chips (SoCs), they


have a controlling processor, some memory, and Testing the design
some peripherals which perform functions such as Once the design is complete you have to test that
data processing or an interface to the rest of the it works as expected before it is committed to
system. “You need to consider how these blocks manufacture, this activity is known as verification.
communicate with each other and what software Verification is a huge part of the silicon design
will run to control the system. The ASIC team also process: “I think the biggest difference is that
needs to consider a whole host of other things software – even if it’s well tested – can be more
like how to start up the device, what clocks are easily changed afterwards,” says Nick. So “most
running, how to cross clock domains. There’s a of my time is spent testing”.
Software code, either C or Verilog, is written to
 nce you’ve got a list of
O stimulate the design and the output is checked.
This testing can be at the block or chip level,
requirements you start normally done through simulation.
Some block or chip-level testing uses
to build the reality constrained random techniques to generate test
conditions that are hard to predict. “We can run
very long list. So now you have an architecture and many of these random tests to help find corner
can start to build your chip.” case issues.”
Some of the blocks Raspberry Pi may already As well as simulation tools, FPGAs (field
own, and can be reused from a previous design, programmable gate arrays) are used to test the
while some the design team needs to build from design. An FPGA is physical hardware that can
scratch or buy. However buying in a block – or be reconfigured to emulate different hardware
IP – isn’t an easy process: they need to choose circuits, this enables testing to take place in near-
the right vendor, configure the block correctly, real-time in hardware (instead of being simulated
integrate and verify it. in software, which is much slower, being limited
“Chip design is written in a language called by available processing power). FPGAs are useful

How Raspberry Pi built a silicon design team magpi.cc 09


THE WORLD OF RASPBERRY PI

X An example IC layout
created with a place
and route tool

for system integration testing and software


development before the chip is available.
Once the design is functioning as expected,
the HDL needs to be converted into a physical
design which is a representation of the geometric
shapes that will create the tiny transistors and
connections on the final chip.
Extra functionality is added to the design to
support manufacturing tests to check for defects
that could affect the correct operation of the
IC. Some of these extra Design For Test (DFT)
functions are structural and are inserted using
T A silicon wafer
containing an array tools which also generate test patterns to test
of integrated circuits. logic cells, and some are internal Built In Self
This is cut to produce
the individual chips Test (BIST) engines to test things like memory. design constraints) and libraries: for example,
To convert the HDL, it is loaded into a synthesis logic gates, memories and analogue blocks. The
tool along with a timing synthesis tool converts the Verilog into a gate-level
constraints file called netlist which is functionally equivalent to the HDL
SDC (standard description, making architectural decisions based
on how fast the design needs to run, while also
considering the power and area to get the most
optimal design.
After synthesis, the gate-level Verilog netlist
is loaded into a ‘place and route’ tool where a
floorplan is created, positioning the memories,
analogue blocks and any IO. A metal power grid
is added to feed the gates with power across the
floorplan. The standard cells are then placed in
rows by the place and route tools, the metal wires
connecting up the standard cells, memories, etc are
routed. The tool continuously checks timing and
when possible fixes any slow paths. The physical
design is checked to make sure it is functionally
correct, meets the timing requirements and can be
manufactured correctly. When complete this is sent
to the wafer foundry to be manufactured.
The “manufacturing process itself is
interesting,” says Tammy. The physical design
is translated into a set of masks, the number
of which increases as technology advances.

10 magpi.cc How Raspberry Pi built a silicon design team


THE WORLD OF RASPBERRY PI

 aspberry Pi has developed from the


R
ground a highly talented design team

S A semiconductor
They grow the silicon crystal by dipping a ‘seed
Hear about RP1
Wafer after the
crystal’ into molten silicon until it turns into dicing process.
Silicon dies are being
a large cylindrical ingot. Then they are sliced extracted by pick
thinly into wafers, ground and polished. Once and Place Machine
Raspberry Pi’s founder and CEO, Eben Upton and
the wafers are created they go through multiple Chief Technology Officer James Adams discuss RP1
process steps to create the IC. Photolithography is in a video on Raspberry Pi’s RP1 documentation
used to transfer the geometric patterns from the page. RP1’s datasheet has detailed information about
mask onto a photosensitive layer applied to the Raspberry Pi’s RP1 silicon chip.
wafer, and in addition to oxide growth, etching,
deposition, ion implantation and metalisation
the IC is created. When complete, the wafer is
covered in rows of ICs which need to be divided
up into individual chips by sawing and placed
in their packages. Once packaged they are
tested to ensure nothing has gone wrong in the
manufacturing process.
Ten years ago Raspberry Pi had no ASIC design
capability, and since then it has developed from
the ground a highly talented design team. We look f magpi.cc/rp1doc
forward to seeing what they create next.

How Raspberry Pi built a silicon design team magpi.cc 11


THE WORLD OF RASPBERRY PI

Introducing
Raspberry Pi Connect
Remote control Raspberry Pi from around the world.
By Gordon Hollingworth, Raspberry Pi CTO (Software)

W e’re pleased to announce the beta


release of Raspberry Pi Connect
(magpi.cc/connect): a secure and
easy-to-use way to access your Raspberry Pi
remotely, from anywhere on the planet, using
machine on a different local network; and of course
with the transition to Wayland in Raspberry Pi OS
Bookworm, classic X remote desktop support is no
longer available.
We wanted to be able to provide you with
just a web browser. this functionality with our usual ‘it just works’
It’s often extremely useful to be able to access approach. Enter Raspberry Pi Connect.
your Raspberry Pi’s desktop remotely. There
are a number of technologies which can be used How do I get Raspberry Pi Connect?
to do this, including VNC, and of course the X First of all, Raspberry Pi Connect needs your
protocol itself. But they can be hard to configure, Raspberry Pi to be running a 64-bit distribution of
particularly when you are attempting to access a Raspberry Pi OS Bookworm that uses the Wayland

12 magpi.cc Introducing Raspberry Pi Connect


THE WORLD OF RASPBERRY PI

window server. This in turn means that, for now,


you’ll need a Raspberry Pi 5, Raspberry Pi 4, or
Raspberry Pi 400.
 ur intention is that Raspberry Pi Connect
O
Assuming you’re using one of these models,
make sure you have the latest Raspberry Pi OS
will remain free for individual users
Bookworm from Raspberry Pi Imager, open a
terminal, and enter: “If for any reason it is not possible to establish
a direct connection between your browser and
sudo apt update Raspberry Pi device, rpi-connect and your browser
sudo apt upgrade may instead opt to securely relay traffic through
sudo apt install rpi-connect our servers, encrypting it with DTLS.”

Now reboot your Raspberry Pi, and you’ll find Peer-to-peer and relayed connections
a new icon in your system tray at the top right of At the moment, the Raspberry Pi Connect service
your screen. Click this icon and choose ‘Sign in’ to has just a single relay (TURN) server, located in the
get started. Hopefully you’ll find the instructions UK. This means that if rpi-connect chooses to relay
easy enough to follow, but if you need it, there’s traffic, the latency can be quite high. Hovering over
extra documentation that covers known limitations the padlock icon in your browser while connected
during the beta. will reveal whether your connection is being
relayed or not, so you can tell whether changes to
What happens under the hood? your networking setup might improve connectivity.
I asked Paul Mucur, who runs web development Our intention is that Raspberry Pi Connect will
at Raspberry Pi, to explain how the underlying remain free (as in beer) for individual users with
technology works: non-relayed connections, with no limit on the
“When you use Raspberry Pi Connect from a web number of devices. We don’t yet know how many
browser to connect to your Raspberry Pi device, people will need to relay their traffic through
we establish a secure peer-to-peer connection our TURN servers; we’ll keep an eye on the use
between the two using WebRTC: the same real- of bandwidth and decide how to treat these
time communication technology that underpins connections in future.
the in-browser clients for Zoom, Slack, Microsoft As I said at the beginning, Raspberry Pi Connect
Teams, and Google Meet,” he says. is in beta at the moment, so please bear in
“Our ‘rpi-connect’ daemon for Raspberry Pi mind that you might come across the occasional
OS is responsible for listening out for new screen limitation or imperfection. We think lots of
sharing sessions from the Raspberry Pi Connect people will find it useful, and we hope you like
website, and negotiating the best possible, or the sound of it enough to follow the instructions
lowest latency, connection between the in-browser above or in the Connect documentation to install
VNC client and a VNC server running on your it and try it out. You can let us know what you
device. In general, once a connection is established, think in the Raspberry Pi Connect section of
no traffic need pass through our servers. our forums (magpi.cc/forum).

Introducing Raspberry Pi Connect magpi.cc 13


THE WORLD OF RASPBERRY PI

Industrial
Compute Module 4
upgraded!
New memory variants for the Raspberry Pi Compute Module family are
ready for industrial applications. By Dave Lee

W Raspberry Pi Compute
Module 4S is an industrial
computer built around
Raspberry Pi 4 technology
with up to 16GB of onboard
eMMC storage

S ince 2014, we have provided the power


of Raspberry Pi in a flexible form factor
designed specifically for industrial
and embedded applications, and we’ve been
surprised and delighted to see the incredible
variety of ways in which industrial customers
use Raspberry Pi Compute Modules. We are
pleased to announce that we have expanded our
Compute Module 4S offering (magpi.cc/cm4s):
these industrial boards are now available with
additional SDRAM, and as well as the original
1GB variant, you can now choose from 2GB,
4GB, and 8GB options.
Compute Module 4S is based on Raspberry
Pi 4’s architecture. We designed it for
industrial customers who are migrating

14 magpi.cc Industrial Compute Module 4 upgraded!


THE WORLD OF RASPBERRY PI

W Compute Module
4S Lite variant
has no onboard
eMMC storage,
which is better for
some industrial
from Compute Module 3 or Compute Module 3+ users’ needs
(magpi.cc/cm3plus), and who are looking to
retain the same form factor but would like greater
computing power and more memory.
Industrial customers have used these
We will keep Compute Module 4S in production boards in everything from self-pour beer
until at least January 2034, and we have produced
a transition document specially to help users taps to electric vehicle charging stations
migrate to it from Compute Module 1, Compute
Module 3, or Compute Module 3+. A full product
brief (magpi.cc/cm4sdoc) and datasheet These modules are supplied only in bulk 200-unit
(magpi.cc/cm4sdata) are also available. boxes, with prices per unit starting from $25 in the
Compute Module 4S boards are in stock and US. Find your local Raspberry Pi Approved Reseller
available now from our Approved Resellers for for industry (magpi.cc/resellers) and contact them
industry, with a maximum lead time of six weeks. directly to discuss sales.

What is Compute Module 4S used for?


Our industrial customers have used these boards
in everything from to self-pour beer taps
(magpi.cc/ipourit) and coffee machines to
electric vehicle charging stations. We’ve also
seen specialised medical monitoring devices
(magpi.cc/biobusiness) built around our Compute
Modules. A market research customer of ours used
the modules to develop a system that understands
the types of TV programmes different people
enjoy watching, and Kunbus has developed an
entire industrial product line around our Compute
Module, the Revolution Pi (magpi.cc/revolutionpi).
You can browse our customer success stories
(magpi.cc/success) for plenty more examples of
all types of Raspberry Pi product in use in business
and industry. You’ll find everything from farming
and factory automation to digital signage and
earthquake monitoring. And to make sure you don’t W The Kunbus
miss any news about Raspberry Pi for industry, sign Revolution Pi is an
industrial product
up to receive our quarterly updates for business line built around
customers (magpi.cc/industryemail). Compute Module 4

Industrial Compute Module 4 upgraded! magpi.cc 15


PROJECT SHOWCASE

sprinklR
irrigation
Keen computer programmer Mark made use of Raspberry Pi to
create his own automatic watering system. By Rosie Hattersley

A utomatic watering systems that tend to


your plants’ irrigation needs cost only
around £30 and work perfectly well.
As maker Mark Niemann-Ross points out, they
reliably turn on and off, sprinkling thirsty crops
when the season demands.
Unfortunately, they score far less highly for
Mark longevity: replacing a worn-out system every year
MAKER

Niemann-Ross or two soon becomes an uneconomical chore.


Such a system can be made smarter with internet
Mark has written connectivity, but this adds roughly $100 to the cost,
several books about
using technology, and the system invariably still falls foul of harsh
particularly the winters. Mark’s DIY irrigation project uses Raspberry
R programming Pi Zero WH and a cheap, but clever, waterproof
language.
housing to ensure it lasts year after year.
niemannross.com
Harsh environment
T Components and code
Portland, Oregon-based Mark has an urban garden were tested over several
that needs to be irrigated each summer. Judging days in a prototype design
from the description of his irrigation system, the
garden is a little larger than the 30-foot back
lawns often attached to suburban UK homes.
Commercially available timers provide reliable
irrigation, but Mark found they don’t last: “If you
Warning! forget to bring them in during the winter, they
Water & Electricity
freeze and break. After a few years, the plastic
Running water and valves wear out and they jam closed (bad for
electrical currents can plants) or jam open (bad for water bills). They
seriously damage your
beloved tech hardware! don’t adjust to rain or hot weather.” Pricier, more
Follow Mark’s lead
and encase your plant
robust timers plus web connectivity to check the
irrigation device in a weather forecast work better but still fail. Mark
waterproof housing such
as a sealed glass jar. had several Raspberry Pi boards at home, and
decided to put them to good use. Having written
magpi.cc/
electricalsafety extensively about Raspberry Pi as well as coding

16 magpi.cc sprinklR irrigation


PROJECT SHOWCASE

Mark’s R-based automated Raspberry Pi Zero WH, kept secure and


irrigation system uses standard dry in a sealed upturned Mason jar, checks
irrigation valves from a hardware store Open-Meteo’s weather forecast and
adjusts the water flow accordingly

Quick FACTS
A single line of R code
initiates plant watering once > The system runs
each evening and monitors off a 1 amp 5v
usage for billing purposes phone charger

> It is set to water


Mark’s plants
daily at 6pm

> But checks


the weather
forecast first

> Mark is now


planning to
automate feeding
his chickens

> With each chicken


having its own
RFID tag

W A web dashboard Mark


created shows rainfall
trends and his irrigator’s
status

sprinklR irrigation magpi.cc 17


PROJECT SHOWCASE

using R (see his blog at niemannross.com), the


combination seemed obvious, although R is a less
common choice of programming language. “My
preferred language is R, which I can run from a
Linux operating system, but not from MicroPython
or C. Irrigation only happens once a day, so I don’t
need speed. What I need is the most convenient
way to express my logic to Raspberry Pi.” Using
Raspberry Pi Zero WH as the controller “makes
it easy to connect to the internet and the headers
 ouseholds can reduce their
H provide a convenient way to connect relays and
buttons,” he explains.
water usage by roughly
Bits and pieces
7600 gallons a year Creating his irrigation system involved assembling
lots of fairly standard components and a certain
amount of planning. Prior knowledge of plumbing
and electronics is helpful, Mark observes. The
planning aspect required Mark to work out how
much rainfall was likely to offset the total number
of gallons of water his garden would need and how
long the valves would need to be open at a time.
He calculated the rate at which his house pipes
could pump water to the irrigation valves (and the
putative number of gallons per hour) as well as the
voltage required for the relays to deliver it.
To see whether his idea would work Mark
began by screwing irrigation valves, two servos
and Raspberry Pi needed to power the system, as
well as a Raspberry Pi Zero, on to a piece of wood.
“There isn’t any water connected to the system at
this point – I’m only trying to test the electronics
and develop and test the code.”
After writing and testing the code on Raspberry
Pi he “ran it with the relays for days without any
valves connected, then tested the plumbing in a
sink before I attached it to the board”.
The US Environmental Protection Agency
estimates 28 million US homes have an automated
watering system, and that households can reduce
their water usage by roughly 7,600 gallons a
year using a weather-based system to gauge
requirements (magpi.cc/irrigationepa). Mark
wanted to see whether he got realistic readings,
and how well the system performed, before
deciding to risk linking it up with his water meter
X Mark designed a for billing. He continues to tweak and update it and
robust replacement
for a commercial
is delighted with just how well his $75 irrigation
irrigation system system is performing.

18 magpi.cc sprinklR irrigation


PROJECT SHOWCASE

Thirsty work

Mark documents setting up his irrigation system


01 at magpi.cc/sprinklrwiki including setting up
the power supply, servos and valves and using R
code on Raspberry Pi to implement daily watering.

An upturned Mason jar provides a useful means


02 of waterproofing the electronics, with cables
fed up through the board and the jar’s sealed lid.

Code running on Raspberry Pi pulls weather


03 data from Open-Meteo to help determine
how much water the plants need.
S Daily irrigation helps keep plants in Mark’s garden healthy

sprinklR irrigation magpi.cc 19


PROJECT SHOWCASE

Audiophile Pi
Alan Boris’ low-cost, high-quality DIY audio streamer
hits all the right notes, as David Crookes discovers

A udio streamers don’t come cheap. You


could easily spend between £500 and
£1,000 for a decent high-end model.
But, as Alan Boris has found, there’s a far less
expensive alternative that won’t look out of place
“I figured they just play back digital audio so
I started looking at DIY options. I knew I wanted
a standard-sized stereo component and decided
an old stereo tuner would be reasonably-priced
because they are not in very high demand, even
in a standard audio system. By snapping up an old among audiophile collectors.”
FM radio stereo tuner – a Sony ST-JX411 dating
Alan back to 1991 – and making use of a Raspberry Pi 4, Treble buy
MAKER

Boris he’s been able to create his own, modern network Alan purchased three Sony ST-JX411s so that he
music streamer that can be controlled by buttons could mix-and-match the best looking parts
Alan Boris is on the front panel. (“most were dented and dirty,” he says). He liked
a technology
executive,
As someone interested in giving old tech a new its look and noted it had space for a decent-sized
entrepreneur, lease of life, the idea came naturally. “I was inspired LCD. “The Sony tuner has a retro vibe but doesn’t
software developer by the many high quality network audio streaming look too dated, and it fits in with much of my
and hardware
devices sold by the major stereo component brands second hand stereo equipment,” he says. “I also
experimenter who
loves Raspberry Pi, such as Sony, Cambridge Audio, NAD and so on but I thought that a repurposed tuning knob would be a
home automation couldn’t justify the cost,” he explains. nice touch for a streaming player – few attractive
and software- modern tuners have one.”
defined radio.

magpi.cc/
T he Sony tuner has The front panels were important. “I wanted to
play a playlist or start and stop the device without
audiophilepi
a retro vibe but doesn’t using a web interface on my computer or phone,”
he explains. “Another requirement was for an
look too dated alphanumeric display for the currently playing
song, title and file format. Since my amplifier
already had a digital-to-analogue converter [DAC],
I wanted quality digital audio – S/PDIF – too.”
For the audio quality, Alan chose a HiFiBerry
Digi2 Pro which uses the I2S sound port for S/PDIF
audio output (without a DAC, he’d have opted for
a DAC HAT such as the Raspberry Pi DAC Pro). To
connect everything together, he used a small proto
PCB board with some male headers. “That way I
could use female-to-female jumpers to connect to
the Pi GPIO pins,” he says.

Setting the tone


Alan retained the logic board which houses the
S Alan would like to add text scrolling to the display for longer titles
front-panel buttons. “The main challenges related
and to keep it in the selected mode when the song changes to reverse-engineering these buttons and I’m

20 magpi.cc Audiophile Pi
PROJECT SHOWCASE

Quick FACTS
> The project uses an
old stereo tuner

Raspberry Pi is connected to > Alan says you


the HiFiBerry Digi2 Pro and an can buy them for
Adafruit Standard 16×2 LCD $5 to $15

> It’s fitted with a


Raspberry Pi 4 4GB

> It will stream music


from a network

> Speakers need


to be connected

The original Sony ST-JX411


case has been retained and
provides plenty of room for
the new components
The audio tuning knob uses the
original switches and functions as
an intuitive previous/next control

not sure I would have accomplished the project


without a schematic diagram I found online,” Alan
continues. As it was, Alan was able to read row and
column values, reducing the number of wires from
17 to 11. He also replaced the logic board’s vacuum
fluorescent with a new alphanumeric LCD, and
Raspberry Pi’s ports were extended to the tuner’s
back panel.
To control the functions, Alan used the open-
source project moOde. “I had already been using
moOde on Raspberry Pi 4 and I was happy with its
features and audio quality,” he says. “I also liked
S The back of the unit
the simplicity of the moOde API, so I didn’t have to remains as neat as
spend much time figuring that out.” it did when it was
made thanks to the
So how does it fare? Great, as it happens. “It use of Adafruit panel
works very well, with no issues,” Alan says. “And mount extensions

since I’m using the original board passively – that W Alan, who has
connected his
is with no power applied – there’s not as much streamer to a
to wear out or go wrong. I now use the music Loxjie A30 amplifier,
is considering
streaming player almost every day and the audio re-labelling the
quality is indistinguishable from the original source front buttons

material, at least to my ears.”

Audiophile Pi magpi.cc 21
PROJECT SHOWCASE

Mini Dexed
A microcontroller synthesiser emulator running on Raspberry Pi
involved plenty of collaboration, discovers Rosie Hattersley

D exed is a multi-format plug-in synth


“closely modelled” on the Yamaha DX7
intended as a companion and tribute to
the 1983 machine that inspired it. So reads the
GitHub entry (magpi.cc/dexedgit), which provides
microcontroller with lots of computing power and
is “using Raspberry Pi more like an embedded
microcontroller than a regular computer”. Quick
boot times, small code size and overall simplicity
are further hallmarks. The project began in
multiple useful links indicating just how many 2022 during a discussion in the Circle project,
directions the concept of this free multi-platform when Probono asked for guidance on how to go
Probono music maker has been extended by audio and about integrating an existing synthesiser engine.
MAKER

(aka Simon electronics enthusiasts. Another maker, Rene Stange (magpi.cc/circlegit)


Peter) Mini Dexed ports the concepts of the digital produced Circle, a library for code that runs it in
synthesiser to Python and Raspberry Pi, and is the a bare-metal Raspberry Pi environment, while
Probono works in
brainchild of Simon Peter (aka Probono, magpi. Holger Wirtz (magpi.cc/picodexedgit) ported the
product management
and is based in cc/minidexedgit), who describes it as a ‘Dexed Dexed synth engine for use with microcontrollers,
Germany, where FM synthesiser similar to 8x DX7 (TX816/TX802) creating a framework specifically for this scenario.
he’s been tinkering running on a bare-metal Raspberry Pi (without a
with Raspberry Pi
projects since their Linux kernel or operating system)’ to produce eight Future sounds
2012 launch. tones. Voices can be programmed using a DX series Mini Dexed is a flexible platform for experimenting
magpi.cc/ editor using MIDI sysex. with electronic sound. Once it had been ported for
minidexedgit Emphasising the importance of Yamaha’s DX7, microcontroller use, Probono deliberately built
composer and MusicRadar journalist OSC Steve Mini Dexed around Raspberry Pi and commonly
argued: “it’s possible to categorise 1980s music available, inexpensive hardware components. He
into two eras; the pre-DX7 era and the post-DX7 says a Raspberry Pi Zero 2 version could be created
era, such was the widespread use of this new for less than €50. Hardware choices and whether to
instrument and its distinct timbral character”. use a dedicated audio DAC are down to individual

Bringing DX7 to life


Probono has been experimenting with Raspberry
Pi, for home automation and 3D printing as well
as digital music, since its launch in 2012. He began
the Mini Dexed project because he was keen to
make a “real musical instrument” rather than
something that felt like a computer. He is in awe
of the original developers of FM synthesisers
and says Mini Dexed “stands on the shoulders
X Different instrument
voices can be called of giants”. To recreate their sounds he was
up looking for a commonly available, inexpensive

22 magpi.cc Mini Dexed


PROJECT SHOWCASE

Mini Dexed emulates the


distinctive Yamaha DX7
synth sound at a fraction
of the cost
Quick FACTS
> There’s a useful
setup video
at magpi.cc/
minidexedyt

> The free Mini Dexed


is comparable to
a 1980s TX816
synthesiser (magpi.
cc/tx816)

> One cost roughly


$5,000 then, or
$15,000 now
with inflation!

> Maker Holger Wirtz


has even enabled a
USB version

> Community
discussions are at
magpi.cc/
minidexed-
discussions

W The hardware setup


is straightforward

Warning!
Use test hardware
The makers strongly
recommend using old or
second-hand equipment
for your experiments,
rather than destroying
wonderful old electronic
instruments.

magpi.cc/minidexeddx7

Mini Dexed magpi.cc 23


PROJECT SHOWCASE

makers’ preferences, while suitable connections


for the audio partly depend on which Raspberry
Pi you’re using (magpi.cc/minidexedhardware).
Those that can be configured to use USB Gadget
Mode instead of USB Host mode (currently
Raspberry Pi 3 and 4 but not yet 5) allow
MiniDexed to be used as a USB MIDI device
and accept audio streaming from MIDI
keyboards, for example. “As someone who
is interested in experimental music, I could
imagine hooking up all sorts of sensors
via MIDI to Mini Dexed, in order to create
an immersive soundscape that changes as its
surroundings change.”
Mini Dexed has also been extended to work
with external DACs (making it usable with
Pico and Raspberry Pi 1 and 2, too) as well as
adapted to support 16 voices by blogger Kevin,
(diyelectromusic.com) who has contributed to
this fantastic synth’s development and raised
its profile. Probono specifically mentions the
potential of Raspberry Pi Pico which Kevin was
able to implement: see magpi.cc/picodexedgit
or magpi.cc/dx7usbdongle.
“While the project can be built without any extra
hardware, a simple display and a rotary encoder
and/or some buttons make it much easier to use,
and an inexpensive digital to analogue converter
I could imagine hooking up all sorts of increases sound quality significantly.” Probono
says “The real cost is the time invested into
sensors via MIDI to Mini Dexed, in order developing, building, refining, testing, discussing
– and the MiniDexed community collectively has
to create an immersive soundscape that put in, and is still putting in, a lot of time and
effort, which I am very grateful for.”
changes as its surroundings change “I am still trying to wrap my head around
how to design sound from scratch using FM, it’s
probably a learning journey for a lifetime.”

X Mini Dexed aims


to replicate the
iconic 1980s
synthesiser sound

24 magpi.cc Mini Dexed


PROJECT SHOWCASE

Sounds familiar

T DIYElectroMusic created Raspberry Pi 4, 5 or Pico can all run Mini Dexed


a USB version of the DX7 01 without booting into the operating system,
ideally with a separate DAC such as the one at
magpi.cc/dacpro connecting via GPIO ports.

A 16×2 LCD display, breadboard and a rotary


02 encoder or joystick are needed to navigate the
menu. A microSD card then needs to be loaded with
the Mini Dexed code and synthesiser software from
Probono’s GitHub (magpi.cc/minidexedgit).

Extract the zip file to the microSD card and


03 save it to Sys Ex, then create a sub-folder
named Voice. Connect a MIDI keyboard or USB
controller, and power on your Mini Dexed.

Mini Dexed magpi.cc 25


PROJECT SHOWCASE

Cat TV
Prolific maker Becky Stern chose a Raspberry Pi display to entertain
her favourite feline. Rosie Hattersley wholeheartedly approves

B ecky Stern is a content creator


extraordinaire! During her six years
as director of wearables at Adafruit she
created, wrote, recorded, presented, and edited
140 videos showing other makers the possibilities
of body-worn tech.
Her enthusiasm for tech shines through in her
current role at DigiKey, while her personal blog
Becky
MAKER

Stern and extremely popular YouTube channel present


such gems as Cat TV (magpi.cc/cattvyt), a self-
S Raspberry Pi Zero and an Elecrow touchscreen form the
Becky is lifelong explanatory project based on Raspberry Pi Zero project’s basis, all wrapped in a custom enclosure
maker with
and a Elecrow touchscreen. With such a busy
interests in art and
electronics who companion, we’re relieved to hear that Becky’s
loves sharing her feline friend is being entertained. Tiny telly
creations online.
Becky chose Raspberry Pi 5 as the basis of
beckystern.com Dress to impress Cat TV, since she wanted to stream video and
Becky’s interest in electronics began at art wanted the extra processing power, but she
school. “I have no formal engineering background, has also tested it with Raspberry Pi 4. She had
but I did drop out of a PhD programme,” she a five-inch touchscreen she was keen to use:
explains. Becky was already working at Adafruit “I knew I wanted to use this particular display
when Raspberry Pi came out in 2012. The company from Elecrow, so I 3D-modelled an enclosure
immediately saw its potential for makers and for that would fit to its dimensions.” Becky used
wearable tech: “I remember we delayed the FLORA Tinkercad to design a CRT-style cabinet complete
launch to focus on Raspberry Pi content,” says
Becky. Her numerous makes include Raspberry
Pi ones, of course, including an automated GIF  y cat loves watching TV.
M
camera (magpi.cc/gifmaker) and a smart mirror:
magpi.cc/beckymirror. The Raspberry Pi streams his
T Benchley sometimes
tries to locate the
While chasing his own reflection in the mirror
might have diverted her cat, Benchley, for a while,
favourite YouTube channel,
wildlife show on
Cat TV Becky thought it was about time he had something
tailored specifically to
full of birds and squirrels
his interests. “My cat
loves watching TV. The with ventilation holes so the miniature TV setup
Raspberry Pi streams looked authentic (magpi.cc/tinkercadcat). “I
his favourite YouTube used the honeycomb shape generator in Tinkercad
channel, full of birds to make grids of holes that are too small for my
and squirrels.” Other cat to reach through,” she says. A bit of glitz was
feline goggleboxers added by using Galaxy Black PLA filament for the
may already be aware front of the 3D enclosure. The whole project cost
of Birder King (magpi. roughly $100, and Becky was able to get all the
cc/birderking), which is electronics she needed from DigiKey (where she
also beloved of parrots works) including a USB speaker and keyboard.
and dogs. Due to Cat TV’s miniature proportions, she had

26 magpi.cc Cat TV
PROJECT SHOWCASE

Becky’s cat Benchley relaxes


by watching lots of TV

The Elecrow touchscreen


hides a Raspberry Pi 5
which streams Birder King
wildlife footage all day long

Quick FACTS
> Benchley is
named after the
writer of Jaws

> Given his enviably


stress-free existence

> ...we’ve renamed


him Riley

Benchley sometimes peeks > Becky made her


behind the 3D-printed TV cats a Raspberry
cabinet looking for the mice Pi-powered
to use a right-angle USB connector and a low- and birds he’s seen on TV automated food
profile HDMI to micro HDMI adapter. bowl too
Once she was happy with how the TV cabinet and
> She believes the
screen fitted together, she installed and set up the
1988 film Scrooged
electronics, taping the display in place in case she
predicted Cat TV
needed any adjustments based on feedback from the
ever-watchful Benchley. Becky explains that Cat TV
doesn’t use any software besides Raspberry Pi OS: “I
boot up, open the web browser, navigate to YouTube,
make the video fullscreen, then unplug the keyboard.
If I were to add some software, I’d write a startup
script that performs the same steps.”
During trials, Becky discovered the touchscreen
was a bit of a problem as the cats would paw the
screen and pause the video, so she replaced the
screen’s USB cable with a charge-only lead, disabling
the data connection for the touchscreen. Once this
S The Birder King YouTube
was done she sealed the case and presented it to channel streams cute
Benchley and his brother Hamlet. “Cat TV gets used wildlife all day long
W You can download
every day! The cat loves it, though it would be cool to Becky’s 3D TV cabinet
add some way for him to change the channel.” design from Tinkercad

Cat TV magpi.cc 27
PROJECT SHOWCASE

RC plane OSD
Upgrading your RC plane is easy when you can get a Raspberry Pi Pico
to give you a HUD. Rob Zwetsloot gives it a go

R emote and wireless technology has come a


long way in the last decade or so. With the
explosion of drones with cameras, and the
continual shrinking of camera tech thanks largely
to mobile phones, RC planes have been able to take
advantage of the trend too. Maker Wojciech Domski
wanted to take it a little further, and decided to
Wojciech overlay data on the picture being sent back.
MAKER

Domski “It is all about telemetry and tracking what is


happening to the plane during flight,” Wojciech
Wojciech has a told us. “For example, the current battery voltage.
PhD in robotics,
and builds It is a pretty good indicator of how much power S The custom PCB used to add the video sync chip
embedded systems you have left and, thanks to it, you can estimate
for professional the remaining flight time.” have carried out tests on different cameras with
applications for
different lighting conditions and it turned out that
fun. He’s been
interested in RC Pico Power without adaptive detection of the synchronisation
planes since 2000 While looking for OSD (on screen display) devices signal from video, this solution would not work in
magpi.cc/rcosd that would fit his need for telemetry, he came my case.”
across a project on an RC forum that worked. Making use of an external video sync signal
“The idea was compelling because it did not use detector, Wojciech was able to sync up everything
many external elements; only a couple of resistors, needed and just needed a way to get the flight
T The resulting
image from a flight
capacitors, and diodes,” Wojciech explained. controller to talk with an OSD. The I2C bus ended
with the OSD “However, it wasn’t going to work for me. I up being the solution.
However, instead of using Raspberry Pi for the
OSD, Wojciech decided instead to experiment
with Pico: “I thought that an OSD project using
Raspberry Pi Pico would be a good starting point.”
“I decided to use it because of the nice features
it has,” Wojciech continues. “For starters, the
amount of flash memory compared to other
microcontrollers but also the PIO. I think it is a
very nice and useful feature that has been lacking
in other microcontrollers.”
He also mentions that its size helped a lot as
well. Along with a custom PCB with the video sync
chip connected, he created the OSD.

Flying higher
“Since using the build, I have not had a single
problem with the OSD device,” Wojciech tells us.
“It is reliable and works under different lighting

28 magpi.cc RC plane OSD


PROJECT SHOWCASE

Warning!
Drone Safety

Be careful when
working with drones,
Video is played back on a separate screen especially those with
spinning blades. Fly
for the user so they can see where they’re safely and responsibly
flying, along with flight data and follow local laws
and regulations.

magpi.cc/dronesafety

Quick FACTS
> The video sync
chip used was
an LM1881

> Wojciech has


been using Pico
Data and other telemetry and RP2040 for
are sent to the controller about two years

> Wojciech uses


Raspberry Pi
I thought that an OSD A camera attached to the nose of the
aircraft allows for a first-person view
elsewhere in a
university setting...
project using Raspberry > … which allows

Pi Pico would be a good students


to program
starting point microcontrollers
remotely

conditions. Also, I believe that the most important > The video system
part of each new feature is the ability to turn it is analogue,
off. When flying, I sometimes disable the OSD in which adds
order to have a full view of the video, without any extra complexity
additional information like text.”
While Wojciech seems satisfied with the result,
there’s other ideas he has for the OSD – he reckons
Pico has enough power left to display more text
and even draw shapes and graphics live.
“Another feature would be add a dimming
option to the text,” Wojiciech says. “It would add
some shadow behind the printed text. This would
significantly increase readability. However, this
would require some more modifications not only to
the code but to the hardware as well.” S With analogue video the quality can deteriorate

RC plane OSD magpi.cc 29


SUCCESS STORY

SUCCESS STORY magpi.cc/success

EpiSensor energy
management
Securing energy services’ IoT infrastructure with
Raspberry Pi for a more sustainable future

O ver the coming years, millions of energy-


consuming and producing things will be
connected to the internet to enable a new
energy economy and facilitate a rapid transition
to sustainable energy. Traditional metering,
on to the need to be more energy-responsible,
EpiSensor has the power to transform electricity
usage and spend in a variety of commercial and
industrial environments.

control, and automation systems were never The challenge


designed to address this problem – they require a Global energy consumption grows year on year,
high level of technical expertise to deploy, and are but it’s estimated that around 70% of all energy
too complex and expensive – slowing down energy produced is wasted due to inefficiencies. Figures
services companies. also suggest that about three quarters of our energy
EpiSensor was founded in 2007 to make it comes from sources that emit greenhouse gases.
easier for energy services companies to scale It’s why there is a global ambition to reach net zero
quickly and communicate with remote sites carbon emissions by 2050, and why accessing more
and assets, bringing a ‘consumer class’ user renewable energy is important.
experience to a high-quality, industrial product “Over the coming years, millions of sites and
range that can meet the highest standards of assets will need to be connected to the Internet
T EpiSensor’s Gateway
routes data from
accuracy, security, ruggedness, scalability, as we rapidly transition to sustainable energy. We
networks directly reliability and interoperability. have the technology today to run our electricity
to the IoT platforms
of its customers
Aiming to accelerate the transition to clean, grids on 100% clean renewable energy, but it
and partners sustainable energy, the company provides an needs a dedicated and specialised communications
internet of things (IoT) infrastructure, so energy-consuming and
infrastructure that – producing ‘things’ have awareness of the
allows its partners conditions on the grid in real time – because
and end customers to traditional systems were never designed for that
easily monitor energy job,” says Brendan Carroll, CEO of EpiSensor.
consumption and EpiSensor’s team had examined traditional
control remote sites providers and noted that despite being accurate,
and assets, so grid reliable, and secure, those systems tended to
operators can integrate be closed, complex, difficult to maintain, and
more renewables, and expensive. Building that specialised infrastructure
people can make more has meant starting from the ground up to integrate
informed decisions that and automate every component, and remove points
improve efficiency, of friction that were slowing down energy services
reduce costs, and reduce providers – without sacrificing the qualities
environmental impact. associated with traditional systems.
With a world Crucially, they wanted it to be easily scalable
increasingly switched so that organisations regardless of size would be

30 magpi.cc EpiSensor energy management


SUCCESS STORY

able to create a system that addressed their needs.


They also wanted it to be easy to use, bringing a
consumer-class experience to the systems so that
they would be widely accessible and easy to adopt.
More recently, the company has focused on
delivering high-end demand response or demand-
side flexibility, which can assist electricity grid
operators with balancing supply and demand computing, iPhone represented a revolution in
by incentivising customers to reduce their mobile and user experience, and new standards
consumption during peak periods. It is a critical like ZigBee made it possible for wireless sensors
tool in energy transition, reducing strain on the to communicate securely and at very low power,”
grid, and EpiSensor sought to be at the forefront by says Carroll. “We set out to apply this new
designing and building highly accurate, scalable, technology stack, that later became known as
and secure IoT infrastructure for demand response. the internet of things, to the world’s energy and
While considering all of this, EpiSensor also efficiency problems.” Over many iterations based
knew that data needed to be handled securely. on customer requirements, this led to the creation
“Data security in commercial IoT programmes is of EpiSensor’s latest API-enabled Gateway built
critical to protect sensitive information, prevent around Raspberry Pi Compute Module 4.
unauthorised access, mitigate cyberattacks, EpiSensor’s Gateway is a compact device that
preserve user privacy, comply with regulations, routes data from networks of wireless sensors
maintain business reputation, ensure operational directly to the IoT platforms of customers and
continuity, and protect intellectual property,” says partners. “It’s a powerful, rugged, and secure
Carroll. EpiSensor discovered that Raspberry Pi embedded computer with an IoT app store
would allow them to achieve all of their aims. and many wired and wireless communications S EpiSensor turned
to Raspberry Pi
interfaces: ZigBee, Wi-Fi, Bluetooth, 4G cellular, Compute Module
The solution LoRa, GPS, CAN bus, RS-485,” Carroll says. 4 to create the IoT
infrastructure layer
When EpiSensor was founded in 2007, it was an EpiSensor has worked hard to automate many of for energy services,
exciting time for the technology sector. “We saw the configuration steps that would normally be helping to accelerate
the sustainable
three new technology launches that felt important: done by experts on customer sites, so the Gateway energy transition
AWS marked the start of a new class of cloud essentially configures and tests itself. “EpiSensor’s across the world

EpiSensor energy management magpi.cc 31


SUCCESS STORY

Gateway is at the core of our advanced IoT The user is able to view real-time information on
solutions,” Carroll says. “It’s secure, developer- the performance of the system, adjust configuration
friendly and has data available in open formats.” easily, and visualise how all of the nodes are
The huge benefit of EpiSensor’s IoT technology connecting over the wireless mesh network.
is that it can easily be deployed and integrated with “Our objective is to be ten times quicker and
systems on customer sites such as existing building easier to deploy than traditional systems which
management systems (BMS) or SCADA, as well as means our partners can scale energy solutions
systems running in the cloud that provide complete faster,” says Carroll. “We enable facilities
energy management or demand response solutions. managers, system integrators, energy service
As well as a set of tools that make building custom companies, energy managers and software
integrations quick and easy, partners can leverage as a service providers to deliver world-class
EpiSensor’s comprehensive list of pre-built energy management, demand response, and
integrations to get connected to all of the leading environmental monitoring programmes, with low
energy services platforms with a few clicks. cost, easy-to-deploy IoT infrastructure.”
As the Gateway gathers data from wireless nodes
in real time, the information is made available Why Raspberry Pi?
via the Gateway web interface and mobile apps. It Since EpiSensor was founded, its expertise has
allows all of the nodes and sensors to be remotely grown. “We’ve attracted a world-class engineering
monitored and managed via the API of the Gateway, team based in Ireland and we are led by our
or using Core, EpiSensor’s device management experienced management team who have grown
platform, making it easier for them to run multiple and sold multiple high-tech companies in related
energy services programmes for their customers. industries in the past. Growing at pace now, our

32 magpi.cc EpiSensor energy management


SUCCESS STORY

IoT infrastructure is relied on by market leaders


worldwide,” Carroll says.
Rather than design the computer module at the
centre of their system architecture from scratch, they
realised Raspberry Pi offered a simple yet powerful
solution. “EpiSensor opts for Raspberry Pi due
to its cost-effectiveness, reliability, and superior
performance, but most importantly the invaluable
support of its thriving community,” Carroll says. “If
a large community is using a computer board like
the CM4 from Raspberry Pi, and you come across
an exotic issue that only happens under certain
circumstances, there’s a higher chance someone else
in the community has already solved it, and that
makes Raspberry Pi our preferred choice.”
Raspberry Pi Compute Module 4 is certainly
powerful. It incorporates a quad-core Arm deployments streaming data every second of every
Cortex-A72 processor and it allows Canonical’s day, all over the world,” Carroll says.
highly secure and reliable Ubuntu Core operating EpiSensor is well positioned for future growth,
system to be run; this includes an IoT app store, with Raspberry Pi enabling the company to nimbly
meaning the functionality of the EpiSensor meet the needs of an expanding and demanding
Gateway can be extended and customised to market. According to Statista, the Energy
include additional functionality like machine Management market worldwide is projected to
learning, device management, and advanced reach a revenue of $10 billion in 2024, growing
at an annual rate
of 10.75%. Growth

E piSensor is well positioned for future is driven by several


factors including rising
growth, with Raspberry Pi enabling the global energy costs,
regulatory change
company to nimbly meet the needs of an (Energy Efficiency
Directive Recast 2023
expanding and demanding market in the EU, for example),
environmental concerns,
networking applications. It also operates over a the race to net zero, renewable energy integration,
wide temperature range, and the company likes and energy security.
that it can operate silently and with low power, Similarly, demand response is growing rapidly
while offering passive cooling – which means driven by challenges faced by grid operators in
higher reliability in harsh environments. managing the intermittency caused by renewable
energy integration and the surge in energy demand.
The results “The task of providing grid flexibility at the asset
EpiSensor maintains business-critical systems with level within milliseconds and aggregating multiple
hundreds of energy services companies worldwide assets into Virtual Power Plants (VPPs) through
S EpiSensor’s team
across more than 20 countries, and testimonials are demand response programmes is a significant examined traditional
glowing. The company’s products are praised for undertaking, one that we have taken on with providers and found
those systems
their scalability and usability. They are also effective the help of Raspberry Pi technology,” remarks tended to be closed
and easy to deploy and commission on site. Cristina Coffey, CSO, EpiSensor. VPPs aggregate
“Our partners include Enel X, the world’s largest various distributed energy resources (DERs) such
Demand Response Aggregator; Veolia, a world- as batteries, UPS systems, EV chargers, industrial
leader in energy and facilities management; Capula, machinery, and even small-scale demand-side
joint-owned by energy giants Dalkia and EDF and resources such as smart appliances or HVAC
a leader in systems integration; and CoolPlanet, systems. Their adoption is growing and they
a specialist in commercial decarbonisation. are seen as a critical component in the future of
Together with our partners, we have large-scale sustainable energy.

EpiSensor energy management magpi.cc 33


SUBSCRIPTION

SUBSCRIBE TODAY
FOR JUST £10
Get 3 issues + FREE Pico W
Subscriber benefits
FREE Delivery
Get it fast and for FREE

Exclusive Offers
Great gifts, offers, and discounts

Great Savings
Save up to 23% compared to stores

Subscribe for £10


Free Pico W
3 issues of The MagPi
£10 (UK only)

Subscribe for 6 Months


Free Pico W
6 issues of The MagPi

+ £30 (UK)
€43 (EU)
$43 (USA)
£45 (Rest of World)

Subscribe by phone: 01293 312193


Subscribe online: magpi.cc/subscribe
Email: magpi@subscriptionhelpline.co.uk
Subscribe for £10 is a UK-only offer. The subscription will renew at £15 every three months unless
cancelled. A free Pico W is included with a six-month subscription in USA, Europe and Rest of World.

34 magpi.cc
SUBSCRIPTION

SUBSCRIBE TODAY AND GET A


FREE Raspberry Pi Pico W
Subscribe in print
today and get a FREE
development board WORTH

A brand new RP2040-


based Raspberry Pi Pico W
$6
development board

Learn to code with


electronics and build
your own projects This is a limited
offer. Not included
with renewals. Offer
Make your own home subject to change or
withdrawal at any time.
automation projects,
handheld consoles,
tiny robots, and much,
much more

Buy now: magpi.cc/subscribe

SUBSCRIBE
on app stores

magpi.cc 35
FEATURE

Hidden inside is a Raspberry Pi 5


and 1TB NVMe drive

The Argon ONE has a built-in IR


receiver and a dedicated remote

BUILD A RASPBERRY
PI 5 MEDIA PLAYER
Free your films, videos and music from
your computer with our complete guide

S
PJ Evans brings
ince its inception, Raspberry Pi has
the popcorn
always been a favourite choice for those
wanting to build their own media centre.
But why bother when so many off-the-shelf
options are available? There are many reasons:
Control over your data, avoiding subscription costs,
accessing more obscure services like public domain
films and homebrew games. The biggest reason
of all is because it’s fun. Over the next few pages
we’ll take a look at the hardware and software
available to you, and run through a powerful setup
using the popular Kodi platform. Soon you’ll be on
the sofa watching all your favourites.

36 magpi.cc Build a Raspberry Pi 5 Media Player


FEATURE

HARDWARE
There are a few things you can do to
really make your media centre shine

Raspberry Pi 5 Argon IR Remote Raspberry Pi TV HAT

Yes, it sounds obvious but the latest Pair your Argon case with this elegant Did you know you can watch over-
iteration of Raspberry Pi is perfect for IR controller and you don’t have to the-air digital broadcasts? Just
video performance up to 4K. leave the sofa. add this HAT!
magpi.cc/raspberrypi5 magpi.cc/argonremote magpi.cc/tvhat
£58 £9 £21

Argon ONE V3 M.2 NVME Case 52Pi NVDAC Mini Bluetooth Keyboard

Argon’s latest for the Raspberry Pi Audio quality your priority? This two- If you fancy browsing the web or
5 features M.2 SSD support, active in-one HAT gives you an M.2 SSD chatting from your chair, get a
cooling and an IR receiver. and a high-quality DAC. wire-free mini keyboard.
magpi.cc/argononev3m2 magpi.cc/52pinvdac magpi.cc/minikeyb
£46 £29 £13

Build a Raspberry Pi 5 Media Player magpi.cc 37


FEATURE

SOFT WARE CHOICES


Now you have your hardware, what to run
on it? Luckily there’s no shortage of options

LibreELEC & Kodi libreelec.tv Volumio volumio.com

� Dedicated image, so easy to install � Audiophile-grade solution


� Handles videos, audio and more � Beautiful interface
� Community supported with hundreds of plug-ins � Wide range of remote control apps

LibreELEC is a dedicated operating system designed to only If you’re looking for a high-quality audio-only solution,
run Kodi, which is one of the most popular media players Volumio have spent years developing their audiophile
available. A solid all-rounder that handles hundreds of solutions for Raspberry Pi. Paired with a good DAC, you have
different audio and video formats, it’s designed for the big a music player with impressive library management that
screen and works brilliantly with a remote control. Access to rivals devices that cost several times more. It’s also available
streaming comes through the huge repository of plug-ins. as an OS image for simple installation.

Plex plex.tv OSMC osmc.tv

� Perfect for streaming both home and away � Elegant interface


� Lots of free content � Highly customisable
� Superb library management � Lots of plug-ins

Where Kodi is for consuming media on a dedicated device, One of the joys of open-source software is that anyone is free
Plex is a server that gives you access to your media anywhere. to ‘fork’ an existing codebase and build their own version.
Install the server and add your media using the excellent OSMC forked Kodi so they could add new features. The result is
web interface then you can use the Plex client app on your an elegant design which suits those of a minimalist persuasion.
computer, phone or even Kodi. You can also access your media Like LibreELEC, it’s available as an OS image. Choose this if you
when you’re outside your home network. want a calm, refined experience from your media centre.

38 magpi.cc Build a Raspberry Pi 5 Media Player


FEATURE

FILL UP
THAT SSD YouTube Videos

There’s no point having a state-of-the-art The most popular video service in the world is obviously
going to be a must-have for your media server. YouTube
media player with nothing to play. Here’s on Chromium works out of the box if you’re using
where you can find great content Raspberry Pi Desktop. If you want to use it with Kodi,
the good news is a plug-in is available directly from the
Kodi interface. Just head over to the Add-ons menu and
search for ‘YouTube’.

Netflix (also Disney+ etc) Movies & TV Qobuz Music

Many on-line streaming services use Widevine, which is a Over the recent years, music file size has stayed the same,
browser-based anti-piracy system. This is not installed by but storage has got bigger and cheaper. There’s no longer
default on Raspberry Pi, so services such as Netflix won’t the need to crush the quality, instead you can use FLAC
work. Luckily it can be installed simply, just follow this guide: which is a ‘lossless’ format that loses no music quality in its
magpi.cc/widevine. If you’re using Kodi, try the unofficial compression. The strangely named Qobuz is a leading online
plugin: magpi.cc/netflixkodi retailer of FLAC-encoded music.

DON’ T MANGLE YOUR MEDIA


Keep on top of some basic housekeeping, and
you’ll always be able to find what you want

Tag all the things

The key to a neat media library is to tag everything. Tags are


metadata encoded in the media file itself that tells the media
library things like titles, artists, genres and track numbers.
Without properly tagged files, you may find things hard to find
and out of order. Try magpi.cc/kid3.

What’s in a name?

Quite a lot, as it turns out. Many media libraries will


make assumptions based on the filename of your media.
For example, Plex likes music files to start with the track
number (e.g. “01 Help.flac”) and will correctly order them.
TV Show filenames should contain the season and episode in
the format “s01e02”.

Use the scraper

Platforms such as Kodi and Plex have built in ‘scrapers’ or


‘agents’ that will look at your media filename and try to tag it
for you (although they don’t always write the tags to the file,
only their database). This can be great for automatically getting
artwork and extra fields like actors, directors or lyrics.

Build a Raspberry Pi 5 Media Player magpi.cc 39


FEATURE

BUILD A KODI
MEDIA CENTRE
If you’re not sure where to start, this tutorial will help you build
a powerhouse Kodi media centre perfect for the living room

Assemble your hardware


01 Following the provided instructions,
mount your Raspberry Pi 5 into the Argon ONE
You’ll Need case. Prepare a microSD card with a copy of
Raspberry Pi OS with Desktop and insert it into
> SD Card the Raspberry Pi. Carefully connect the NVMe
> Argon ONE V3 M.2 ribbon cable. Connect a monitor, keyboard
> rgon remote control and mouse then boot up. To enable the NVMe
SSD, run sudo raspi-config, select Advanced
> M.2 NVMe SSD (We
Options, Bootloader Version then Latest. Save
used a 1TB)
and reboot.

Initial configuration and


03 file transfer
On first boot Kodi will start a setup wizard
where you can configure things like Wi-Fi and
ssh access. Now it’s time to load up some local
media or configure network connections. For
local storage you can map the content folder to
a local mapping using Samba or use scp to copy
files across on the command line (hostname:
libreelec.local). Kodi has already created some
folders for you in the root directory for movies
and music. Start by uploading some tunes into
the ‘music’ directory.

Install LibreELEC
02 Once rebooted, In the Desktop, run
the Imager (you’ll find it under Accessories)
and select ‘Raspberry Pi 5’ as the device,
‘LibreELEC’ as the OS (under ‘Media Player OS’)
and select your SSD as the storage. Once the
image is written, shut down and remove the
microSD card. Put everything back together and
boot the Raspberry Pi. Make sure you’ve got a
keyboard connected for the next bit.

40 magpi.cc Build a Raspberry Pi 5 Media Player


 great money-saving way to watch
A
classic films is to investigate the
world of the public domain

Public domain content

A great money-saving way to watch classic films


is to investigate the world of the public domain.
These are films that have lapsed out of copyright
so are free to view and download. You may
Configure libraries
04 The default folders are already
have to wallow through some stinkers but there
are some genuinely brilliant movies out there.
‘mapped’ to the different categories in Popular repositories are:
Kodi, but you need to initiate the first scan. � archive.org
Select ‘Music’ then ‘Enter Files Section’. � magpi.cc/pubdomfilms
You’ll see ‘Music’ next to a disc drive icon. � publicdomaincinema.net
Right-click on the icon and select ‘Scan item � magpi.cc/retroflix
to library’. Your music will now be indexed
by Kodi and within a few seconds you’ll be
able to return to the Music library and see Gaming
all your cover art. Repeat this process for
your movies and videos. Many media streaming services now include
gaming. Raspberry Pi is no different. Kodi
offers a range of gaming plug-ins including
many popular retro computer emulators. Plus,
thanks to Microsoft’s Xbox Cloud Gaming
service, you can play the latest AAA console
games in your living room using a Raspberry
Pi. For a full tutorial have a look at issue #136
(magpi.cc/136).

Add remote control


05 So you can get all cosy on the sofa
and enjoy your media, the Argon ONE case
has an infrared receiver. With the Argon
remote, you can control Kodi from across
the room. Instructions are provided on how
to configure the remote here: magpi.cc/
argonremoteconfig. Once installed, you’ll no
longer need your keyboard and mouse and
your new device will be ready to take pride of
place in your media setup.

Build a Raspberry Pi 5 Media Player magpi.cc 41


TUTORIAL

Learn Python:
Part 04

discover data
types and build a
budget tracker
Storing and using data is at the heart of programming. Discover
how to use various data types to build interesting programs

D ata isn’t just the name of an old android


in Star Trek, it’s also the heart of computer
programming. The word simply means
“an item of information” from its singular Latin
“datum” (meaning “that which is given”).
Basic data tends to be a single item: a number,
word, or statement. Complex data tends to
be collections of items, such as lists (that can
contain other data).
Let’s start with the most basic of all data
Programs largely revolve around data. Obtaining types: numbers.
it from input (often from the keyboard and

Lucy
mouse), storing it, manipulating it, and then Integers and Floats
MAKER

sending it back in the form of output (typically There are two types of numbers we’re going to
Hattersley
to the screen). look at here. Whole numbers are called “integers”
Lucy is editor of Right down at the metal, everything is just or “ints” and fractional numbers with a decimal
The MagPi and electronically flipped on and off switches, but point, which are called “floats”. This is short for
was taught quite
firmly to keep an that is far too complex for everyday use so “floating point number”.
eye on her pennies everything is abstracted up to a level where we Open Thonny IDE and enter:
when young. It’s a can comfortably deal with it. And part of this
northern thing..
is data segmented into different types: some $ foo = 42
magpi.cc of these will be familiar: strings and integers $ bar = 4.2
(numbers). Some are more esoteric: bools,
dictionaries, and tuples, for example. … in the Shell window below (press ENTER
In this tutorial, we cover various data types in after each line). We’ll just type our test data into
Python so you can learn to identify them when the Shell for now. Check the values with foo and
you see them. Then we will use these to create a bar in Shell. It will return “42” and “4.2”.
budget tracker program, that uses different data You can check the type of data using the
types together to help users manage their money. type() function. This is handy because – in
We separate data in Python into two different Python – different types react differently when
types. The first is Basic and the second is Complex. used. Enter:

42 magpi.cc Learn Python: discover data types and build a budget tracker
TUTORIAL

You’ll Need
> Raspberry Pi

> Raspberry Pi OS
Our Budget Tracker
code in Thonny features > Thonny IDE (optional)
integers, floats, strings,
and lists of data

Top Tip
The data is saved into a JSON file, Why not float
which is a text file containing data everything?
in a common format
What is the point
of ints? Why not
just make 42 into
42.0 and have
everything as a
$ type(foo) has been cast into an int and stored in foo. The float? The answer
$ type(bar) process of turning a float into an int gets rid of lies deep in the
the fractional value (it doesn’t round up or down binary hardware. It
is easy to represent
… and Shell will return: it gets rid of the fractional end: 5.9 becomes 5 and
whole numbers in
so on). The reverse process adds a “.0” to the end binary, but much
<class 'int'> of an int. more complex to
<class 'float'> represent fractional
numbers. So it is
$ bar = string(4) much more efficient
$ bar for code to use
So what happens if we add an int and float a different (and
simpler) int system
together? The answer is: it depends. Enter … returns a float: “4.0”. One of the main uses
for whole numbers.
type(foo + bar) and you’ll currently get for type casting is converting ints into strings
“type<float>” because it’s adding together a full so they can be printed out alongside messages.
number and a fraction. You can see the result by It’s fine to enter print(foo) for example, which
using foo + bar which returns: “46.2”. returns. But enter print("The number is: " +
In general, if you add together ints you get an foo) and you’ll get an error: “TypeError: can T Our budget tracker
int, whereas if you add an int and a float together only concatenate str (not "int" to str”. Reading program enables
you to enter various
you get a float. this error carefully tells us that the error is a type data types: strings,
error: our “int” cannot be concatenated (a fancy ints, and lists
Type casting
It is important to change data types from one to
another in Python through a process called ‘type
casting” (not to be confused with typecasting
of actors). This makes it easy to turn an int into
a float, or a string, or a different type. This is
important because different functions may expect
a specific data type (printing out an int requires it
to be turned into a string first). You convert a float
into an int using the int() function, placing the
variable to be converted inside the brackets:

$ foo = int(5.6)
$ foo

… returns 5. This is because 5.6, the value,

Learn Python: discover data types and build a budget tracker magpi.cc 43
TUTORIAL

way of saying “joined”) to our string. We can fix


this by type-casting the int to a string. $ string = "Hello, World!"
$ first_char = string[0] # 'H'

Top Tip $ foo = 42


$ print("The number is: " + foo)
$
$
last_char = string[-1] # '!'
substring = string[7:12] # 'World'

Consistency Which outputs “The number is: 42”. There’s a lot you can do with strings, enough
is key for its own chapter. A lot of Python is spent

The Python style


Strings connecting, adding, slicing and dicing lists and
guide doesn't have This brings us neatly to our second basic data type, strings. We’ll come to Lists (which are like
a rule regarding the string. Strings are sequences of characters. strings in a moment, first let’s talk about True
double or single They are typically used to represent words, but at a or False values.
quotes for strings.
But suggests you
Python level they are a list of characters (including
remain consistent spaces). You create one just like an integer but you True or False
with one or the tell Python it’s a string by enclosing it in quotation A third type of basic data in Python is the boolean
other. We prefer
marks (single or double quotes): Value. Known as True or False. These values are
double quotes but
would use single entered without quotation marks, and with a
quotes if we were $ string = "Hello!" capital “T” or “F”.
editing code that $ string
used them.
magpi.cc/pep8
$ a = True
If you try entering a string without quotes, Python $ b = False
assumes that you’re assigning one variable to
another. Entering string = Hello! would produce True and False values are created throughout
an error (in this case “Invalid Syntax” as “!” is not Python when you evaluate expressions or use
a valid character for a variable name. logical operators.
Strings can be added together, like numbers
using the “+” operator, which combines: $ a = (5 > 3) # True
$ b = (5 == 3) # False
$ greeting = "Hello" $ print(a and b) # False
$ name = "Alice" $ print(a or b) # True
$ message = greeting + ", " + name + "!" # $ print(not a) # False
"Hello, Alice!"
You use True and False values in most Python
Enter message in Shell to view “Hello, programs to control flow.
T The output of our
Alice!”Strings are indexed characters, and can be
budget tracker accessed by adding square brackets “[]” afterwards $ a = True
calculates your
income and
with a number (starting at 0). $ if a:
outgoings Test this out in Shell: print("a is True")
$ else:
print("a is False")

There’s a concept known as “truthiness” in


Python where various objects can be evaluated
as true or false. Try this:

$ if "Hello":
print("truthy")
$ else:
print("not truthy")

Run this code and Python will print “truthy”.


Replace “Hello” with various things: 0, False,
None, empty strings "" or lists [] will all
run the else path and return “not truthy”.

44 magpi.cc Learn Python: discover data types and build a budget tracker
TUTORIAL

Top Tip
X The SHELL in Thonny IDE is
useful for quickly entering Remember
Python commands and
examining code to cap
Remember to use
capital “True” and
Positive or negative ints (-1, 1, 2, 3, and so on) $ # Inserting items “False”. If you use
evaluate to True. As do lists with items, strings $ my_list.insert(2, "new") # my_list is now lowercase letters
Python will think
with characters and so on. Experiment with [1, 2, 'new', 3, 4, 5, 6] you're creating
different values to discover if they are inherently variables called
True or False. $ # Removing items “true” and “false”.
$ my_list.remove("new") # my_list is now [1,
Complex data types 2, 3, 4, 5, 6]
Now that we’ve looked at the basic data types.
It’s time to have a look at more complex things. $ popped_item = my_list.pop(2) # popped_item
And the first item you’ll encounter is a list.
Lists are created by using square brackets and
is 3, my_list is now [1, 2, 4, 5, 6]
Top Tip
placing items inside, with a comma separating $ # Slicing lists
each item. Lists can contain just about anything: $ sliced_list = my_list[1:4] # sliced_list Why 0?
ints, floats, strings, bools, even variables and is [2, 4, 5]
Some programming
other lists. languages, like R,
index from 1, but
$ # Creating a list What’s a tuple? Python, C, Java and
most languages
$ my_list = [1, 2, 3, 4, 5] A tuple is similar to a list, except you create it start at 0. Partly it's
using round brackets instead of square ones. traditional (and soon
$ # Lists can contain different data types The big difference is that tuples are immutable, becomes habit) and
on a physical level
$ mixed_list = [1, "Hello", 3.14, True] meaning that they cannot be changed after you
items are stored in
have created them (you can’t add, remove or a RAM address and
Items in a list may be accessed using square reorder items in a tuple). you can reference
brackets with a number pointing to its position in the first item, then
add 1, 2, 3 and so on
the list (zero-indexed so the first item is 0, the $ # Creating a tuple to get the next items
second item is 1, and so on). $ my_tuple = (1, 2, 3) in the list.

$ # Accessing elements $ # Tuples can contain different data types T Practice working
$ print(my_list[0]) # Output: 1 $ mixed_tuple = (1, "Hello", 3.14, True) with data in Thonny
IDE to gain an
$ print(mixed_list[1]) # Output: "Hello" understanding of
$ # Single element tuple (note the comma) how various Python
elements work
The key thing with lists is that they are
“mutable”. That means you can change them: add,
remove, swap values etc. This is typically done
using dot notation commands after your variable.
So to add an item you would use my_list.append()
and put the new value inside the brackets. Here
are some examples:

$ # Initial list
$ my_list = [1, 2, 3, 4, 5] # my_list is [1,
2, 3, 4, 5]

$ # Appending items
$ my_list.append(6) # my_list is now [1, 2,
3, 4, 5, 6]

Learn Python: discover data types and build a budget tracker magpi.cc 45
TUTORIAL

$ single_element_tuple = (1,)

They have advantages over lists in that they can


be fixed.

Dictionaries
A dictionary (also known as a “dict”) is a list with
key/value pairs. That means you add a key (which
can be a word such as “name”, and “age” and a
value such as “Bob” and “32”.
Then, when accessing the values in a dictionary
you use the key rather than the index position
(as you would in a list). So rather than saying
item[0] and getting “Bob” you would say
budget.py
item["name"]. Let’s create and use a dictionary:
> Language: Python
$ # Creating a dictionary
$ my_dict = {"name": "Alice", "age": 25, 001. import json # Import the json module to work
"city": "Cambridge"} with JSON data
002. import os # Import the os module to work with
$ # Accessing values file paths
$ print(my_dict["name"]) # Output: Alice 003.
004. # Define a function to load data from a JSON file
Like lists, you can add values. You do this using 005. def load_data(filename):
square brackets with the new key, an equals 006. if os.path.exists(filename):
assignment operator and the value: 007. with open(filename, ‘r’) as file:
008. return json.load(file)
$ # Adding or modifying values 009. else:
$ my_dict["age"] = 26 # Modifying an 010. return {}
existing value 011.
$ my_dict["email"] = "alice@example.com" # 012. # Define a function to save data to a JSON file
Adding a new key-value pair 013. def save_data(data, filename):
014. with open(filename, ‘w’) as file:
You can delete values using del and the key, 015. json.dump(data, file, indent=4)
but it’s more common to use a command called 016.
pop. This ‘pops’ a value off the list and returns it 017. # Define a function to add monthly income
to be stored. 018. def add_income(data):
019. income = float(input(
$ # Using del “Enter your total monthly income: “))
$ del my_dict["city"] 020. data[‘income’] = income
021. return data
$ # Using pop() 022.
$ email = my_dict.pop("email") 023. # Define a function to add an expense
024. def add_expense(data):
Don’t be surprised if key/value pairs are 025. if ‘expenses’ not in data:
confusing at first. It takes a while! 026. data[‘expenses’] = {} # Create an empty
dictionary for expenses if it doesn’t exist
Wrapping up 027.
That’s our whistle-stop tour of Python data types 028. category = input(“Enter the expense category
wrapped up. Now enter our budget.py code to (Housing, Utilities, Groceries, Transportation,
create a working budget tracker. It also saves data Entertainment, Other): “)
to a JSON (JavaScript Object Notation) file. You 029. amount = float(input(“Enter the expense
can learn more about JSON at json.org. amount: “)) # Convert the input to a float

46 magpi.cc Learn Python: discover data types and build a budget tracker
TUTORIAL

DOWNLOAD
THE FULL CODE:
magpi.cc/github

030. description = input( 057.


“Enter a brief description of the expense: “) 058. # Define the main function
031. 059. def main():
032. if category in data[‘expenses’]: 060. data_file = ‘budget_data.json’
033. data[‘expenses’][category]. 061. budget_data = load_data(data_file)
034. append({‘amount’: amount, 062.
‘description’: description}) 063. while True:
035. else: 064. print(
036. data[‘expenses’][category] = “\n--- Home Budget Tracker Menu ---”)
[{‘amount’: amount, ‘description’: description}] 065. print(“1. Add Monthly Income”)
037. 066. print(“2. Add Expense”)
038. return data 067. print(“3. Show Monthly Summary”)
039. 068. print(“4. Exit”)
040. # Define a function to display a monthly summary 069. choice = input(“Enter your choice: “)
041. def monthly_summary(data): 070.
042. total_expenses = 0 # Initialize a variable 071. if choice == ‘1’:
to store the total expenses 072. budget_data =
043. income = data.get(‘income’, 0) add_income(budget_data)
044. expenses = data.get(‘expenses’, {}) 073. elif choice == ‘2’:
045. 074. budget_data =
046. print(“\nMonthly Summary:”) add_expense(budget_data)
047. print(f”Total Income: ${income:.2f}”) 075. elif choice == ‘3’:
048. 076. monthly_summary(budget_data)
049. for category, entries in expenses.items(): 077. elif choice == ‘4’:
050. category_total = sum( 078. save_data(budget_data, data_file)
item[‘amount’] for item in entries) 079. print(
051. total_expenses += category_total “Data saved. Exiting program.”)
052. print(f”{category}: ${category_ 080. break
total:.2f} ({(category_total / income * 081. else:
100):.2f}%)”) 082. print(
053. “Invalid choice. Please choose a valid option.”)
054. net_savings = income - total_expenses # 083.
Calculate the net savings 084. # Call the main function
055. print( 085. if __name__ == “__main__”:
f”Total Expenses: ${total_expenses:.2f}”) 086. main()
056. print(f”Net Savings: ${net_savings:.2f}”)

Learn Python: discover data types and build a budget tracker magpi.cc 47
TUTORIAL

Programming with
Part 04

Scratch 3
Learn how to start coding using Scratch, a block-based programming language.

K ey to the accessibility of coding on


Raspberry Pi is Scratch, a visual
programming language developed by the
Massachusetts Institute of Technology (MIT).
Rather than using text-based instructions,
Scratch has you build your program using
blocks – pre-written chunks of code disguised
as colour-coded jigsaw pieces.
Gareth
MAKER

Scratch is a great first language for budding


Halfacree
coders of any age, and you can use it to create
Gareth is a freelance everything from simple games and animations
technology journalist, through to complex interactive robotics projects.
writer, and former
system administrator Scratch 3 loads like any other program on
in the education Raspberry Pi: open the Raspberry Pi menu, move
sector with a passion the cursor to the Programming section, and click
for open-source
on Scratch 3. After a few seconds, the Scratch 3
software and
hardware. user interface will display. You may see a message S Figure 1: Drag and drop the block into the code area
about data collection: you can click Yes if you’re then let go of the mouse button. You don’t have to
freelance.
halfacree.co.uk happy to submit usage data, otherwise click No. be precise; if it’s close enough, the block will snap
Start by clicking on the Looks category in the into place. If it doesn’t, click and hold on it again to
blocks palette, found at the left of the Scratch adjust its position until it does (see Figure 2).
window. This brings up the purple blocks under that Your program is now complete. To make it work,

Top Tip
category. Find the “Say Hello” block, click and hold known as running the program, click the green flag
the left mouse button on it, and drag it over to the icon at the top-left of the stage area. If all has gone
code area at the centre of the Scratch window before
Scratch letting go of the mouse button (Figure 1).
versions T he block is expecting to
Say hello to the Scratch interface
There are two
Look at the shape of the block you’ve just dropped:
have something above it
versions of Scratch
available for
Raspberry Pi OS:
it has a hole at the top and a matching part
sticking out at the bottom. Like a jigsaw piece,
and something below it
Scratch and Scratch
this shows you that the block is expecting to have
3. This article is
written with Scratch something above it and something below it. For well, the cat sprite on the stage will greet you with
3 in mind, which is this program, that something above is a trigger. a cheery ‘Hello!’ – your first program is a success!
only compatible Click on the Events category of the blocks palette, Before moving on, name and save your
with Raspberry Pi 4,
Raspberry Pi 5, and coloured gold, then click and drag the when green program. Click on the File menu, then Save to
Raspberry Pi 400. flag clicked block – known as a hat block – onto your computer. Type in a name and click the Save
the code area. Position it so that the bit sticking out button (Figure 3).
of the bottom connects into the hole at the top of Your program has two blocks, but it only has
your say Hello block until you see a white outline, one real instruction: to say ‘Hello!’ every time the

48 magpi.cc Programming with Scratch 3


TUTORIAL

A. Stage area. Like actors in a play, your


characters move around the stage under
the control of your Scratch program
B. Sprite. These characters are known
as sprites
C. Stage controls. To change the stage,
such as to add your own background,
use the stage controls
D. Sprites list. All the sprites you have
created or loaded are in the Sprites list
E. Blocks palette. All the blocks
available for your program appear in
the blocks palette, which features
colour-coded categories
F. Blocks. Blocks are pre-written
chunks of code
G. Code area. You build your program
in the code area by dragging and
dropping blocks from the blocks
palette to form scripts

W Figure 2: The when


program runs. To do more, green flag blog
you need to know about clicked into say
[Hello!]. Click the
sequencing. Computer green flag above the
programs, at their simplest, stage and the cat will
say ‘Hello’
are a list of instructions,
just like a recipe. Each
instruction follows on
from the last in a logical You’ll Need
progression known as a
linear sequence. > Raspberry Pi (4, 400, 5)

> Raspberry Pi OS
Next steps
> Internet connection
Start by clicking and
dragging the say Hello!
block from the code area
back to the blocks palette.
This deletes the block,
removing it from your
program and leaving just the Trigger block, when
green flag clicked (Figure 4).
Click on the Motion category in the blocks
palette, then click and drag the move (10) steps
block so it locks into place under the trigger block
on the code area.
As the name suggests, this tells your sprite
– the cat – to move a set number of steps in the
direction it’s currently facing.
Next, add more instructions to your program
to create a sequence: click on the Sound category,
colour-coded pink, then click and drag the
play sound [Meow] until done block so it locks
underneath the move (10) steps block. Now keep
S Figure 3: Save your program with a memorable name the sequence going: click on the Motion category

Programming with Scratch 3 magpi.cc 49


TUTORIAL

runs before you can see the cat sprite move. There’s
another way to fix this, beyond using the play
sound [Meow] until done block: click on the light
orange Control category of the blocks palette, then
click and drag a wait (1) seconds block between
the play sound [Meow block and the bottom move
(-10) steps block.

when green flag clicked


move (10) steps
play sound [Meow v]
wait (1) seconds
move (-10) steps
S Figure 4: To delete a
block, simply drag it again and drag another move (10) steps block
out of the code area underneath your Sound block, but this time change Click the green flag to run your program one last
“10” to “-10” to create a move (-10) steps block. time, and you’ll see that the cat sprite waits for
a second after moving to the right before moving
when green flag clicked back again. This is known as a delay, and is key to

Top Tip move


play
(10) steps
sound [Meow] until done
controlling how long your sequence of instructions
takes to run.
move (-10) steps
What can Looping the loop
it say? Click the green flag above the stage to run the The sequence you’ve created so far runs only once.
program. You’ll see the cat move to the right, make You click the green flag, the cat sprite moves and
Some blocks in
Scratch can be a ‘meow’ sound – make sure you’ve got speakers or meows, and then the program stops until you
modified. Try headphones connected to hear it – then move back click the green flag again. It doesn’t have to stop,
clicking on the word to the start again. Every time you click the green though, because Scratch includes a type of Control
‘Hello!’, then type
something else and
flag the cat will repeat these actions. block known as a loop.
click the green flag Congratulations! You’ve created a sequence of Click on the Control category in the blocks
again. What happens instructions, which Scratch is running through one palette and find the forever block. Click and drag
on the stage?
at a time, top to bottom. While Scratch will only this into the code area, then drop it underneath
run one instruction at a time from the sequence, the when green flag clicked block and above the
it does so very quickly: try deleting the play sound first move (10) steps block.
[Meow] until done block by clicking and dragging
the bottom move (-10) steps block to detach it, when green flag clicked
dragging the play sound [Meow] until done block forever
Top Tip to the blocks palette, then replacing it with the move (10) steps
simpler play sound [Meow] block before dragging play sound [Meow v]
Add steps your move (-10) steps block back onto the bottom wait (1) seconds
of your program. move (-10) steps
Try adding more
steps to your
sequence and when green flag clicked The C-shaped forever block automatically grows
changing the values move (10) steps to surround the other blocks in your sequence. Click
in the existing steps.
play sound [Meow] the green flag now and you’ll quickly see what the
What happens when
the number of steps move (-10) steps forever block does: instead of your program running
in one move block once and finishing, it will run over and over again
doesn’t match the Click the green flag to run your program again. – quite literally forever. In programming, this is
number of steps
in another? What Only this time the cat sprite doesn’t seem to move. known as an infinite loop – a loop that never ends.
happens if you try to The sprite is moving, but it moves back again so If the sound of constant meowing is getting
play a sound while quickly that it appears to be standing still. This is to be a little much, click the red octagon next to
another sound is
because using the play sound [Meow] block doesn’t the green flag above the stage area to stop your
still playing?
mean that the program will wait for the sound program. To change the loop type, pull the first
to finish playing before the next step. Because move (10) steps block, and the blocks beneath
Raspberry Pi ‘thinks’ so quickly, the next instruction it, out of the forever block, then drop them

50 magpi.cc Programming with Scratch 3


TUTORIAL

program by clicking Save


to your computer. If you
saved the program earlier,
you’ll be asked if you want
to overwrite it, replacing
the old saved copy with
your new, up-to-date
version. Next, click File
and then New to start a
new, blank project (click
OK when asked if you want
to replace the contents W Figure 5: Give your
of the current project). new variable a name
underneath the when green flag clicked block. Click on the dark orange Variables category in the
Click and drag the forever block to the blocks blocks palette, then the Make a Variable button.
palette to delete it, then click and drag the repeat Type “loops” as the variable name, then click OK
(10) block under the when green flag clicked to make a series of blocks appear in the blocks
block so it goes around the other blocks. palette (Figure 5).
Click and drag the set loops to [0] block to the
when green flag clicked code area. This tells your program to initialise the
repeat (10)
move (10) steps
variable with a value of 0. Next, click on the Looks
category of the blocks palette and drag the say Top Tip
play sound [Meow v] [Hello!] for (2) seconds block under your set
wait (1) seconds loops to [0] block. What
move (-10) steps happens
set [loops v] to (0) now?
Click the green flag to run your new program. say [Hello!] for (2) seconds
What happens if you
At first, it seems to be doing the same thing as change the number
your original version: repeating your sequence As you found earlier, the say [Hello!] blocks in the loop block
of instructions over and over again. This time, cause the cat sprite to say whatever is written to make it larger?
What happens if
though, rather than continuing forever, the loop in them. Rather than writing the message in the it’s smaller? What
will finish after ten repetitions. This is known as block yourself, though, you can use a variable happens if you put
a definite loop – you define when it will finish. instead. Click back onto the Variables category in the number 0 in the
loop block?
Loops are powerful tools, and most programs, the blocks palette, then click and drag the rounded
especially games and sensing programs, make (loops) block – known as a reporter block, found
heavy use of both infinite and definite loops. at the top of the list with a tick-box next to it –
over the word Hello! in your say [Hello!] for (2)
Variables and conditionals seconds block. This creates a new, combined block:
The final concepts you’ll need to understand before say [loops] for (2) seconds.
beginning to code Scratch programs in earnest are
closely related: variables and conditionals. A variable set [loops v] to (0)
is, as the name suggests, a value which can vary – in say (loops) for (2) seconds
other words, change – over time and under control
of the program. A variable has two main properties: Click on the Events category in the blocks
its name, and the value it stores. That value doesn’t palette, then click and drag the when green flag
have to be a number, either. It can be numbers, text, clicked block to place it on top of your sequence
true-or-false (also known as boolean values), or of blocks. Click the green flag above the stage
completely empty – known as a null value. area, and you’ll see the cat sprite say ‘0’ – the
Variables are powerful tools. Think of the value you gave to the variable ‘loops’ (Figure 6).
things you have to track in a game: the health Variables aren’t unchanging, though. Click on
of a character, the speed of moving object, the the Variables category in the blocks palette, then
level being played, and the score. All of these are click and drag the change loops by 1 block to the
tracked as variables. bottom of your sequence.
First, click the File menu and save your existing Next, click on the Control category, then click

Programming with Scratch 3 magpi.cc 51


TUTORIAL

change [loops v] by (1)

Click on the green flag above the stage area and


you’ll find the program works the same way as
before: the cat sprite counts from 0 up to 9 and
then the program stops. This is because the repeat
until block is working in exactly the same way as
the repeat (10) block, but rather than counting
the number of loops itself, it’s comparing the
value of the loops variable to the value you typed
to the right of the block. When the loops variable
reaches 10, the program stops.
This is known as a comparative operator:
it literally compares two values. Click on the
Operators category of the blocks palette and find
S Figure 6: This time
the cat will say the
and drag a repeat (10) and drop it so that it starts the two other diamond-shaped blocks above and
value of the variable directly beneath your set loops to 0 block and below the one with the = symbol. These are also
wraps around the remaining blocks in your sequence. comparative operators: < compares two values and
is triggered when the value on the left is smaller

Top Tip when green flag clicked


set [loops v] to (0)
than the one on the right, and > triggers when the
value on the left is larger than the one on the right.
repeat (10) Click on the Control category of the blocks
Counting say (loops) for (2) seconds palette, find the if then block, then click and
from zero change [loops v] by (1) drag it to the code area before dropping it directly
beneath the say [loops] for (2) seconds. It will
Although the loop
you’ve created Click the green flag again. This time, you’ll see the
runs ten times, cat count upwards from 0 to 9. This works because
the cat sprite only
counts up to nine.
your program is now changing, or modifying, the T his Operators block lets
variable itself: every time the loop runs, the program
This is because
we’re starting with adds one to the value in the ‘loops’ variable. you compare two values,
a value of zero You can do more with a variable than modify it.
for our variable.
Including zero and
Click and drag the say (loops) for (2) seconds including variables
nine, there are ten block to break it out of the repeat (10) block and
numbers between drop it below the repeat (10) block. Click and automatically surround the change loops by 1
zero and nine – so drag the repeat (10) block to the blocks palette to block, so click and drag on that block to move
the program stops
before the cat ever delete it, then replace it with a repeat until block, it so it connects to the bottom of your if then
says ‘10’. To change making sure the block is connected to the bottom block instead. Click on the Looks category of the
this, you could set the of the set loops to [0] block. It should surround blocks palette, then click and drag a say [Hello!]
variable’s initial value
both of the other blocks in your sequence. Next, for (2) seconds block and drop it inside your if
to 1 instead of 0.
click the Operators category in the blocks palette, then block. Click on the Operators category of the
colour-coded green, then click and drag the
diamond-shaped () = () block and drop it on
the matching diamond-shaped hole in the repeat
until::control reporter block.
This Operators block lets you compare two values,
including variables. Click on the Variables category,
drag the (loops) reporter block into the empty space
in the () = () Operators block, then click on the
space with 50 in it and type the number 10.
When green flag clicked:

set [loops v] to (0)


X Figure 7: Thanks to
the loop, the cat now
repeat until <(loops) = (10)>
counts upwards say (loops) for (2) seconds

52 magpi.cc Programming with Scratch 3


TUTORIAL

W Figure 8: Using a ‘repeat


until’ block with a
comparative operator

S Figure 9: The cat


blocks palette, then click and drag the () > () File and New. Before you begin, give it a name by makes a comment
block into the diamond-shaped hole in your if clicking on File and Save to your computer: call it when the number
reaches six
then::control reporter block. ‘Astronaut reaction timer’.
The if then block is a Conditional block, This project relies on two images – one as a
which means the blocks inside it will only run if stage background, one as a sprite – which are
a certain condition is met. Click on the Variables not included in Scratch’s built-in resources. To
category of the blocks palette, drag and drop the
(loops) reporter block into the empty space in
download them, click on the Raspberry Pi icon
to load the Raspberry Pi menu, move the mouse Top Tip
your () > () block, then click on the space with pointer to Internet, and click on Chromium Web
50 in it and type the number 5. Finally, click on Browser. When the browser has loaded, type Challenge:
the word Hello! in your say [Hello!] for (2) rptl.io/astro-bg into the address bar, then press high and low
seconds block and type “That’s high!”. the ENTER key. Right-click on the picture of space
How could you
and click on Save image as, then click on the Save change the program
when green flag clicked button (Figure 10). Click back into the address so the cat sprite
set [loops v] to (0) bar, and type rptl.io/astro-sprite followed by the comments on how
low the numbers
repeat until <(loops) = (10)> ENTER key. below five are
say (loops) for (2) seconds Again, right-click on the picture of Tim Peake instead? Can you
if <( loops) > (5)> then and click on Save image as, then choose the change it so that the
cat will comment
say [That’s High!] for (2) seconds Downloads folder and click on the Save button.
on both high and
end With those two images saved, you can close low numbers?
change [loops v] by (1) Chromium or leave it open and use the taskbar to Experiment with the
switch back to Scratch 3. if then else block to
make this easier!
Click the green flag to run your program. At Right-click the cat sprite in the list and click
first, it will work as before with the cat sprite delete. Hover the mouse pointer over the Choose
counting upwards from zero. When the number a Backdrop icon. Next, click the Upload Backdrop
reaches six, the first number greater than five, icon from the list that appears.
the if then block will begin to trigger and the cat T Figure 10: Save the
sprite will comment on how high the numbers are background image
getting (Figure 9). Congratulations: you can now
work with variables and conditionals!

Build an astronaut reaction timer


Now that you understand how Scratch works, it’s
time to make something a little more interactive:
a reaction timer, designed to honour British ESA
astronaut Tim Peake and his time aboard the
International Space Station.
Save your existing program, if you want to
keep it, then open a new project by clicking on

Programming with Scratch 3 magpi.cc 53


TUTORIAL

Find the Space- when green flag clicked


background.png file say [Hello! British ESA Astronaut Tim Peake
in the Downloads here. Are you ready?] for (2) seconds
folder, click on it to wait (1) seconds
select it, then click say [Hit Space!]
OK. The plain white reset timer
stage background
will change to the Add a wait until block, then drag a key space
picture of space, pressed? Sensing block into its white space.
and the code area This will pause the program until you press the
will be replaced SPACE key on the keyboard, but the timer will
S Figure 11: The space
background appears
by the backdrops area (Figure 11). Here you can continue to run – counting exactly how much
on the stage draw over the backdrop, but for now just click on time has passed between the message telling you
the Code tab at the top of the Scratch 3 window. to ‘Hit Space!’ and when you actually press the
Upload your new sprite by hovering your SPACE key.
mouse pointer over the Choose a Sprite icon.
Next, click the Upload Sprite icon at the top of when green flag clicked
the list that appears. Find the file Astronaut- say [Hello! British ESA Astronaut Tim Peake
Tim.png in the Downloads folder, click to select here. Are you ready?] for (2) seconds
T Figure 12: Drag it, then click OK. The sprite appears on the wait (1) seconds
the astronaut
stage automatically, but it might not be in the say [Hit Space!]
sprite to the lower
middle of the stage middle of the stage: click and drag it with the reset timer
mouse and drop it so wait until <key [space v] pressed?>
it’s near the lower
middle (Figure 12). You now need Tim to tell you how long you
With your new took to press the SPACE key, but in a way that’s
background and easy for you to read. To do this, you’ll need a
sprite in place, you’re join () () Operators block. This takes two values,
ready to create your including variables, and joins them together one
program, so click after the other – known as concatenation.
the Code tab. Start Start with a say [Hello!] block, then drag and
by creating a new drop a join () () Operators block over the word
variable called time, Hello!. Click on apple and type “Your reaction
making sure that For time was ” – make sure you have a blank space
all sprites is selected at the end – then drag another Join block over
before clicking OK. Click on your sprite – either on the top of banana in the second box. Drag a timer
the stage or in the sprite pane – to select it, then Reporting block from the Sensing category into
add a When green flag clicked :: reporter block what is now the middle box, and type “ seconds.”
from the Events category to the code area. Next, into the last box – make sure to include a blank
add a say [Hello!] for (2) seconds:: reporter block space at the start.
from the Looks category, then click on it to change
it to say Hello! British ESA Astronaut Tim Peake when green flag clicked
here. Are you ready? say [Hello! British ESA Astronaut Tim Peake
here. Are you ready?] for (2) seconds
when green flag clicked wait (1) seconds
say [Hello! British ESA Astronaut Tim Peake say [Hit Space!]
here. Are you ready?] for (2) seconds reset timer
wait until <key [space v] pressed?>
Add a wait (1) seconds block from the Control say (join [Your reaction time was ] (join
category, then a say [Hello!] block. Change this (timer) [ seconds])
block to say ‘Hit Space!’, then add a reset timer
block from the Sensing category. This controls a Finally, drag a set my variable to [0] Variables
special Scratch variable for timing things, and will block onto the end of your sequence. Click on the
be used to see how quickly you react. drop-down arrow next to ‘my variable’ and click

54 magpi.cc Programming with Scratch 3


TUTORIAL

W Figure 13: Time to play the


game!

on ‘time’ from the list, then replace the 0 with a


timer Reporting block from the Sensing category.
Your game is now ready to test by clicking on
the green flag. As soon as you see ‘Hit Space!’,
S Figure 14: Tim tells
press the SPACE key as quickly as you can block onto the end of your sequence and add two you how far the ISS
(Figure 13). join::operators reporter blocks, just as you did has travelled

You can extend this project further by having before. In the first space, over apple, type “In that
it calculate roughly how far the International time the ISS travels around ”, remembering a space
Space Station has travelled in the time it took you at the end; in the banana space, type “ kilometres”,
to press the SPACE key, based on the station’s again remembering a space at the start.
published speed of 7km/s. First, create a new Finally, drag a join Operators block into the
variable called distance. Notice how the blocks middle blank space, then drag a distance Reporting
in the Variables category automatically change block into the new blank space it creates. The join
to show the new variable, but the existing (time)
variable blocks in your program remain the same.
block rounds numbers up or down to their nearest
whole number, so instead of a hyper-accurate but Top Tip
Add a set distance to [0] block, then drag hard-to-read number of kilometres you’ll get an
a () * () Operators block – which indicates easy-to-read whole number. Challenge:
multiplication – over the 0. Drag a (time) Click the green flag to run your program and custom
Reporting block over the first blank space, then see how far the ISS travels in the time it takes artwork
type the number 7 in the second space. When you to hit the SPACE key. Remember to save your
You can click
you’re finished, your combined block reads set program when you’re finished, so you can easily on a sprite or
distance to time * (7)::variables reporter. load it again in the future without having to start background, then
This will take the time it took you to press the from the beginning (Figure 14)! click the Costumes
or Backdrops tab to
SPACE key and multiply it by seven, to get the bring up an editor
distance in kilometres the ISS has travelled. when green flag clicked with drawing tools.
say [Hello! British ESA Astronaut Tim Peake Can you draw your
own characters and
when green flag clicked here. Are you ready?] for (2) seconds
background and edit
say [Hello! British ESA Astronaut Tim Peake wait (1) seconds the code to have
here. Are you ready?] for (2) seconds say [Hit Space!] your character say
wait (1) seconds reset timer something different?

say [Hit Space!] wait until <key [space v] pressed?>


reset timer say (join [Your reaction time was ] (join
wait until <key [space v] pressed?> (timer) [ seconds])
say (join [Your reaction time was ] (join set [time v] to (timer)
(timer) [ seconds]) set [distance v] to ((time) * (7))
set [time v] to (timer) wait (4) seconds
set [distance v] to ((time) * (7)) say (join [In that time the ISS travels
around ] (join (distance:: variables) [
Add a wait (1) seconds block and change it to kilometres.])
4. Next, drag another say [Hello!]:: reporter

Programming with Scratch 3 magpi.cc 55


TUTORIAL

CDP Studio:
Control a robot arm
Part 02

with a Wii Remote


Use CDP Studio with a Nintendo Wii controller to
manipulate a Raspberry Pi-based robot arm

L ast issue, we showed you how to use the


CDP Studio software development tool
and its Kinematics framework to record
movements for a Raspberry Pi-based robotic
arm – the myCobot 280 Pi from Elephant
CDP Studio 4.12, along with the one already ticked
for your host PC. You will then be able to deploy
projects to the myCobot 280 Pi arm, which uses a
64-bit version of Ubuntu.
If you already have CDP Studio installed, make
Robotics – that could then be played back to sure it’s updated to the latest version (Help >
perform a ‘pick and place’ routine using the Check For Updates). Then go to Help > Package
Adaptive Gripper add-on. This time we’ll using Manager and select ‘Add or remove CDP versions’
Phil
MAKER

the same setup, but controlling the arm manually to add the ARMv8 64-bit (Debian 11) component if
King
using a Nintendo Wii Remote and Nunchuk. not already added.
Long-time contributor If you don’t have the robot arm, you can still
to The MagPi, Phil is a run the project by deploying it to a Raspberry Pi
freelance writer and
editor with a focus and viewing the movements in the on-screen
on technology.

@philkingeditor
arm visualiser.
02    Download the project
This is a complex project that would
be time-consuming to build from scratch, so
we’ll download it from CDP Studio’s GitHub

01    Install the software


If you haven’t already done it for the
repo. Go to magpi.cc/mycobotwiiremote, click
the green Code button, and select ‘Download
T You need to previous tutorial, you’ll need to install CDP Studio. ZIP’. Unzip the file on your PC. Move the
pair CDP Studio
with the arm’s
On your PC, visit cdpstudio.com/getstarted and resulting myCobotWiiRemote-main folder to
Raspberry Pi download the free non-commercial version for the CDPStudioWorkspace/systems folder.
over the Wi-Fi
network to deploy
Windows or Linux. During installation, select the
the project ‘ARMv8 64-bit (Debian 11)’ component under

03    Download and build library


To deploy the project to the robot arm,
you’ll need a couple of libraries. If you don’t
already have the myCobotLib library from the
previous tutorial, go to the GitHub repo at
magpi.cc/mycobotlib, click the Code button and
Download ZIP again. Extract it and then move
the resulting myCobotLib-main folder to the
CDPStudioWorkspace/libraries folder.
Open the myCobotLib.pro project file in CDP
Studio, check ARM 64-bit is checked in the Deploy
Configuration tab, then right-click its name in the
left panel and select Build.
You’ll also need the xwiiremotelib library
at magpi.cc/xwiimotelib and the xwiimote

56 magpi.cc CDP Studio: Control a robot arm with a Wii Remote


TUTORIAL

We run the project in CDP


Studio on a PC and deploy
it over the network to the
myCobot’s Raspberry Pi

You’ll Need
The arm’s end-point > Windows or Linux PC
can be moved and > CDP Studio 4.12
its Adaptive Gripper cdpstudio.com/
attachment opened getstarted
and closed
> myCobot 280 Pi
robot arm
magpi.cc/
mycobot280

> myCobot
Adaptive Gripper
magpi.cc/
mycobotgripper

> Wii Remote


and Nunchuk

The myCobot 280 Pi


robot arm will follow the
movements of the Wii
Remote or Nunchuk

submodule on which it’s based at magpi.cc/


xwiimote. You can either clone the library with the
recursive option:

$ git clone --recursive https://github.com/


CDPTechnologies/xwiimotelib.git

Or you can download and extract the ZIP file,


then download and extract the xwiimote ZIP
and place the folder’s contents into the library’s
xwiimote subfolder.
Move the xwiimotelib-main folder to
CDPStudioWorkspace/libraries, then open the
xwiiremotelib.pro project file in CDP Studio. Before
building the library, open the Deploy Configuration
tab for the wiimoteIO component and check that
S Pair and then
the ARMv8 64-bit (Debian 11) toolkit is enabled. connect the Wii
If you get errors when building it, make sure CDP comprises a myCobotWiiRemoteController Remote controller
with the arm using
Studio has been updated (see Step 1). application with various components. A key part the Bluetooth
is the Kinematics-based ArmDHModel, which Manager in Ubuntu

features a DHChain Visualizer pane that can be


used to view the arm positions on-screen in 3D.

04    Open the project


Now open the main myCobotWiiRemote.
This can be used even if you don’t have a real arm
connected, so you can still run the project and see
pro project file in CDP Studio. In the left panel how your Wii Remote and Nunchuk actions affect
of the Configure window, you’ll note that it its movements.

CDP Studio: Control a robot arm with a Wii Remote magpi.cc 57


TUTORIAL

$ sudo systemctl restart sshd

06    Pair the arm with CDP


Open the Deploy Configuration tab for
myCobotWiiRemoteController. Under Networks,
press the Select button for ‘WiFi’. The ‘Devices
– WiFi’ table below should start showing any
devices available to pair with CDP Studio. Click the
Username field for your myCobot (based on its IP
address) and enter ‘er’, then click the Pair button
S You can test the
Wii Remote with next to it. You will be prompted to enter the

05   Prepare myCobot password – the default is Elephant.


the ‘xwiishow 1’
command in a
terminal in the If you’ve already set this up in the first Under Applications, for Device select your
arm’s Ubuntu OS tutorial, you can skip the first part of this step. myCobot IP address or name, then change the
The myCobot arm’s Ubuntu OS has a non- Toolkit to ARMv8 64-bit (Debian 11). When
standard version of the OpenSSH server. So you run the myCobotWiiRemote project, it will

Top Tip you’ll need to make a small change to a config


file so CDP Studio can communicate with it
then be deployed over the wireless network to
the robot arm.
over the network. SSH into the myCobot with
Another arm the username ‘er’ at its IP address; the default
password is Elephant. Then enter:
While this project
is designed for
the myCobot 280 $ sudo nano /etc/ssh/sshd_config 07    Pair the Wii controllers
You’ll need to pair the Wii Remote and
Pi, you could use Nunchuk controllers via Bluetooth with the
a different robot
arm – you’d just
Locate the line that sets the robot arm’s Raspberry Pi. First, open the battery
need to create PubkeyAuthentication parameter and set it to yes compartment of the Wii Remote and press
a new IO library (and make sure the line is not commented out). the small red Sync button to start pairing; the
to communicate
Press CTRL+X, then Y to exit and save. Remote’s blue player LED should start blinking.
with it.
Restart the OpenSSH server with: Now, from the robot arm’s Ubuntu MATE
desktop (viewed on a monitor or remotely via

X You can view the arm’s


movements on-screen
in the ArmDHModel
DHChain Visualizer

58 magpi.cc CDP Studio: Control a robot arm with a Wii Remote


TUTORIAL

T You can see how the


VNC), open the Menu (top left) then search for project’s components
and open Bluetooth Manager. Click Search and you connect to each
other in the Block
should see the Wii Remote, possibly as ‘Nintendo Diagram view
RVL-CNT-01’; select it and choose Pair. The
Remote’s LED should stop blinking.

08    Run the project


Right-click myCobotWiiRemote in the
left panel of CDP Studio and select Run & Connect.
If you have a myCobot arm connected, it should
follow the movements you make with the Wii
controllers; if not, select ArmDHModel in the
project’s left panel to view a 3D representation of
the arm with its six joints. The gripper status is
indicated by a green (closed) or grey (open) dot.
By default, the arm’s servos are released. Press
the Remote’s 2 button to engage them. Now hold
the A button and tilt the Remote to tilt the arm’s
endpoint accordingly. Note that if you move
outside the arm’s range, the Remote will rumble.
Pressing the Home button returns the arm to a
preset home position. 10    Exploring the project
You can click the Block Diagram tab to see
The Nunchuk’s joystick can be used to move the
arm’s endpoint forward, back, left, and right. When
how the project’s block-based components have
been put together. These include an IO block to Top Tip
holding the Z button, you can also tilt the Nunchuk interpret the controller actions, along with blocks
to move the endpoint up and down. Pressing the for the desired arm position, gripper orientation, No arm?
C button toggles the gripper status between open and gripper open/closed status. A couple of
You can still run
and closed. mux blocks enable the arm’s home position and the project without
To disengage the servos again, press the orientation to be triggered. The ArmDHModel a robot arm, by
Remote’s 1 button, but be ready to catch the limp block calculates the arm joint angles required for a deploying it to a
Raspberry Pi (or
arm as it falls! required position, and also triggers the Wii Remote other Linux PC).
rumble if a position is out of range. Just make sure
To take the project even further, you could the ARM toolkit
used matches the
add some extra actions for the unused controller
32-bit or 64-bit

09   Kinematics
This project makes used of CDP
buttons – by opening the xwiimoteIO.cpp code
file and adding events and return codes for them
architecture of
its OS.
Studio’s Kinematics framework, in the form of there, then creating actions for the latter in the
the DHChain component. The basic concept of main application.
kinematics is that if you input joint angles for a
robot arm, or chain of links, the framework can
calculate the end position in 3D space. This is used
to control the arm’s joint movements to reach
a certain x/y/z position, such as for the home
position and the those reached via the Wii and
Nunchuk movements.
Kinematics has many uses in the field of
engineering, helping to calculate positions and
velocities of moving parts such as those in
an industrial robotic arm, or a bionic limb or
exoskeleton. An example real-world case is the S Using the Nunchuk, you
can manoeuvre the arm’s
use of CDP Studio and kinematics is for controlling Adaptive Gripper and close
deck cranes on ships. it to pick up an object

CDP Studio: Control a robot arm with a Wii Remote magpi.cc 59


TUTORIAL

Rescue your
backups
Recover data from ageing floppy disks,
CDs and Zip disks before it’s too late!

T his month, we’re going to rescue hard-to-


read media, from forensic disk imaging
tools that attempt to recover data from
your drive, bit-by-bit, to the important manual
work of cleaning your disks and drives to restore
02   Using ddrescue
ddrescue should not be used on a read-
write mounted drive – we’ll directly address the
device name without mounting it. If your device is
auto-mounted, unmount it before you begin the
deterioration and prevent further damage. rescue process. We’ll provide an example.
We’ll take a close look at recovering data from Insert your disk, and list your block devices with
CDs and floppy disks, helpful physical and software this command:
K.G.
MAKER

tools, and even help you get equipped to recover


Orphanides
data from Iomega’s Zip disk superfloppy formats. $ lsblk
K.G. still has all their Please note that none of the techniques detailed
childhood floppy here are a substitute for professional disk recovery, Our floppy drive shows up as /dev/sda, while
disks, unfortunately
including the one and that attempting to read damaged floppy disk CDs appear at /dev/sr0. The MOUNT POINTS
in the photo used media can harm both the disk and your disk drive. column indicates whether or not it’s mounted. If
to illustrate an required, we can unmount it thus:
unrecoverably
damaged floppy.
$ sudo umount /dev/sda
@owlbear
  Introducing ddrescue
01 In issue 140 (magpi.cc/140), we looked at The basic ddrescue command (including a
using the Linux dd command to make byte-for-byte mapfile) is ddrescue [device block] [filename
images of (non-copy-protected) floppy disks. You to save] [mapfile name]. /dev/sda requires root
can also use it to create an iso file copy of a CD (once permissions on Raspberry Pi OS, so type:
again, assuming it doesn’t have copy protection).
But if your storage media are too damaged to be fully
read, then your image files will be unusable.
Warning! The GNU ddrescue data recovery tool is an
Copyright! entirely separate tool to dd, despite the similar
name. It’s designed to retry and hopefully rescue
This feature discusses data from damaged areas of your medium. You
making backup copies
of CD-ROMs and floppy can have it create a log (mapfile) that allows you
disks. Please ensure that
you have a licence to
to to interrupt and seamlessly resume it, and
reproduce a disk before use tools to visualise the damage to your disk.
doing so.
We’ll also use the ddrescueview mapfile viewer.
copyright.gov
magpi.cc/copyright
Like dd, ddrescue only works on disk formats
that your operating system can mount, which
is generally limited to IBM PC formatted disks.
X Beware: Circular
scratch patterns on
Open a terminal and type:
a floppy disk can
indicate damage that
can in turn damage
$ sudo apt install gddrescue ddrescueview
your drive heads

60 magpi.cc Rescue your backups


TUTORIAL

This 3D printed frame holds the disk open,


allowing both sides to be accessed for
cleaning with isopropyl alcohol
You’ll Need
> USB floppy drive

> USB disk drive

> Access to a 3D
printer (optional)

The handle part of the disk


cleaning kit allows you
to rotate the disk so that
you can get to the entire Warning!
read surface. It also helps Solvents!
you test that your disk
We discuss the use of
can turn smoothly before
isopropyl alcohol and
putting it in a drive cyclomethicone. Both are
flammable solvents and
eye irritants which should
be kept out of the reach
of children and animals to
avoid accidental ingestion.

magpi.cc/solventsafe
   Merge two rescue images
$ sudo ddrescue /dev/sda floppy.img floppy1.log
04 ddrescue can also be used to merge two
Once the process is complete, you can give images. The command structure is:
ownership of the files to yourself:
ddrescue – m [mapfile to merge] [image to
$ sudo chown YourUserName floppy.* merge] [merged image] [merged mapfile]

Repeat this for as many mapfile and image


pairs as you have to merge, targeting the same

03    Check progress with ddrescueview


ddrescueview is a GUI tool that can open
merged image and mapfile each time.
This is particularly useful for recovering
ddrescue mapfiles (previously known as logfiles data using multiple drives. Different drives
– a term you’ll still see reference to in ddrescue can read the media differently enough to
flags and conventions. You can start rescueview each recover data that the other missed,
from your Raspberry Pi OS’s Accessories menu, or allowing a more complete image to be
from a terminal with the command: reconstructed by combining their reads.

$ ddrescueview floppy1.log

You can use it to watch ddrescue’s progress and


get an overview of a disk’s rescue status. We also 05    Cleaning a CD
Most CD read problems are the result of
S Although it’s possible
to jury-rig adaptors
for internal and even
found it useful to create visual comparisons of dirt or fingerprint smudges on the disc, which parallel Zip drives,
rescue attempts using different drives. can be safely wiped off with a microfibre cloth. USB drives are by
far the most reliable
You’ll find the full ddrescueview manual at It is also safe to use water, alcohol and washing way of accessing Zip
magpi.cc/ddrescuedocs up liquid, individually or in combination, to clean disks on Raspberry Pi

Rescue your backups magpi.cc 61


TUTORIAL

Download both parts of Lemaru’s 3.5in Floppy


Disk Cleaning Tool at magpi.cc/diskcleanertool
– they’ve also created cleaning tools for 3in disks
(used by Amstrad in the UK) and 5.25in floppies,
which, which you’ll find on their Thingiverse
X When working with
floppy disks, it’s a
account. They’re simple prints, and Lemaru
good idea to make provides slicer configuration suggestions for
them physically
read-only. On most
Creality Ender 3 printers.
3.5in disks, you just
need to slide this
switch to expose
a square hole

CDs. Make sure to completely dry the media 08    Clean your floppy disks
To clean your floppy, mount it face-down
and ensure that it’s streak-free. Immersing CDs in the 3D-printed cradle with the metal disc cover
in water is usually safe, but can, in rare cases, open. The disk holder will keep this open. Line up
damage the top layer of the disc, so is best avoided the handle so that the square and rectangle slot
unless strictly necessary. into those on the disk’s central hub. You’ll now be
If the damage is visible from the underside of able to rotate the internal disc for cleaning, giving
the disc but appears to affect the top layer or even you access to both sides of the disk. If necessary,

Top Tip interior, this can’t be cleaned or repaired, although


we have managed to use ddrescue over a period
blow dust away using a can of compressed air or
an electronics cleaning blower. Clingier mould and
of several days to recover data from a CD with the dirt can be removed with 70% to 99% isopropyl
RTM beginning stages of oxidation of the disc’s data alcohol on a microfibre cloth, on single-use
layer, also known as “disc rot” or “bit rot”. alcohol wipes, or even a cotton bud if you’re
The ddrescue
manual can be careful. We recommend higher volume alcohol, as
found at magpi.cc/ it evaporates faster. Give the alcohol time to dry
ddrescueman before inserting the disk into a drive.

06    CD scratch removal
If your CD has significant scratches on the
bottom, these can cause read errors. The best tool to
correct these is a professional-grade CD resurfacing
machine (magpi.cc/ecopro2), which removes and 09   Lubrication
A companion measure to cleaning your
replaces the bottom layer of a damaged disk. In disk with isopropyl is lubrication. Apply a scant
the UK, many branches of CEX have one and will drop or two or of the silicone oil cyclomethicone
resurface your discs for a small fee. and then rotate the disk to lubricate it. The
If you live somewhere where that’s not an Cyclomethicone evaporates particularly fast, but
option, you can try to buff out scratches from your can temporarily smooth over damage sufficiently
disk with Brasso metal polish, using a microfibre
cloth and a circular motion. Ensure that you fully
remove the polish from the disc with water after
polishing. For a good look at the technique, see
this video: magpi.cc/polishdisc

X On most 5.25in
07    Print your own
floppy cleaning toolkit
floppies, you’ll need Floppy disks can degrade over time, shedding their
to cover the disk’s
write-protection
magnetic surface, but more often, read errors are
notch with a sticker caused by dust or mould on the surface of the disk.
to make it read-only.
These were provided
This can be cleaned off with isopropyl alcohol,
with packs of disks, but you’ll need a way to rotate the accessible
but any sturdy,
opaque sticker
surface of the floppy. Fortunately, the 3D printing
or tape will do community has you covered.

62 magpi.cc Rescue your backups


TUTORIAL

to allow a floppy to be read, even in cases where a


disk has visible scratches. Note that using solvents
can accelerate the destruction of a disk’s surface
if it is already decaying and that trying to read
 sing solvents can
U
a damaged disk can in turn damage your floppy accelerate the destruction T ddrescueview can
drive’s heads.
of a disk’s surface open a map file
created by ddrescue,
allowing you
visualise the status
of your disk recovery

10    Clean your floppy drive heads


If you’re going to be using dirty disks in
your floppy drive, its drive heads can accumulate
dirt. This can in turn cause read errors and even
damage to disks that are inserted into them. The
easiest solution to this is a floppy drive cleaning
disk, but if you don’t have one, you’ll have to find
second hand, refurbished or new old stock. While
their accompanying bottles of isopropyl alcohol
may have dried up, we’ve already got some of that.
You can also manually clean your floppy
drive heads, either via the slot or, better, by
disassembling it, which also allows you to
lubricate its rails with white lithium grease, but
this can damage the heads if not done with care
and is labour-intensive.

Reading Zip disks Top Tip


In the late ’90s, Iomega’s Zip disks were briefly popular running Linux or Windows, or an older 32-bit Mac. If you Format
in academia, enterprise and music production as a hope to access a common parallel port Zip drive, you’ll restrictions
high-capacity, rewritable storage medium. Zip drives have more trouble. Although multi-purpose USB to
would become the most widely used high-capacity parallel chips exist, the majority of USB parallel cables can If you need to copy
‘superfloppy’ disk format, until they were swept away only handle LPT printer connections. The discontinued disks for other
by first writable and rewritable CDs and then sol- StarTech ICUSB2321284 should do the job, but the newer computer systems,
id-state storage. ICUSB1284D25 does not, for example. such as the Amiga
or Atari ST, you’ll
If you need to retrieve data from a Zip disk, you should Similarly, internal ATAPI Zip drives don’t appear correctly
want a flux copying
obtain a USB Zip drive, which will simply display the disk as when connected to many modern IDE/SATA to USB
device such as
a USB mass storage device on most modern computers. adaptors, while older adaptors that only support IDE to Greaseweazle
The number in the names of each of the main three Zip USB are more likely to work. You’ll also need a true ATAPI
generations – the Zip 100, Zip 250 and Zip 750 – indicates Zip drive, rather than earlier IDE Zip drives that didn’t use
the capacity of its discs. The final generation of Zip drives, the ATAPI protocol – this can be a bit hit and miss with Zip
the Zip 750 released in 2002, had a capacity of 750MB. 100 models in particular. For a video guide to connecting
Each generation of drive can read both its own and the internal Zip drives, see magpi.cc/zipdriveusbide
previous generation of Zip discs. Zip drives from the ’90s were prone to the ‘Click of
The Zip 250 can only write to Zip 100 disks slowly Death’, which affected an estimated one in 200 drives
and the Zip 750 can’t write to Zip 100 disks at all. at the time of a 1998 lawsuit. But the disks appear to be
Write speeds can, however, be disregarded for robust – we were able to read all of the 25+ year old Zip
recovery purposes. media we’ve tried, making Zip drives a useful way of
Zip 100 disks are the most common, but if you’re getting large amounts of data onto old computers, once
looking to recover your own backups, you’ll need to make you’ve retrieved your precious file archives from them.
sure you have a drive that is at least as high capacity as the We were unable to obtain SCSI or FireWire models for
disks you wish to read. testing, although, like USB models, the latter should work
If you have a USB Zip drive, then you’re in luck. Just on any computer with FireWire support. Zip drives are not
plug it into Raspberry Pi – or indeed any modern PC compatible with Jaz disks, a sibling product from Iomega.

Rescue your backups magpi.cc 63


TUTORIAL

KiCad: making an
RP2040 game controller
Let’s explore adapting our RP2040 layout to make a USB game controller

I
n earlier articles in this series, we We want to add six tactile buttons to our RP2040:
established that we have a reasonable four in a D-pad arrangement and two as A- and
working RP2040 layout, so now it’s B-style buttons. We want these buttons to be
pretty trivial to create new RP2040 momentary press buttons and ‘push to make’. We
devices. In the last section we made an then plan to use these buttons to connect one side
‘Urumbu’-style motor driver board, and in to a GPIO and the other side of the button to ground.
Jo Hinchcliffe this section we are going to create a simple USB Scouring the JLCPCB parts library, we came across
game controller (Figure 1). the C221902 button. This part looked a nice size, so
Jo Hinchliffe (AKA
Concretedog) is a constant It’s largely the same process we undertook for the we took a look at the EasyEDA schematic and
tinkerer and is passionate Urumbu project, but simpler. We started by making a footprint. It has four pins and, reading the schematic,
about all things DIY space.
copy of our Urumbu project and cleaned out the files we could see that if we connected pin 2 to a GPIO
He loves designing and
scratch-building both in the new project copy that we wouldn’t need. So, and then connected all the other pins to ground, it
model and high power any particular files like the board edge geometry, the would work as we wanted. Additionally, with the four
rockets, and releases the
designs and components
Gerbers, and CSV files can be deleted as we will SMD pads, it should mechanically be pretty strong.
as open-source. He also replace them with ones generated for the new With our choice made, we used the excellent
has a shed full of lathes project. We also quickly deleted all the Urumbu parts Wokwi EasyEDA 2 KiCad website to convert the
and milling machines and
CNC kit! we didn’t need from the schematic. Note that we supplied footprint to a KiCad format: (hsmag.cc/
don’t really need to delete items in the PCB Editor, easyEDA2KiCad). We then added it to our custom
as when we eventually pull in the updated netlist library. We covered this in earlier sections of this
and bill of materials, we can automatically delete series, but it’s pretty straightforward. You upload the
Figure 1 unreferenced footprints, and the new footprints will EasyEDA JSON file, and it then downloads a KiCad
The completed game
controller PCB be brought in. PCB file with the footprint loaded into it.

64 magpi.cc KiCad: making an RP2040 game controller


TUTORIAL

To add the buttons to our schematic, we created


Figure 2
a custom 4-pin schematic symbol and inserted it Using hierarchical sheets makes it easy to add multiple
into a hierarchical sheet. We wired the GPIO pin and similar connected schematic blocks, such as the buttons

the other pins to ground and then brought out the Figure 3
Our completed PCB layout
GPIO hierarchical pin. We then copied the
hierarchical sheet to create six versions, one for
each button, adjusting the label and the sheet name


as we added each (Figure 2). Again, we’ve covered
this in earlier sections.
Additionally, with
Next, we assigned the new footprints to the
schematic symbols and began to edit the PCB the four SMD pads, our
layout. We created a new board edge geometry SVG PCB should mechanically


in Inkscape with some mount holes before carrying
out the usual exporting of Gerbers, BOM, and be pretty strong
positional files for JLCPCB services (Figure 3).

Having ordered the boards, one final fun activity


This tutorial is from
on the hardware side of this build was to export a
HackSpace magazine.
STEP file from KiCad to model around in FreeCAD. Each issue includes a
To export a basic STEP file from the KiCad PCB huge variety of maker
Editor, select File > Export and then choose STEP as projects inside and
the output format. Note that we haven’t added outside of the sphere
custom 3D models for all of our custom of Raspberry Pi, and
also has amazing
components, so obviously the STEP file isn’t
tutorials. Find out
completely correct, but it serves as a good enough more at hsmag.cc
guide to model around in FreeCAD.

KiCad: making an RP2040 game controller magpi.cc 65


TUTORIAL

HIGH PERFORMANCE
In this tutorial, we’ve looked at creating a gamepad
that’s easy to understand and extend. However, if
you’re looking to build a high-performance gamepad,
then there are lots of things that you need to take
into account. Part placement is obviously a large
part of it, as you need to be able to press buttons
consistently and accurately.
However, another part is the software. Our
CircuitPython code could be improved, but
ultimately, if you’re looking for high performance,
CircuitPython isn’t the right choice. Fortunately,
there is another option.
GP2040-CE is a firmware for RP2040-based devices.
You can configure it with details of what hardware
is connected where. It understands more than just
buttons, so you can add analogue inputs as well.
There’s documentation on the project website:
hsmag.cc/GP2040-CE.

In the free-to-download book FreeCAD For Makers, appropriately for the gamepad. We’ve called ours
Figure 4
Modelling a simple we explored using FreeCAD and the KiCad StepUp hackspace_gamepad.
enclosure in workbench that allows you to create and position There are two files that we need to adjust to take
FreeCAD to make our
controller a little more custom 3D component models for use in KiCad. We into account our board. Firstly, there’s pins.c, which
comfortable to hold
also explored all the skills needed to create all kinds should have the following:
of models. With the knowledge you gain from this
book, you could certainly make a controller enclosure #include "shared-bindings/board/__init__.h"
like the one we quickly modelled (Figure 4).
STATIC const mp_rom_map_elem_t board_module_
THE SOFTER SIDE globals_table[] = {
Now we have created our board, it’s time to write CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
some code for it. We could write our code in C using
the Pico SDK. We could also use the Pico build of { MP_ROM_QSTR(MP_QSTR_UP), MP_ROM_PTR(&pin_
MicroPython or CircuitPython. However, since we’ve GPIO0) },
created a new board, let’s create a firmware tailored { MP_ROM_QSTR(MP_QSTR_RIGHT), MP_ROM_PTR(&pin_
specifically for it – we’ll create a custom build of GPIO1) },
CircuitPython. This allows us to do a couple of things. { MP_ROM_QSTR(MP_QSTR_LEFT), MP_ROM_PTR(&pin_
Firstly, it lets us name the specific pins, so rather than GPIO2) },
using, say, GPIO0, we can use BTN_A. Secondly, it { MP_ROM_QSTR(MP_QSTR_DOWN), MP_ROM_PTR(&pin_
lets us select which modules we want to include. In GPIO3) },
our case, we’ll add Adafruit HID, which enables us to { MP_ROM_QSTR(MP_QSTR_BTN_A), MP_ROM_PTR(&pin_
use our game controller as an input device. GPIO18) },
The general process for creating a build of { MP_ROM_QSTR(MP_QSTR_BTN_B), MP_ROM_PTR(&pin_
CircuitPython is given in the documentation at GPIO19) }
hsmag.cc/BuildCP. We won’t go through it in detail, };
so follow that guide to set up your environment. MP_DEFINE_CONST_DICT(board_module_globals, board_
Once you have everything set up, you need to module_globals_table);
create this board. In the directory circuitpython/
ports/raspberrypi/boards, copy the Raspberry In this, we’re adding items to the board module.
Pi Pico directory into a new one that’s named Specifically, one for each button.

66 magpi.cc KiCad: making an RP2040 game controller


TUTORIAL

Left
We found it easiest to build CircuitPython using
Windows Subsystem for Linux

OTHER GAMEPADS
This example should get you started in the world of
game controllers, and there are loads that you can
look at for inspiration:

• The Arduino Esplora is now retired, but was one of


the first hackable game controllers on the market:
hsmag.cc/ArduinoEsplora
We’ll add Adafruit HID, • There’s an online community at PCBWay’s shared
projects site that includes many game controllers,
which enables us to use including: hsmag.cc/PicoGamepad
our game controller as • Gamepads come in many shapes. They’re usually


designed around ergonomics, but you can get a little
an input device creative. For example, this maker has built a bat-
shaped controller: hsmag.cc/BatController

Next, we need to edit mpconfigboard.mk to be make BOARD=hackspace_gamepad


the following:
This will compile your code, and you should end
USB_VID = 0x1209 up with a build-hackspace_gamepad directory. In
USB_PID = 0xB182 there, you’ll find a firmware.uf2 file that you can
USB_PRODUCT = "HackSpace gamepad" load onto your gamepad just as you would any other
USB_MANUFACTURER = "HackSpace magazine" UF2 file.
Obviously this isn’t complete firmware as it’s only
CHIP_VARIANT = RP2040 the programming language. We now need to write a
CHIP_FAMILY = rp2 program to get everything working. Fortunately, we
have all the modules we need baked in, so there’s
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" no need for anything there. We’ve drawn inspiration
from the CircuitPython example code here:
CIRCUITPY__EVE = 1
import time
import board
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_ import digitalio
CircuitPython_HID import usb_hid
from adafruit_hid.keyboard import Keyboard
In this file, we define the type of flash chip we from adafruit_hid.keyboard_layout_us import
have and also add any ‘frozen’ modules we want. KeyboardLayoutUS
Frozen modules can be anything that we want to be from adafruit_hid.keycode import Keycode
included on the build by default (other than the core
modules that are automatically included). Frozen # A simple neat keyboard demo in CircuitPython
modules have to be in the circuitpython/frozen
directory, but you should find that the Adafruit_ # The pins we'll use, each will have an internal
CircuitPython_HID module is already there. pullup
You can now create your build by going to keypress_pins = [board.UP, board.DOWN, board.LEFT,
circuitpython/ports/raspberrypi and running: board.RIGHT, board.BTN_A, board.BTN_B]

KiCad: making an RP2040 game controller magpi.cc 67


TUTORIAL

LEAD-FREE keyboard.release(key)
time.sleep(0.01)
It’s often cheaper to get boards made using leaded
solder. However, this might be a false economy. As you can see, we can use board.UP, board.DOWN,
Leaded solder is harmful to both your health and the board.LEFT, board.RIGHT, board.BTN_A, and board.
health of our planet. In the case of a games controller BTN_B in our code. This has a couple of advantages.
– something that you’re going to hold in your hand
Firstly, it is more intuitive for programmers.
time and again – it’s more important than usual to opt
Secondly, if we created another version of the board
for lead-free solder. Even if only a tiny amount gets
on your hands each time you use it, that will still add with the buttons on different pins, the same code
up over the course of the controller’s life, and could could still run on both.
have negative effects on your health. This code is a bit lazy. For example, there’s no
debouncing on the buttons. In practice, we’ve found
that this doesn’t cause many problems, especially
with the time.sleep(0.01) in there. This means it’s
# Our array of key objects not the most responsive controller, so if you’re
key_pin_array = [] playing games where hundredths of a second matter,
# The Keycode sent for each button, will be paired you probably want to use something different,
with a control key including tuned debouncing, written in C. However,
keys_pressed = [Keycode.UP_ARROW, Keycode.DOWN_ this controller isn’t suitable for that type of game
ARROW, Keycode.LEFT_ARROW, Keycode.RIGHT_ARROW, anyway. This is also fairly cavalier with the number of
Keycode.A, Keycode.B] reports it sends (a report being a status update sent
from keyboard to computer). This will send six of
# The keyboard object! them every loop, which means several hundred a
second. Again, this isn’t great for performance.
time.sleep(1) # Sleep for a bit to avoid a race However, it works reliably and is easy to understand.
condition on some systems With this code loaded, you should be able to plug
the controller into any computer and it will recognise
keyboard = Keyboard(usb_hid.devices) it as a USB keyboard. Press one of the buttons and
keyboard_layout = KeyboardLayoutUS(keyboard) the computer should recognise that button press just
as it would from any keyboard. With this, you can
# Make all pin objects inputs with pullups control any game that takes input from a computer.
for pin in keypress_pins: Creating a custom version of CircuitPython isn’t
key_pin = digitalio.DigitalInOut(pin) essential when you build a new board; however,
key_pin.direction = digitalio.Direction.INPUT once you’ve been through the process once, it’s
key_pin.pull = digitalio.Pull.UP easy, and makes life a little bit nicer, especially if
key_pin_array.append(key_pin) you’re distributing the board to other people.

print("Waiting for key pin...")

while True:
# Check each pin
for key_pin in key_pin_array:
i = key_pin_array.index(key_pin)
key = keys_pressed[i]
Right if not key_pin.value: # Is it grounded?
Our custom build print("Pin #%d is grounded." % i)
of CircuitPython
brings everything # "Type" the Keycode or string
we need, including
keyboard.press(key) # "Press"...
pin names
and modules else:

68 magpi.cc KiCad: making an RP2040 game controller


PLAY
& CODE
GAMES!
RETRO GAMING WITH

RASPBERRY PI 3 RD E D I T I O N
Retro Gaming with Raspberry Pi shows you how to set up
Raspberry Pi 5 to play a new generation of classic games. Build your
gaming console and full-size arcade cabinet, install emulation software
and download original games with our step-by-step guides. You’ll
discover a vibrant homebrew scene packed with new games for original
consoles and legal access to all those retro games you remember!

Set up Raspberry Pi
for retro gaming
Emulate classic
computers and consoles
Learn to code
retro-style games
Build a console,
handheld, and full-size
arcade machine

BUY ONLINE: magpi.cc/store


FEATURE

Summer
projects
Summer is here, so what better time to start thinking
about which Raspberry Pi projects can help make
the sunnier months even more pleasurable?
W hether you’re going away or planning
a staycation over the summer, one
thing’s for sure: these are the best
months of the year for getting out and about.
The better weather means you can enjoy your
By David Crookes garden, consider having an adventure or spend
some time sensibly soaking up the rays by the
coast. But you don’t necessarily have to abandon
your Raspberry Pi. As we’re about to see, our
favourite computer can be used to create a host of
useful projects that can give you more time to have
a great time. Happy days await.

Garden
projects
Spend less time maintaining your garden and more time
enjoying all it has to offer – weather permitting, of course

Rain detector
magpi.cc/summerrain

Summer isn’t always a guarantee of sunshine


– you just know the moment you get the barbecue
out, decide to mow the lawn or put the washing
on the line, rain will begin to fall. With this simple
rain detector powered by a Raspberry Pi Zero W
you can receive an alert straight to your mobile
S You can make use of any
phone whenever there’s about to be a sudden
good-sized watertight
downpour, giving you time to take action. It’s container you may have
lying around
highly effective, hyper-local and rather inexpensive
W The rain water sensor
too. And since it doesn’t require any soldering, it’s modules can be picked up
a perfect project to get you started. very cheaply online

72 magpi.cc Summer projects


FEATURE

PiMowBot
magpi.cc/summermow

If you don’t like mowing the lawn, there are


generally three alternatives: you let the grass grow,
employ a gardener or invest in a robot mower.
If the final option appeals, then you may find
yourself shelling out at least £450 – unless, that
is, you decide to build your own based around
a Raspberry Pi Zero. The PiMowBot, which also
includes a Raspberry Pi Camera Module and a solar
panel, has evolved over recent years and, while the
management software remains a work in progress,
the build shouldn’t cost you more than £300. It has
also been created to last with no real wearing parts, S Most of the parts including the PiMowBot’s housing and
chassis are 3D printed
battery aside, so you’ll be able to relax with a cool X All of the electronic parts are neatly tucked away inside the
drink while it does its thing for many years to come. mower’s housing

Raspberry Pi Plant Watering


magpi.cc/summerwater

The sunny days can leave your plants very thirsty so


it’s important to keep them regularly watered. With
Christopher Barnatt’s amazing system, built around
a Raspberry Pi Zero computer, you don’t need to set
reminders or make arrangements if you’re going
away. You can just allow a moisture sensor to check
that a plant is sufficiently hydrated every 30 minutes
S It looks like an elaborate system but then let water automatically flow if the soil is too dry.
Christopher talks you through the Water flow is controlled by a solenoid valve and, as
whole setup process
W A resistive moisture sensor costing just £4
a fun bonus, the build includes a camera so that you
is connected to Raspberry Pi can record a time-lapse movie of the growing plants.

W A CAP1188 turnkey
Bird Feeder Monitor capacitive touch sensor
magpi.cc/summerbird is located within the
weatherproof box
T Stephen has managed
During the Summer, lots of wildlife may visit your to use the project to
garden. Some animals are likely to be unwanted capture some stunning
natural images
– foxes and badgers can tear gardens apart so you
may want to deter them (magpi.cc/summerdeter)
but most, such as birds, are very much welcome.
Stephen B Kirby’s Bird Feeder Monitor detects
our feathered friends as they perch ready for
some food before taking photographs of them in
action. The images are then stored along with
information about the local humidity, cloud cover,
temperature, wind speed, gust and direction,
allowing you to work out when different species
of bird are most likely to visit.

Summer projects magpi.cc 73


FEATURE

 n your travels this


O
Adventure Summer, you may yearn

projects
to have your Raspberry Pi
close to hand

Raspberry Pi can be the perfect companion whether you’re


hiking, camping or simply looking for lots of fun outdoors

Raspberry Pi Backpack
nicholashacault.com

When you’re out and about on your travels this


Summer, you may yearn to have your Raspberry Pi
close to hand. If that’s the case then this project
literally has your back, allowing you to take your
favourite computer on any adventure you desire.
Created by Nicholas Hacault, it incorporates a
seven-inch screen into a backpack that’s linked to
a Raspberry Pi. Operated using a wireless keyboard
and mouse, and juiced via a 30,000 mAh portable
power bank, it could even include a walking
S The Raspberry Pi is housed inside the bag within a
animation connected to an accelerometer. And
metal case to dissipate heat
X Thanks to the accessible connector on the side,
since Raspberry Pi devices are small, there’s plenty
it’s easier to turn on and power the bag of room for all of your other stuff too.

Recovery Kit Version 2


magpi.cc/summerrecovery

Originally created five years ago by Jay Doscher,


this tough cyberdeck was designed to withstand
pretty much anything that could be thrown at
it. Incorporating a seven-inch Raspberry Pi
touchscreen, thereby removing the need for a
mouse, it effectively placed a Raspberry Pi 4
inside a small, air and watertight Pelican case
and allowed it to be powered using 5V. More
recently, Jay has revisited the project using
Raspberry Pi 5, a large battery and new Drop/OLKB
Planck v7 keyboard. He’s also made it easier to
build, and you could easily adapt this one to suit S The build makes use of an ortholinear keyboard. These
have the keys aligned to a strict grid
your needs. It sure beats having to worry about
X The screen sits in its own compartment which can be
damaging an expensive laptop. pulled from the Pelican case for access.

74 magpi.cc Summer projects


FEATURE

ML Clip Cam
magpi.cc/summerclipcam
W It still looks like a
prototype but get
This project isn’t your usual Raspberry Pi HAT. your thinking cap
Instead, it’s a cool camera device that works with on – you may be able
to work out a way to
a hat of the more traditional variety – you know, make it look pretty
the ones you wear on your head. Created by Jacob T An ESP32-S3 1.28-
inch touchscreen
David C Cunningham, the lightweight camera clips is incorporated
on to the peak of a cap, allowing you to make easy into the project
point-of-view recordings of your adventures. It
would also be possible to incorporate machine
learning into this project by getting it to identify
particular objects on your travels and make a log of
them (the ML Clip Cam is able to identify RC planes
in real time). With a bit of time, you may be able to
create a case for the camera, particularly if you’re
fashion conscious or want to protect the Raspberry
Pi Zero 2 W from the elements.

TARDIS Treasure Hunt


magpi.cc/summertardis

You can add another dimension to any adventure


by incorporating a game and, if fun’s what you’re
after, Roberto Tyley’s project can certainly provide
it. He hid two screens in a local park, each of
which could be used to generate one half of a
passphrase. When the time-limited passphrases
were combined, they could be entered into a
TARDIS built out of LEGO – this would cause
the windows to gradually light until they were
all lit, thereby completing the game. As well as
requiring three teams (one situated at each of the
S The passphrases are displayed on
Pick-Clock-Green LED-digit electronic passphrase generators and another at the TARDIS,
clocks designed for Raspberry Pi Pico all communicating by walkie-talkies), the project
X The aim of the game is to fix a ‘broken’ also needed a trio of precision real time clocks and
TARDIS by entering the correct combination
of passwords in the correct sequence some nifty coding so that the system could work
out if the code combos issued at any one time were
correct. The Time Lords would be proud.

Wish you were here!


Many of us like to share our adventures with others and Raspberry Pi
can help you. As well as taking quality snaps using your own, cool, DIY
camera, such as the retro-styled RUHAcam (magpi.cc/ruhacam),
you could produce your own DispatchPi (magpi.cc/dispatchpi) – a
digital e-ink photo frame that allows you to instantly share black-
and-white images using photos emailed to a Google Mail inbox. You
can also capture any action at 90fps with the piOneer action camera
(magpi.cc/pi0neer) which is a great low-cost alternative to a GoPro.

Summer projects magpi.cc 75


FEATURE

Seaside
projects
 obody wants to arrive at
N
the beach only to discover
that it’s not there!
Who doesn’t love to be by the seaside? Use Raspberry Pi
to help you make the most of your time on the beach

W You will need to attach


Tide Tracker a GPIO header to your
magpi.cc/summertide Raspberry Pi
T The tide tracker works
with a tidal stations of your
Nobody wants to arrive at the beach only to choice and shows the rise
discover that it’s not there! Likewise, you don’t and fall of the water

want to aim for a dip in the sea and find that it’s
actually far away. In either case, it’s so much more
convenient to get a handle on the times for high
and low tides and that can be achieved using a tidal
forecast API from the Admiralty in conjunction
with Raspberry Pi. Add a screen such as an Inky
pHAT display, find your tidal station, tinker with
some code and you’re effectively good to go. The
display will tell you the current situation and
indicate the time it’s due to change.

Pico Held
magpi.cc/summerheld

You can take your pick from scores of maker-led


handheld games consoles but we do like the Pico
Held, primarily because it’s open source, based
around our favourite flexible microcontroller board
and is capable of playing titles developed for the
Sega Mega Drive. Its potential low cost also means
you’re less likely to worry about sand infiltrating
the case or accidentally dropping it in the sea,
allowing you to simply kick back on the beach and
concentrate purely on the games. We like that the
S The device has three buttons 3.2-inch display is large enough to see (the games
and an analog control stick for
interacting with your games should be bright enough even if you’re wearing
W The Pico Held is a smart- sunglasses, too). The device’s handheld library will
looking device that may
well attract envious looks
also allow you to create your own classic pixel art
on the beach games if you fancy getting creative.

76 magpi.cc Summer projects


FEATURE

Drinks machine
magpi.cc/summerdrinks

Being by the seaside in hot weather can make you


thirsty, so it’s a good idea to take a refreshing
drink with you. Rather than put some concentrated
juice in a flask and add water from the tap,
however, you could create this fun drinks machine.
Originally designed to sit on a desk and pour a
fresh glass of squash when you’re working, it lets
you press a button to activate a relay and switch
on a small submersible pump. The drink will be
created and its name will be displayed on the
screen, ready for you to take on your travels. It
S The drinks machine’s case was designed in Fusion 360 and
can even be set up to dispense drinks at set times
3D-printed using a red filament
– great if you’re going in and out of the garden X The project uses Raspberry Pi, allowing you to SSH into the
and need some timely top-ups. device and select a drink from afar

Flight tracker with weather


magpi.cc/summerflight

Want to enviously cast your eyes skywards at


people traveling abroad for some time by the
sea? Then this flight tracker is for you. It draws
information from FlightRadarAPI and compares the
lat/long data of planes with your precise location.
Whenever a plane passes overhead, it’ll display
the flight route, airline, distance and direction on
a 64x32 RBG matrix panel. If the skies are empty,
it’ll show the current time, date, temperature and
three-day weather forecast – perfect if you’re
planning a trip of your own. More recently, creator
S The flight tracker shows the airports S When there are no planes, the current
tracked planes are travelling between, temperature is displayed every 10 minutes
Adam Paulson has added an auto-dimming option
as well as the airline logo and forecasts are updated every hour as well as a new collection of airline logos.

Look after your home


If you’re going away this summer, you’ll still need to keep a check on
your home. Those with pets who can’t travel may want to try Rebecca
Peck’s Raspberry Pi-powered pet feeders (magpi.cc/summerpets)
and those worried about burglars should consider making an intruder
alarm (magpi.cc/summeralarm). You could communicate with visitors
while you’re out and about using a smart doorbell and video intercom
system (magpi.cc/summerdoorbell). And you can help prevent
people nicking parcels from your doorstep using the package thief
deterrent (magpi.cc/summerpackage).

Summer projects magpi.cc 77


REVIEW

CrowVi
Elecrow magpi.cc/crowvi From £92 / $115

Is this the ultimate portable monitor for Raspberry Pi?


SPECS Rob Zwetsloot takes a look at this interesting display
DISPLAY:
13.3-inch,
1920×1080
IPS LCD
DIMENSIONS:
312mm ×
198mm × 9mm
I/O:
USB-C power,
USB-C data,
Mini HDMI
in, 3.5mm
audio jack

X The cover can be


removed if you
don’t plan to use it

P ortable monitors are a slightly odd beast


– you’re expecting a display as good as the
one at your PC desk, yet it also needs to be
compact and easy to set up at your destination.
However you only have to look at adjacent
Plug and play
All versions of the CrowVi are able to be
used out of the box with no extra set up
– touchscreen models require you to use
the USB-C port (not the power one) so the

Verdict products to see it done well – say, such as with


an iPad and its smart cover.
connected Raspberry Pi (or PC) can detect the
inputs – but all models just need power and a
A great monitor in Elecrow, maker of the CrowVision screens we’ve HDMI connection.
its own right that reviewed in the past, has taken a little inspiration There’s no battery installed in the CrowVi so
performs well out
from this to create a small yet functional monitor you’ll have to provide external power, portably
of the house and
well enough in line that comes with its own cover and stand. It with a mobile battery or powered by the device
direct sunlight comes in a range of sizes and resolutions, with you’re connecting it to at home if you don’t

8
and without touch control. We have one of the have a spare plug. To cut down on cables and
1080p 13.3-inch non-touch versions to review, power sources, CrowVi suggests daisy chaining

/10
however there’s also a 4K version and a 15.6-inch power by using the USB-C data port on the
alternative, all with the cover/stand included. display to power a Raspberry Pi while out and

78 magpi.cc CrowVi
REVIEW

T If your smartphone
supports display
out, it’s a great way
to have a portable
video player

about. You won’t be able to get Raspberry Pi 5


up to full power this way, however it will run
well enough.
As an aside, we understand the touchscreen
is much like a standard touch display and is not
sensitive enough for drawing, but does have
the functions you’d otherwise expect from a
smartphone or tablet.

Out and about


With unseasonable warmth during the review T he colours and responsive of the screen is
period, we were able to take the screen out
and test it in the most extreme of conditions: great too. Colours are sharp and it was as
direct sunlight. IPS displays do tend to have
better visibility out in the sun and this screen
good as any monitor we use at home
performed fine, just as you’d expect any display
to work. Make sure to crank up the brightness
but find shade if you can.
As for power draw, a beefy power bank was
able to keep everything running fine for a
couple hours. Brightness levels and speaker use
will affect this, so using external speakers or
headphones will also change power draw.
The colours and responsiveness of the screen
are great too. The image is sharp, and it was as
good as any monitor we use at home. The cover
is very stiff, and the magnets attaching it very
strong, to make sure the display is held in place
when propped up – it may be a touch too stiff
at the bend and we weren’t always sure it was
in standing position. Over time, though, it has
loosened up enough.
The sturdy construction feels and looks great
too – and as we’re home bodies we’re currently
looking into how we can integrate it as a third
screen in our set up, which is pretty high praise
S It works great with a Raspberry Pi 5, and there’s
we think. even a kit that comes with Raspberry Pi 400

CrowVi magpi.cc 79
RESOURCES

10 amazing:
Gaming
accessories  Adafruit Arcade Bonnet
Enjoy your Raspberry Pi games more Stripped down arcade
with these excellent upgrades Create a small yet powerful arcade machine out of Raspberry Pi Zero
with this minimalist add-on for JST connectors

W e meet a lot of people who use Raspberry Pi for


gaming. Whether on the go or in their living room,
there’s so many ways to play with Raspberry Pi and
even Pico. We’ve put together a list of some items that are sure
to improve your experience.
magpi.cc/arcbonnet I £12 / $15

 Pico Dongle Lite


Custom input
If you’ve made custom input devices for
games with a Pico, this is another great
way to interface that Pico with the device
you’re gaming on

magpi.cc/picodongle I £2 / $3

 Game 5Pi Retro Gaming Case


Classic enclosure
Upgraded to the latest Raspberry Pi 5 but still want to rock a retro case?
Game 5Pi allows you to sneakily camouflage your Raspberry Pi 5 as
something resembling a NES. It also comes with a heat sink fan kit.

magpi.cc/game5pi I £17 / $21

 Adafruit Joy Bonnet


Miniature console
Turn your Raspberry Pi Zero into the tiniest plug-and-play console ever
– all you need is a screen to plug it into!

magpi.cc/joybonnet I £12 / $15

80 magpi.cc 10 amazing gaming accessories


RESOURCES

 PiBoy XRS
Handheld power
This case turns your Raspberry Pi
into a handheld console that feels
like a top quality official product.
Very little assembly required too!

magpi.cc/coolercover I £3 / $4

 8BitDo Pro 2 controller


Wireless gaming
Our favourite retro-styled controller got even better with the Pro 2. Not
only will it sync with a Raspberry Pi but also your Nintendo Switch too

magpi.cc/pro2 I £42 / $52

 Classic wired joypad


Nostalgic control
Sometimes the best way to play old games is with a controller you
remember. No fancy analogue sticks, just eight buttons and a D-pad

magpi.cc/classicpad I £14 / $17

 PiStation Case + LCD


Portable console
A throwback to the '90s, this
console-plus-screen combo is
definitely more powerful than the
 Picade X HAT
machine it’s emulating, but that
Arcade heart
just makes it cooler
If you’re planning to build an arcade based on Raspberry Pi, the Picade X
HAT is the ultimate way to connect it all together
magpi.cc/pistation I £81 / $101

magpi.cc/picadex I £16 / $20

 8BitDo Wireless
Adapter 2
Wireless gaming
Connect all manner of Bluetooth
controllers to your older Raspberry Pi (or
any other system!) thanks to this powerful
dongle – it also supports gyro controls

magpi.cc/8bitdongle I £19 / $24

10 amazing gaming accessories magpi.cc 81


RESOURCES

Learn networking
with Raspberry Pi
Resources to help you understand
computer networking. By Phil King

An Introduction to Computer
Networking for Teachers
Raspberry Pi Computer networking is a vital a good overview of the topic of
CREATOR

Foundation part of modern life, enabling networking. Over the three-


us to browse the web and week duration (although you can
Price:
Free communicate with people all complete it at your own pace),
over the globe, but do most of you will learn about the different You’ll also gain a greater
magpi.cc/
rpfnetwork us really know how it works types of computer networks, and understanding of how the
behind the scenes? their pros and cons. internet works, including
Aimed at educators, Key topics include the routing, DNS, and the World
specifically GCSE/high-school transmission of data, covering Wide Web. The course content
computer science teachers, this IP packets and networking comprises mainly illustrated
Raspberry Pi Foundation course protocols such as TCP and text and a few videos, including
– now available via edX – gives DHCP, along with cybersecurity. some cool animations.

Computer Networking:
A Top-Down Approach
James F Kurose, This hefty 800-page guide Now in its eighth (global) principles
CREATORS

Keith Ross is recommended reading for edition, the book has been of network
computer science students updated to reflect recent applications,
Price:
£67 / $80 and often used to accompany advances in networking, such transport-
courses. Like most textbooks, as the importance of software- layer services,
magpi.cc/
topdownnet it can be a bit dry at times, defined networking (SDN) and the network layer (data and
but it’s approachable enough the rapid adoption of 4G/5G control planes), link layer/
for beginners, and offers mobile networks. LANs, wireless/mobile networks,
an excellent foundation Starting with an introductory and cybersecurity. Use it as a
to understanding the key overview of the internet reference book or read it all to
concepts in the field of and computer networks, its obtain comprehensive knowledge
computer networking. subsequent chapters cover the of networking.

82 magpi.cc Learn Networking with Raspberry Pi


RESOURCES

Useful
websites
Check out the
wealth of networking
resources online

Mastering Python Networking


Eric Chou This 594-page book is aimed at fundamentals, the book then
CREATOR

IT professionals and operations explores its applications in DEBIAN REFERENCE


Price:
£38 / $50 engineers, so you’ll need at legacy and API-enabled network Since Raspberry Pi OS is
least a basic knowledge of devices. It demonstrates based on Debian Linux, the
magpi.cc/
pythonnet4e Python programming and making use of Python packages networking section of this
networking to get the most out for network automation, online reference manual is
of it. The updated fourth edition monitoring, management, and ideal for learning a host of
features extra chapters on security. The content progresses useful commands.
Docker containers and Python 3 to cover AWS and Azure cloud X magpi.cc/
Async IO for network engineers. networking. You’ll also learn Git debianrefnetwork
All of the other chapters are for code management, GitLab
updated with the latest libraries for continuous integration, and
with working examples, too. Python-based testing tools for LINUX KERNEL
Starting off with Python network verification. The networking section of the
Linux Kernel documentation is
packed with useful info on all
aspects of Linux networking,

Online courses
from AF_XDP to XFRM.
X magpi.cc/
kernelnetworking

Enrol in a computer networking web course today RASPBERRY PI FORUMS


If you’re having networking
INTRODUCTION TO OPEN SO YOU WANT TO BE A issues with your Raspberry Pi,
SOURCE NETWORKING NETWORK ENGINEER? the ‘Networking and servers’
TECHNOLOGIES The video lectures in this free section of the official forums is
This edX course from the Linux Udemy course will give you a a good place to go for help.
Foundation covers topics such basic understanding of networking X magpi.cc/
as software-defined networking, technologies and could set you on etworkingforum
automating tasks, and open a new career path.
networking operating systems. X magpi.cc/soyouwant
X magpi.cc/lfnetwork

THE BITS AND BYTES OF


COMPUTER NETWORKING
Ideal for beginners, this Google
course on Coursera offers 27 hours
of learning, covering modern
networking fundamentals and
troubleshooting techniques.
X magpi.cc/bitsbytes

Learn Networking with Raspberry Pi magpi.cc 83


INTERVIEW

Ken
St. Cyr
The star of What’s Ken Making on game
emulation and his first experience of Raspberry Pi

> Name Ken St. Cyr > Occupation Software engineer


> Community role Video maker > URL whatskenmaking.com

R etro game emulation


has been improving by
leaps and bounds over
the last decade through various
technologies, and one of those
What is your history with
making things?
I’ve been a maker for as long as
I can remember. My interest in
electronics started as a kid in the
When did you learn about
Raspberry Pi?
I want to say it was probably
about 10 years ago now… I was
teaching a class at work, and one
is Raspberry Pi. It brings huge ’80s when I got a Radio Shack of the students had a Raspberry
power in a small form factor electronics lab kit. It had these Pi that he brought with him. I
and is perfect for the hobby, and little springs, which you could remember examining it after
game preservation. attach wires between to make class one day and marvelling at
Software engineer Ken St. different circuits. it. I was tinkering with Arduino
Cyr runs a YouTube channel, I spent hours wiring up the at the time, so the idea of a
called What’s Ken Making, example circuits and trying out single-board computer that
that’s dedicated to modern different things to see what ran an operating system and
retro gaming, which includes would happen – it was really gave me access to GPIO really
Raspberry Pi-powered devices. quite magical! enthralled me. I bought one as
“My earliest gaming memory
is split between playing Pitfall
on my uncle’s Coleco Vision and
typing up BASIC games from
a book into a TI-99/4A,” Ken
tells us. “I also would go to my
friend’s house down the street
to play his Atari VCS on a fuzzy
black-and-white TV, which I’m
pretty sure is the reason why I
wear glasses today. After that, I
received a NES for Christmas, and
that’s what I primarily played
until I got a Tandy 1000HX and
discovered Sierra adventure
X The hardware differences
games. Even today, I still enjoy
(and similarities) between playing the Police Quest, Kings
the NES and its Japanese
version the Famicom are
Quest and Space Quest series on
fascinating my MiSTer’s AO486 core!”

84 magpi.cc Ken St. Cyr


INTERVIEW

S The handheld made


soon as I could and have been enjoy the teaching aspect of my Heckendorn. We’re working on from a Raspberry Pi Zero
playing with them ever since. videos more than anything, so version four now, and there are when assembled
the idea of parking on one topic some interesting changes in the T Raspberry Pi Zero has
What’s your favourite video for a period of time to unpack it works that I think people will always been great for
slipping into smaller
you’ve made? is really appealing to me. absolutely love! projects, like this
That’s like choosing a favourite handheld console
child! If I had to pick one, I’d What have been some of your
say it’s probably the video favourite projects?
series I’m working on right now, My favourite projects tend
called ‘Inside the Famicom’, to be microcontroller-based
which is a multi-episode deep recreations, like the handheld
dive on Nintendo’s Famicom ZX Spectrum that I made a
and NES. I currently have nine video about earlier this year.

 y favourite projects tend to be


M
microcontroller-based recreations,
like the handheld ZX Spectrum
episodes planned, which I’ll I’ve also really enjoyed working
be releasing throughout the on the gameBadge, a Pico-
summer – and the first episode based handheld game system,
went live last week. I really with maker extraordinaire Ben

Ken St. Cyr magpi.cc 85


THIS MONTH IN RASPBERRY PI

NASsie
A full-featured NAS solution using Raspberry Pi

W e got an email from Jeff Loeliger about


a very cool project he’s been working
on recently.
“When you have several computers and lots of
files around the house it is useful to have a NAS
– network attached storage – device to share files,
stream media with Plex, and back things up,” Jeff
writes. “My current system is an old QNAP TS-251
and a very old, and unsupported, QNAP TS-110. I
wanted something new and faster, which sounded
like a project for the Raspberry Pi. It has a compact
completely 3D-printed case with a custom pHAT
interface board.”
He’s since gone on to write up a comprehensive
tutorial on how to build a NASsie (magpi.cc/nassieh)
and set up the software on it (magpi.cc/nassies).
It uses a Raspberry Pi Compute Module 4 and runs
OMV 6 (Open Media Vault) with custom software to
run the little display interface on the case.

01. You can fit a lot of storage inside the case – both
spinning platters and solid state
02. This really cool, Loch Ness Monster-inspired case,
is 3D printed and very customisable
03. It’s a tight squeeze, but that big case fan will keep
everything cool 01

02 03

86 magpi.cc NASsie
THIS MONTH IN RASPBERRY PI

Events in pictures:
Roanoke Robotics
Club Raspberry Jam
Community and official events in the wild

02

03

01

D
FIND
id you know that if you hold a Raspberry OU T A
M ON BOU T
TH’S
Jam and get it listed on the events EV EN N E X T
T S ON
website, you’ll be sent some swag
PAGE
92
for the event? Several months ago it included
Raspberry Pi 5.
“The Roanoke Robotics Club held our
Raspberry Pi Jam [on] Saturday March 2 at our
neighbourhood library,” Gary Yohe of the Roanoke 04
Robotics Club tells us. “We had a great turnout
and appreciate the Raspberry Pi 5s shipped just in
time for the exhibits.”

01. Roanoke Jam is held in a local library


02. Many projects were on display, including this
Pico-controlled Raspberry Pi camera
03. Raspberry Pi 5 was put to the test against a
Raspberry Pi 4
04. It’s a whole operating system running off a
Raspberry Pi Pico!

Events in pictures magpi.cc 87


THIS MONTH IN RASPBERRY PI

MagPi
Monday
Amazing projects direct from social media!

E very Monday we ask the question: have you


made something with a Raspberry Pi over
the weekend. Every Monday, our followers
send us amazing photos and videos of the things
they’ve made.
01

Here’s a selection of some of the awesome things


we got sent this month. Remember to follow along
at the hashtag #MagPiMonday!

01. Etching the case to show which switches have


been thrown is a genius idea
02. We’re always still learning ourselves! Fritzing is a
great tool to have in your belt as well
03. The Pimoroni weather stations are some of
our fave summer projects too – we did a list of
them last issue
04. We can see where it gets its name – also a very
good legacy
05. This musical project is getting there!

02 03

88 magpi.cc #MagPiMonday
THIS MONTH IN RASPBERRY PI

04

05

Crowdfund this
Great crowdfunding projects this month

XGO-Rider RaceBox Micro

We’ve reviewed XGO robots in the past but none This is a DIY GPS chip compatible with Raspberry Pi and
of them have looked like this two-wheeled bipedal includes an accelerometer and gyroscope. It’s being
robot. The videos on the Kickstarter page are very marketed for hobbyists with remote control cars, drones,
impressive as they follow people around with very planes, etc, and comes with a huge range of features
little wobbling at all. for tracking your device’s movements.

f kck.st/3y6G6wW f kck.st/43ZsZtk

#MagPiMonday magpi.cc 89
YOUR LETTERS

Your
Letters
Future forecast
Very much enjoyed the ‘Final Word’ in [The MagPi 140]. I Luckily I am closer to retirement than the start of my career;
currently teach GCSE computer science, and specifically Python I have this nagging feeling that things are going to change
programming, to a generation of pupils that are encountering the significantly and quicker than people realise.
dawn of the AI age. The past 18 months have made me question
the value of what I am teaching them, and your point about
abstraction is one that I have made to several of my colleagues. Paul via email
Python already abstracts machine code, so why should we
object to GPT abstracting writing the Python? Should I be With stuff like code it’s very easy to see how the LLMs would be
teaching pupils how to phrase questions in a way that will able to put together great code for people to tweak thanks to a
generate the most efficient code from GPT? It’s not hard to large open-source dataset with instructions and such – we’ve seen
foresee a time when we can ask GPT to cook up a recipe, code, a couple of ML-generated STLs, and they might be a bit further off
SLT drawing files and parts list to create some of the projects though. Hopefully the power and computation requirements get
that are typically shown in your magazine. more efficient in the future for it!

X We don’t think
Stack Exchange is
going anywhere
just yet though

90 magpi.cc Your Letters


PWM 5 USA SPECIAL!
I’m new to the world of Raspberry Pi. I recently
purchased a Raspberry Pi 5 for a film digitiser
project. My project that involves a bit of I/O
6 ISSUES
FOR $43
using interrupts with an encoder, stepper motor
control and a few other general switches. I’m
looking for resources for the GPIO. It seems
the new RP1 chip has thrown the development
community a new challenge.
What resources does The MagPi team suggest for
the Raspberry Pi5 GPIO tasks?

Steven via email

The Raspberry Pi docs (rptl.io/docs) are always a


great start for this – they’re very comprehensive,
and have examples for just about every function for
Raspberry Pi in Raspberry Pi OS. The Raspberry Pi
forums (magpi.cc/forums) are also your number
one place for more info if something is eluding you.

FREE
RASPBERRY PI
S The Raspberry Pi documentation is really, really
comprehensive. We’re often surprised ourselves!
PICO W

Contact us!
> Mastodon magpi.cc/mastodon
>
>
Threads
Facebook
@themagpimag
magpi.cc/facebook
Subscribe online:
>
>
Email
Online
magpi@raspberrypi.com
forums.raspberrypi.com
magpi.cc/subscribe
Email: magpi@subscriptionhelpline.co.uk

Continuous credit card orders will auto-renew at the same price unless cancelled.
A free Pico W is included with all subscriptions. This is a limited offer.
Not included with renewals. Offer subject to change or withdrawal at any time.
EVENTS

04

Community
Events Calendar
Find out what community-organised Raspberry Pi-themed
events are happening near you…

01. M
 elbourne Raspberry Pi Meetup 03. Cornwall Tech Jam
Sunday 2 June Saturday 8 June
107 Victoria Harbour Promenade, Melbourne, Australia Fraddon Village Hall, Saint Columb, UK
magpi.cc/mrpm142 magpi.cc/ctj142
Open to everyone with an interest in electronics, robotics, ​Cornwall Tech Jams are run by volunteers working in IT and
home automation, 3D printing, laser cutting, amateur radio, education throughout Cornwall. They are supported by
high altitude balloons, space tech, etc. Makers are invited to Software Cornwall, its members and other local businesses.
bring along projects and project ideas, and come connect Our volunteers give their own time and expertise to plan
with other makers. Get your questions answered, show off each Cornwall Tech Jam and to the regular maintenance of
your work, and get support to resolve nagging issues. all our equipment.

FULL CALENDAR
Get a full list of upcoming
community events here:
magpi.cc/events

02. Code Battle 04. Riverside Raspberry Pi Meetup


Saturday 8 June and Sunday 9 June Monday 10 June
Campus Idéale, Nabeul, Tunisia 3600 Lime Street, Riverside, CA, USA
magpi.cc/cb142 magpi.cc/rrpm142
The Code Battle competition around water resources The purpose of Riverside Raspberry is to share knowledge
with ScratchJr, Scratch, micro:bit and Raspberry Pi Pico related to Raspberry Pi hardware in particular, and to
aims to raise awareness among kids of the importance promote interest in tech development in the Inland Empire
of sustainable water management while developing their in general. The group is currently meeting on the second
programming and technology skills. Monday evening of every month.

92 magpi.cc Community Events Calendar


EVENTS

03

02

01

INTERNET OF THINGS WITH Internet of Things


RASPBERRY PI PICO
with Raspberry Pi
Pico workshop
> Where Lagos, Nigeria
> When Monday 3 June to Thursday 6 June

T he Internet of Things with Raspberry Pi


Pico is a free workshop taking place in
Lagos, Nigeria. Over the course of two days,
participants will learn how to use a Raspberry Pi Pico
microcontroller to solve real-world challenges using
sensors, networking, and cloud technology. This
workshop is intended for enthusiasts and university
students in the Lagos technology community and it’s
hosted by Raspberry Pi.

magpi.cc/iotpico24

Community Events Calendar magpi.cc 93


COMPETITION

WIN ONE OF TEN


M.2 HAT+
Unleash the power of PCIe with the release of the
much anticipated M.2 HAT+ – allowing for M.2 SSD
cards, machine learning, and many more high-speed
operations. We have ten to give away to lucky readers.

Head here to enter: magpi.cc/win | Learn more: magpi.cc/m2hat

Terms & Conditions


Competition opens on 29 May 2024 and closes on 27 June 2024. Prize is offered to participants worldwide aged 13 or over, except employees of Raspberry Pi Ltd, the prize supplier,
their families, or friends. Winners will be notified by email no more than 30 days after the competition closes. By entering the competition, the winner consents to any publicity
generated from the competition, in print and online. Participants agree to receive occasional newsletters from The MagPi magazine. We don’t like spam: participants’ details will
remain strictly confidential and won’t be shared with third parties. Prizes are non-negotiable and no cash alternative will be offered. Winners will be contacted by email to arrange
delivery. Any winners who have not responded 60 days after the initial email is sent will have their prize revoked. This promotion is in no way sponsored, endorsed or administered by,
or associated with, Instagram, Facebook, Twitter (X) or any other companies used to promote the service.

94 magpi.cc WIN one of ten M.2 Hat+


Raspberry Pi Custom DSI Display
CM4 Carryboard, and Industrial Tablet

Custom DSI Displays

Development of Industrial Tablet


CM4-compatible carryboard development capabilities

Looking for cooperation Contact us


Tel: +44 7587611960
partners around the E-mail: straight@jmolcd.com
world. Website: www.jmolcd.com
SUBSCRIBE AND

SAVE UP
TO

35% on the cover price

ISSUE #79

OUT NOW
hsmag.cc
NEXT MONTH

EDITORIAL

Starter Editor
Lucy Hattersley

robotics
lucy@raspberrypi.com
Features Editor
Rob Zwetsloot
rob@raspberrypi.com
Sub Editor
Ian Evenden
Build wheeled, walking, ADVERTISING
and AI-powered robots Charlotte Milligan
charlotte.milligan@raspberrypi.com
+44 (0)7725 368887

DESIGN
Head of Design
Jack Willis
Designers
Sara Parodi, Natalie Turner
Illustrator
Sam Alder
Photographer
Brian O’Halloran

CONTRIBUTORS
David Crookes, PJ Evans,
Gareth Halfacree, Jo Hinchcliffe,
Rosie Hattersley, Phil King,
K.G. Orphanides

PUBLISHING
Publishing Director
Brian Jepson
brian.jepson@raspberrypi.com
Director of Communications
Liz Upton
CEO
Eben Upton

DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000

SUBSCRIPTIONS
Unit 6 The Enterprise Centre

The Magpi #143 Kelvin Lane, Manor Royal,


Crawley, West Sussex, RH10 9PE
+44 (0)1293 312193
On sale 27 June magpi.cc/subscribe
magpi@subscriptionhelpline.co.uk

DON’T MISS OUT! magpi.cc/subscribe This magazine is printed on paper sourced


from sustainable forests and the printer

Raspberry Pi
operates an environmental management
MASTODON magpi.cc/mastodon system which has been assessed as
conforming to ISO 14001.
in industry The MagPi magazine is published by
THREADS @themagpimag Raspberry Pi Ltd, 194 Cambridge Science Park,

A giant
Milton Road, Cambridge, England, CB4 0AB.
The publisher, editor, and contributors
accept no responsibility in respect of any
retro mirror FACEBOOK magpi.cc/facebook omissions or errors relating to goods,
products, or services referred to or advertised
in the magazine. Except where otherwise

The EMAIL magpi@raspberrypi.com noted, content in this magazine is licensed


under a Creative Commons

Dicemaster 2000
Attribution-NonCommercial-
ShareAlike 3.0 Unported
ONLINE forums.raspberrypi.com (CC BY-NC-SA 3.0).
ISSN: 2051-9982.
THE FINAL WORD

Summer time
The sun is starting to shine which causes a
dilemma for homebody Rob Zwetsloot

I n the (fantastic) game Stardew


Valley, you play out several
years each split up into four
distinct seasons lasting 28 days.
It’s a farming sim after all. On
months of cold and dreary rain, it’s
lovely to have a bit of sun. It also
helps that I live near the beach so I
can go for sunny and beautiful walks.
I’m also pretty good with a barbecue
improved with a Raspberry Pi, rather
than forcing myself to do something
new just to use the SBC.
Last year I decided on a near-whim
to go hiking in the Peak District
the last day of summer there’s a if I do say so myself. with some friends. It was a very
nighttime event that ends with a load At the time of writing this Final wet August weekend so I’m glad I
of glowing jellyfish swimming by Word, the aurora borealis had didn’t take a Raspberry Pi with me,
before a message pop ups: “the glow appeared all over the UK thanks to but I understand there is a ton of
of summer has faded, now… and the Earth being in the path of a solar geocaching you can do in the area.
moonlight jellies carry on toward storm and… I missed it. I had no I’ve never played around with a
the great unknown”. idea it was happening until I was geocache project, so if I revive the
I’ve never had any real melancholy snuggled up in bed on a Friday concept this year I might just have to
for summer ending – aside from, I night and friends from Scotland and make a Raspberry Pi-powered one.
suppose, having to go back to school northern England started sharing
photos. Good for them, I thought! Staying in
It wasn’t until the morning I found Unfortunately I also like staying
out it had also reached my end of home a lot. Maybe I need to invent a
T hat made me realise the country. Raspberry Pi-powered air conditioner
for myself as it is getting extremely
that a long exposure Suit your needs roasty-toasty at home these days.

Raspberry Pi camera I went out the following night


to try and catch a glimpse but
I’m also always very interested in
some minor gardening, whether it
would have worked unfortunately for me – and the hoard be herbs or some flowers, so perhaps
of locals convening at a dark corner this is the year I finally make an
perfectly… just of the beach – there was nothing to automated plant watering system.
see apart from some pretty stars. Well, with all that planning out of
like in the many People had been taking photos the way, maybe I can start thinking
on smartphones with night shot about Autumnal projects. Those long
astrophotography features, and that made me realise months of sunshine and heat can

features I’d written that a long-exposure Raspberry


Pi camera would have worked
get oppressive…

perfectly… just like in the many Rob Zwetsloot


AUTHOR

astrophotography features I’d


Rob is not really much of an amateur
when I was a kid – but while reading written. Unfortunately it was too astronomer but looking up at the stars at
the game’s text I think I came close late for photography that night, 1am when it’s a pleasant 18°c while the
to understanding why people do. but it got me thinking about other waves are lapping nearby sounds nice

I do like summer though; after outdoor activities I do which could be magpi.cc

98 magpi.cc Summer time


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


PiKVM
Manage
Manage your
servers
servers or PCs
remotely!
remotely!

Remote control redefined

PiKVM V4 Mini
Small, cost-effective, and powerful!

Power consumption in idle mode: just 2.67 Watts!


Transfer your mouse and keyboard actions
Access to all configuration settings like UEFI/BIOS
Capture video signal up to 1920x1200@60 Hz
Take full control of a remote PC’s power

PiKVM V4 Plus
The most feature-rich edition

More connectivity
Extra storage via internal USB 3.0
Upgraded powering options
More physical security features
Extra HDMI output
Advanced cooling solution

A cost-effective solution for data-centers,


IT departments or remote machines!

Availableatatthe
Available themain
mainRaspberry
Raspberry Pi
Pi resellers
resellers

List of official
resellers by country:

You might also like