Mag Pi 136
Mag Pi 136
£5.99
ComfilePi
WELCOME
WELCOME
to The MagPi 136
T
here’s a lot of excitement around Raspberry Pi
thanks to the ongoing waves of Raspberry Pi 5’s epic
launch.
We’ve got a lot of Raspberry Pi 5 coverage this month. From
in-depth heating, cooling and thermal testing (page 66) to Lucy
EDITOR
benchmarking (page 72). We’ve also got an in-depth guide Hattersley
to Overclocking (page 42). Lucy is editor of
The MagPi and has
Once you’re done speed testing and overclocking your new thoroughly enjoyed
overclocking
Raspberry Pi 5 you’ll want to make something with it. Check her Raspberry
Pi. Next up is a
out our Buyer’s Guide (page 32). This is packed with present seriously fast retro
ideas for the holiday season. From dynamic robots to weather gaming project.
magpi.cc
trackers this feature is packed with gifts that will put a smile
on any maker’s face.
Happy holidays!
magpi.cc 03
GET YOUR
RASPBERRY PI 5
FIRST!
We’ve reserved Raspberry Pi 5 boards
for The MagPi subscribers
magpi.cc/priorityboarding
TERMS & CONDITIONS A Priority Boarding code will be emailed to everybody who takes out a print subscription to The
MagPi or HackSpace magazine. People who subscribe to both magazines will get two codes. Print subs only! Priority
Boarding does not apply to people with App Store, Google Play, Zinio, PDF contributions, or other paid-for subscriptions. Each
code will entitle you to purchase 1x (one) Raspberry Pi 5 model (either 4 GB or 8 GB) for the standard retail price and delivery.
Multiple codes need to be used individually. This is a limited offer and is subject to change or withdrawal at any time.
CONTENTS
Contents
> Issue 136 > December 2023
Cover Feature
32 Complete Raspberry Pi 32
Buyer’s Guide
Regulars
90 Your Letters
92 Community events calendar
97 Next Month
98 The Final Word
Project Showcases
08
The MagPi is published monthly by Raspberry Pi Ltd, Maurice Wilkes Building, St. John’s Innovation Park, Cowley Road,
Cambridge, CB4 0DS, United Kingdom. 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 60 46
42 Overclock Raspberry Pi 5
46 Cloud gaming on Raspberry Pi 5
50 Python coding on Raspberry Pi 5
54 Remote control with TigerVNC
56 Using Ubuntu – part 2
Make a mecanum robot – part 2 Cloud gaming on Raspberry Pi 5
60 Make a mecanum robot – part 2
76
The Big Feature
66
PicoVision review
84
Benchmarking Raspberry Pi 5
Reviews
76 PicoVision
79 10 amazing 3D prints
82 Learn Scratch
Community
84 Odd Jayy interview
86 This Month in Raspberry Pi Odd Jayy interview
WIN RASPBERRY PI 5 95
1 OF 10 ACCESSORY PACKS
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
PROJECT SHOWCASE
Retro Pi
World Radio
An old valve radio provides the ideal housing for this
nostalgic Raspberry Pi build, finds Rosie Hattersley
M
ost of the maker-interviewees who Raju describes himself as an AFOL (adult fan of
feature in The MagPi’s project showcase LEGO) and, as well as building his own Optimus
pages have a deep love of technology Prime, Hulkbuster and other complex kits, he has
and, often, a career in computing. Retro Pi World used the brightly-coloured bricks in his mission
Radio creator Raju Salubramanian is just such a to teach his kids and their friends how to code. He
fellow, but he is also on a mission to teach the does this as a ‘coach’ for the FIRST LEGO League
next generation to code: something that exactly (firstlegoleague.org) in his home town of San Jose,
chimes with why Raspberry Pi exists in the California. He is almost as big a fan of Raspberry
Raju
MAKER
magpi.cc/
worldradio
e posted a video
H
of his project on
YouTube showing
station selection
Quick FACTS
> Raju and his partner
both love 3D
An old wooden radio case with off-centre Raju wrote a single-page printing projects
speaker has been turned into a world radio web app to display the
controlled via a 2GB Raspberry Pi 4 map and stations menu > And sell their
designs online
in our current fast-paced digital world > But Raju was able
to repurpose many
components he
his belt and six Raspberry Pi boards in use around already owned
his home (not all disclosed to his partner!).
Despite his thoroughly modern career as a > Next, he’s going
software engineer in Silicon Valley and a CV that to tackle a
lists VMware and Google among his credits, Raju Raspberry Pi LEGO
has a fondness for the old days. “I have always Robotics project
A nod to nostalgia
For the retro radio build Raju wanted something
that would force us to slow down in our current
fast-paced digital world. He says the analogue
controls of the radio are in some way the opposite
of how we interact with our devices today with
touch and voice. The project was also meant to e posted a video of his project on YouTube showing station selection
H
Keep on improving
Raju had seen other retro radio upcycling projects
online, and was particularly keen on creating one
similar to this internet radio project:
magpi.cc/internetradio. He used a 2GB Raspberry
Pi 4 because he “needed the extra horsepower of
Raspberry Pi 4 to get experience with the map
display”. He bought the main components from
online stores such as Adafruit.
Sourcing a suitable radio and writing the
software interface were his main challenges,
he searchable Radio Garden site serves up stations from around the globe
T
Rig up a radio
Confetti Bot
Want a party to go off with a bang? Then you want a
device that fires confetti, as David Crookes explains
I
f you’re going to celebrate, then you should all confetti cannons are not the same size so, even
do so in style. So what better way than sending between brands, sometimes the clasp wouldn’t hold
a stream of confetti flying through the air at a the cannon strongly and the cannon would turn with
press of a button? That’s the premise behind the the motor without popping anything. The cables
Confetti Bot, a small cannon that shoots small to the battery are still hanging out, so hopefully a
pieces of coloured paper (biodegradable, of course) second version will enclose everything.”
skywards with a decent amount of power. With
a Raspberry Pi 3 B+ at its heart, it’s a relatively Party time
Hazal
MAKER
inexpensive way to get a party started. The software was written in Python, making use of
Mestci The device was created to mark the public launch the Viam Python SDK. “Viam’s compatibility with a
of Viam, a software platform for smart machines. variety of hardware components allowed seamless
Hazal Mestci is a
Turkish technologist The company’s project manager, Fahmina Ahmed, integration,” Hazal explains. “I didn’t have to write
and artist who lives wired a button and a motor together to pop confetti backend code to activate the specific motor I was
in NYC. Her day-
in celebration of the milestone. using, and I didn’t have to understand the nits and
to-day life involves
building fun robots, Developer advocate Hazal Mestci then suggested grits of computing boards to be able to get a reading
coding, drawing, taking the device further. “I thought we should from a pin.
reading, doing make this project presentable and fully functional “Thanks to the Python SDK, most of the
sports, and cooking.
and provide a step-by-step tutorial for Viam users boilerplate code was already dynamically created for
magpi.cc/ to follow,” Hazal says.What emerged was a device me. In the Viam app, as you add your components
confettibot
to your config, the Code Sample tab automatically
F itting all the components gives you working code to get your resources. So it
initiated the board and the motor as I added them,
inside was the hardest part and imported all relevant libraries for me.”
Although the Confetti Bot works well as it
that uses Raspberry Pi 3 B+ and an L298N motor is, Hazal says it can certainly be improved, and
driver to turn a GPIO motor when the button is she has one particular idea in mind: “I want
pressed to trigger the release of confetti. “I chose to incorporate a camera and machine learning
ALERT! to use Raspberry Pi due to its versatility and ability capabilities so that it can automatically release
to function as a compact and affordable computing confetti when a person approaches my desk,” she
Make sure you handle platform,” Hazal says. “It provided the necessary says. “It will surprise them on a good day and
and use confetti
cannons carefully. computing power to control the button, motor and scare them on a bad one.”
other hardware components involved, and its GPIO
allowed me to program and control the actions of
the Confetti Bot.”
Tight squeeze
The device is connected to a 12V battery to make
it portable, and the components are placed within
an enclosure designed with the assistance of senior
robotics engineer Jeremy Hyde using the 3D CAD
package SolidWorks. “Fitting all the components
The motor driver inside was the hardest part,” Hazal says. “I had to
is an inexpensive
design multiple versions of the enclosure and test
but important
part of the build the prototype many times. I was also unaware that
S
yrian electronic engineer Aula Jazmati
was amazed when she encountered her
first Raspberry Pi in 2014. “It was like
a miracle in a country suffering from difficult
circumstances”, so much so that Aula set about
sharing the joy with students and children as
a means to inspire their love of making. Many
Raspberry Pi and Hexabit projects later, Aula
Aula Jazmati
MAKER
the fan speed and disc rotation. These signals are > Though you could
provided by Raspberry Pi Pico and a potentiometer design and 3D print
connected to it by an ADC pin. your own
rePalm
You’ve got to hand it to Dmitry Grinberg – squeezing PalmOS 5 onto
Raspberry Pi Pico is no mean feat, as David Crookes discovers
Y
ou can’t run Raspberry Pi OS on a RP2040
microcontroller, but that doesn’t mean
Raspberry Pi Pico is too underpowered
for an operating system. As Dmitry Grinberg
has shown, it’s capable of running a port of the
classic PalmOS 5 – the mobile operating system
unveiled in 2002 – although it’s not been without
considerable effort.
Dmitry
MAKER
16 magpi.cc rePalm
PROJECT SHOWCASE
Quick FACTS
> The project ports
PalmOS 5 to
Raspberry Pi Pico
rePalm magpi.cc 17
PROJECT SHOWCASE
Raspberry Pi Pico
is mounted on
the back of the
touchscreen display.
As Dmitry says, a
$1 microcontroller
is being used to
replicate what was
once a $400 device
“Applications work best at resolutions that are also allowed the thing being tapped to be seen,
integer multiples of 160 × 160, and extra space can while fingers are relatively large and obscure
be used for the dynamic input area. A 320 × 240 what you tap.”
resolution is not super common but is supported
relatively well.” Ramming in RAM
Dmitry says it helped that the screen was easy The more Dmitry used RP2040, the more he
to purchase. “It is a pet peeve of mine when realised it was a good fit for the project. “First, the
people publish a project and their parts list PIO system is very versatile, allowing me to pretend
includes ‘that one thing I bought at a garage sale to be a RAM and a ROM to the host 68k processor
once’ or ‘an old tube my grandpa left me in his (in the case of PalmCard) while also driving my
will’,” he explains. But it was also important to display with no CPU cycles needed. No other micro
have a resistive touchscreen. out there has anything quite like it,” he says.
“Devices today are designed for capacitive “Second, the performance is good. Cortex-M0
touch, hence the large touch targets,” he says. may not be a very performant core per-cycles, but
“PalmOS predates cheap capacitive touch so it the fact that I can easily run it at 200MHz+ surely
is designed for resistive touch screens which papers over a lot of that! Third, the documentation
needed quite a bit of pressure to work, hence does not suck, and this cannot be overstated.
the fact that styluses had a fine tip. The fine tip Whoever wrote the RP2040 docs needs a medal, a
bonus or a hug because it is clear and accurate.”
[That would be Alasdair Allan – Ed].
But that’s not to say Pico is perfect. “There is
barely enough RAM to turn around in, so it’s not
a practical PalmOS device,” he laments. “PalmOS
5 needs at least 64KB of RAM for the storage heap
where the databases are stored and at least 128KB
of dynamic heap, where temporary allocations
come from, to boot.
Dmitry has also “My kernel and DAL need about 30KB for itself
found a way to wire and we also need to fit at least one full frame
up external RAM to
the RP2040 in a way buffer [screen image] into the RAM. At 320 × 240
that it’s writable,
× 2 bits per pixel, the framebuffer is almost 19KB.
readable, and cached
(magpi.cc/romram) Adding that up gives us 241KB. Now, RP2040 has
18 magpi.cc rePalm
PROJECT SHOWCASE
Looking ahead
This all means PalmOS 5 just about barely fits on
Raspberry Pi Pico and, once it boots, only basic
programs run with a few KB of RAM left over for a
memo pad note or two. There’s not enough RAM
to load a game, and Dmitry would love an RP2040
with more RAM. “It would work better,” he says.
Every feature that existed in PalmOS is
02 available – including every bug – and that
T here is barely enough RAM to makes the build great for software compatibility,
Dmitry says. The OS can be navigated using a
turn around in, so it’s not a stylus, just as Palm devices were back in the day.
rePalm magpi.cc 19
PROJECT SHOWCASE
magpi.cc/
project for one maker, learns Rosie Hattersley rspcadeterrents
M
oving house is stressful enough; significant compute capabilities of Raspberry Pi
unpacking only to discover your new 4 prompted him to explore its machine learning
garden is favoured by unexpected potential at home.
local wildlife that doesn’t respond to unsubtle
hints is unsettling too. Software engineer James Inaudible alarm bells
Milward decided on a technology-based approach Having moved house in 2022, James and his
to tackling his night-time visitors, creating a family quickly discovered an issue with their
Badger and Fox Deterrent based around Raspberry new home: local foxes and badgers “loved
James
MAKER
Pi 4 and some machine learning. With a day job ripping the garden up, digging deep holes
Milward involving data and AI, James already had a fair and leaving ‘gifts’ everywhere for us”. Most
clue of how to go about it. disturbingly, they brought in insects carrying
James is a software
engineer for a He had a number of Raspberry Pis at home who knew what in terms of germs and potentially
company that and built a solar-powered watering system harmful diseases. Once local wildlife experts
manages data and using Raspberry Pi A+ back in 2015. He says confirmed these fleas and ticks were definitely
uses AI and enjoys
3D printing and the low-powered footprint paired with the from their garden visitors, James was “set on a
creating electronic
projects
medium.com/@
james.milward
ifferent frequencies
D
warn off foxes and
badgers, respectively
Quick FACTS
> TensorFlow Lite
draws less than 6 W
on Raspberry Pi
James repurposed an He used TensorFlow
ultrasonic wildlife deterrent to Lite machine learning on > Even while
automatically detect different Raspberry Pi to detect foxes actively processing
types of nocturnal visitor and badgers, but trained it to images and cross-
ignore other moving objects checking them
Ring doorbell
A
camera added Raspberry Pi was the perfect Raspberry Pi would be the perfect choice to help
add some intelligence to these very basic devices.
to the setup also
triggers an alarm
choice to add some intelligence
Tense, nervous, headache
to these very basic devices James had already experimented with TensorFlow
and figured the combination
of this open-source machine
learning platform’s object
recognition capabilities
and Raspberry Pi could
work well for his Fox and
Badger Deterrent, modifying
the ultrasonic repellent
for remote use. By adding
wireless connectivity and an
ESP8266 microprocessor, he
would even be able to have
the repellent operate at a
targeted frequency range to
“accurately deter targets”.
The project’s real headache
he fox and badger
T came when trying to get video
detector machine
learning to detect frame rates good enough
the two animals
for object detection at a
he machine learning
T
model identifying a fox
Tide Clock
How do you know the tide is right for a walk? If you’re
Levi Maaia, you create a special – and very pretty
– tide clock. Rob Zwetsloot braves the seas for a look
I
f you’ve ever lived near the sea, you’ll know be found here. As it turns out, there’s a good
that it never gets old to walk along the reason for that. Similar to many coastal areas
beach, especially when the weather is good. around the Pacific and some of the northern
For Levi Maaia, it turned out the weather wasn’t Mediterranean coast, the US west coast has a
the main problem. more complex tidal pattern, which means that
“I live 200 feet above the Pacific on an ocean without constant adjustment, a basic tide clock
cliff,” Levi explains. “I try to make it a weekly ritual would get out of sync with the ‘mixed semi-diurnal’
to walk down the cliff to the shore. However, it’s tides here in just a few days.”
Levi
MAKER
disappointing to reach the seaside stairs, expecting a This meant Levi needed a way to keep the clock
Maaia nice sandy walk, only to find waves lapping against up to date with the NOAA (National Oceanic and
the base of the bluff.” Atmospheric Administration) tide data, which led
A researcher,
film-maker, and For us landlubbers, tides aren’t always something him to turn to Raspberry Pi. “The device stays
educator, Levi likes we have to think about, although Levi was familiar
to tinker with tech with the tide clocks where he grew up. Not being
and learn about the
people who tinker able to find one for his new Californian home, Levi
ll of the meters and
A
with it too decided to make his own: “It displays current tide
height in feet, predicted hours until next tide and
lights are driven by
pathwaysto
invention.org predicted height of the next tide using analogue the GPIO pins on a
meters and LED lights.”
Raspberry Pi 3B+ running
Tidal changes
Making a clock wasn’t quite as easy as he first a Python script that
thought, though.
“Growing up in Rhode Island, round, four- gathers tide predictions
segmented tide clocks were a common sight
The LEDs let you
know if it’s a good in homes near the Atlantic,” Levi tells us. accurate as long as it has a Wi-Fi connection,” Levi
time to head out,
“But after moving to California, I noticed that says. “The red light on the right side of the front
with green as the
usual ‘go’ signal these simple analogue clocks were nowhere to panel indicates a rising tide and the green light on
the left illuminates when the tide is falling. All of
the meters and lights are driven by the GPIO pins
on a Raspberry Pi 3B+ running a Python script
that gathers tide predictions from the US National
Oceanic and Atmospheric Administration’s API.
The script converts the raw tidal data into PWM
values to drive the meters and the binary state
voltage for the LEDs.”
Sea worthy
As well as the electronic aspect of the project,
Levi was keen to make it look more rustic to
camouflage the internal tech, using analogue
gauges and a wooden fascia. “Obviously there
Quick FACTS
All the information > Gohar Muzammil
you’ll need before helped with the
taking a stroll Python code
down the cliff
> Levi wants to make
a durable wooden
enclosure for it
Pihome
Save money on energy bills using Raspberry Pi Pico?
It’s more likely than you think. Rob Zwetsloot takes a reading.
I
n the current climate, saving money on Efficient code
heating is something a lot of people are While initial work was done on Raspberry Pi,
interested in doing, so it’s no surprise that Thomas switched to Pico for the project.
someone decided to tackle this head on using “Raspberry Pi Pico W is used to collect
Raspberry Pi Pico W. temperature and humidity data sent by
“I’m using temperature and humidity trend ThermoBeacons and transmits it to a cloud
data for optimising my heating systems and application for further analysis,” Thomas says.
monitoring individual room temperatures and “Actual data is additionally shown on a local
Thomas
MAKER
humidity,” Thomas Ackermann tells us. He display and provided by a local web server running
Ackermann lives in Bavaria, which has a similar climate to on Pico W.”
the UK with distinct seasons and a temperature Thomas had to do some serious coding
A software engineer
since the ’90s, ranging from freezing in the winter to too hot wizardry to get everything to run properly on
Thomas started his (25-30 °C) in the summer. “Up until now I have Pico – including tracking down a memory leak
career writing C on
had three systems running: two systems for room in MicroPython.
Unix systems.
monitoring which I am using for rooms which “I had to extend the original Pico LCD driver
magpi.cc/ are not occupied currently and need monitoring to support a configurable frame buffer,” explains
pihome
for deep temperatures and high humidity in the
winter. The other system is for optimising an old
oil heating system. The sensors are attached to the
T his helped to identify
piping and so indicate when the individual pumps
for heating, hot water and hot water circulation,
a useless circulation
and the oil burner, are active.” pump which could be
Thomas began this project with the goal of
refreshing his Unix/Linux skills and learning disconnected and so
Python on Raspberry Pi – and has ended up with a
saving of about €700 (£609/$741) a year on oil. power could be saved
The hygrometer
is hidden away
by some pipes to
take readings
26 magpi.cc Pihome
PROJECT SHOWCASE
This Bluetooth
ThermoBeacon
sends sensor
Quick FACTS
data to Pico
> The code makes
use of asyncio for
multitasking on Pico
Thomas. “This is used to have enough free memory heating system; the real temperature was 5 °C
> Data is sent to
for the https communication to the cloud service” higher than the temperature measured from the
the ThingSpeak
You can get the full code at magpi.cc/pihome heating controller and so the hot water pump cloud platform…
was activated too often. Finally it was used to
What a savings measure the effect of added insulation. The > …which also
With the data collected from his sensors, Thomas burner temperatures are significantly lower includes diagnostic
was able to make some interesting discoveries. with the new insulation.” data on how Pico
“This helped to identify a useless circulation Now that Thomas has taken his project is performing
pump which could be disconnected and so this far, he’s keen to add more Bluetooth
power could be saved,” Thomas says. “It was also beacons and more types of sensor to the overall > TI SensorTags were
switched out for
used to track down a problem with an incorrect system. Here’s hoping it helps him save even
ThermoBeacons
hot water temperature measurement in the more money…
> With a smart
thermostat, a
project like this
could control
your heating
Pihome magpi.cc 27
PROJECT SHOWCASE
I
f you’re already tiring of the wedding season, which the chosen one, played by Keanu Reeves,
this project isn’t going to make you feel any dodges bullets with an impressive backbend.
better. Sebastian Staacks has out-gifted us all. You might also have heard of it as a frozen
No serving spoon sets or gift vouchers here. For moment, dead time, flow motion, or time
his cousin’s wedding he made a bullet time photo slice video.
booth using an array of DSLR cameras triggered by “My cousin asked me if I could build a photo
Raspberry Pi Picos. booth for his wedding,” explains Sebastian,
“where guests could create fun memories with
Sebastian
MAKER
Staacks What does bullet time mean? props like hats and giant glasses. I wanted to try
Bullet time photo booths comprise multiple something fancier. A video booth with a bullet
Sebastian is a cameras rigged together. Each camera takes a time effect”.
physicist and photograph at the same moment simultaneously,
the developer of
phyphox (phyphox.
or with a small delay between them. Software then A three-Pico wedding
org). He is a father joins each of the photographs to create a video Twelve cameras are attached to a curved rig that
of two, a drummer, with the striking “bullet time” effect. The effect looks a bit like a ballet barre. Look at the image
coder, and maker. is best known for – and indeed named after – its and you’ll notice the cameras are placed at greater
staacks.de use in The Matrix (magpi.cc/matrixbullettime) in distances apart towards the wall on the left,
and much closer together on the other end. This
The green button is used to start the recording
countdown and to confirm that a recording achieves the impression of the action accelerating
should be kept when the guests review their when the shots are played back in sequence.
result. The red button discards the recording
“I set myself a limit of €50 [£43.50] per
camera,” says Sebastian. “which means that the 12
cameras alone would cost €600 [£521].”
Sebastian did consider Raspberry Pi Camera
Module but decided on picking up extremely
old DSLR cameras instead, picking “the oldest
mainstream beginner DSLR that has a decent
resolution”. He settled on 12 10MP Canon EOS
400D cameras, which he picked up on Craigslist.
A Raspberry Pi Pico (magpi.cc/pico) acts as the
camera trigger. It has to make sure all the camera
shutters go simultaneously in order for the bullet
time effect to work. Two further Raspberry Pi
Pico Ws sit inside Bluetooth wireless buttons so
the wedding guests can control the action. The
green button starts the countdown to a recording
and saves it, and the red button can cancel a
countdown, or trash it if everyone looks idiotic.
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 magpi.cc
SUBSCRIPTION
magpi.cc 31
COMPLETE
RASPBERRY PI
BUYER’S
GUIDE
Everything you
need for starting
your Raspberry
Pi adventure
R
aspberry Pi is an incredible device that
can empower people to do, well, just
about anything. It can’t do it all on its
own though without the help of the incredible
accessories, add-ons, and kits available.
Whether you got a new Raspberry Pi 5 over the
holiday season or looking for something new to
do with your existing boards, we’ve put together
a definitive list of essential and not-essential-
but-very-cool items for you to peruse that could
help kickstart your next project.
Let’s get making.
OFFICIAL MOUSE
PRICE £9 / URL magpi.cc/mouse
OFFICIAL
A USB mouse in POWER SUPPLY
Raspberry Pi colours
PRICE £12 / URL magpi.cc/psu
ARGON
Make sure your Raspberry Pi
is properly powered
NEO CASE
PRICE £15 / URL magpi.cc/argonneo
HDMI TO MICRO
HDMI CABLE
Add passive cooling with a great
looking aluminium case
OTHER ACCESSORIES
PICADE X HAT
PRICE £16 / URL magpi.cc/picadex
POE HAT
PRICE £23 / URL magpi.cc/poehat
RASPBERRY PI
Power-over-Ethernet for industry
CAMERA MODULE
PRICE £34 / URL magpi.cc/camera
TV HAT
PRICE £16 / URL magpi.cc/tvhat
ESSENTIAL ITEMS
SOLDERING IRON
Use liquid metal to join components
WIRE
CUTTERS
A good pair of wire
cutters can also
strip them
ELECTRONICS KITS
STARTER KIT FOR
RASPBERRY PI PICO
PRICE £10 / URL magpi.cc/starterpico
CHOOSE A RASPBERRY PI
3D PRINTER
With so many 3D printers to choose
MERCH!
from, its best to ask the experts, which in Show off your love for Raspberry Pi
our mind is our colleagues on our sibling with official merchandise
publication HackSpace magazine.
Issue 59 (hsmag.cc/59) has a guide on
building an open source 3D printer, as
Enamel pin
well as reviews of 3D printers throughout
its other issues, such as the new Prusa PRICE £4
MK4 in issue 67 (hsmag.cc/67). URL magpi.cc/pin
Water bottle
MAKE YOUR OWN PRICE £18
Overclock
Raspberry Pi 5
Take the already speedy Raspberry Pi 5 all
the way up to 3.0GHz. By Lucy Hattersley
B
y default, Raspberry Pi 5 offers a huge But more speed is what we’re after here, so we
speed increase over previous models. heavily suggest using a cooling device, such as
Lucy Having said that, more is always a bonus the Active Cooler or official Raspberry Pi Case for
MAKER
Hattersley and it’s possible – if not always desirable, or Raspberry Pi 5. These devices contain fans which
necessary – to push the speed pedal a little harder. will keep the temperature down and the speed up.
Lucy is editor of The With some Raspberry Pi devices, you can make Thanks go out to Jeff Geerling whose work
MagPi magazine the clock speeds run even faster, a process known predated ours (magpi.cc/jeffoverlock) and forms
and enjoys
computers and her as “overclocking”. the basis for the config.txt code in this tutorial.
cat. Overclocking Overclocking Raspberry Pi 5 via Raspberry Pi Let’s put the pedal to the metal!
the cat is probably OS isn’t dangerous, but it isn’t supported either
a bad idea though.
(and not all Raspberry Pi 5 boards respond to
Probably?
overclocking, see “YMMV”).
magpi.cc
Edit config
Overclocking causes Raspberry Pi 5 to use more
power, and the board will consequently run a lot
01 Set up a fresh installation of Raspberry Pi 5
hotter. This isn’t dangerous because Raspberry OS. Be prepared for some experimentation here so
Pi OS will throttle performance to bring the heat don’t use an SD card with anything on it you don’t
levels down. mind losing. If you have an Active Cooler or case
You’ll Need
> R
aspberry Pi 5
magpi.cc/
raspberrypi5
> R
aspberry Pi OS
(Bookworm)
magpi.cc/software
> Active Cooler
or Fan Case
recommended
magpi.cc/
activecooler
Warning!
Crash likely!
Experimenting with
overclocking may crash
Raspberry Pi OS. There
You can overclock Raspberry
with a fan is also a chance of
Pi 5 without cooling, but it corrupting the microSD
now is the time card. Experiment with
will quickly throttle down to
to fix it. Boot into a clean Raspberry Pi
protect the CPU negating OS installation and
Raspberry Pi OS. the effect. The Active Cooler ensure no important
Our instructions to will keep it running fast
data is at risk.
Speed test
04 If Raspberry Pi OS runs without crashing
take a look at the increased speed in action. To
check the new maximum clock speed open a
terminal window and enter:
Increase frequency
03 Take it further
Now we are going to increase the frequency
of the CPU from its core speed of 2400MHz.
05 Now we’re going to take the Arm clock
Eventually we plan to take this up to 3000MHz, up to the maximum we have found reliable on
our test devices, 3MHz. Open a Terminal window have maxed out at 3000 and 900 for our CPU and Using a Terminal
command to
and enter nano /boot/config.txt to edit the GPU, respectively. monitor clock
configuration files: Overclocking does use more power than speeds while running
YouTube videos
running at the standard speed. And, we can’t
# Set Arm core frequency in MHz (default stress enough that the regular 2.4GHz and
2400) 800MHz clock speeds for the CPU and GPU are
arm_freq=3000 more than sufficient for all the tasks we’ve used
Raspberry Pi for. So this is more of a novelty
Again, reboot Raspberry Pi OS and check that to play around with for us. Perhaps of more
everything is running correctly. Repeat Step 4 to use would be underclocking Raspberry Pi 5 for
test the speed. If your Raspberry Pi crashes follow projects that demand less power, and need to
the “Recover from crash” boxout and reduce the make the most use of battery power (see our
speed to 2800. Some Raspberry Pi boards are more “Underclocking” boxout).
amenable to overclocking than others (see the
“YMMV” boxout).
config.txt DOWNLOAD
THE FULL CODE:
GPU frequency
06 Our next step is to increase the GPU
> Language: Bash magpi.cc/github
frequency. By default, this is 800Mhz, and we have
successfully increased this to 900MHz on our test 001. # Increase the voltage
Raspberry Pi boards. Edit config.txt and add: 002. over_voltage_delta=50000
003.
# Set GPU frequency in MHz (default 800) 004. # Set Arm core frequency in MHz (default 2400)
gpu_freq=900 005. arm_freq=3000
006
Reboot and test Raspberry Pi OS by launching 007. # Set GPI frequency in MHz (default 800)
a web browser and testing YouTube. Some users 008. gpu_freq=900
have reported that gpu_freq=1000 also works on
their devices, so feel free to test that out. But we
D
id you know your Raspberry Pi can also included. We’ll also cover other options such as
double as an Xbox or a high-end gaming Nvidia GeForce Now. Sadly, Sony’s PlayStation
PC? You can now play the latest games in equivalent is PC-only, and we encountered issues
PJ Evans
MAKER
full HD using just your humble credit-card-sized using Amazon’s Luna. Xbox and Nvidia can work
PJ is a writer, computer. Your inputs (controller, keyboard) are with Raspberry Pi as they both support streaming
software engineer sent to the remote ‘rig’ and a video stream of the to the browser, including Chromium.
and tinkerer. He game is sent back. Recent improvements mean
really enjoyed
the testing phase lag is barely perceivable and the video quality is
of this article. excellent. It’s not quite as easy as powering up
Choose your hardware
mastodon.
social/@mrpjevans
and jumping into Baldur’s Gate III, however, and
you’ll need to make a few decisions along the
02 A good controller is essential for any
way. This tutorial will walk you through it all. gaming, cloud or otherwise. We’ve chosen the
8BitDo Pro 2. Not only is it a great Bluetooth
controller, but it’s also proven with Raspberry Pi
hardware and approved by Xbox. You can also use
Choose your platform
01 There are a handful of cloud gaming
an official Xbox controller if you prefer. You’ll also
need to interact with a keyboard and mouse. Of
services available. Out of all of them we’ve chosen course, you can use a regular wired keyboard and
Xbox Game Pass Ultimate as a great service for mouse connected to the USB ports, but if you’re
our Raspberry Pi 5. For a monthly subscription, setting up a gaming environment you may want to
you can access hundreds of games that are consider a wireless keyboard such as the Logitech
instantly playable, and many top games are K400 series which combines a keyboard and
trackpad in one.
Initial setup
03 We’re going to need the ‘full’ version
of Raspberry Pi OS, complete with desktop, as
You’ll Need we need the Chromium web browser. Using the
Raspberry Pi Imager (magpi.cc/imager) select
> F
ast internet
Raspberry Pi OS (64-bit) and write the image
connection
(ideally fibre)
to your SD card to get the latest evolution of
the operating system. We strongly recommend
> 8
BitDo Pro
using a wired internet connection to your Raspberry
2 controller
magpi.cc/pro2 Pi if possible, for best results, but if you’re using
Wi-Fi, set it up now (and SSH too if you need
> W
ireless
remote access). Once booted and ready to go, check
keyboard/mouse
magpi.cc/k400 and install any software updates (or run sudo apt
The 8BitDo Pro 2 controller is a perfect choice for this
project, and is endorsed by Microsoft for Xbox Games Pass update && sudo apt upgrade in the Terminal).
You’ll need to use the keyboard and mouse as well as a Thanks to HDMI, you
game controller, so choose a wireless option like these can do your gaming
on the big screen
Set up your controllers With cloud gaming our
04 The keyboard (with built-in trackpad)
favourite diminutive
computer can hold its own
we have chosen is very simple to set up because
against bigger machines
it uses a dedicated USB dongle. Just plug in the
receiver, and make sure the keyboard has some
batteries and is switched on. Both it and the
trackpad should work immediately. Bluetooth
devices, such as our controller, need to be paired
first. Click on the Bluetooth icon at the top-right
of the screen and select ‘Add Device’. When the
scanning window appears, put your controller
into pairing mode (on the Pro 2, press Start + X
then press the sync button for a few seconds). The
Sign up for Game Pass Ultimate
device should appear in the window. Now click
‘Pair’ to connect. You only have to do this once.
06 Xbox’s Game Pass service comes with Top Tip
different tiers of access. Cloud gaming is only
provided with the Ultimate package, which at Choose the
ecent improvements
R time of writing is £12.99 per month with a £1 right mode
offer for the first month. For your money you get
mean lag is barely full access to over 300 games, from classics like Using the 8BitDo
Pro 2? Always
perceivable and Fortnite and GTA, indie greats like A Short Hike
and newer top titles such as Starfield and Football
begin by pressing
the X + Start
the video quality Manager 2024. Sign up will require credit card
details which will be debited monthly. You can
buttons to ensure
maximum Xbox
is excellent cancel your subscription at any time. Get yourself compatibility.
signed up and then you’re ready to start gaming.
Get an account
05 Try it out
It is a necessity of cloud gaming that you
have an account with the provider. In Xbox’s case,
07 Open up Chromium on your Desktop and
this is Microsoft. So if you haven’t got one, now is go to xbox.com. If you haven’t already, log in
a good time to get yourself set up with a Microsoft now. When you are returned to the front page,
ID. Go to xbox.com, click ‘Sign in’ then ‘Create click ‘Games’ then ‘Cloud games’. You’ll have
account’. Go through the steps to get set up, and a selection of games chosen for you, or you can
don’t forget to choose a strong password and scroll to the bottom and click ‘See all games’.
multi-factor authentication. Now you can log into Choose a game and then click ‘Play’. You may get
xbox.com and get ready to start gaming. a warning that a controller has not been detected.
You’ll
need to sign up
for Xbox Games Pass
Ultimate. It comes
with access to over
300 games
Troubleshooting
If so, click A on your controller and it should clear.
If that doesn’t work, check your pairing. You’ll
09 Now you will find out whether your setup
now be put in a queue for the first available rig. has a good enough connection. The service will
try to adjust video quality, prioritising speed
over resolution. If you find it inadequate, try
moving from Wi-Fi to a wired connection. Check
Playtime!
08 Your wait time will depend on the game’s
whether your sibling is streaming HD video while
uploading 5,000 selfies. If nothing works, contact
requirements and popularity. In our testing, most your internet provider to see if there are any faster
games kept you waiting no more than a couple options available to you. We’ve found that fibre-
of minutes, but popular and resource-hungry based services are the only way to get close to a
games can see waits of 30 minutes or more at real console experience. If you’re finding response
peak times. If this happens, try choosing another times laggy, nearby radio interference may be the
game. The wait screen will keep you informed of cause, and using an Ethernet cable to connect to
progress. When the game starts, it will be as if your router can fix this too.
you were in front of a real console and you play
Our experience
streaming games accordingly. Pressing the 8BitDo controller’s
with Luna wasn’t
‘heart’ button will bring up an overlay so you can
good, but it might
Boot straight in
work for you end the game or adjust settings.
10 To finesse your Xbox experience, we can
configure Raspberry Pi OS so you can boot straight
into a full-screen browser. Open up a Terminal
window or SSH into your tiny gaming rig. Now
issue this command:
nano ~/.config/wayfire.ini
[autostart]
chromium = chromium-browser https://www.
xbox.com/en-GB/play?xr=shellnav/ --kiosk
Nvidia’s GeForce
--noerrdialogs --disable-infobars --no-first-
run --ozone-platform=wayland
T he service will try to Now platform comes
with some great
demos for free, such
Python on
Raspberry Pi
There’s been a major change to Python. Now is a great time
to learn about virtual environments. By Alasdair Allan
R
aspberry Pi OS Bookworm brings a big From Bookworm onwards, packages installed
change for Python users, as we implement via pip must be installed into a Python Virtual
Alasdair a change introduced by the Python Environment using venv (magpi.cc/venv). This
MAKER
Allan community in upstream Debian: from Bookworm has been introduced by the Python community,
onwards, packages installed via pip must be not Raspberry Pi, see PEP 668 for more details
Alasdair Allan installed into a Python Virtual Environment. This (magpi.cc/pep668).
is a scientist,
will affect a lot of people, and we understand it will Installing packages using apt is the preferred
author, hacker
and journalist. In be disruptive for many as we all get used to the new method for installing Python libraries on Raspberry
the past he has way of doing things. Pi OS Bookworm. Packages installed via apt are
mesh networked In this tutorial, we take a look at what has tested, usually pre-compiled so they install faster,
the Moscone
Center, caused a
changed and how to effectively use Python on and are designed for Raspberry Pi OS. They won’t
US Senate hearing, Raspberry Pi OS Bookworm. break your system. Additionally, installing via this
and contributed Python 3 is installed by default on Raspberry route means that all required dependencies are also
to the detection of
Pi OS and is used for many important functions. installed, and a log of installation is maintained by
what was – at the
time – the most Interfering with the system Python installation the OS so the installation can be easily rolled back
distant object can therefore cause problems for your operating (uninstalled) if needed.
yet discovered in system, so it’s important that if you install third- For instance, to install the Python 3 library to
the Universe.
party Python libraries you use the correct package support our Build HAT:
magpi.cc/docs management tools.
There are two routes to installing libraries into $ sudo apt install python3-build-hat
the default python distribution. Firstly you can use
apt and install pre-configured system packages, or …to install the pre-built library.
alternatively, you can use pip to install packages that Using apt makes installing larger packages,
are not distributed as part of Raspberry Pi OS. like numpy which has many native dependencies
including a Fortran compiler, much simpler than
installing individual packages using Python’s own
package management system.
If you want to install a Python library called
“numpy” you can use apt search foobar to search
for the exact package name. In most cases, you’ll
find that the required package is going to be called
python-foobar or python3-foobar.
Virtual environments
In previous versions of the operating system you
used to be able to directly install libraries, system-
wide, using the package installer for Python,
commonly known as pip. You’ll find the following
Once in a virtual environment you can install
Python packages in Thonny using the Package sort of command in many tutorials online:
$ source env/bin/activate
(env) $
(env) $ deactivate
$
User environments
An alternative method to creating a virtual
environment for each of your Python projects is to We can again check we’re in a separate
create a single virtual environment for your user environment by using pip list:
account and then activate that environment before
running any of your Python code. This approach (.env) $ pip list
may be preferred if you commonly install the Package Version
same set of modules for each project, and don’t ---------- -------
want to have to bother creating individual Python pip 23.0.1
environments for each project, essentially just setuptools 66.1.1
duplicating your environment.
… and leave it using deactivate.
$ python -m venv ~/.env
$ source ~/.env/bin/activate (.env) $ deactivate
(.env) $ $
Remote control
Raspberry Pi with VNC
Use TigerVNC to remotely access the latest and
greatest version of Raspberry Pi OS desktop
A
s is so often the case in computing, a
new version of an operating system
brings advancements but also some
PJ Evans
MAKER
Using Ubuntu
Part 02
on Raspberry Pi
Exploring more features of the Ubuntu
Desktop Linux OS on Raspberry Pi
I
n the first part of this tutorial series (magpi. and get under the hood of the operating system.
cc/135), we showed how to install and set up We’ll be using it to perform various tasks.
Phil the Ubuntu desktop operating system on a To open a Terminal window in Ubuntu, click the
MAKER
King Raspberry Pi, and took you through some of its Activities button at the top of the left sidebar and
key features. search for ‘Terminal’, then double-click the icon to
A long-time This time we’ll look at how to access the launch it. Alternatively, use the keyboard shortcut:
contributor to The command line, set up remote connections via SSH CTRL+ALT+T.
MagPi, Phil is a
freelance writer and and RDP, install media codecs, use Raspberry Pi’s The terminal window will show the usual
editor with a focus GPIO pins, change the desktop environment, and command-line prompt where you can enter a
on technology. use alternative ways of installing software. host of commands. To see the path for the current
@philkingeditor working directory (i.e. the folder you’re in), enter
pwd. To list its contents, enter ls. You can use the
cd command to change directory; for example,
Access the command line
01 As well as navigating Ubuntu’s desktop
cd Downloads.
For lots more useful commands, check out the
GUI, you can open a CLI (command-line interface) command-line tutorial in The MagPi issue 125
Terminal to use powerful text-based commands (magpi.cc/125).
You’ll Need
> R
aspberry Pi 4,
400, or 5
After installing
Ubuntu-restricted-
extras, you can
play MP4 videos
in a media player
such as VLC
$ sudo apt install gnome-tweaks By default, there’s only a choice of two DEs:
Ubuntu (the default) and Ubuntu on Xorg (which
Opening the Tweaks app will enable you to alter switches the display manager from Wayland to
the appearance of the cursor, icons, fonts and other X11). You can install extra environments from the
settings. You can add more options from custom command line, however. For example:
themes by installing the Extension Manager:
$ sudo apt install kde-plasma-desktop
$ sudo apt gnome-shell-extension-manager
You should then be able to select it – Plasma
Open the Extension Manager app, click the (X11) in this case – from the login screen DE
Browse tab, then User Themes and Install. In the selection menu.
web browser, download a theme or icons from
gnome-look.org, such as Orchis. Extract the file
(double-click in the file browser).
Coding with Python
In Terminal, create two new directories (for
GTK/GNOME Shell and icon/cursor-based themes
09 You can still use Raspberry Pi’s GPIO
respectively) in your home folder: pins in Ubuntu, but you’ll need to install a new
Python module:
$ mkdir ~/.themes
$ mkdir ~/.icons $ sudo apt install python3-lgpio
In the Files browser, press CTRL+H to show You can then import it like any other Python Top Tip
hidden files/folders. Now move the extracted theme module at the top of your code, with import
folder(s) into the relevant folder, such as .themes lgpio. You can write programs in Ubuntu with a IP address
for Orchis. Reopen the Tweaks app, and you should text editor such as nano, or a Python IDE such as
now see new options in the Shell and Legacy Apps Spyder: sudo apt install spyder. To obtain
drop-downs. You may get a system prompt to For details of the lgpio module’s functionality, Raspberry Pi’s
install missing snaps; click ‘Yes’. see magpi.cc/lgpio. For some code examples, visit IP address, to
magpi.cc/lgpioexamples. The ‘basic GPIO example’ connect from
will blink an LED connected to GPIO 23 and a GND another device via
pin. Paste it into a new document, named blink. SSH or Remote
Switch desktop environments
08 You can even switch to a different desktop
py, using Nano (or another text editor), then run it
with the command python3 blink.py. Alternatively,
Desktop, enter
the command
environment (DE) from the user login screen – to you can install a Python IDE such as Spyder – sudo hostname -I.
get back there, click the top-right power icon and apt install spyder – and run it from there.
Raspberry Pi:
Part 02
Mecanum robot
with sensors
Expanding on our mecanum robot project, add a distance
sensor to avoid crashing into obstacles. Learn how
collision avoidance is used to make driving safer
T
he mecanum robot in the earlier tutorial taken between the signal being transmitted and
Stewart
MAKER
(MagPi issue #135, magpi.cc/135) could be the response received can be used to work out
Watkiss
controlled with a gamepad. If you didn’t the distance to an object.
Also known as react fast enough, then it was quite easy to crash Figure 1 shows the HC-SR04 sensor used for
Penguin Tutor. A the robot. Adding an ultrasonic distance sensor this project. There are different models of the
Maker and YouTuber
means that the robot can automatically stop HC-SR04, some of which can work down to 3.3V.
who loves all things
Raspberry Pi. Author before colliding with a wall or other object. This circuit is based around the 5V version for
of Learn Electronics The sensor used is similar to those found in car maximum compatibility.
with Raspberry Pi. parking sensors. The robot senses the distance to
penguintutor. objects in front and automatically stops forward
com movement when an object is too close. With
Sensor signals
@stewartwatkiss additional code, this could be used as the basis of
a robot that could navigate a maze.
02 In addition to the power supply, the
HC-SR04 semsor module has two pins for an
input and output signal. The trigger needs to be
You’ll Need sent a short 10µS pulse to start the measurement.
Ultrasonic distance sensors
> HC-SR04 Ultrasonic 01 There are various different sensors that
The transmitter then sends eight sonic bursts and
the reciever listens for an echo.
distance sensor
can be used to detect distance. The one used here After determining how long it took to receive
magpi.cc/hcsr04
is based on ultrasonic distance measurement, a response at the receiver, the echo pin is then
> 330 ohm resistor and works by emitting an ultrasound signal and raised high for a length of time proportional
magpi.cc/330r
then listening for an echo response. The time to the distance. This is shown in Figure 2.
> 470 ohm resistor The output from the echo pin is 5V, which is
magpi.cc/470r too high for the GPIO pins. Therefore a resistor
voltage divider can be used to drop the signal to
approximately 3.3V.
An ultrasonic distance
sensor is used to detect
the distance of objects
in front of the robot
dist_sensor.distance
dist_sensor = DistanceSensor(echo=6,
trigger=5)
pgzrun mecanum-pgz.py
DOWNLOAD
mecanum-pgz.py THE FULL CODE:
magpi.cc/mecanumrobotgit
> Language: Python Pygame Zero
001. # Minimal version of mecanum-pgz 049. keys.K_6 : (1, -1, -1, 1), # Right
002. from gpiozero.pins.pigpio import PiGPIOFactory 050. keys.KP6 : (1, -1, -1, 1), # Right
003. from gpiozero import Device, PWMOutputDevice, 051. keys.K_8 : (1, 1, 1, 1), # Forwards
004. Motor, DistanceSensor 052. keys.KP8 : (1, 1, 1, 1), # Forwards
005. 053. }
006. WIDTH=800 054.
007. HEIGHT=600 055. # Track direction
008. 056. current_direction = (0, 0, 0, 0)
009. Device.pin_factory = PiGPIOFactory() 057.
010. 058. # speed is as a percentage (ie. 100 = top speed)
011. pwm_pin = 18 059. speed = 50
012. m_f_l = (2,3) 060. pwm_out.value = speed/100
013. m_f_r = (22,23) 061.
014. m_r_l = (14,15) 062. def draw():
015. m_r_r = (24,25) 063. screen.fill((192,192,192))
016. 064. for arrow in arrows:
017. motors = [ 065. arrow.draw()
018. Motor(m_f_l[0], m_f_l[1], pwm=False), 066.
019. Motor(m_f_r[0], m_f_r[1], pwm=False), 067. def update():
020. Motor(m_r_l[0], m_r_l[1], pwm=False), 068. global current_direction
021. Motor(m_r_r[0], m_r_r[1], pwm=False) 069. try:
022. ] 070. if (dist_sensor.distance <= min_distance):
023. 071. # Is robot going forward (or diagonal)
024. pwm_out = PWMOutputDevice (pwm_pin) 072. if (current_direction[0] == 1 and
025. dist_sensor = DistanceSensor(echo=6, trigger=5) current_direction[1] == 1):
026. 073. print (“Warning - crash imminent”)
027. arrows = [ 074. # Force stop using stop key number
028. Actor(“arrow.png”, center=(500,300)), # Right (5)
029. Actor(“arrow.png”, center=(400,200)), # Up 075. set_direction (direction[keys.K_5])
030. Actor(“arrow.png”, center=(300,300)), # Left 076. except:
031. Actor(“arrow.png”, center=(400,400)) # Down 077. print (“No distance sensor detected”)
032. ] 078.
033. arrows[1].angle = 90 079. def on_key_down(key):
034. arrows[2].angle = 180 080. global speed, current_direction
035. arrows[3].angle = 270 081. # Get next key pressed
036. 082. if (key in direction.keys()) :
037. # distance in meters - a value between 0 and 1 083. set_direction(direction[key])
038. min_distance = 0.09 084.
039. 085. def set_direction(direction):
040. # list to convert key into motor on/off values to 086. global current_direction
correspond with direction 087. current_direction = direction
041. # direction based on number keypad 088. for i in range (0, 4):
042. direction = { 089. if direction[i] == -1:
043. keys.K_2 : (-1, -1, -1, -1), # Backwards 090. motors[i].backward()
044. keys.KP2 : (-1, -1, -1, -1), # Backwards 091. elif direction[i] == 1:
045. keys.K_4 : (-1, 1, 1, -1), # Left 092. motors[i].forward()
046. keys.KP4 : (-1, 1, 1, -1), # Left 093. else:
047. keys.K_5 : (0, 0, 0, 0), # Stop 094. motors[i].stop()
048. keys.KP5 : (0, 0, 0, 0), # Stop 095.
Code
Configure
Analyze
cdpstudio.com
Tel: +47 990 80 900 • [email protected]
CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
HEATING
& With the release of Raspberry Pi 5,
we’re introducing two new official
hardware solutions for cooling.
COOLING
By Alasdair Allan
E
very time a new Raspberry Pi is released,
there are questions about thermal control
of the new board. People want to know
whether it’s necessary, and if so, what you’ll need
to do to make it happen.
For normal usage of your Raspberry Pi, adding
cooling is entirely optional. The idle performance of
a Raspberry Pi 4 and a Raspberry Pi 5 is about the
same, and under typical loads, Raspberry Pi 5 will
run cooler than a similarly loaded Raspberry Pi 4.
However, a heavy continuous load will mean that the
board could potentially go into thermal throttling.
Throttling happens as there are software controls to
limit CPU speeds if things get start to get too toasty.
Although, even when fully throttled, a Raspberry Pi 5
is still going to run faster than a Raspberry Pi 4.
But data makes everything better, so I decided to
grab some early production hardware and run some
tests to help you make up your mind about whether
ben showing off a prototype of the Active
E
Cooler for Raspberry Pi 5 you’re going to need to cool your Raspberry Pi 5.
No cooling
The first thing to do is to measure what happens
when your Raspberry Pi 5 is not cooled. Without
CPU temperature
The vcgencmd command is an amazingly useful
the open air on the lab bench.
For normal use adding cooling is optional. If
you’re watching a YouTube video, or working on
source of information about the things that are the desktop, you aren’t going to be stressing the
happening on your Raspberry Pi, and the Python CPU like we did in this test. But, unsurprisingly,
bindings (magpi.cc/vcgencmd) surface all of with the heavy sustained load we’re imposing
that and let you programmatically monitor pretty on the CPU with no cooling the maximum
much everything that needs monitoring. Here temperature climbs to and then remains stable
he clock speed
T
we’re going to use the vcgencmd Python bindings just above the 85 °C thermal limit during extended intermittently throttled
to monitor and log the temperature, along with testing. This leads to sustained thermal throttling on an uncooled
Raspberry Pi
the current CPU clock speed and throttling state, after the temperature reported by the processor undergoing a stress
test to maintain a
to a file (see measure_temp.py, p69). rises above the throttling limits.
constant maximum
Once we have the script up and running in a thermal temperature
Terminal window, we can open up another and
kick off a stress test on all four cores to load
the CPU. To do that, I’m going to use the stress
(magpi.cc/stress) command line tool to impose a
heavy workload on all four of the CPU cores.
Active Cooler
I then ran the same test with managed active cooling
to full speed. When the temperature drops back
below these limits, the blower’s fan will spin
down automatically.
using the new Active Cooler, and then with the Thanks to the passive heatsink, with the
Active Cooler still fitted but with the blower’s fan Active Cooler fitted we see a much lower idle
disconnected. Both these tests were done with the temperature, around 45 °C. During extended
Raspberry Pi sitting in the open air on the lab bench. testing under load, the fan of the Cooler spins up
The Active Cooler is a single-piece anodized at low speed to stabilise the CPU temperature at
aluminium heatsink with an integrated blower. It 60 °C, with a maximum temperatures of 62 to 63 °C
rocessor
P has pre-applied thermal pads for heat transfer, and being seen during the tests.
temperature in
°C against time in is mounted to the Raspberry Pi 5 board directly using Noise levels of between 35 to 40 dB were
seconds. At time
T=T₀ stress testing
spring-loaded push pins. It is actively managed by measured during the load test while the fan
was started Raspberry Pi’s firmware. At 60 °C the blower’s fan was in operation – that’s about as much noise
as you’ll make turning the page of a book.
During the extended stress testing the fan never
actually needed to run at full speed to maintain
temperature control of the Raspberry Pi.
Unplugging the fan and relying solely on
the passive cooling provided by the aluminium
heatsink, the idle temperatures were similar,
but under extended load the CPU temperature
eventually reaches the point at around T₀ + 200
seconds where thermal throttling occurs.
Reattaching the cable causes the fan to spin
up to full speed immediately, and with the
load removed, the CPU is cooled back to an idle
temperature of around 45 °C within a further 300
seconds, with the fan spinning back down to lower
speeds as the temperature falls back to normal.
measure_temp.py DOWNLOAD
THE FULL CODE:
> Language: Python magpi.cc/github
By A lasdair
Allan
T
here is nothing so important to an engineer
who gets their hands on a new bit of
hardware as to immediately try and figure
out how fast it can go. On the other hand, there
is nothing more hotly debated between engineers
as to how to measure how fast things go. But like
many things, what you should measure really
depends on how and why you will be using the
hardware in the first place.
As our American friends might say, your
mileage may vary (magpi.cc/ymmv).
Single core
Single-core scores measure the processing
realistic case where jobs are being distributed
across all the cores of the board’s CPU. These
sorts of scores are more relevant for heavily
power of one CPU core and are more relevant threaded applications such as web browsers,
for applications that are lightly threaded, which generally try to offload individual tabs
meaning they rely mostly on a single core to into separate process threads.
process instructions. Over one hundred runs of Geekbench 6 we
Over one hundred runs of Geekbench 6 saw saw an average score of 1,604±22 for Raspberry
an average score of 764±6 for Raspberry Pi 5 Pi 5 using a 4KB page size, and 1588±63 using a
using a 4KB page size, and 774±6 using a 16KB 16KB page size. That’s a ×2.2 speed increase over
page size. That’s a ×2.4 speed increase over Raspberry Pi 4.
Raspberry Pi 4.
Raspberry Pi 4 340
2.4GHZ 3.0GHZ
Cryptographic
benchmarks for
Raspberry Pi 4 and
5 by Jeff Geerling
Some ncnn
framework
benchmarks from
Seeed Studio
PicoVision
(Pico W Aboard)
Pimoroni magpi.cc/picovision £35 / $37
A
RP2040 (GPU),
imed mainly at fans of retro gaming and for programming in MicroPython or C/C++, or
2 × 8MB PSRAM,
PCM5100A DAC old-school programming, PicoVision is flashing Pico W with new firmware.
for audio, 3 × user a surprisingly capable digital video stick Alternatively, PicoVision can be powered via two
buttons, status with a pre-soldered Raspberry Pi Pico W on board. unpopulated pins. There’s also a breakout header
LED, reset button, Using Pico W’s RP2040 microcontroller chip as for CPU and GPU debugging, plus a few other GPIO
microSD card slot
the CPU, it adds a second RP2040 to act as a GPU to pins. A single Qwiic/STEMMA QT port can be used
CONNECTIONS: help handle the big-screen visuals. Two extra 8MB to connect I2C breakouts or sensors.
HDMI video out, RAM chips are used to swap frame buffers between On the front of the board are three user buttons,
3.5mm audio line the two RP2040s, enabling PicoVision to output an activity LED, and a handy reset button. At the
out, breakout
reasonably high-res graphics (for a microcontroller) rear is the bonus of a microSD card slot to provide
header, Qw/ST
port, micro USB to a monitor via a standard HDMI output. extra storage for assets such as graphics.
(on Pico W) The only slight drawback is that it’s not able to
DIMENSIONS:
output audio via HDMI. For this, there’s a 3.5mm Instant menu
87 × 38 × 9mm stereo line out jack to connect a pair of PC speakers Getting started is as easy as connecting PicoVision
or headphones. to an HDMI monitor or TV and powering it up. It
Power is connected using Pico W’s micro USB comes pre-flashed with MicroPython firmware
port – as usual, you can hook this up to a computer that auto-runs a menu of example programs. The
A and X user buttons are used to move up and version of the firmware), with up to ten per any
down through the menu options; and a press of single scanline.
the Y button will select one.
Among the example programs are a fun Start coding
Flappy Bird-style game, magic mirror dashboard, When it comes to programming PicoVision
and Teletext-style headlines – the last two yourself, a comprehensive GitHub repo (magpi.cc/
require connection to a Wi-Fi network. picovisiongh) provides lots of useful info, along
with MicroPython and C/C++ libraries and code
Verdict
mong the example
A examples from which to learn. The most basic are
Hello World programs to print text to the screen.
With a second
RP2040 and extra
programs are a fun Flappy Graphics are handled using Pimoroni’s standard
PicoGraphics module, while a PicoSynth sound
RAM to boost Pico
W’s capabilities,
Bird-style game, magic module is used to play simple tunes and noises
PicoVision
offers plenty of
using I2S audio from the board’s DAC chip. possibilities for
mirror dashboard, and You’ll also want to try playing classic Doom on retro gaming and
PicoVision – which works really well. Just flash coding projects.
Teletext-style headlines
9
the Doom firmware UF2 to PicoVision and add the
game’s WHX file to a microSD card. For control,
/10
Several graphical demos showcase PicoVision’s you’ll need to connect a USB keyboard via a splitter
capabilities. These include a classic 3D starfield cable (as supplied in the optional accessory kit).
effect (remember Windows 3.1’s screensaver?), a
screen modes menu with numerous resolutions
(some require GPU overclocking), and a parallax
scrolling animation that makes use of PicoVision’s
scroll modes – up to seven groups of scanlines can
be scrolled separately.
Up to 80 sprites can be shown on screen
simultaneously (or 32 with the special widescreen
10 Amazing:
3D prints simplyRetro Z5
Comfy and large
Print your own custom project
Some 3D printed handheld consoles are very small and portable, but
pieces for Raspberry Pi sometimes a bigger screen is more comfy. The Z5 offers this.
magpi.cc/retroz5
3
D printing and making go hand-in-hand, and these amazing
prints and projects involving Raspberry Pi are fantastic
ways to upgrade, or even realise your dream project. After
many years, there’s a huge range to choose from – here’s just ten Rapiro
we like.
Bipedal robot friend
Rapiro was a very cool kit
from several years ago
which always had open
source STL files so you
could print your own.
magpi.cc/rapirostl
RaspBMO ZeroBot
Friendly console Practical and small
While this BMO will be able to emulate games, it’s also just a nice This cool looking robot for Raspberry Pi Zero is great for remote
thing to have sitting on your desk. controlling and looking where you’re going with computer vision.
magpi.cc/raspbmo magpi.cc/zerobot
3D prints magpi.cc 79
RESOURCES
Gameboy
NANO
Small and portable
This very tiny handheld console
fits Raspberry Pi Zero – upgrade
to Zero 2 and watch it really fly.
magpi.cc/gameboynano
C
ase with
Tank Bot camera mount
Treads for grip Goose neck mount
There are many robots on Thingiverse – we quite like this one as it can be
Watching your 3D printer with a
used for rough terrain better than normal wheels
3D-printed Raspberry Pi stand may be
a little meta, but it’s fun and useful.
magpi.cc/tankbot
magpi.cc/casewithcam
R
etro
desktop tower
FreeCAD for Makers
Nostalgic protection
Fancy making your own 3D
More powerful than a ’90s PC, and a prints? Our colleagues at
neat way to present Raspberry Pi. HackSpace magazine put
together a great resource for
magpi.cc/retrotower designing 3D models in FreeCAD
80 magpi.cc 3D prints
Your FREE guide to
making a smart TV
BUILD A RASPBERRY PI
MEDIA PLAYER
Power up your TV and music system
raspberrypi.com
FROM THE MAKERS OF THE OFFICIAL RASPBERRY PI MAGAZINE
magpi.cc/mediaplayer
RESOURCES
Learn Scratch
with Raspberry Pi
Resources to help you start coding with
the block-based language. By Phil King
Reading material
Books to help CODING WITH SCRATCH sturdy cards covering various projects
Part of the QuestKids series aimed at – such as Pong Game and Virtual Pet
you learn youngsters, this colourful 80-page – with instructions to make them.
Scratch coding guidebook sees the cartoon gang nostarch.com/scratchcards3
show you how to create platform
games. There’s also a second Scratch CODING FOR BEGINNERS
book that covers driving games. USING SCRATCH
magpi.cc/qkscratch This appealing spiral-bound Usborne
book helps you to get started with
OFFICIAL SCRATCH Scratch and create a range of projects
CODING CARDS including animations and simple
This set of 76 flash cards breaks games. There are also handy tips and
simple projects down into easy-to- links to working projects.
follow steps. There are ten sets of magpi.cc/usbornescratch
Scratch Ideas
MIT Media Lab A popular section of the official with an educator guide if you’re
Online
AUTHOR
Scratch Team
loops, and variables.
magpi.cc/cs50scratch
videos, the official Scratch Team different types of projects, video series shows how to
Price: channel on YouTube is an ideal including a Pong game and set up a basic tower defence
Free
destination. Tutorials include virtual town. game, add game logic and
youtube.com/
how to remix the built-in The Tips & Tricks selection rules, design UI elements,
@ScratchTeam
Scratch sprites, create new ones, covers useful pointers in two incorporate sound and music,
import your own drawings, categories. ‘Unlock the Block’ then test and debug it.
plus add and record sounds. videos help you to ‘unlock magpi.cc/scratchtdgame
the magic’ behind some of
the key Scratch blocks, while
‘Scratching the Surface’ is a 5 PROJECTS IN 5 DAYS
series of one-minute videos Subtitled ‘Scratch Game
that explain intermediate-level Programming for Kids’, this
coding concepts. beginner-level course by the
You’ll also find some Create- Little Apple Academy shows
Along videos of livestreams in how to create five simple
which the Scratch Team create interactive animations and
a project in an hour, along with games. Video-based, it’s fun
Scratcher Stories and video to follow.
updates from the team. magpi.cc/5projects
Jorvon
Moss
A maker and roboticist known commonly as
Odd Jayy, Jorvon creates cool stuff for Digi-Key
I
f you’ve been to major
Maker Faires in the US
recently you’ve likely see
Jorvon, aka Odd Jayy, and his
amazing steampunk creations.
Sometimes robots, sometimes
wearables, and always very
cool. He describes himself as
an oddity, hence the name
Odd Jayy.
“I have an art background,
BFA in Illustration, and self-
e describes himself
H
as an oddity, hence
the name Odd Jayy
taught electronics. but mainly
focus on character based
robotics,” Jorvon tells us. “I
just decided to start [making]
one day in college as a hobby
but then realized it was a
passion of mine. I started
learning back in 2014, but it has
only been my full time job for
the last two years.”
Jorvon is always
working on
new robots
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 01
send us amazing photos and videos of the things
they’ve made.
Here’s a selection of some of the awesome
things we got sent this month – and remember to
follow along at the hashtag #MagPiMonday!!
01.
We like a nice custom home sensor suite
02.
3D printing cases is a great way to keep
your Raspberry Pi safe
03.
A nice live light is useful whether you’re
working from home or streaming on Twitch
04. This is cool and we love how low-tech and
cheap this solution is
05. The Digital Maker badge is something we
wish we had when we were kids
06. Wonder what the scale of this is compared
to the original
07. This is a cool little project – check out
HackSpace 55 and Andy’s Hackaday
for more info 02
08. Kev’s robots invaded Italy recently, with
some Raspberry Pi 5 power ups
09. Sound catcher or sound shooter? Do
you need a sight for sounds? We have
many questions…
03
04
05
06
07
08
09
Events in pictures:
Raspberry Pi 5 launch
at the Raspberry Pi Store
Raspberry Pi 5 is here! We caught up
with folks buying their boards on day one
I
n the Grand Arcade at Cambridge, the
01
Raspberry Pi Store usually opens at
a reasonable 10am but on Monday 23
October we were there at a pre-dawn 7:30
am to witness the release of Raspberry Pi 5
at 8am. While there weren’t the huge lines
you’d see at a pop up, a handful of die-hard
Raspberry Pi fans were ready to get their new
everything computer.
01.
People were able to reserve their
Raspberry Pi before hand or just buy
one if they fancied on the day
02.
Boards, PSUs, cases, and coolers
were available to grab
03.
Experience Raspberry Pi 5 at the
store before buying one
04.
The calm before the storm with
Features Editor Rob
03
02
04
88 magpi.cc Mondays
Coolest
Events inProjects
pictures
are for Pico
online!
THIS MONTH IN RASPBERRY PI
Crowdfund this!
Crowdfunding projects for Raspberry Pi accessories
kck.st/3QcioER magpi.cc/crowfund
YOUR LETTERS
Your
Letters
Priority boarding period
I have been on holiday and found out about the priority
boarding codes long after the magazine came out – is
it too late for me to get one of these codes?
Az via Facebook
FREE
RASPBERRY PI
PICO W
All our issues are available as PDFs from magpi.cc/issues
Contact us!
> Mastodon magpi.cc/mastodon
>
>
Threads
Facebook
@themagpimag
magpi.cc/facebook
Subscribe online:
>
>
Email
Online
[email protected]
forums.raspberrypi.com
magpi.cc/subscribe
Email: [email protected]
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
Community
Events Calendar
Find out what community-organised Raspberry
Pi-themed events are happening near you…
04
RASPBERRY PI 01
STORE POP-UP
Raspberry Pi pop-up
Leeds – Experience
Raspberry Pi 5
> Where Victoria Gate, Leeds, UK
> When Saturday 4 November to Saturday 30 December
G
et hands-on with the all-new
Raspberry Pi 5 in our holiday pop-up
02 store on the ground floor of Victoria
Gate in Leeds, England. Experience Raspberry
Pi 5’s blazing performance and check out the
newest accessories. The store will have the full
line of Raspberry Pi products for purchase.
03
magpi.cc/popupleeds
magpi.cc/beginnersguide
COMPETITION
Competition magpi.cc 95
SUBSCRIBE AND
SAVE UP
TO
ISSUE #73
hsmag.cc
NEXT MONTH
ENTU
[email protected]
DV R
Features Editor
E
Rob Zwetsloot
A
[email protected]
Sub Editor
Ian Evenden
ADVERTISING
A beginner’s guide Charlotte Milligan
[email protected]
to mastering +44 (0)7725 368887
Head of Design
Lee Allen
Designer
Sam Ribbits
Illustrator
Sam Alder
CONTRIBUTORS
Alasdair Allan, David Crookes, Pj
Evans, Rosie Hattersley, Phil King,
Stewart Watkiss, Ashley Whittaker
PUBLISHING
Publishing Director
Brian Jepson
[email protected]
Director of Communications
Liz Upton
CEO
Eben Upton
DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000
SUBSCRIPTIONS
Unit 6 The Enterprise Centre
Kelvin Lane, Manor Royal,
THE MAGPI #137 Crawley, West Sussex, RH10 9PE
+44 (0)1293 312193
ON SALE 14 DECEMBER magpi.cc/subscribe
[email protected]
professional
editor, and contributors accept no
responsibility in respect of any omissions
FACEBOOK magpi.cc/facebook
robotic arm
or errors relating to goods, products, or
services referred to or advertised in the
magazine. Except where otherwise noted,
Amiga with
NonCommercial-ShareAlike
3.0 Unported
ONLINE forums.raspberrypi.com
floppy drive
(CC BY-NC-SA 3.0).
ISSN: 2051-9982.
THE FINAL WORD
Christmas with
Raspberry Pi 5
Writing about Christmas in early
November is weird, even for Rob Zwetsloot
T
hese Final Word columns tend about turkey dinners and stockings had trouble balancing it on my fake
to be one of the last things on a rainy October evening. tree. I should also get them all
we write for the magazine, automated with voice commands.
meaning that even with print lead Raspberry Pi-powered Anyway, keep an eye on the MagPi
times the context of these columns Christmas socials for anything I decide is
is still fairly fresh. As I’m writing Many of the Christmas tutorials that worth posting.
this, I realise we don’t have one of have appeared in the magazine over
my seasonal features in this issue the years are based on projects I’ve Under the tree
for Christmas – my favourite winter Hopefully you’ll have made use of
holiday! I’m Mr Mince Pie according
to my friends, after all.
Many of the our Priority Boarding offer to get a
Raspberry Pi 5 for yourself or
(Don’t tell anyone, but I might Christmas tutorials someone else who will be opening it
enjoy writing the annual Halloween on Christmas morning. If you’re
feature a little more as I get to that have appeared looking for stocking stuffers, the
embrace my inner crypt keeper and Official Handbook 2024 is a great gift,
alliterate more than is advisable.) in the magazine along with the newly updated
Lucy, MagPi Editor, firmly believes
that Christmas can’t start until after
over the years are Beginners Guide. We work hard on
those to make them extra special, and
Bonfire Night [i’m right –Ed], and
while I understand and respect that,
based on projects they’re a great way for new users to
pick up Raspberry Pi.
I’m full on Christmas mode the I’ve built myself Anyway, have a great holiday and a
moment the clocks turn midnight on happy new year. And yes, we do have
Halloween. Which, if we were to write built myself as Christmas another issue out between now and
a Christmas projects feature, would decorations, although I unfortunately then. The print industry is odd.
have been roughly the deadline for it. broke the 3D-printed star I made
That’s weird, right? I know TV shows many years ago. I’m trying to figure
Rob Zwetsloot
AUTHOR
tend to film their Christmas specials out what to do this year, and I think
in July and It’s a Wonderful Life was I’m long overdue a Pico overhaul of
By the end of October, Rob has consumed
shot during an unusually hot summer some of my lights around my home. more mince pies than most people eat in
with everyone in big coats being Maybe it’s time to make a new star a year. He’s currently considering making
pelted by newly-invented fake snow, ornament? I do need to go back and a Christmas cake.
but it’s still a little odd to be writing make the star itself a lot lighter, as I magpi.cc
PiKVM HAT
for DIY and custom projects Pre-Assembled version
Real-time clock with rechargeable super capacitor OLED Display Bootable virtual CD-ROM
& flash drive Serial console Open-source API & integration Open-source software