Mag Pi 135
Mag Pi 135
Mag Pi 135
LAUNCH SPECIAL!
Quickstart setup • Build ideas • Accessories guide
50 Raspberry Pi Projects
XGO robot dog
PicoTouch Synth
£5.99
11›
9 772051 998001
ComfilePi
WELCOME
WELCOME
to The MagPi 135
R
aspberry Pi 5 is out now! This is a landmark event
for Raspberry Pi as it brings speed parity with
traditional desktop computers.
That you get all that speed and power in a tiny single-
board computer is nothing short of miraculous. And we Lucy
EDITOR
can’t wait to see what you make with it. Our Launch Hattersley
Special starts on page 36. Lucy is editor of
The MagPi and has
We’ve also got 50 Raspberry Pi project ideas starting on been making retro
synthpop in the
page 70. If you’re thinking of something to make with your Welsh countryside
for the last few
shiny new Raspberry Pi 5, this feature is sure to fire some weeks. Ideas for
brain cells. her synthpop
band name on a
We can’t wait to see what you make with Raspberry Pi 5. postcard, please!
magpi.cc
So please remember to share your creations (big or small)
with us using #MagPiMonday on social media. Or, email us
directly: [email protected]. We always love to hear
from you! GET
RASPBERRY
PI 5 FIRST!
Lucy Hattersley Editor Priority Boarding
PAGE 30
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 135 > November 2023
Cover Feature
36 Raspberry Pi 36
Launch Special
Regulars
32 Case Study: Arribada
92 Your Letters
94 Events calendar
97 Next Month
98 The Final Word
Project Showcases
10 Blackberry Pi
14 Drill Press Camera
16 TouchCam 20
20 ScreenDress
22 Instant Framed Camera
26 Gutter Probe
28 PicoSynth
16
TouchCam ScreenDress
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 58 64
50 Using Ubuntu - part 1
54 Introduction to MQTT
58 Make a mecanum robot
64 Build a Bluetooth torch remote
Make a mecanum robot Build a Bluetooth torch remote
The Big Feature
70 83
86
50 Raspberry Pi Projects
Reviews
82 ClipZin
83 CM4 XGO-Lite robot dog kit
84 Learn circuits and electronics
Community
86 Nai-Wen Hsu interview
88 This Month in Raspberry Pi Nai-Wen Hsu interview
1 OF 10 CASES
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
THE WORLD OF RASPBERRY PI
P
encoed is not a big town, having a
population of under 10,000. However, big
things come out of there. It’s where you’ll
find the Sony UK Technology Centre, one part
factory where the vast majority of Raspberry Pis
are made, alongside other products such as Sony
broadcast cameras, and also where Sony supports
tech startups, prototyping, and code clubs.
We were lucky to be given a tour of the facilities
where machines, robot arms, and real people make
250,000 Raspberry Pi computers a week – from
board to box. Have you ever seen a machine put
a little computer in a box? It’s very cute, and
the mechanism to fold the lid is a very simple
Sheets of naked Raspberry Pi 4, ready to be assembled angled piece of metal that runs along the line,
Blackberry Pi
The BlackBerry is back – or at least that’s what David Crookes
thought until he looked more closely at Zhou Xu’s amazing creation
T
here was a time, before Apple and Google Even so, there’s still something rather
entered the fray, when BlackBerry charming about BlackBerry handsets and, for
smartphones were all the rage. They were anyone wanting to do some serious computing
introduced in 1999 and, at their peak in 2011, on-the-go, tapping away on physical keys
attracted more than 85 million users. From remains more comfortable. For those reasons, it’s
that point on, however, it was all downhill as hard not to be enthused about Zhou Xu’s amazing
BlackBerry’s big selling points – the physical project. It allows Linux software to run via a
keyboard and email service – gave way to Raspberry Pi Zero W computer on a 320×240 LCD
Zhou
MAKER
touchscreens and rival alternatives. screen and it’s controllable using a BlackBerry-
Xu style keyboard.
Zhou is an electron
“The idea started from my Game Boy Zero Plus
microscope build that was based on a stripped Raspberry
scientist working at Pi 3A computer,” Zhou explains, referring to a
Monash University
project in which a new Game Boy handheld was
in Australia. He also
describes himself built by inserting a thinned-down Raspberry Pi
as a maker, 3D 3A into an original case. “After completing it,
printing nerd, and I decided that I would then love to make use of
LEGO MOCer.
Raspberry Pi in a handheld format for testing
magpi.cc/bbpi and debugging in the field. But I did not have a
clear plan for the keyboard design until I recently
found the BBQ20KBD from Solder Party.”
Key components
The BBQ20KBD is a QWERTY keyboard and
optical track pad device powered by an RP2040
microcontroller. Identical to the BB Q20 used
in the BlackBerry Classic released in 2014, the
tiny set of keys is placed onto a custom-printed
circuit board and, because it has a USB Type-C
hou gathered all
Z
of the components socket, it’s easy to hook up to Raspberry Pi.
together before
The keyboard gave Zhou’s Blackberry Pi a
considering the
design of the case strong direction. “The design was heavily inspired
10 magpi.cc Blackberry Pi
PROJECT SHOWCASE
> BlackBerry Pi
is designed for
by many other Raspberry Pi handheld projects, potential future
such as Beepy and ClockworkPi,” he adds. There expansion
were some other requirements. “One of the aims
> External devices
for this design was to test an SDR radio antenna
may need an add-
in my backyard. A battery-powered handheld is
on battery pack
so much easier for this job,” he says.
Zhou chose a 2500 mAh LiPo battery, as well as > The STL and STEP
an Adafruit PowerBoost 1000C power supply. He files are at:
also took a GearBest 3.5 composite LCD display magpi.cc/bbpi3D
out of his Game Boy Zero Plus build, and added
a Raspberry Pi Camera Module 2 NoIR. Of all the
components, though, selecting to use a Raspberry
Pi Zero W was the easiest decision.
“I started playing with Raspberry Pi with the
original version so I’m very comfortable tinkering
with the config files and soldering the pins,”
he case was designed in SolidWorks, a 3D CAD
T
package for Windows that dates back to 1995! Zhou says. “Even though many Raspberry Pi
Blackberry Pi magpi.cc 11
PROJECT SHOWCASE
Clever case
A lot of thought went into the case. “I’m pretty
proud to point out that all the GPIO pins are
accessible from the top of the screen and I
12 magpi.cc Blackberry Pi
PROJECT SHOWCASE
Blackberry Pi magpi.cc 13
PROJECT SHOWCASE
E
xperienced at etching PCBs in his garage, crosshairs on its screen are lined up with the
John McNelly found that one of the most centre of the drill bit,” he says. “Once a PCB is
frustrating and time-consuming parts of placed on top of the drilling platform, the user can
fabricating two-sided boards was drilling the see a magnified view of the traces and intended
through-holes. Keen to speed up the process, he drilling location.” Since the position where the
created the Drill Press Camera, a clever piece of drill bit will make a hole is indicated by the
kit that makes his life so much easier. crosshairs on the camera screen, “lining up holes
“I got tired of squinting at a teeny-tiny drill bit with the centre of the drill bit is about as easy as
John
MAKER
A periscope-style section
features an angled mirror to
enable the camera to see the
underside of the platform
Quick FACTS
> John spent around
The LCD camera view
50 hours on
features crosshairs to
the project…
aid precision alignment
of the drill with the hole
> …including
20–30 hours on the
CAD model
TouchCam camera
A love of making shines through in this Raspberry Pi
4-based TouchCam project, finds Rosie Hattersley
M
ukesh Sankhla’s enthusiasm for tech as well as offering on-demand photography and
jumps off the page. His responses to The remote printing. He used Fusion 360 to come up
MagPi’s questions about his TouchCam with his own camera case design, and NextPCB for
camera project are packed with words such as the bespoke printed circuit board. Both the Linux-
‘inspire’, ‘love’ and the absolute joy he’s found based PiCam and the TouchCam have Raspberry Pi
in sharing his roster of makes over the past three 4 at their core and Remote.It and SSH, so the HQ
years. Having completed his studies only a year camera can be triggered from anywhere.
ago, the computer science graduate was quickly
Mukesh
y goal was to
M
MAKER
A sample photo
taken using the skills have developed and was used to showcase
TouchCam triggered his design prowess for his BSc.
remotely
With the TouchCam, Mukesh was keen to design
Raspberry Pi HQ
Camera offers high- a system that is compact and easy to carry and that
quality photography would appeal to multitaskers who enjoy activities
using its 12.3
megapixel Sony such as 3D printing, time-lapse photography,
IMX477 sensor electronics, robotics, programming, and machine
learning. He also thinks the TouchCam could be
used for software development, low-cost personal
servers, and similar uses.
TouchCam tips
TouchCam is an
HQ Camera remote server also gained more evolution of the
prominence. “I chose the Raspberry Pi because PiCam Mukesh
designed and built
it’s affordable, powerful, and has an internet full Assemble the camera case, adding a heatsink
of resources. I am using the Raspberry Pi 4 8GB
02 for Raspberry Pi 4. Follow the instructions at:
variant.” The components were sourced online, magpi.cc/touchcamins.
ScreenDress
We’d definitely say yes to this dress – a stunning creation by Anouk Wipprecht
that is proving to be an eye-opener, as David Crookes discovers
I
t’s fair to say that clothing fashion and quality functional production parts,” Anouk
computing don’t always go hand-in-hand. continues, pointing to the components being light
But bring amazing talent such as Anouk – an important factor when being worn.
Wipprecht on board and all eyes are definitely Behind each of the HyperPixel 2.1 round hi-res
going to be on the wearer – as this striking screens that display the eyes are Raspberry Pi Zero
ScreenDress shows to great effect. 2 W computers. “There are six of them,” Anouk
As well as fitting snugly around the body, says. They take information from the sensor that
the 3D-printed dress includes a set of circular has been analysed in real-time and determine
Anouk
MAKER
LCD screens, each of which looks like an eye. how the animated eyes appear on the screen.
Wipprecht Connected to an EEG sensor – a four-channel BCI
Anouk Wipprecht is
headset developed by neurotechnology company Got the look
a Dutch FashionTech g.tec – they change according to how the wearer To ensure the ScreenDress is in-tune with the
designer and feels by reading brainwaves and working out a wearer’s brain, anyone wearing the clothing,
innovator who works person’s cognitive load. which has the eyes flaring out from a sculpted
and travels between
San Francisco, Los To that end, the screens can show signs of neck-piece, has to undergo a two-minute
Angeles, Miami, stress, fatigue, and frustration. The more a person training session. Machine learning then begins
and Amsterdam. subconsciously feels to understand the
anoukwipprecht.nl their mental load is
increasing, the wider
The 3D-printed dress wearer’s mental
workload so that the
the iris and pupils includes a set of circular eyes work as accurately
dilate. By making as possible.
changes in real- LCD screens “Our fortunes turned
time, Anouk, a Dutch when Raspberry Pi
FashionTech designer, says the dress is able show Zero 2 W, equipped with a quad-core Cortex A53
a direct correlation between a person’s actions processor, was released,” Anouk says. “This
and their brain’s reaction. One thing’s for sure, upgrade significantly enhanced the processing
it’s certainly eye-catching. capabilities [over Raspberry Pi Zero W], allowing
us to manage data seamlessly and achieve the
Dress to impress desired performance.”
ScreenDress was created from scratch. As ScreenDress is certainly cool and it turned a lot
well as the headset – called the Unicorn of heads when it was first put on show at the ARS
Headband – the dress was designed in Onshape Electronica Festival in Linz, Austria in September
(magpi.cc/onshape), a free, cloud-based CAD app. before being presented in Budapest, Hungary and
Anouk said it helped her to understand the look Eindhoven, Netherlands. It has also posed a lot
and feel of the possible embedded LEDs and how of questions.
light reflected back on the body and space around “What does it mean when we can connect
it. “I used various Onshape design capabilities technological-expressive garments to our bodies,
including mixed modelling, generative design, body signals, and even emotions? What dialogues
render studio, and in-context design to reference can we trigger? This is what I am exploring with
hardware elements,” she adds. designs like these,” Anouk explains. It also means
The dress was outputted to an HP Jet Fusion that Raspberry Pi computers can be seen as a
5420W 3D printer using a form of nylon. “This fashion accessory, potentially inspiring many
material is ideal for engineering-grade, white, other makers.
20 magpi.cc ScreenDress
PROJECT SHOWCASE
Quick FACTS
> The dress has been
featured around
the world
> A prototype is
displayed at the
Museum voor Beeld
& Geluid
ScreenDress magpi.cc 21
PROJECT SHOWCASE
Instant Framed
Camera
A little tinkering has given this classic camera a
second shot. Nicola King focuses on the facts
A
broken Polaroid Land Camera may, for
some people, not prove particularly
inspiring. However, Max van Leeuwen’s
grandfather had given him the antiquated object,
and Max was determined to give it a new impetus.
“I really wanted to hide a Raspberry Pi in there
and bring this vintage object back to life in some
way,” he tells us. “I loved the idea of adding some
Max van
MAKER
A flash of inspiration
Using a Raspberry Pi Camera Module 3, a couple
of Raspberry Pi 3 Model A+ boards, and some
Python code, along with the other required
bits of hardware, Max has essentially created a
camera within a camera here, as a digital camera
is hidden within the body of the original shell.
“When the camera’s button is pressed, it makes a
hidden digital camera take a picture,” he explains.
“This picture is sent to a server, for the display
frame to show.”
Interestingly, Max decided that he wanted the
picture to then be deleted from the camera itself
and, once the frame has downloaded this picture
to display it, it is deleted from its storage as well.
aspberry Pi is
R “I really like the idea of having only one copy of
equipped with a
Waveshare Li-ion the picture baked into the e-ink display. It makes
Battery HAT, enabling
the picture feel important, and it fits with the
a 14500 battery to be
recharged via USB-C essence of Polaroid photos,” declares Max. When
Quick FACTS
> The hardware cost
a new picture is taken, the old one disappears Max around €200
from the frame.
> The parts list
The e-paper display module was a key
is in the GitHub
inspiration to Max to make the photo frame: “I
repo: magpi.cc/
really like the look of a display that doesn’t emit instantcamgh
any light, so it’s more like an e-book instead of a
screen. It’s really fun to see the individual dots on > This was one of
it; it looks just like a real print.” When he found Max’s very first
a type of e-paper that could do colours, there was Raspberry Pi
no stopping him. “The slow drawing speed of the projects
e-paper module (~1 minute) fits with the idea of
mimicking developing film, which was a happy > Although time-
consuming,
accident,” he enthuses.
he thinks it’s
Max was determined that the camera should
straightforward…
send pictures to a server, instead of directly to the
other device, so that it works “even if both devices > “Anyone with an
are on opposite sides of the planet.” Deciding affinity for coding
against using a SIM card in the camera and frame, can pick this up and
ax considered using a Pico in the camera, but eventually opted
M
he instead opted for Wi-Fi, and the camera simply for a Raspberry Pi 3A+ for its extra RAM improve it!”
omprising another
C connects to Wi-Fi networks by taking a picture of real camera’s button trigger a signal necessitated
Raspberry Pi 3A+ and
e-paper display, the
a QR code. some good old-fashioned trial and error. “I ended
digital photo frame up using a metal spring with aluminium foil on it,
downloads each
image from the server Shooting the snags and the ends touch when the button is pressed to
Max found that the physical build was the hardest make a closed circuit.”
element of the project, and many hours of work
went into the venture. “At first, I only made little
steps at a time for a couple hours a week but, once
I really like the idea of
it started taking shape, I dedicated a few days to having only one copy of
it to make some real progress,” he reveals. Most
of his time went into the physical photo frame the picture baked into the
and the camera body. “Breaking the camera
open on the inside without breaking it on the e-ink display
outside was a bit of a tedious task. And the photo
frame needed a wooden shape on the back to fit Finally, deciding on power options for the
the computer and wires, so that became a little camera demanded some further head-scratching
arts‑and-crafts-session.” – “I ended up using a battery HAT that works for
Max’s father was on hand to help him with the about an hour on this setup and can be recharged
woodwork for the frame, but “I was scared I’d with USB-C.” The end-product was well worth
break the camera when drilling a hole through the the labour and troubleshooting required en route,
top for an LED light,” he shares. Also, making the however. As long as there is Wi-Fi available, “the
No negatives here
Understandably, many people have enjoyed
reading about Max’s camerawork.“There were
a lot of positive reactions online! I really loved
reading them. All the individual steps to making
this project are nothing new, but bringing them
together into this simple idea is what people
seemed to appreciate the most.”
Significantly, he has had messages from a
number of people who are keen to replicate
his endeavours using similar vintage cameras.
Protected by a Perspex cover, the Camera
Describing this as “super-cool”, Max is very keen 01 Module is connected to a Raspberry Pi 3A+
that people make their own variations and, indeed,
inside the Polaroid camera body, powered by a
improvements to the project. “One possible Li‑ion Battery HAT.
variation someone told me about was to make
multiple photo frames and connect them to the ax handcrafted a
M
wooden back for the photo
same camera, so you can update a whole group at
frame to fit in Raspberry Pi
once! That could be fun.” and the wiring
Gutter Probe
Trying to discover the cause of a blockage, Peter Anderton invented an ingenious
solution that resulted in a twist ending. Rob Zwetsloot listens to the tale
R
aspberry Pi is used for a lot of things – rainwater would just overflow. He didn’t want
some more surprising than others. When to hire expensive equipment to confirm this
Peter Anderton emailed us about a very theory, though.
unique use of Raspberry Pi to solve a conundrum, “I then had the bright idea of mounting a
we decided we had to share it in the magazine. Raspberry Pi Camera on the end of a long pole to
“My wife and I had noticed that, whenever get a view of the plant itself,” Peter mentions.
it rained hard, we were getting a serious “The sticking-point here was how to connect the
overspill from one of our house gutters onto camera to Raspberry Pi whilst still being at the
Peter
MAKER
our conservatory,” Peter says in his email. far end of the pole. At first, I considered having
Anderton
“Unhelpfully, the overspill appeared to originate Raspberry Pi and camera both mounted at the far
A civil engineer with from an inner-corner joint of the gutter, over end, but this would have required much longer
a background in 15 feet up and directly over the conservatory, so power and display cables than I had available; the
computer science virtually impossible to reach without scaffolding obvious alternative was just to have the camera at
who eventually
became a software or a cherry-picker, either of which would be the far end of the pole but, at the time, I only had
developer before extremely expensive if it turned out there were to hand the short ribbon cable that came with the
semi-retiring, and no alternatives. We first thought the cause might camera, and had no idea whether longer cables
now does a lot of
just be a leaky joint, but one day we spotted were even available. However, after discovering
making and puzzle-
solving for fun. a suspicious growth poking out above the that cables up to 2 m in length existed - thank
gutter itself.” you, The Pi Hut! - I had at least solved the
With a bit of deductive reasoning, Peter figured connectivity issue.”
out that the plant was blocking the joint, so the
Printed solution
Peter turned to Fusion 360 to design and then
3D-print a mount that would allow the Camera
Module to slot inside a bike lamp bracket, which
was then mounted to a pole. After taking a peek,
Peter found the true culprit – a plant growing in a
big clump of soil.
“I now had a much clearer idea of what exactly
we were dealing with, but there was still the
matter of how to get the offending plant out,”
Peter continues. “It was unlikely any cherry-
picker would be able to fit through either of our
side gates to reach the rear of the house where
this gutter was, so it would have to operate from
the adjacent road, with all the safety and other
implications that would entail. However, to go
The original mount used to take a peek at the gutter down the scaffolding route would be equally
A tw0-metre-long camera
cable was used to extend
the camera down the pole
viewing generally
Quick FACTS
problematic, not least because it would have to
bridge over the conservatory to get to the gutter in > The project was
the corner, with no obvious way to support it.” printed in PLA after
For one small plant, this was a bit overkill. initial tests in ABS
However, he did have a pole that could reach
> The WOLF-Garten
the plant, so he began Phase 2 of the operation:
tool was originally
attaching a trowel. He already had a WOLF-Garten
used to scrape a
system that he’d 3D-printed parts for, so he made
corrugated roof...
a further extension to fit the trowel on.
> …and Peter had to
Remote gardening print a different
After digging up a bit of the soil, the plant was scraper so it would
removed and the gutter stoppage fixed. It worked fit properly
so well, it’s inspired him to do more.
“I would be the first to admit that I produce > Apart from the
extra-long camera
more things using my 3D printer than I do using a
cable, everything
Raspberry Pi,” Peter says. “However, the success
used was stuff
of this venture has opened my eyes (no pun
From a previous project, this Peter had
intended!) to the potential for remote-viewing
trowel worked perfectly to
generally using Raspberry Pi / camera combination > The original
scoop out the offending plant
and, to this end, I have bought a second 2 m camera used was
camera cable and connector, as well as a new a Raspberry Pi
Raspberry Pi Camera Module 3.” Camera Module V1
PicoSynth
One maker has turned PicoTouch capacitive board into a wave synthesiser.
Lucy Hattersley channels her inner Kraftwerk
T
od Kurt is a maker with a love of There is also a PicoTouch Slidercase that is “a
musical synths and his latest creation is simple 3D-printable protective enclosure for the
PicoSynth, a MIDI synthesizer based on the PicoTouch USB MIDI / HID controller board.”
PicoTouch board. “The result is still very thin and helps prevent
PicoTouch is a thin capacitive touch platform, false triggers or bad calibration if touching the
and Tod’s software turns Raspberry Pi Pico into a back on power up,” explains Tod. You print it in
MIDI synthesizer that he can use to play sounds two pieces, and no supports are required. Snap the
directly, or connect to another computer to control top piece around the PicoTouch board, then slide
Tod
MAKER
audio software (magpi.cc/picotouch). the combo into the bottom piece. A third ‘picocap’
Kurt
The PicoTouch CapSense MIDI keyboard is a piece can be printed and glued to the top piece to
Tod is a maker slim plastic board with 22 touch pads and 19 RGB protect the Pico.
from Pasadena CA. LEDs. “It’s one of the thinnest MIDI controllers The PicoTouch Synth software is installed
He runs ThingM, at about 6 millimetres when Raspberry Pi Pico is on Pico as a ready-made U2F file (magpi.cc/
is co-founder of
CrashSpaceLA installed,” says Tod. picosynthgit). The source code is also available.
hackerspace. The ten pads on the bottom are note triggers
mastodon. for the C major scale, while the two pads on the MIDI sound
social/@todbot right shift the octave up and down. The top row Once up and running, PicoSynth is powered by
of pads controls wave and filter functions. Finally, a USB-C socket on the right, and to the left sit
three ‘patch select’ buttons on the right move three 3.5 mm audio jack connections that provide
between different waveforms. You can pick the audio out, MIDI in, and MIDI out. The device can
board up from Tindie for $11, although it will need be connected directly via USB-C to a computer
a Raspberry Pi Pico soldering inside. running audio software, such as Ableton. You can
“It’s not too bad!” says Tod. “It’s a pretty also use Reaper if you want something that works
easy first-time, surface-mount device natively on Raspberry Pi
soldering project.” Tod has created a video
showing how to solder Pico to the board
(magpi.cc/picotouchsolder).
28 magpi.cc PicoSynth
PROJECT SHOWCASE
Quick FACTS
> Tod needed a MIDI
The sound is generated by controller for his
Raspberry Pi Pico which also acts as computer
a MIDI connection when connected
to a MIDI device or computer > It’s hackable,
cheap, and thin
MIDI to my computer “It’s currently running CircuitPython and > The board costs
talking MIDI to my computer which is running just $11
Ableton Live so it can do monophonic and
polyphonic stuff; you can even play drums with it
if you want to,” says Tod.
“It’s a lot of fun!”
PicoTouch can
be used for other
The PicoTouch bare board is available on Tindie projects as well as
if you want to recreate this project at home creating PicoSynth
PicoSynth magpi.cc 29
SUBSCRIPTION
SUBSCRIBE TODAY
FOR JUST £10
Get 3 issues + FREE Pico W
Subscriber Benefits
FREE Delivery
Get it fast and for FREE
Exclusive Offers
Great gifts, offers, and discounts
Great Savings
Save up to 23% compared to stores
30 magpi.cc
SUBSCRIPTION
magpi.cc 31
SUCCESS STORY
Arribada
technology for
conservation
Raspberry Pi is key to Arribada’s wildlife monitoring projects
By Rosie Hattersley
THE SOLUTION
A Raspberry Pi Zero and a Raspberry Pi Camera
Module were enclosed in a lightweight, waterproof
enclosure. This could be attached, harmlessly, to
the shell of a sea turtle, to track its journey under
the waves. The device captures photos, video, and
location data.
“Once the video has been recorded, the tag is
released from the shell of the turtle and is then
recovered from the water’s surface two weeks
later. This lets us capture behaviour footage of both longest-established conservation charities, was keen
female and male turtles,” Davies explains. to explore the use of LoRa radio communications to
A challenge for turtle monitoring is that GPS monitor fishing activity.
location tags are only effective when the creature The boat-based LoRaWAN gateway that
surfaces, which is often for less than two seconds. Arribada set up can provide a detailed overview
Waking up the monitoring devices to get a of local fishing activity, and report any potential
triangulation fix is not instantaneous, so Arribada encroachment on the five critical turtle breeding
developed its own Horizon Assisted-GPS tag as a sites around the country’s coast. Cypriot mobile
key part of its Raspberry Pi Zero-based kit.
The kit means that turtles’ behaviour, as well as
their locations, can be discerned. The first turtle The Penguin Watch camera units survived
tags were developed when AI and machine learning
were in their infancy, but, Davies says, we’re in three Antarctic winters before the Arribada
a very different space now. “You can imagine
the benefit of running AI models on Raspberry team made a maintenance visit
Pi devices for the sea turtle: we can wake up [the
device], capture a scene, process that scene, we phone regulations, requiring SIM cards to be
can even [get the device to] make some intelligent registered after four months, made using them
decisions to say, is this worth recording? Is it worth for cellular communications troublesome, hence
going back to sleep, or should I stay on?” the LoRaWAN setup using a Raspberry Pi 4 with a
In addition to making decisions about continuing Raspberry Pi Power-over-Ethernet HAT. This setup
to monitor a site, perhaps going into a sleep cycle also meant there was no cost to the boat owners
and awakening again an hour later to see what’s for having a tracking system on-board. An antenna
changed, using Raspberry Pi offers machine learning on an eight-metre pole offered a clear view of any
advantages. “We can pull the models off, sit there fishing vessels in a 15 km radius, providing a robust
and go through and train them a little bit more, and visible monitoring system.
tweak and review the video content. We can do
it all at very little cost, because [Raspberry Pi] is WHY RASPBERRY PI?
so affordable.” Raspberry Pi has become a keystone to almost all
It’s an approach that has begun to mark out of Arribada’s projects. Davies explains that it has
Arribada as a sophisticated research partner, with always been one of the tools he uses “because
conservation organisations showing “a real interest it is so accessible and affordable for anyone to
in what Edge ML is going to do. We still use it get involved. You are always partnering with a
on the Raspberry Pi. We don’t just use it with researcher or a local community member who works
sea turtles.” with an NGO and has a specific challenge. We get
Some initiatives need bespoke solutions. This called in to solve it with technology. They’ll always
was the case in Cyprus where the Society for the say it has to be affordable, it has to be repairable
Protection of Turtles (SPoT), one of the country’s and accessible.”
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
LAUNCH
SPECIAL! It’s here! Here are some ideas for the
latest and greatest Raspberry Pi
Configuration
You need to install Samba onto Raspberry
Pi OS, usually done with:
03 The magic of the NAS box is in the Samba
configuration file – it’s like writing a spell to
sudo apt install samba samba-common-bin open up the shared storage to the network.
Here’s one example, and there’s another in the
We like to use NTFS for the shared drive so that screenshot above, but tweak it to your own needs:
other operating systems can use it easily, so we
install that with: [share]
Comment = Network share
sudo apt install ntfs-3g Path = /mnt/location
Browseable = yes
Writeable = yes
only guest = no
Storage setup
02 Usually we use an external hard drive,
create mask = 0777
directory mask = 0777
but using the SSD drive will be very similar – Public = yes
plug it in, make sure it’s formatted, and then Guest ok = yes
mount it to Raspberry Pi OS. It will do this
automagically when you plug it in once booted,
but to automount it on boot (there is a difference)
you’ll need to edit the fstab file with sudo nano
/etc/fstab and add a line like:
RAID NAS
PJ Evans shows you a way to create a
/dev/sdb1 /mnt/location ntfs nls-utf8,umask- home file server with redundancies over at
0222,uid-1000,gid-1000,rw 0 0 magpi.cc/raidnas.
Timing
ith the ability to add two cameras to
one Raspberry Pi 5, it’s never been
02 The trick to getting the perfect shot is
easier to create 3D video or take 3D timing the cameras. In a previous tutorial by
photos with Raspberry Pi. It can take some regular PJ Evans, he linked up to Raspberry Pi
tweaking to get it right, but here’s how you can Zero with cameras attached and had them shoot
get started. images at the same time. This was done with
some smart Python code, and you can look at how
he did it here: magpi.cc/make3dcam.
Editing video
together will be
VR or movie necessary
01 There are two distinct ways for doing
Stitching
3D filming – the kind you see in movies with
two slightly overlapping frames that 3D glasses
03 The images or
selectively view to make the flat image on the video, once created,
screen have depth, and the VR version which need to be stitched
either has two distorted images that a headset can together. For video,
render as a scene in front of you in high quality, we suggest giving each
or a slightly lower-quality 360° scene all around one a look on video
you. The latter uses two cameras with wide-angle editing software to
lenses opposite each other, while the former use make sure they line
two cameras facing forwards, and can be a bit up properly. PJ, in
easier. Also, with the lack of 3D TVs these days, his tutorial, created
we’ll be looking at using a VR headset. a way for images to
be put together for
3D (find the code at
magpi.cc/3dcameragit).
However, you can also do it in video editors like
Adobe Premiere.
3D video now
The POPCAM is a 360-degree 3D camera kit that
uses Raspberry Pi CM4 – it’s not out quite yet,
but we’ve been using a pre-release model and
it’s very good. If you’d like to skip the DIY, find out
more at magpi.cc/popcamera.
A previous version of 3D photography with Raspberry Pi
RRY PI
BE
RASP
A RTER
T
ETTY
S DE
I S P R
P B E R RY PI OLLOW
I N G U P RAS RD. JUST F SLEY
SETT HTFORWA IE HATTER
U I
STRAIG VICE OF ROS
G
THE AD
USB mouse
A tethered mouse that physically attaches to
your Raspberry Pi via a USB port is simplest and,
unlike a Bluetooth version, is less likely to get
lost just when you need it. Like the keyboard,
we think it’s best to perform the setup with a
wired mouse. Raspberry Pi sells an Official Mouse
8GB microSD card (magpi.cc/mouse).
You’ll need a microSD card with a capacity of
8GB or greater. Your Raspberry Pi uses it to store
games, programs, and boot the operating system.
Many Raspberry Pi computer kits come with a card Power supply
pre-written with Raspberry Pi OS. If you want to Raspberry Pi 5, 4 and 400 need
reuse an old card, you'll need a card reader: either a USB Type-C power supply.
USB or a microSD to full-sized SD (pictured). Raspberry Pi sells power supplies
(magpi.cc/usbcpower), which
provide a reliable source of power.
Raspberry Pi 1, 2, 3, and Zero models
Windows/Linux PC or Mac computer need a micro USB power supply
You’ll need a computer to write Raspberry Pi OS (magpi.cc/universalpower).
to the microSD card. It doesn’t matter what
operating system this computer
runs, because it’s just
for installing the OS Display and HDMI cable
using the Raspberry Pi A standard PC monitor is ideal, as
Imager app. the screen will be large enough
to read comfortably. It needs
to have an HDMI connection,
as that’s what’s fitted on your
Raspberry Pi board. Raspberry
Pi 5, 4 and 400 can power two
HDMI displays, but require a
micro-HDMI to HDMI cable.
Raspberry Pi 3B+ and 3A+
USB keyboard both use regular HDMI cables;
Like any computer, you need a means to enter web Raspberry Pi Zero W needs a mini-HDMI
addresses, type commands, and otherwise control to HDMI cable (or adapter).
Raspberry Pi. The Raspberry Pi 400 comes with
its own keyboard. Raspberry Pi sells an official
Keyboard and Hub (magpi.cc/keyboard) for
other models. USB hub
Raspberry Pi Zero and Model A boards
have a single USB socket. To attach a
keyboard and mouse (and other items),
you should get a four-port USB hub
(or use the official USB Keyboard
and Hub which includes three ports).
Instead of standard-size USB ports,
Raspberry Pi Zero has a micro USB port
(and usually comes with a micro USB to
USB-A adapter).
RRY PI
ASPBE
UP R
SET 02 Connect a mouse
Connect a USB wired mouse to one of the
other larger USB-A sockets on Raspberry Pi. As
with the keyboard, it is possible to use a Bluetooth
Raspberry Pi 5 / 4 / 3B+ / 3 has
wireless mouse, but setup is much easier with a
plenty of connections, making it wired connection.
easy to set up
PI 400
BERRY
P RASP
SET U 02 Attach the micro-HDMI cable
Next, connect a micro-HDMI cable to one of
the micro-HDMI sockets on the rear of Raspberry
Pi 400. The one next to the microSD card slot is
the first one, but either connection should work.
Connect the other end of the HDMI cable to an
Raspberry Pi 400 has its own HDMI monitor or television.
keyboard – all you need to connect
is the mouse and power
The microSD
03 If you purchased a Raspberry Pi 400
Connect a mouse
01 Connect a wired USB mouse to the white
Personal Computer Kit, the microSD card will come
with Raspberry Pi OS pre-installed. All you need
USB connection on the rear of Raspberry Pi to do is connect the power and follow the welcome
400. The two blue USB 3.0 connectors are faster instructions. If you do not have a Raspberry Pi OS
and best reserved for external drives and other pre-installed microSD card, follow the instructions
equipment that need the speed. later in ‘Set up the software’.
I ZERO
ERRY P
RASPB
SET UP
Mouse and keyboard
02 You can either connect your mouse to a
USB socket on your keyboard (if one is available),
You'll need a couple of adapters to then connect the keyboard to the micro USB
set up Raspberry Pi Zero / Zero 2 W socket (via the micro USB to USB-A adapter).
Or, you can attach a USB hub to the micro USB
to USB-A adapter.
Get it connected
01 If you’re setting up a smaller Raspberry
Pi Zero, you’ll need to use a micro USB to USB-A
More connections
adapter cable to connect the keyboard to the
smaller connection on the board. Raspberry Pi
03 Now connect your full-sized HDMI cable
Zero models only have a single micro USB port for to the mini-HDMI to HDMI adapter, and plug the
connecting devices, which means you'll need to adapter into the mini-HDMI port in the middle of
either get a small USB hub or use an all-in-one your Raspberry Pi Zero. Connect the other end of
mouse and keyboard. the HDMI cable to an HDMI monitor or television.
SE T UP
TWARE
HE S OF
T
Use Imager to install Raspberry Pi
OS on your microSD card and start
your Raspberry Pi
Top Tip
Choose OS Advanced
02 Click on ‘Choose OS’ in Raspberry Pi Imager options
N
ow you’ve got all the pieces together, it’s and select the recommended Raspberry Pi OS. Click
time to install an operating system on ‘Choose SD card’ and select the microSD card you Click the cog
your Raspberry Pi so you can start using just inserted (it should say 8GB or the size of the to customise
it. Raspberry Pi OS is the official software for card next to it). Click on ‘Write’. Your computer will Raspberry Pi OS
Raspberry Pi, and the easiest way to set it up on take a few minutes to download the Raspberry Pi with options
your Raspberry Pi is to use Raspberry Pi Imager. OS files, copy them to the microSD card, and verify such as Wi-Fi
See the ‘You’ll Need’ box and get your kit together. that the data has been copied correctly. passwords and
usernames.
You’ll Need
> A Windows/Linux
PC or Apple Mac
computer
Set up Raspberry Pi
03 When Raspberry Pi Imager has finished
> A microSD card
(8GB or larger)
Download Imager
01 Raspberry Pi Imager is available for
verifying the software, you will get a notification
window. Remove the microSD card and put it in your
> A microSD to
USB adapter (or
Windows, Mac, and Linux computers. You can also Raspberry Pi. Plug in your Raspberry Pi power supply a microSD to
SD adapter and
install it on Raspberry Pi computers, to make more and, after a few seconds, a blue screen will appear SD card slot on
microSD cards once you are up-and-running. with ‘Resizing Filesystem’. It will quickly vanish and your computer)
Open a web browser on your computer and visit be replaced by ‘Welcome to Raspberry Pi’. Click on
> Raspberry Pi Imager
magpi.cc/imager. Once installed, open Imager and Next and follow the on-screen instructions to set up magpi.cc/imager
plug your microSD card into your computer. Raspberry Pi OS and start using your new computer.
Using Ubuntu
Part 01
on Raspberry Pi
Enjoy a new Raspberry Pi desktop experience by installing Ubuntu Linux
W
hile the official Raspberry Pi OS is
an excellent, easy-to-use operating
system tailored for Raspberry Pi
computers, there are numerous alternatives
you can use instead – see our feature in issue
111 (magpi.cc/111). The most popular among
these is Ubuntu, based on Debian Linux (just like
Raspberry Pi OS).
Phil King
MAKER
Ubuntu is to use the official • Activities: This option (top left) brings up an
overview of current open windows.
Raspberry Pi Imager tool • Show Apps: Clicking this icon (bottom left)
shows all the installed apps. Top Tip
• Home: Double-clicking this icon (bottom
Final configuration Mount a
04 Following the reboot, you’ll see the Ubuntu
right) takes you to your home folder in the
Files browser. USB drive
user selection screen with the username you • Taskbar: At the top right you’ll find Wi-Fi,
selected. Click on it; if you opted to require the audio, and power icons; click to see their When you insert
a USB flash drive,
password to log in, you’ll need to enter it. settings. Or click the time to view a mini
it’s automatically
Finally, the full Ubuntu desktop appears. A calendar, along with any upcoming events on it. detected and
window offers you the option to connect to your its icon appears
online accounts – Google, Nextcloud, and/or in the Dash –
Microsoft – but you can skip this for now and do remember to
Launch an app right-click and
it later in the Settings. You’re also asked whether
to send system info to Canonical, and turn location
06 After clicking the Show Apps icon at the
Eject before
physically
services on. It then gives you a preview of some of bottom left, you’ll see a grid of icons for installed removing it.
the apps you can use in Ubuntu. apps and other tools. Clicking the right-hand
The Activities
Keyboard shortcuts
overview offers an
easy way to switch
arrow takes you to a second screen for more apps.
In addition, there’s a search option at the top; just
08 Here are just a few of the many handy
between windows
and workspaces start typing and relevant app icons will appear. keyboard shortcuts you can use in Ubuntu. Note
To launch an app, the Shotwell image organiser that SUPER is typically the Windows key, or
for instance, just click on its icon. It will open in Raspberry Pi logo key on Raspberry Pi 400.
a new window on the desktop, and its icon will
appear in the Dash sidebar. To keep it in the Dash • SUPER – Activities overview
as a favourite, right-click the icon and select Pin • SUPER+A – Show Apps
to Dash (to remove, right-click and Unpin). • SUPER+↑ – full-screen window
• SUPER+↓ – revert to standard window size
y default, there are two
B • SUPER+← – move window to left side
• SUPER+→ – move window to right side
desktop workspaces which • SUPER+TAB – switch between apps
• ALT+ESC – switch between windows in
you can switch between current workspace
• SUPER+ALT+←/→ – switch between workspaces
Activities overview
Top Tip 07 Naturally, you can run several apps at
same time. The easiest way to see them all, and
Shut down Install more apps
switch between them, is to click Activities (top
left) to open an overview of all the open windows.
09 While there are several ways of installing
To shut down the
Just click on one to select it. You can also search new software in Ubuntu (which we’ll explore next
system safely,
click the top-right for open apps. time), the easiest is to use Software Centre – akin
taskbar icons, You’ll also notice that, by default, there are two to an app store. Click on the Ubuntu Software icon
then the power desktop workspaces which you can switch between (briefcase) in the Dash sidebar to launch it.
icon and select – very handy to avoid clutter when multitasking. In the Explore tab, you’ll see a range of app
Power Down. In Activities, you can drag and drop an app categories including Education, Games, and
There are also
window from one workspace to another; an extra Productivity; clicking one shows the relevant apps.
options to Restart
or Log Out. empty workspace will then be created, so you can (The other tabs show installed apps and available
have as many as you like! updates.) Alternatively, click the search icon (top
left) and start typing the name of the app you Software & Updates). It will then check for
would like to install. firmware and software updates. You then have the
Clicking an app icon brings up its details option of installing them now or later. If you get a
screen, including user reviews (at the bottom) and message about Software Updater not responding,
whether it’s by a known developer. Click on Install click Wait. Enter your password to authenticate
and enter your password to download and install and install updates. It may take a while (so go and
it. Once done, its icon will appear on the Show make a cup of tea). Finally, click Restart Now (or
Apps screen. To uninstall an app, open its details Later) to finish installing the updates.
in Ubuntu Software, click the Installed button, and
select Uninstall. Taking it further
Next time, we’ll cover more advanced Ubuntu
aspects such as using the command line,
enabling SSH and VNC, installing media codecs, Viewing an app’s
details in the
Change settings
10 There are several ways to reach the Settings
using the GPIO pins, installing software from
other sources, and switching to a different
Ubuntu Software
Centre; just click
Install to download
screen: by searching for it in Activities or Show desktop environment. and install it
Apps, or by clicking the icons at the top right of
the taskbar and then the gear icon.
There are numerous settings categories,
including Appearance, Desktop, Notifications,
Multitasking, Apps (individual app settings),
Power, Displays, and Printers.
In the Appearance section, for instance, you
can switch to dark mode and/or select a different
backdrop for the desktop – from the selection or
by importing your own appropriately sized image.
System update
11 From the Show Apps screen, launch
Software Updater (not to be confused with
An introduction
to MQTT
Communication between your devices.
By Tim Richardson
terminal subscribes to
Richardson the queue ‘MyHouse/
garage/temperature’
Tim has been
involved with
Raspberry Pi’s
community almost
from the start. He is
part of the Pi Wars
organising team
and their resident
course designer/
builder, as well as
writing the CamJam
EduKit worksheets,
former CamJam
organiser and
L
current maker. earn how to send messages between MQTT works on a publish/subscribe basis.
@Geeky_Tim Raspberry Pi computers, Raspberry Pi Pico, That means a device can either publish (or send)
and lots of other devices using a simple messages or can subscribe to (or listen for)
protocol called MQTT. messages. In between the devices is what is known
MQTT (Message Queuing Telemetry Transport) as an MQTT ‘message broker’. This is software that
was originally created back in 1999 to be a runs on a server that receives published messages
lightweight way of passing small messages and sends them out to subscribers. The broker is
between devices on unreliable or low-bandwidth also lightweight, so any Raspberry Pi computer can
networks. Its main use is for machine-to-machine run the MQTT broker software.
communication, or for the Internet of Things. To explain that with a real-life example,
Being lightweight means that it can be used by imagine you have a BME280 sensor connected to
small, resource-constrained microcontrollers, like a Raspberry Pi Pico measuring the temperature,
Raspberry Pi Pico. That does not mean its use is pressure and humidity within your garage or
limited, though. There are plenty of ways you can garden cabin. You are going to want to see what
use it within a home network, across the internet is being measured without going out to the garage
or even on a small cluster of devices that need or cabin or having to log into it remotely to get
to talk to each other. Its use is only limited by readings. You can program Pico as an MQTT client
your imagination. which will publish the measurements within
On topic
MQTT clients publish to and subscribe to topics,
which are a hierarchy similar to the folder
structure on your computer. Think of the top level
as being the home folder on your Raspberry Pi,
/home. Underneath /home are the user folders,
like /home/pi. And under that are various folders
belonging to the user, like the Documents or
Downloads folders, /home/pi/Documents or
/home/pi/Downloads. The only difference with
MQTT is that there is no ‘/’ at the beginning of the don’t need to understand any complex structures Figure 1: An example
MQTT network
top-level topic. to be able to use MQTT. You just need to decide
Let’s call our top-level topic MyHouse. what text you want to send (publish) and be able to
Subtopics are added using a ‘/’ at the end of the interpret it on the other end (subscribe).
top-level topic followed by the subtopic name.
For example, MyHouse/garage. You might want Using MQTT
to go down one more topic level and have a topic MQTT is a well-defined and supported protocol. As
for the temperature only; e.g. MyHouse/garage/ such, there are plenty of broker implementations,
temperature. This helps you to organise your both commercial as well as open-source. MQTT
MQTT into, say, rooms of the house, types of device clients can be written in many languages, such as
(e.g. switch, light), what is being measured (e.g. C, Python, C# or Rust. Lots of tools and software
also support MQTT, like Node-RED and OctoPrint
Figure 2: An
example topic
structure
started via systemd. To check that the server is • The -t option identifies the topic you want
running, use systemctl: to subscribe to. In this case, it is MyHouse/
garage/temperature.
sudo systemctl status mosquitto
The test client will sit there and wait for a
If it is not running for any reason, the service message to be sent on the topic. Leave it running
can be restarted using: and open a second terminal window and type in
the following command to send a message on the
sudo systemctl restart mosquitto chosen topic:
mqtt_publish.py DOWNLOAD
THE FULL CODE:
The program mqtt_publish.py is the minimal > Language: Python 3 magpi.cc/mqttgit
code you can write to send MQTT messages. Type
it in and run it. You should see the number ‘13.2’ 001. # An Introduction to MQTT, by Tim Richardson
appear in the subscriber terminal window you left 002.
running earlier. 003. # Import the paho-mqtt client library.
The first line of code imports the client section 004. import paho.mqtt.client as mqtt
of the paho-mqtt library. 005.
The second creates a client object. ‘Sender’ is the 006. # Create an MQTT Client – the client ID must be unique
client identification, and must be unique for your 007. client = mqtt.Client("Sender")
broker as it is used to identify that client amongst 008.
all the others that may connect. 009. # Connect the client
The third line connects the client to the broker. 010. client.connect("localhost")
As we are running this code on the same Raspberry 011.
Pi as the broker, we are using ‘localhost’. 012. # Publish a message to the MyHouse/garage/temperature topic
The last line of code publishes a message with 013. client.publish("MyHouse/garage/temperature", "13.2")
the topic MyHouse/garage/temperature. Any
client that has subscribed to that topic will receive
that message.
mqtt_subscribe.py DOWNLOAD
Subscribing THE FULL CODE:
The mqtt_subscribe.py program starts out the
same as mqtt_publish.py by creating a client > Language: Python 3 magpi.cc/mqttgit
(with a unique identifier) and connecting it to
the broker.
However, there is now a ‘callback’ function 001. # An Introduction to MQTT, by Tim Richardson
named message_received. The client.on_message 002.
line tells the client object which function to call 003. # Import the paho-mqtt client library.
when a message is received on any topics that the 004. import paho.mqtt.client as mqtt
client subscribes to. 005. from time import sleep
The client.subscribe line subscribes the client 006.
to a topic. You can subscribe to as many topics 007. # A function to handle any messages received
as you want to, handling the message within the 008. def message_received(client, userdata, message):
client.subscribe callback function 009. print("Message received on topic:", message.topic)
Finally, the subscription loop is started, telling 010. print("Message contents:", message.payload.decode("utf-8"))
the client object to start listening for messages. 011.
The program then goes into a forever loop (or until 012. # Create an MQTT Client – the client ID must be unique
you stop it). 013. client = mqtt.Client("Recipient")
Open a new terminal window and run the 014.
program. In the original window (or IDE) run the 015. # Connect the client
mqtt_publish.py program. You should now see 016. client.connect("localhost")
the subscriber report that it has received a message 017.
on the topic MyHouse/garage/temperature with 018. # Define the 'callback' function when a message is received.
its value. 019. client.on_message = message_received
020.
Conclusion 021. # Subscribe to a topic
In this tutorial we have only just scratched 022. client.subscribe("MyHouse/garage/temperature")
the surface of MQTT, but hopefully you now 023.
understand what it is and how simple it is to 024. # Start listening for a message on the subscribed topics
use. Areas not covered include securing MQTT, 025. client.loop_start()
formatting messages, ensuring that messages are 026.
received, using MQTT in Node-RED, and more. 027. print("Waiting for a message to be sent")
If you need to send information around your 028.
network, then MQTT should be included within 029. # Wait forever
your armoury of go-to tools. 030. while True:
031. sleep(1)
Raspberry Pi
Part 09
mecanum robot
Create a robot which can go forwards, backwards, sideways,
diagonally, and turn on the spot. The mecanum wheels allow
the robot to navigate the tightest of spaces
T
ake your Raspberry Pi on the move by This is achieved by having rollers angled around
Stewart
MAKER
designing and making a wheeled robot This the wheel. The rollers of diagonally opposite
Watkiss tutorial will explain how you can design and wheels need to be in the same direction. Turning
make your own robot. Start by designing your the wheels in a certain combination will determine
Also known as
Penguin Tutor. own chassis and mount mecanum wheels with the direction. This is easiest to understand
Maker and YouTuber full direction control. The robot will then need through watching the video on YouTube:
that loves all things
four separate motors individually controlled with magpi.cc/mecanumrobotyt.
Raspberry Pi and
Pico. Author of a H-bridge driver for each wheel. Take control
Learn Electronics by learning how to use AntiMicroX to control the
with Raspberry Pi. robot with a gamepad.
penguintutor.com Creating a chassis
twitter.com/
02 For any kind of vehicle, you will need a
stewartwatkiss chassis to mount the motors and electronics. You
Mecanum wheels
01 Mecanum wheels are a type of
can use any method you choose. The base should
be thin enough to accommodate the size of the
omnidirectional wheel which can be used to move wheels, but otherwise most materials can be used.
a robot vehicle in multiple directions. They are You could use plywood, acrylic sheet, or even
particularly good at getting into tight spaces as thick cardboard.
Figure 1: Robot the wheels can propel the robot forwards and If you have access to a 3D printer then you can
chassis design
created in FreeCAD. backwards as normal, but can then also move design your own 3D-printed chassis, or use the
Includes four motor
diagonally or sideways without any forward or one available at magpi.cc/robotmecanum. This is
brackets which are
printed separately backwards movement. shown in Figure 1.
You will need some way of fixing the motors.
Brackets are included in the 3D printer files, or you
can purchase suitable brackets which are included
in the component list.
Raspberry Pi Zero W
03 Whilst any model of Raspberry Pi can be
used, a Raspberry Pi Zero W or a Raspberry Pi Zero
2 W are well-suited for a robot vehicle. They are
small, making them easier to fit on a mobile robot,
and they also have lower power requirements
than some of the other models. The wireless
capability is useful when programming the robot
and for getting the controller working. A micro- you can normally use a single power supply for
USB to USB adapter is needed for connecting the both your Raspberry Pi and the motors.
controller. A shim adapter is also recommended. The different options are a 6 V power supply You’ll Need
(4 × AA batteries) or a USB power bank. The
breadboard layout shows both options. Raspberry >2
× TB6612FNG
Pi is powered through GPIO 2 using a diode which motor drivers
magpi.cc/
Powering the robot
04 The motors are designed for 6 V, whereas a
protects against reverse voltage and drops the
voltage slightly. If using the USB power bank and
TB6612FNG
Raspberry Pi needs a 5 V power supply. In practice, the voltage is too low, then the diode bypassed >M
ecanum wheels
magpi.cc/
if required. In either case, power must NOT be
mecanumwheels
connected to your Raspberry Pi power input socket
when powered through the GPIO. >4
× geared motors
magpi.cc/
gearmotor
>M
otor brackets
magpi.cc/
H-bridge motor controller
05 To allow the motors to go both forwards
motorbracket
Figure 4: Schematic
diagram which makes it
easier to see which pins
are connected. Labels
are used to avoid the
confusion where wires
cross each other
Figure 5: A wireless
USB gamepad. This
is detected by Linux
as an Xbox 360
controller
you to map each of the buttons to the relevant reconnecting the USB dongle after AntiMicroX is
keys, and this is illustrated in Figure 6. running. Then, choosing Update Joysticks from
You can map each button on the gamepad, or the menu.
import the suggested layout which is included in
the GitHub repository.
Future upgrades
12 The robot can be controlled using a game
Troubleshooting
11 The gamepad must be recognised by
controller, or using a keyboard.
With some extra electronics and code, the
Linux to work with AntiMicroX. Some controllers robot can do more. There are holes included in
appear to work consistently, whereas others need the front of the chassis which can be used to add
reconnecting once or twice before they will work an ultrasonic distance sensor to detect and avoid
with AntiMicroX. nearby objects. Or, you could add a line sensor
If the gamepad doesn’t work after a reboot, to allow your robot to follow a line drawn along
then you may need to try disconnecting and the floor.
DOWNLOAD
mecanum1.py THE FULL CODE:
> Language: Python 3 magpi.cc/mecanumpy
001. import sys, tty, termios 028. '4' : (-1, 1, 1, -1), # Left
002. from gpiozero import PWMOutputDevice, Motor 029. '5' : (0, 0, 0, 0), # Stop
003. 030. '6' : (1, -1, -1, 1), # Right
004. motors = [ 031. '7' : (0, 1, 1, 0), # Diagonal left
005. Motor(2, 3, pwm=False), #Front left 032. '8' : (1, 1, 1, 1), # Forwards
006. Motor(22, 23, pwm=False), # Front right 033. '9' : (1, 0, 0, 1) # Diagonal right
007. Motor(14, 15, pwm=False), # Rear left 034. }
008. Motor(24, 25, pwm=False) # Rear right 035.
009. ] 036. current_direction = "stop"
010. pwm_out = PWMOutputDevice (18) 037. # speed is as a percentage (ie. 100 = top speed)
011. 038. speed = 50
012. # get a character from the command line 039. pwm_out.value = speed/100
013. def getch() : 040.
014. fd = sys.stdin.fileno() 041. print ("Robot control - use number keys to
015. old_settings = termios.tcgetattr(fd) control direction")
016. try: 042. while True:
017. tty.setraw(sys.stdin.fileno()) 043. # Get next key pressed
018. ch = sys.stdin.read(1) 044. ch = getch()
019. finally: 045. if (ch == 'q') : # Quit
020. termios.tcsetattr( 046. break
fd, termios.TCSADRAIN, old_settings) 047. elif (ch in direction.keys()) : # Change
021. return ch direction
022. 048. for i in range (0, 4):
023. # list to convert key into motor on/off values to 049. if direction[ch][i] == -1:
correspond with direction 050. motors[i].backward()
024. direction = { 051. elif direction[ch][i] == 1:
025. # number keys 052. motors[i].forward()
026. '1' : (-1, 1, -1, 1), # Turn left 053. else:
027. '2' : (-1, -1, -1, -1), # Backwards 054. motors[i].stop()
028. '3' : (1, -1, 1, -1), # Turn right 055. print ("Direction "+ch)
SAVE UP
TO
ISSUE #72
hsmag.cc
TUTORIAL
Build a Bluetooth
remote for a flashlight
Make a remote Bluetooth remote control for the
Pico-powered flashlight using MicroPython
R
ecently, the author created a GitHub site for this project at this link:
remote-controlled light based on hsmag.cc/Bluetooth_Flashlight.
an old camera flash he found for
sale on a market stall. The light NO NEED TO PAIR
contains a Raspberry Pi Pico W The Wi-Fi-controlled flashlight is configured with
programmed in CircuitPython that network credentials, and the user must visit a
acts as a web server on a local network. The colour specific web address to connect to the flashlight
Rob Miles
of the light is controlled via the web page hosted controller page. The Bluetooth light and remote
@robmiles by the light. The Pico W also supports Bluetooth, control use a Bluetooth addressing scheme in
and so in this project, a new version of the light which there is no need to explicitly pair two devices
Rob Miles has been is created which is controlled by a second Pico that wish to communicate. There is no need to
playing with hardware
W-powered device sending Bluetooth commands. configure either the light or the control. However,
and software since
almost before there was Continuing the upcycling theme of the previous if you wanted to use multiple lights with a single
hardware and software. article, this one uses an upcycled milkshake box as controller in the same room, things get a little
You can find out more
about his so-called life at a case for the controller (Figure 1). You can find all trickier. You will need to use a different Bluetooth
robmiles.com. the software for the light and the controller on the addressing scheme if you want to enable multiple
Far Left
Figure 1. The
light output has
been reduced for
the purpose of
photography.
Figure 2
The remote control
works well with
only three alkaline
batteries, as the power
requirements of the
device are not high
sender.update()
time.sleep_ms(20)
connections. However, if you just want to send data The statements above create a BLE_sender instance
from one device to another over short distances, and feed it a ColourControls instance that reads the
the method described here works very well, and it control inputs. It then repeatedly calls the update
is easy to change the type and amount of method in the sender, which reads colour values
data sent. from the control. The ColourControls class reads the
control inputs. The code for the class is shown below.
CREATING A REMOTE CONTROL
Figure 2 shows the circuit diagram for the device. class ColourControls:
The three potentiometers are connected to the def __init__(self):
YOU’LL NEED
analogue-to-digital converter (ADC) inputs on the self.red_ADC = machine.ADC(0)
Pico. The input from the ADC is scaled to produce self.green_ADC = machine.ADC(1) A suitable box
(you can put
intensity values in the range 0–255. These values are self.blue_ADC = machine.ADC(2) the control into
sent via Bluetooth to the light. self.old_red=-1 anything you fancy)
self.old_green=-1 A Raspberry Pi
SENDING VALUES WITH CLASS self.old_blue=-1 Pico W (remember
The Pico W in the remote control runs a self.update() to get the 'W'
version as this has
MicroPython program called ble_sender.py, which Wi-Fi and Bluetooth
repeatedly reads the ADC devices connected to the def update(self): capability)
red, green, and blue potentiometers and sends a self.red = round(self.red_ADC.read_
3 × linear
block of data containing the colour intensity values. u16()/256) 10 K rotary
If the user adjusts one of the colour settings the self.green = round(self.green_ADC.read_ potentiometers
updated value is sent out over Bluetooth to the u16()/256) Other resistance
values will work as
light. The ble_sender program uses a class called self.blue = round(self.blue_ADC.read_ well. Make sure you
BLE_sender. This is supplied with an instance of u16()/256) get potentiometers,
not rotary encoders.
the ColourControls class which interacts with if self.red==self.old_red and self.
The potentiometers
the potentiometers: green==self.old_green\ will have only
and self.blue==self.old_blue: three connections,
whereas a rotary
def run(): return False encoder will
print("Light sender starting") self.old_red=self.red have four
controls = ColourControls() self.old_green=self.green
A single pole
sender = BLE_sender(controls) self.old_blue=self.blue single throw
while True: return True power switch
”
inside ColourControls Examples.
class. The class stores
previous values of red, You don’t need to know how RECEIVING LOUD
green, and blue readings AND CLEAR
the BLE_sender class works
and update returns True Figure 3 shows the
to send different kinds of
”
if it detects the inputs Pico from the flashlight
have changed. The pack information using it being reprogrammed.
method returns the byte The Pico was loaded
values to be sent to with MicroPython, as
the light. It packs the red, green, and blue intensity the original Wi-Fi-controlled light uses CircuitPython.
values into three bytes. The BLE_sender class calls Below, you can see the MicroPython code that
update and then calls pack if update returns True. runs when the light starts running. The Pico W in
the controller acts as a server, serving out red,
TWO CLASSES ARE BETTER THAN ONE green, and blue intensity values which can be
You may be wondering why two classes are used, used to set the intensity of a light. The program
when it would be perfectly possible for a single ble_reciever.py runs in the light to receive these
class to do everything. This is to provide flexibility. values. It uses a class called BLE_receiver to receive
If you want to send values from a different device data from the controller and use the data to set the
Below
The control is set (for example you might want to send values colour of the light.
to around halfway. from a distance sensor) you can create your own
You can tell this
because the little version of the ColourControls class (perhaps called def run():
plastic finger over the print("Light Receiver Starting")
wiper is connected
pixieLight = PixieLight(0.2)
to the centre of
the circular track POTENTIOMETERS receiver = BLE_receiver(pixieLight)
connecting the outer
two contacts AND ROTARY ENCODERS while(True):
receiver.update()
There are two types of twiddly knobs you can
use with microcontrollers: potentiometers time.sleep_ms(50)
and rotary encoders. The former, which
we've used here, create a changing The run function above implements the receiver
voltage as they’re turned. This voltage behaviour. It creates a BLE_receiver instance called
can be read by an analogue input. receiver. The receiver is given the device to control,
They're easy to use and hold a
in this case, an instance of the PixieLight class.
physical memory of their position (i.e.
if you power off the project, they will Once the receiver has been created the run function
read the same value when you power repeatedly calls the update function of receiver. The
it back on). However, they can only be update function creates a connection to a transmitter
turned a fixed amount. Rotary encoders and then fetches blocks of data from Bluetooth
emit a series of pulses as they’re turned, which are then passed onto the pixieLight.
often with a soft click as they do. You can
keep on turning them forever in either
direction and they’ll keep on pulsing. from machine import Pin,UART
They’re great for user interfaces (scroll from Pixie import Pixie
wheels are one type of rotary encoder). import time
import struct
class PixieLight:
def render(self):
self.pixies.fill((self.red,self.green,self.
blue))
def set_colours(self,red,green,blue):
if red==self.old_red and green==self.old_
green\
and blue==self.old_blue:
return False
self.red = red
self.green = green
self.blue = blue
self.old_red=self.red
self.old_green=self.green
self.old_blue=self.blue
self.render()
return True
def dump(self):
print("Red:%3d Green:%3d Blue:%3d"%(self. aware of the content of the data they are transferring.
red,self.green,self.blue)) They just move blocks of binary data from one place Figure 3
If the light output
to another over Bluetooth. The form and meaning is not set very
bright, the light
The PixieLight class is shown above. The receiver of the data is determined by a ’contract’ between software can be
will get blocks of data from Bluetooth and pass the ColourControls and the PixieLight classes. The tested using just
a USB connection
them to pixieLight by calling the unpack method. pack method in ColourControls assembles a block of for the power
The unpack method is supplied with a block of data three bytes which contains the red, green, and blue
which must be unpacked and then used to set a new intensity values selected by the user. The unpack
light colour. It sets the colours of the light and, if the method in PixieLight then takes these three values
colours have changed, it prints the new values to from an incoming block and uses them to control the
the terminal. colour intensities in the lights it is driving.
Both the classes need to agree on the encoding
TAKING OUT A CONTRACT (8-bit values) and the order (red, green, blue) of the
The BLE_reciever and BLE_sender classes are not values. Any misunderstandings will result in wrong,
CIRCUITPYTHON VS MICROPYTHON
The code to control the original light was written using CircuitPython. However, at the
time of writing, there are no Pico W Bluetooth libraries available for CircuitPython.
Bluetooth connections are presently only supported by MicroPython. CircuitPython
and MicroPython are very similar; they differ mainly in the availability of different
libraries for specific devices. If you are serious about becoming an experienced Figure 5
embedded developer, you should aim to be familiar with both implementations. The When drilling the holes for the controls, start
with a small hole and then drill it out to fit.
author originally chose CircuitPython because of the availability of a library for the This makes it much easier to correct any
Pixie lamp he was using. However, he was able to convert this library to MicroPython mistakes with the initial hole position. It also
and then use MicroPython for this project. produces a nicer finish to the hole
Each time update is called, it gets the current time and purchased for this project. The author really likes
then works out how many milliseconds have elapsed strawberry milkshake.
since update was last called. If the interval is greater Figure 5 shows the controls fitted to the top of
than update_tick_interval, the render function is the milkshake box. The switch was pushed through
called to display the lights and keep the Pixie shining. the top of the box and then connected to the Pico
and the battery. The Pico and battery holder were
FINAL ASSEMBLY then secured to the inside of the box using adhesive
Figure 4 shows the wiring for the light controller. It Velcro. The resulting box looks quite pleasing (at least
Below
was first built on the desk and tested before being to the author), and the device inside works well. Only a good idea
transferred to the case. The power is controlled by It would be possible (and indeed quite easy) to if your device
doesn’t use radio
a push-button which is connected in series with the use the same technique to create other Bluetooth- communications
battery box. Once the circuit had been tested, it was connected devices.
then ready to be put inside the case, which was a
box of milkshake which was in no way specially
BOXING CLEVER
The author likes the idea of upcycling, where a project
reimagines an existing product. The controller for the light
is fitted inside a box that previously contained milkshake
powder. Here are some tips for upcycling.
• Use longish connecting wires. The author used • Use heat-shrink tubing to cover connections
to take great pride in how all his wires between and make sure that connections have physical
components were exactly the right length. This, integrity. If you are soldering a wire to a terminal,
while aesthetically pleasing, did tend to make make sure to hook the wire through a hole to give
fitting the components into the box much harder the connection physical strength, and then use
and more likely to cause damage. Longer wires solder to hold the wire in place and provide the
give a lot more leeway in case construction and electrical connection. Then cover the whole
can be safely tucked inside the case. thing with heat-shrink tubing. This makes
everything look a lot tidier and means that loose
• Don’t always twist all the connecting wires wires won’t cause problems. This is particularly
together to make a wiring harness. This sounds important if you are using a metal case, as it
counter-intuitive, but it does make sense (at least prevents signals shorting.
to the author). If you have ten wires going to a
component, you could twist them all together to • Use connectors with components that fit into
make a single cable. However, because all the the case from the outside. Some components,
wires will be different lengths, this means that the for example, some switches and lights, are fitted
weight of all the wires may end up being borne from the outside of the case and then secured
by the shortest cable connection, which will internally. In the light control, the push-button
then break. If all the wires are separated, each power switch is fitted into the case from the This tutorial is from
connection will only have to support the weight outside, and so it is connected using push-fit HackSpace magazine.
of one wire. If you really do want to group cables connectors rather than being connected directly. Each issue includes a
together, make sure they are supported inside huge variety of maker
the case. • Don’t stick components into your case using projects inside and
a permanent adhesive. The author is a big fan outside of the sphere
• Construct and test your circuit outside the case. of self-adhesive Velcro, which can be used to of Raspberry Pi, and
It is very hard to check connections once you hold processors and batteries in place. The also has amazing
have put them in a box. Create the entire circuit components are held firmly, but they can be tutorials. Find out
and test it first. Then put it in the box. removed if required. more at hsmag.cc.
2
NB100 Cyberdeck
magpi.cc/nb100
3
Upcycling old tech using
Raspberry Pi is marvellous fun, as
RetroPie gaming 6 Fancy Octopus Arcades
this repurposing of an Amstrad
magpi.cc/octopusarcades
A4 notepad with a split keyboard retropie.org.uk
and 8.8-inch widescreen display New Yorker Shonee Strother’s
RetroPie provides a simple,
shows. Retaining nothing but amazing custom-built RetroPie
software-based way of getting to
the 1980s case, it’s now a fully arcades are co-designed by his
enjoy old favourites on any version
functioning Cyberdeck computer six-year-old son and packed with
of Raspberry Pi you choose, with
with 2020s processing chops. incredible detail.
or without a classic console case.
Half the fun is repurposing an old
console or customising a biscuit
tin to house your brand-new
gaming device.
9
musical tastes. The Display-O-Tron
LED screen will even show news Team Pinball
headlines – or you can have them
magpi.cc/teampinball
read aloud.
Pinball wizardry has also been fascinating,
for the intricate table designs as much as
the flipper-based play. Wales is home to the
UK’s only pinball factory, where it’s a labour of
Raspberry Pi CM3-based love for its designer-
maker team. Their retro game, The Mafia, “brings
the player back to Chicago and the 1930s
Prohibition Era with gangsters, casinos, and of
course, a bank to rob!”
10 Retro gaming
Mini PC
magpi.cc/minipc
11 is marvellous fun
”
a Bluetooth speaker. Seeing its
resemblance to a small desktop Unity 3D
computer, owner Carter made magpi.cc/unityintro
the vision a reality with the aid
of Raspberry Pi 3B, a BlackBerry With guidance on how to
keyboard, and some 3D printing. It create characters and your
runs Raspberry Pi OS and could be own 3D adventure game,
replicated using Raspberry Pi Zero. Unity 3D offers lots of
Raspberry Pi-based coding
fun and an alternative to
the better-known Python,
C, and Scratch. Kids will
respond to the bright
visuals and the chance to
create their own worlds,
collecting experience
badges along the way.
13 15
EPIC Satellite
14 Astro Pi Challenge
magpi.cc/epicsatellite astropi.org
NASA shares daily photos from its Mini Mars Rover While on the International Space Station,
Deep Space Climate Observatory astronauts undertake experiments on Raspberry
magpi.cc/minimarsrover
including its EPIC (Earth Pi computers devised by dozens of groups as
Polychromatic Imaging Camera) Lightweight but durable materials part of the annual Astro Pi challenge. Read about
which is trained on the sunlit and a simple design that others teenagers’ attempts to measure variations in the
side of the Earth. This gorgeous can easily replicate were the strength of magnetic north, climate change in
project by Matt Gray shows off principles behind this wonderful inaccessible locations, and much more.
these visual treats wonderfully on Pico W-based Mars rover, inspired
Young people aged 19 and under can enter
a HyperPixel Round Touch Display, by a workshop at Belgium’s
Astro Pi and Mars Mission between now and
having pulled them into view CubeSat Summer School. Maker
the end of the year. Entry packs will be sent out
using NASA’s Blue Marble API and Nikodem designed everything in
to schools, code clubs and groups of friends,
Raspberry Pi Zero W. CAD himself, then 3D-printed it
regardless of where in the world you live.
and set up the MicroPython code
to control his mini marvel.
Credit: ESA/NASA
17 RockyBorg
magpi.cc/rockyborg
18
PiBorg’s RockyBorg is an enduring
favourite at Raspberry Pi Towers. K-9
The three-wheeler corners
magpi.cc/k9
like a dream and is capable of
magnificent speeds. Two 180 rpm True Whovians will approve of the fact that maker/tinkerer
motors on the rear provide forward Fitz used whatever he had to hand when creating The Doctor’s
momentum, while a servo tilts famous companion and adapting the schematic shared by
the robot’s body of the robot to other fans: magpi.cc/k9pdf. K-9 features various mechanisms
change direction. This £99 kit to defend himself, but also uses AI to sense friends nearby – at
just needs a Raspberry Pi and HQ which point, the camera in his head takes a quick snap that K-9
Camera to complete. prints out through his mouth and presents to his new buddy.
Microsoft’s annoying
Windows assistant
gets a seemingly
20 Love Machine & Olga
magpi.cc/lovemachine
sentient makeover
with this Raspberry Pi 3B+ character that uses Among the most endearing Raspberry Pi
Adafruit’s Cricket HAT to connect up various servos, projects we’ve covered recently are two by Will
motors and solenoids to create a chirpy Clippy who Lahrs and his creative team at Kakapo Labs.
chats back. First, they designed the smooth-talking Love
Machine which uses AI and ChatGPT to connect
with passers-by and engage them in flattering
WhatsApp banter. They then went on to create
Olga The Fortune Teller who shares much of the
Photography
original project’s Pico W-enabled interaction and
prints out fortunes on a Zebra thermal printer.
22
Good photographs need good lighting as well
as an interesting subject and framing. This Pico-
based light meter, coded by our friends at Veeb.ch,
using MicroPython helps you get the balance right.
Digital Toy
Camera 23 Instant 24 POP 360-Degree
magpi.cc/digitaltoycam
Photo Printer Camera
magpi.cc/cameraprojects magpi.cc/popcamera
Despite declaring digital sensors
“a pain,” maker Volzo designed You can easily print out your best A virtual reality
a camera that uses the 5 MP snaps using a thermal printer housed camera in a Flip video
Raspberry Pi Camera Module in a cardboard box. Use any Raspberry camera-sized form, this CM4-
V1 lens and Raspberry Pi Zero Pi and add based VR videocam is impressively
to capture Lomographic photos large push- straightforward to use. Although the
that are far more interesting, and buttons to visuals are blockier than we’d like,
quirky, than those you get with a initiate the it’s another example of Raspberry Pi
boringly efficient smartphone. print process. pushing technological barriers.
“
according to the soundscape. You
can conduct your own experiments You can conduct
using Raspberry Pi, an HQ Camera,
and some simple garden tools your own
by following Bugg founder
experiments
”
Sarab’s instructions (linked above).
Give your houseplants some loving The Sense HAT is capable of all kinds of computing capers, but
care without having to bother your lends itself especially well to projects where you want to be able
neighbours or kids to keep an eye to get the gist of something without really trying. Lorna Jane’s
on them. Simple moisture sensors Night Clock Sense HAT coloured grid shows you whether it’s
either sprinkle your plants – or not – night or day, so you can immediately decide whether to get up.
Sensing & Monitoring
39 NeoPixel Stairlights
magpi.cc/neopixelstairs
Robot maker Kevin McAleer kitted out his beloved dogs with
light-up jackets using NeoPixels, then headed to Blackpool for a
celebratory promenade. This innovative dog coat is not just about
style; it’s about ensuring the safety of his pets during night-time
walks. Kevin’s creation uses a Raspberry Pi to control the LED
patterns, making the coat functional and fashionable.
41 Wearable Tech 44
magpi.cc/wearabletech
42 Mona Lisa
chic that wearing a beret conveys create
43
an instant classic.
Fluid Painting
magpi.cc/monalisafluid
The ‘Make sound with Pico’ article is well worth a look if you need
some ideas of what you might make. Included alongside the DIY Trill
guitar (magpi.cc/trillguitar) is the Lo-Fi Orchestra, in which multiple
instruments controlled by Arduino and Raspberry Pi boards feature.
46 PaperPi V3
magpi.cc/paperv3
47 PicoStepSeq
magpi.cc/picostepseq
”
mean feat it can easily be customised with
info feeds, as well as blending in
wonderfully with your décor. Follow
48
PJ Evans’s tutorial to create your own
The Lost magic mirror your own way. This LCD
50
We really like the low-tech approach
to this project in which bird silhouettes Bristol Braille Canute 360
emit their corresponding bird sound
magpi.cc/bristolbraille
when the electrical circuit is complete.
The Raspberry Pi-based project only Extending the possibilities of Braille
costs a few pounds to replicate, and is literacy for blind and partially sighted
perfect for getting citizen scientists to users is no mean feat: community
notice their surroundings and show off interest organisation Bristol Braille took
their findings. eight years and a dozen iterations to
bring the world’s first multi-line Braille
reader into being. This Raspberry Pi
Zero-based device and its Raspberry Pi
400-based sibling, the Canute Console,
hugely extend reading options and
digital library access.
ClipZin
EDAC magpi.cc/clipzin £4 (pack of two)
A
imed mainly at breakout/carrier board a design or want to later replace a standard Pico
SPECS manufacturers, along with advanced board with a Pico W.
electronics hobbyists, ClipZin is a new way
FEATURES: to connect a Raspberry Pi Pico to a PCB. Clip in, clip out
Gold flash-
Ever wondered why Pico has those castellated In practice, we found it extremely easy to clip a
plated
contacts, (bumpy) edges alongside the two strips of 20 GPIO Pico onto a sample PCB fitted with a pair of surface
surface-mount pin holes? You can use these castellations – actually mounted, 20-way ClipZin connectors. Just push
connectors, gold-plated half-holes – instead of the usual pins Pico down and it clicks securely into place, held
board retention to connect Pico to other electronics. This kind by individual springy pins that maintain a good
clips
of card-edge technology has long been used in
DIMENSIONS: computer design.
57 × 26 × 6 mm While you could always just solder Pico’s J ust push Pico down and it
castellations directly onto metal contact pads
on the surface of another PCB, ClipZin has the
clicks securely into place
advantage of being able to clip the board in and out
at any point – ideal for when you’re prototyping connection with each castellation. Small plastic
retention clips on either end also help to keep it
in place.
Removing Pico from the ClipZin connectors is as
simple as gently pulling one of the retention clips
and lifting the board out.
While a little more expensive than the alternative
Pico clicks neatly and of using FlexyPins (magpi.cc/flexypins), ClipZin
securely into place
connectors benefit from being all-in-one (coming
between two 20-way
ClipZin connectors in 6-, 8-, 17-, and 20-way versions), making them
far less fiddly to solder onto a PCB.
Verdict
with Pico’s castellations
Should prove
handy for Pico-
based PCB
prototyping and
could also be
used in
final products.
8 /10
82 magpi.cc ClipZin
REVIEW
CM4 XGO-Lite
Robot Dog Kit
Elecfreaks magpi.cc/cm4xgo £469 / $599
SPECS
A Compute Module 4-powered robot dog with five limbs and
a huge amount of potential. Rob Zwetsloot takes it for a walk
SIZE:
W
250 mm × 145 mm
× 170 mm while e’ve seen a small explosion of dog- It’s definitely a very well put together product,
standing, 620g like robot kits over the past few years, although it’s not the most stable looking
LIMBS: although we cannot put a finger on robot we’ve ever seen. The price is also a little
Four walking what might have started it. Perhaps the cuteness eyewatering, but we think the tech inside justifies
limbs and one of a four-legged pet is hard to resist when you can it, especially if you’re looking for a more advanced
gripper allowing program it yourself, which brings us to the very bit of kit.
for 15 degrees of
movement, and
powerful XGO line of robot kits.
three on the arm Unlike a lot of a robot kits, this one has metal
construction throughout, making it chunky and
T here are several bits
PROGRAMMING
LANGUAGES:
weighty in the satisfying way quality technology of example code that
can be. It also comes all pre-assembled so you
Blockly, Python,
ROS won’t be bending any metal plates or doing any illustrate the impressive
complicated wiring to get it working, like with
BATTERY: other legged robots. features of the robot, such
2500 mAh lithium
ion battery with
120 minute life Smart dog as facial recognition
At its core is a powerful
Compute Module 4,
controlling the robot The box comes with
some coloured balls
and allowing for
that you can program
reprogramming with XGO to pick up
custom code over a web
Verdict browser – although you
can also plug it into a monitor (or go a
A very impressive VNC route) if you want and program it
robot kit that the old-fashioned way. There are several
while fine for
bits of example code that illustrate the
beginners may be
impressive features of the robot, such as
better suited to
those already into facial recognition with the inbuilt camera,
robotics due to remote control, and more. There’s a full
the price breakdown of the Python commands on
9
the quite detailed documentation over at
magpi.cc/xgodocs, and it even has a block
/10
code editor for people not quite up to speed
on Python.
Learn circuits
with Raspberry Pi
Start building electronic circuits with the help
of these resources. By Phil King
CamJam EduKit
CamJam Raspberry Pi’s 40-pin GPIO started: a 400-point breadboard,
AUTHOR
Get kitted out Start building circuits with these electronics kits
out a circuit design before you Raspberry Pi Pico among other user and programming guide
Price: go ahead and build it, which is microcontrollers and there’s a that includes several chapters
Free where a circuit simulator comes variety of examples and shared dedicated to connecting
wokwi.com in handy. There are several user projects to try out, along electronics such as LEDs, push-
available online, but Wokwi is with starter templates for Pico. buttons, and sensors.
In the Simulation window on magpi.cc/rpicookbook4
the right, you can add all sorts
of electronic components –
including sensors and motors/ GET STARTED WITH
servos – and wire them up MICROPYTHON ON
(with or without a breadboard) RASPBERRY PI PICO
to Pico’s pins. The left-hand This official Raspberry Pi Pico
window is used to code your guide book features step-by-
project, in MicroPython or step guides on building a range
C/C++; just run it to see if it of circuits and programming
works correctly. If so, you can them in MicroPython on the
download the project code to use powerful microcontroller board.
on Pico for real. magpi.cc/picobook
Nai-Wen Hsu
Taiwanese Raspberry Pi reseller and Raspberry Pi community
organiser, you can’t miss Nai-Wen in the Taiwanese maker space
W
hile the Raspberry Pi Raspberry Pi educational Since coming into contact with
community spreads courses,” Nai-Wen tells us. Arduino in 2009, I have been
across the globe, each using MCU and SBC combined
country has its own unique What is your history with mechanical structures to
community with its own with making? solve problems in small projects.
events and ideas. Taiwan is I studied manufacturing
no different, with the founder technology and computer When and where did you learn
of the Taiwan Raspberry Pi engineering in college and about Raspberry Pi?
Community also an Approved graduate school respectively, In July 2012, I was looking for
Reseller of Raspberry Pi. so I am familiar with program a small computer for a power-
Excellent projects are “My job is to promote and sell development and processing of saving project and bought a
shown off at the meetups
Raspberry Pi, provide Raspberry various materials such as metal, Raspberry Pi 1 Model B. The
– we wonder if this one
can beat captcha Pi-based solutions, and design wood, and acrylic. first one was 256MB. The goal
of the project, at that time, was
to monitor the flow of people
and adjust the air-conditioning
settings according to the people
present to achieve energy saving.
ThermalPi is used
around Taiwan to check
temperatures of people
so COVID can be detected
MagPi
Monday
01
E
very Monday we ask the question: have you
made something with a Raspberry Pi over
the weekend. Every Monday, our followers
send us amazing photos and videos of the things
they’ve made.
Here’s a selection of some of the awesome
things we got sent this month. Remember to follow
along at the hashtag #MagPiMonday!
01.
Raspberry Pi 5 robotics has begun and it’s
not even out yet
02.
A robot-heavy month, we love to see all
these automatons
03.
A very cool robot, it reminds us of the one
in Jedi Survivor
04. Raspberry Pi Pico is still a great controller
for robots
05. If you’re getting interrupted during video
calls, a little notifier can be a lifesaver
06. A camera that specifically reads QR
codes is a great idea – perhaps an NFC 02
alternative?
07. We’re calling this a rave in the box. Who
has a Ministry of Sound CD?
08. Do, Re, Egon, let’s light ‘em up
03
04
05
06
07
08
Events in pictures:
Experiencing Raspberry Pi 5
at the Melbourne Raspberry Pi
Makers Meetup
Community and official events in the wild
W
e showed some images from the
Melbourne Meetup last month but, 01
this time, the meetup was a bit
more special, allowing people to experience
Raspberry Pi 5 before it was even out! You can
find out other events with a Raspberry Pi 5 on
our events calendar over on page 94.
01.
There were still room for other projects,
like this Raspberry Pi Zero robot
02.
Free swag of excellent magazines
always goes down well
03.
It’s a Raspberry Pi 5 in the wild!
04.
This robot is not powered by Raspberry
Pi 5 in the traditional sense
02 03
04
90 magpi.cc Mondays
Coolest
This Month
Projects
are
infor
Raspberry
Pico
online! Pi
THIS MONTH IN RASPBERRY PI
magpi.cc 91
YOUR LETTERS
Your
Letters
Raspberry Pi 5 projects
I’m very excited by the news of Raspberry Pi 5 coming
out, and really looking forward to getting mine. My
mind is abuzz with ideas but I was wondering if you’d
be able to propose any projects that make use of the
new features?
FREE
for The MagPi subscribers
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…
FULL CALENDAR
Get a full list of upcoming
community events here:
magpi.cc/events
01
02
04
03
RASPBERRY PI
AT MAKER FAIRE
Where can you find
Raspberry Pi next?
> Next location Maker Faire Shenzhen
> Where Vanke Design Commune, Shenzhen, China
> When Saturday 11 November to Sunday 12 November
R
aspberry Pi is proud to partner
with Raspberry Pi Approved
Reseller Seeed Studio, to be at
Maker Faire Shenzhen for the first
time ever. Come and meet members of
the Raspberry Pi team, learn about their
latest products, and share what you’ve
made with Raspberry Pi technology.
magpi.cc/smf23
EDITORIAL
Editor
Lucy Hattersley
[email protected]
Features Editor
Rob Zwetsloot
[email protected]
Sub Editor
Nicola King
THERMAL TESTING
+44 (0)7725 368887
DESIGN
criticalmedia.co.uk
Head of Design
Take Raspberry Pi to its full potential with Lee Allen
CONTRIBUTORS
David Crookes, Rosie Hattersley,
Nicola King, Phil King,
Rob Miles, Tim Richardson,
Stewart Watkiss
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,
Crawley, West Sussex, RH10 9PE
DON’T MISS OUT! magpi.cc/subscribe from sustainable forests and the printer
operates an environmental management
system which has been assessed as
conforming to ISO 14001.
Holiday buyer’s MASTODON magpi.cc/mastodon The MagPi magazine is published by
Raspberry Pi Ltd, Maurice Wilkes Building,
guide St. John’s Innovation Park, Cowley Road,
Cambridge, CB4 0DS. The publisher,
THREADS @themagpimag editor, and contributors accept no
Raspberry Pi OS
responsibility in respect of any omissions
or errors relating to goods, products, or
FACEBOOK magpi.cc/facebook services referred to or advertised in the
Number 5 is alive!
Now what will we all make with it?
By Lucy Hattersley
W
atching Raspberry Pi along the lines of the PlayStation and Over to you!
5 come to life was an GameCube era. Cloud Gaming from That’s just the start! What we’re
incredible process. From Games Pass is also an incredible really looking forward to is what you
hearing about the initial designs, experience (and a whole lot cheaper all make with Raspberry Pi 5. Our
to seeing the problem-solving, and than buying an Xbox Series X). readers always surprise us with the
hearing clever solutions proposed We’re also busy looking at the dual incredible things they make with
by the incredible design team. camera support and stereographic Raspberry Pi products. Whether it’s
On our part, there was the stress photography for 3D images. And, live-action RGB lighting in a pole
of making sure everything was ready dancing club, automatic weeding
for launch. And the fear of being the achine learning is
M machines for Japanese gardens, retro
one to accidentally leak it and ruin equipment repairs, or monitoring
the surprise for everyone. It’s been a another area where animals in the wild: the uses for
real eye-opener. Raspberry Pi are wildly varied.
It’s not really real until this point we’re very keen to I was reminded of this while
though. When it launches and gets
into the hands of our readers, and
see what advantages reading through our Handbook 2024
(available now: magpi.cc/handbook).
they start to build stuff with it:
that’s when Raspberry Pi 5 becomes
the new, much faster This collects all the best community
projects, tutorials, and kits from
a real product. CPU offers the last year. It’s a tour-de-force
So, what are we all to do with of the best The MagPi readership
this super-fast, packed-with- we’ve mooted the idea of using two has to offer - which is an incredible
new-features, and ringing and small screens for creating a virtual amount of variety and cleverness.
singing full of bells-and-whistles reality option (although this is very I really can’t wait to see what you
new computer? much in the ideas stage). all make with Raspberry Pi 5. Here’s
Machine learning is another area to 2024, and another year of
Where to start? where we’re very keen to see what Raspberry Pi-goodness.
Like many new Raspberry Pi 5 advantages the new, much faster
owners, my first port of call was CPU offers. We’re waiting on an
Raspberry Pi OS Bookworm (magpi. update to TensorFlow Lite to get
cc/downloads). This is now available things working, and are going to be Lucy Hattersley
AUTHOR
for download and offers a vast all over image recognition projects.
Lucy is editor of The MagPi and is
increase in speed. I’ve also been We’re also waiting on the M.2
currently putting this issue to press with
testing out the advances in retro drive, at which point we will be an 8BitDo controller in her inbox, which
gaming (expect a big feature on this turning Raspberry Pi 5 into a server. is ready and waiting for a Raspberry Pi 5
soon). Early reports suggest a big So, there’s lots to talk about in the retro gaming weekend.
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