Mag Pi 142
Mag Pi 142
Mag Pi 142
BUILD A
R ASPBE RRY PI 5
ME DIA PL AYE R
High-quality audio Massive M.2 storage Stream anything
£5.99
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.
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
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
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
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
cdpstudio.com
Tel: +47 990 80 900 • info@cdptech.com
CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
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
X An example IC layout
created with a place
and route tool
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.
Introducing
Raspberry Pi Connect
Remote control Raspberry Pi from around the world.
By Gordon Hollingworth, Raspberry Pi CTO (Software)
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).
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
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.
sprinklR
irrigation
Keen computer programmer Mark made use of Raspberry Pi to
create his own automatic watering system. By Rosie Hattersley
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
Thirsty work
Audiophile Pi
Alan Boris’ low-cost, high-quality DIY audio streamer
hits all the right notes, as David Crookes discovers
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.
20 magpi.cc Audiophile Pi
PROJECT SHOWCASE
Quick FACTS
> The project uses an
old stereo tuner
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
Audiophile Pi magpi.cc 21
PROJECT SHOWCASE
Mini Dexed
A microcontroller synthesiser emulator running on Raspberry Pi
involved plenty of collaboration, discovers Rosie Hattersley
> Community
discussions are at
magpi.cc/
minidexed-
discussions
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
Sounds familiar
Cat TV
Prolific maker Becky Stern chose a Raspberry Pi display to entertain
her favourite feline. Rosie Hattersley wholeheartedly approves
26 magpi.cc Cat TV
PROJECT SHOWCASE
Quick FACTS
> Benchley is
named after the
writer of Jaws
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
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
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
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
EpiSensor energy
management
Securing energy services’ IoT infrastructure with
Raspberry Pi for a more sustainable future
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
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
+ £30 (UK)
€43 (EU)
$43 (USA)
£45 (Rest of World)
34 magpi.cc
SUBSCRIPTION
SUBSCRIBE
on app stores
magpi.cc 35
FEATURE
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.
HARDWARE
There are a few things you can do to
really make your media centre shine
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
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.
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.
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’.
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.
What’s in a name?
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
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.
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
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
Learn Python: discover data types and build a budget tracker magpi.cc 43
TUTORIAL
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
$ if "Hello":
print("truthy")
$ else:
print("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,)
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
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.
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
> 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
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.
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?
CDP Studio:
Control a robot arm
Part 02
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
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
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
Rescue your
backups
Recover data from ageing floppy disks,
CDs and Zip disks before it’s too late!
> Access to a 3D
printer (optional)
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]
$ ddrescueview floppy1.log
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,
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.
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.
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).
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.
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 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
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.
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:
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
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
PiMowBot
magpi.cc/summermow
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.
projects
to have your Raspberry Pi
close to hand
Raspberry Pi Backpack
nicholashacault.com
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.
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
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
Drinks machine
magpi.cc/summerdrinks
CrowVi
Elecrow magpi.cc/crowvi From £92 / $115
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
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
magpi.cc/picodongle I £2 / $3
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 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
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
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.
Useful
websites
Check out the
wealth of networking
resources online
Online courses
from AF_XDP to XFRM.
X magpi.cc/
kernelnetworking
Ken
St. Cyr
The star of What’s Ken Making on game
emulation and his first experience of Raspberry Pi
NASsie
A full-featured NAS solution using Raspberry Pi
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.”
MagPi
Monday
Amazing projects direct from social media!
02 03
88 magpi.cc #MagPiMonday
THIS MONTH IN RASPBERRY PI
04
05
Crowdfund this
Great crowdfunding projects this month
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
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
03
02
01
magpi.cc/iotpico24
SAVE UP
TO
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
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
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
PiKVM V4 Mini
Small, cost-effective, and powerful!
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
Availableatatthe
Available themain
mainRaspberry
Raspberry Pi
Pi resellers
resellers
List of official
resellers by country: