Learn: Python
Learn: Python
CC/STORE
LEARN TO
CODE
TAKE
NIGHT SKY
PHOTOS
WITH
PYTHON GET STARTED
WITH PICO
CIRCUITS
magpi.cc/store
ComfilePi
WELCOME
WELCOME
to The MagPi 128
L
earning to code can be a life-changing experience.
Computers are useful things, and learning how to get
under the hood is - in itself - pretty rewarding, and
there’s plenty of demand for coders worldwide.
But beyond that, learning to program teaches you how Lucy
EDITOR
to think. You learn how to break down complex tasks and Hattersley
put things in order. It teaches you how to solve seemingly Lucy is the editor
of The MagPi
impossible problems. Our Learn to Code with Python feature and would like
to petition for a
(page 44) can help you out on this journey. I hope you take it. Raspberry Pi office
puppy. Or she’ll
You’ll also discover excellent Computer Science resources in build another robot
this issue (page 80), including CS50 and MITx (both of which magpi.cc
magpi.cc 03
TOE
TCP/IP Offload Ethernet
Design Contest
Supporting up to 80 Mbps Speed
Targeting High Performance
Applications
USE W5300
● 8/16 bit Data Bus Interface (Direct & Indirect Address Mode) Contest
begins Mar 16
● High Network Performance : Max 80Mbps (by DMA)
● 8 Independent hardware sockets
Get a Mar 16
Buy
Sample ~ April 30
Contents
> Issue 128 > April 2023
Cover Feature
44 Learn to Code 44
with Python
Regulars
08 World of Raspberry Pi news
40 Case Study: Yoto Player
90 Your Letters
92 Community Events calendar
97 Next Month
98 The Final Word
Project Showcases
14 Heavy Pan Tilt System
18 Word Clock 26
20 Game Boy Interceptor
24 Aquarium dosing pump
26 Tank Driving Simulator
30 Progress Bar
32 BrachioGraph
34 Herbie_Bot
36 CinePI
14
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
56 60
Tutorials
52 Introduction to microcontrollers
56 Build an ML digital transcriber
60 Make a binary clock
Build an ML
digital transcriber Make a binary clock
The Big Feature
66 78
Reviews 86
72 Vizy Camera
74 Meteor 10.1” touchscreen
76 Alpakka controller
78 Ten amazing displays
80 Learn computer science
Community
84 Trevor Warren interview
86 This Month in Raspberry Pi This Month in Raspberry Pi
95
WIN A RETERMINAL
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
R
emember those new cameras we launched great fit for sports photography and machine
way back in the dawn of… January? [see vision applications, where even small
magpi.cc/126 – Ed]. We have another one amounts of distortion can seriously degrade
for you – and this time we’re getting specialised. inference performance.
We’re launching something a little different: the
Raspberry Pi Global Shutter Camera, available Rolling shutters, global shutters
now at $50 (magpi.cc/globalshuttercam). Every camera we’ve released to date, from
Built around Sony’s 1.6-megapixel IMX296 2014’s Camera Module 1 to our High Quality
sensor, the Global Shutter Camera is able to Camera and beyond, has used a rolling shutter
capture rapid motion without introducing sensor. These sensors have a two-dimensional
rolling shutter artefacts. This makes it a array of light-sensitive pixels, which generate
an analogue value proportional to the
amount of light falling on the
pixel during the exposure
time; and a row of
analogue-to-digital
converters (ADCs),
which convert
now with a
cdpstudio.com
Tel: +47 990 80 900 • [email protected]
CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
THE WORLD OF RASPBERRY PI
Raspberry Pi Pico
Windows Installer
A simpler solution to getting Pico up and running with Windows computers.
By Gordon Hollingworth, Raspberry Pi, Director of Software Engineering
R
aspberry Pi is introducing Raspberry Pi also documented how to get the toolchain up and
Pico Windows Installer, a simple solution working on both Apple’s macOS and Microsoft
to install everything you need to develop Windows for folks that wanted to use those
for Raspberry Pi Pico, and for other RP2040- platforms. Unfortunately, while installing the SDK
based boards, using C or C++ on Windows. on macOS isn’t too different from doing so under
The Raspberry Pi Pico C SDK (magpi.cc/picocsdk) Linux, and works almost out of the box, installing
can initially seem quite daunting. There are a lot things on Windows is much more difficult; it’s just
of moving parts to install before you can blink a very different environment.
your first LED on, and then off again, especially if Fortunately, an enterprising young engineer
you want proper debugging using something like called Nikhil Dabas (magpi.cc/ndabas) decided
our new Debug Probe (magpi.cc/debugprobe). to see whether he could do better. It turned out,
While there has been a ‘one-click’ solution of course, that he could, so I asked him to help
(magpi.cc/picosetup) to install the toolchain us create something even better: a complete
on a Raspberry Pi since launch – see integrated installation package that would give
Chapter 1 of the Getting Started guide people a nice, easy way of building and debugging
(magpi.cc/gettingstartedpico) – installing the the Pico SDK.
toolchain on other platforms, like macOS or
Windows, has always been a little more difficult. Installing the toolchain
When we launched Raspberry Pi Pico and its Installing the toolchain is now as simple as
SDK, our assumption was that people would be downloading, and running, the Pico Installer
The new Raspberry Pi
Debug Probe happy with a Linux-based toolchain. However, we (download link: magpi.cc/picosetupwindows). At
the end, the installer will offer to clone and build
the Pico examples (magpi.cc/picoexamples), giving
you the option of changing where the examples are
installed. Leave that ticked, and the installer will
open a command window to do the initial checkout
and build of all the Pico repositories. Once done,
you can safely close this window.
simple solution to
A PicoProbe using a second Raspberry Pi Pico. If you
don’t have a Debug Probe, see Appendix A of the
Raspberry Pi Debug
Probe connected
to a Dell computer
install everything you Getting Started (magpi.cc/gettingstartedpico) running Windows
Next steps
For more information on creating your own
project outside of the pico-examples, see the
tutorial at magpi.cc/piconewproject, or read
Chapter 8 of the Getting Started guide (magpi.cc/
The pico-examples repository open in Visual Studio Code gettingstartedpico) for a full walkthrough.
E
lectronics engineer Vito counts astronomy the work of many months. Its strength derives
and photography among his interests. After from the two aluminium frames, while Vito made
using Raspberry Pi a few years ago as part everything else from parts he 3D-printed. He
of his role in the medical sphere, he realised it was lucky enough to have access to a fairly high-
would fit rather neatly with his hobbies too. This end PolyJet 3D printer, which meant he got very
led to him setting up the YouTube channel Vigasan accurate results. Vito also designed the electronics
(magpi.cc/vigasanyt) to showcase his projects. and the control software, plus a custom circuit
The Heavy Pan Tilt System addresses a common board, pairing a Raspberry Pi 4 and a small camera
Vigasan
MAKER
issue with astrophotography: the need for a setup capable of automatic object tracking, as his video
robust enough to take a hefty digital SLR camera shows: magpi.cc/pantiltyt.
With 20 years in the
medical field as an and have it pan smoothly across the night sky Vito began by creating a project using Raspberry
electronic engineer, without juddering or losing either focus or the Pi for object tracking, before moving on to the
Vigasan frequently object in the viewfinder. Commercial options tend thornier issue of the mechanical design: “The need
uses Raspberry Pi
for both work and to be “quite expensive astronomical mounts,” so to move a camera with lenses of a certain weight
his hobby projects. Vito set about create his own version using his requires considerable torque from the motors. So,
magpi.cc/ own mechanical designs and software to automate to avoid using too big stepper motors, I designed a
motorizedcamgit object tracking. Raspberry Pi provided the critical reduction system based on belts and pulleys with
stepper motor controls and OpenCV libraries for the advantage of using smaller motors.”
computer vision. Judging by the many plaudits
quickly garnered online when Vigasan revealed Cost-benefit analysis
his build, he’s nailed it, even if some people think Although he can’t quantify the time taken for
it would be ideal for deadly accurate tennis ball designing the software and incorporating the
volleys and other forms of sharp-shooting. necessary libraries (he’s been an engineer for 20
years, so programming is part of his day job), Vito
Labour of love says the specific app to control things took him
Not surprisingly, the Heavy Pan Tilt System – a about a month, while designing the hardware took
“very robust motorised pan-tilt system capable about twice that. Having initially tried to create
of supporting cameras with heavy lenses” – is the project using an ESP32 microcontroller and
Quick FACTS
> Designing the
complex pulley
The heavy duty metal system took
frame and precision- several attempts
designed 3D moulded
parts are sturdy enough > The project was
to take expensive originally based
Maker Vigasan enjoys all
camera equipment and on an ESP32
forms of photography
angle it just so microcontroller...
including astrophotography,
for which long exposures and
> ...but really needed
object tracking are needed
Raspberry Pi 4
processing power...
finding it lacked power, Vito was glad he switched One of the incredible
Vito designed and laser-cut the aluminium
to using Raspberry Pi 4, which “guarantees good
photos Vigasan was able to
capture using his pan-tilt
02 frames. These precision parts and other
DSLR camera setup 3D-printed elements were designed to fit the
computing power and the existence of a large
number of libraries for any type of requirement.” two STM L6470 stepper motors and belts, which
Raspberry Pi 4 controls.
Word Clock
David Crookes reckons it’s time we all paid some attention to Christopher Hall’s amazing clock
I
f you want to know the time, there are many something practical; something with function,” he
methods available to you. Perhaps you’d like to explains. “I was browsing Printables when I came
glance at a digital or analogue clock or watch. across a similar project and thought, ‘I bet I have
Maybe you’d like to ask your favourite virtual most of the stuff I need to make this’.” Even so,
assistant to read it out loud. If you’re feeling bold, aspects of the build posed a challenge.
you consult a sundial, a time ball or a merkhet. Or, Since Christopher was making his own housing
if you’re Christopher Hall, you could use a word for the clock, he needed to use a 3D graphics tool.
clock and see the time as written sentences. “That meant learning Blender and taking precise
Christopher
MAKER
Word clocks are not new but they sure are fun, measurements with callipers,” he says. He also
Hall and Christopher’s entry goes further than most. opted to use a 128×64 HUB75 LED matrix that he’d
Christopher Hall is As well as telling the time, it announces holidays received with a monthly HackerBox subscription,
a senior network and birthdays by shining LED lights behind and this influenced the size of the word matrix
engineer from specific letters and numbers on a custom-made that he had to print.
Pikeville, KY, USA.
He’s a maker at
panel. Everything is controlled by a Raspberry “There was a lot of trial and error,” he says. “A
heart and lover of Pi computer. “When I thought of the project, key problem I noticed early on was light. I opted to
all things geeky. Raspberry Pi felt like a natural fit,” he says. use a 2×2 grid of LEDs per illuminated letter, but
magpi.cc/ putting the letters too close meant I could see each
wordclock Time to try light,” Christopher says. “In the end, I designed
The idea came when Christopher bought a 3D a lattice to sit between the RGB matrix and the
Christopher
discovered he could printer. “Rather than printing figurines, I wanted printed word matrix. Between it, I placed a grey
not have islands in sheet of paper cut to size, and this worked pretty
the letters – O, P, R,
and so on needed well to diffuse the light.”
to be hollow. “I tried
a stencil font but
ultimately couldn’t Clocking on
get the visibility I
wanted,” he says
Since the word matrix was 62×32 characters,
Christopher realised he had space for many letters.
“Once I’d finished arranging the time parts, I had
more than half a screen’s worth of real estate left,
which is why I decided to also announce the date
and any holidays and family birthdays,” he says.
To keep time, Christopher included an RGB
Matrix HAT + RTC from Adafruit so that the
project could benefit from a persistent real-time
clock. Setup involved connecting this to the
Raspberry Pi computer, and hooking everything to
the display inside the printed case.
Of course, Christopher also needed to program
the device. “The project I found on Printables
had an example Python script, so that was a good
jumping off point, but it still needed to be heavily
modified,” he says. “I used a holidays library to
determine if the current day was a holiday or not. I
also had the challenge of lighting the letters.”
Game Boy
Interceptor
A challenge by fellow Game Boy Tetris fans led to this
Pico-based recording device, discovers Rosie Hattersley
T
he addictive qualities of the computer game since childhood, Sebastian follows his own advice
Tetris are well-known, so it’s perhaps that the best way to learn new skills is “to become
no surprise to learn that there is a whole obsessed with a project that is just a little bit
community of Game Boy Tetris fans who meet above your current abilities.”
online for tournaments. When he got his first Raspberry Pi a decade ago,
The RP2040 microcontroller-based Game he wasn’t quite sure what he would do with it.
Boy Interceptor came about when just such Sebastian has been running a Raspberry Pi-based
a tournament was being planned, “and, of home automation setup ever since, and also keeps
Sebastian
MAKER
course, they wanted to stream the contestants’ a Raspberry Pi handy for the constant stream of
Staacks
gameplay,” relates fellow Tetris fan Sebastian projects that invariably need a simple server for
Sebastian is a Staacks. “Streaming would not be a problem with IoT purposes. When Raspberry Pi Pico launched, he
physicist and a modified Game Boy or a modern Game Boy clone was curious about Raspberry Pi microcontrollers,
developer of the
such as the Analogue Pocket,” says Sebastian, especially after working with Arduinos for a while.
app ‘phyphox’
at the RWTH “but it would mean contestants would be forced to Happily, “the RP2040 turned out to be a perfect
Aachen University use the same platform in order to compete.” This match for GB Interceptor!” Unlike modern devices,
(Germany). He is a change just wouldn’t fly: “the contestants always the Game Boy reads data from the cartridge as
father of two and
presents his hobby
played their favourite Game Boy model and, in a fast as from its RAM, so there is no reason for it
projects in his blog... contest, would want to use the model on which to load its code into RAM first. Instead, the code
there.oughta.be they trained their muscle memory.” is executed directly from the cartridge (with few
Getting everyone to modify their beloved exceptions) and a device in between would know
handheld console was out of the question. Sensing exactly what the Game Boy was doing.
a challenge he could relish, Sebastian agreed to
work out a way of streaming the tournament that Unexpected benefits
would satisfy everyone. His idea was to insert At first, Sebastian simply hoped to use RP2040
a device between the game cartridge and the to capture information from Tetris, but the
Game Boy that checks what the handheld console microcontroller was powerful enough to render the
is doing and reconstructs the gameplay from graphics, emulate the code from whichever game
the data. was being played, and act as a general-purpose
video capture device. The power and sophistication
Game on! of the RP2040 meant the Game Boy Interceptor
Physicist Sebastian holds a PhD in solid-state was a much more useful and flexible device than
physics, “which means that I know the basics of Sebastian had anticipated. “You can simply plug
almost everything technical, but nothing that is it between the cartridge and your Game Boy
required to apply it,” he announces modestly. A and connect it to a host device via USB.” There,
self-taught programmer and electronics enthusiast it shows up like a webcam and, as a USB Video
he GB Interceptor
T Class device, it does not need a driver and just
can even be used as a
webcam, as Sebastian works on Linux, Windows, and Android. It works
demonstrates
with macOS too, though Sebastian says he still
experiences some issues with M1- and M2-based
Macs. It can even make use of the Game Boy’s
camera and function as a webcam.
Aquarium
dosing pump
There’s something fishy about this fabulous project,
but that’s the whole point, as David Crookes explains
K
eeping corals healthy is a tricky task. As tube while preventing back-flow. Sourcing the
well as requiring the right temperature pumps and the relay took Joe a few hours. He was
and proper aquarium lighting, corals need then able to design a case using 3D modelling
a balanced healthy diet and extremely precise software, map the wiring and electronics on paper,
water chemistry. Joe Stiff, who keeps corals and solder a prototype, and write the software.
macroalgae in 7.5-litre and 41-litre salt water
tanks is fully aware of this. “Dosing various Good dose
ions such as calcium and magnesium, as well as “When you buy a commercial doser, you’re stuck
Joe Stiff
MAKER
other chemicals, is necessary when taking care of with the company’s proprietary software which is
corals,” he says. usually awful and painful to use, or simply doesn’t
Joe’s life is powered
Rather than pay anywhere between £80 and work half the time,” Joe says. “This project fit my
by Raspberry Pi at
this point and it’s part £500 on a commercial dosing pump, however, he ultimate aim which is to build everything for the
of the ecosystem decided to make one himself. By using a Raspberry aquarium myself, from the LED fixtures to the
of his home. He Pi Pico microcontroller, along with good-quality doser and temperature/pH monitoring system.”
promises more
projects are coming relays and pumps, he has been able to create a Joe wrote the program in MicroPython and,
soon! driver for a fraction of the cost – just £14 in total. after calibrating each of the doser’s two pumps
mustardcorner.com He has also done so without compromising. “Price to run at the same speed, he set it to run every 15
wasn’t a limiting factor at all because these parts minutes. This allowed a small amount of calcium
are relatively cheap,” he explains. hydroxide to flow 96 times a day from one pump,
Nothing fishy
Although he was always keen to keep costs hen you buy a
W
under £30, the main requirement was to create
a device that could dose a configurable amount
commercial doser, you’re
of chemicals accurate to within 0.5 millilitres
or less. He also needed each pump to separately
stuck with the company’s
operate a configurable number of times each proprietary software
day so that different liquids could be used at
different quantities.
“The doser needed to be low voltage because of ensuring 200 ml of the chemical would be dosed
its proximity to water, and I wanted it to be small on a daily basis. The other pump was set to dose
and neat so that it could go near a beautiful reef other chemicals, such as amino acids and food,
tank and not look out of place,” Joe continues. “I when needed.
also needed it to be repairable and easy to take It’s certainly effective. Joe says that the Pico
apart if necessary to replace the parts. This is why controls the relay, turning the pumps on and off
I chose particular peristaltic pumps. You can take with simple code sent via one of the GPIO pins.
out the tubing and replace it with new tubing very A few functions calculate the dosage/timing and
easily from the front.” the code just loops, sleeping in-between dosing.
Peristaltic pumps are low-maintenance and easy “My next step will be to upgrade to Raspberry Pi
to sterilise. They use rollers or shoes to effectively Pico W,” he says. “I will then write some wireless
massage a fixed amount of chemical through the LAN code to control it via my mobile phone.”
Quick FACTS
> The device
provides micro-
doses of
a chemical
Tubes can be easily attached to
A Raspberry Pi Pico microcontroller the front of the pumps which, > It’s being used to
sits within this beautiful 3D-printed in turn, are connected directly keep coral healthy
case. The settings are currently being to a 5 V power supply. A signal in a tank
changed by connecting the doser to a from the Raspberry Pi Pico is
laptop, but Joe wants to go wireless needed to turn the switch on > It could also be
used to water
plants automatically
Tank Driving
Simulator
A Swiss tank museum is home to an historic training vehicle that has
been upgraded with a Raspberry Pi. Rosie Hattersley finds out why
A
lthough it has become known by its any components that failed. Their aim was to
German moniker of FASIP (shorthand replace each item “as faithfully as possible.”
for Panzerfahrsimulator), the vehicle Sadly, the original 1970s MITRA-125 computer
was actually developed in France in the 1970s, which controlled almost every aspect, including
explains Gerold Handschin, one of the trio from responding to the displacement sensors and
the tank museum who set about saving the controlling the simulator’s movements, lamp,
unlikely survivor. “A total of eight tracks were and displays, was defective. This central control
used to train prospective tank drivers, initially for unit clearly needed to be replaced. “Fortunately,
the Centurion tank and later for the Panzer 68 and the program in operation on the MITRA-125 was
Leopard 2,” Gerold relates. The trainee driver sat available as a hard copy. So we decided to replace
in a replica driver’s cab, with a screen displaying the old computer with a new system,” says Gerold.
the terrain he needed to negotiate. Hydraulics The only issue: it was all in French. Scanning in
under the cab replicated the tank’s movements, the several-thousand-page document and using
while a camera on a trolley travelled the length text recognition software helped, but in some cases
of the 12 m-long detailed terrain model. The the type had faded so much that the characters
combination of responsiveness to the driver’s could not be recognised. “We sometimes had to
steering movements and on-screen display created approach the correct parameter values by trial and
a realistic driving experience that predated arcade error,” says Gerold, but new C-based simulator
games by several years. In addition to the large software for Raspberry Pi was eventually written.
terrain model and hydraulic system, various
Gerold Restoration challenges
MAKER
Quick FACTS
> The team had four
custom circuit
boards made...
Tank training
he team looking
T
realistic driving
A over the scale
model that the tank 02
The corroded old network and IOs needed
to be replaced with components capable of
‘drives’ around
experience that predated delivering a constant voltage.
arcade games
The IO plug-in unit’s original boards, XERUDI
and XUCI, were replaced by the new board
and Raspberry Pi too, but it was a challenge to
work out the correct timing when driving the
components of the interface plug-in unit. The
overhaul of the simulator was completed at the
end of July 2020. Since then, it has been possible
The original tank sim rig needed a complete
to drive the Panzer 68 simulator through the 03 overhaul, custom circuit board and adapters,
grounds at the Swiss Military Museum in Full plus reprogramming in C.
by appointment.
Progress Bar
Do you tend to keep an eye on the clock during the working day?
Nicola King learns how watching for a rainbow is far more enjoyable
W
e have all, let’s be honest, clock- admittedly “tricky”, says Martin, but the gcalcli
watched at some point in our working command-line tool (magpi.cc/gcalcli) handles all
lives. Well, friends of The MagPi, Martin the Google authorisation.
Spendiff and Vanessa Bradley have come up with The duo used the Wi-Fi-capable Pico W because
a little idea that might improve your working “running a fully-fledged computer to turn on a
day, bringing a colourful rainbow display at few lights would be overkill,” says Martin. “It
close of business, where once there was the face needs to connect to the internet, so we [opted for]
of a benign and mundane clock. This physical Pico W. It was the first time we’ve used one and it
Progress Bar (magpi.cc/progressbar) could be was surprisingly easy.”
just the ticket to brighten up your office and He and Vanessa are always open to suggestions
gladden your soul. for tweaks – when someone saw the GitHub
Inspiration, Martin tells us, came from “a page and wanted to use it in a school without the
fondness for clocks and way too much time Google Calendar link, they were keen to help, “The
Martin looking at progress bars. As a random bit of pub
MAKER
Spendiff trivia… the progress bar was first used long before
& Vanessa computers were invented – back in the 1800s.” It needs to connect to the
Bradley So, Veeb’s fresh take on the concept began
percolating and, armed with a Raspberry Pi
internet, so we opted
Martin is a
mathematical
modeller who
Pico W, a metre-long piece of frame from a
hardware shop, a plastic light diffuser, and a
for Pico W
left the UK for one‑metre, 144-LED, 5 V addressable LED strip,
Switzerland, and
the duo set to work. idea of a classroom getting to see a rainbow at
a fan of FOSS and
tech that serves home time was sufficiently appealing to make us
users, rather than A work in… progress refine the code.”
the people who Martin and Vanessa quickly put the hardware
made it. Vanessa
is new to coding together, wrote some MicroPython code, and Easy as Pi
and a constant then connected Pico W, which is the brain of the One of the great features of the Progress Bar is
source of weird and Progress Bar. “Pico W connects to the internet its relative simplicity, with very little needed in
good ideas.
and finds out what time it is,” reveals Martin. terms of hardware, making it an ideal project for
veeb.ch “After that, it checks the working hours (that any new makers. “It is a nice little example that
you put into the code). It just does a little bit of involves very little soldering and relatively simple
arithmetic to figure out if you’re at work, and code,” Martin highlights.
how far through the day you are. It’s then easy to He and Vanessa have received highly positive
figure out how many lights in the [LED] strip it feedback from the maker community – although
should turn on.” Martin recalls how one person did declare,
Cleverly, the pair also incorporated a link to ‘imagine hating work so much that you need
Google Calendar, so any appointments are shown to keep looking at one of these.’ The pair are
on the bar (and constantly updated through the pragmatic: “If being pleased it’s home time is a
day), and the bar also flashes at appointment crime, guilty as charged!” They use their Progress
time as a vibrant reminder, although Martin Bar every day, highlighting, “There’s a lovely
envisages that maybe “a Knight Rider-style sweep element of it gently reminding you to work and
would be better!” Linking to Google Calendar was when to down tools for the day.”
BrachioGraph
A charmingly inaccurate plotter driven by Raspberry Pi draws the interest of Rosie Hattersley
M
any of us remember being shown, or Motion capture
even making, pantograph pen plotters Playing around with servos and Raspberry Pi was
from the days before graphing tools the entry point for Daniele’s plotting device project.
were part of a standard home or office computing Moving them around was easy enough, but he was
feature set. Open-source computing guru keen to see a practical result: “What can we actually
Daniele Procida recalled just such a device when do?” With nostalgia for pantographs and XY aerial
considering a low-tech example of what Raspberry plotters in common, Daniele explains he found
Pi could be used for while planning for the PyCon “their ability to reproduce something we do with
Daniele
MAKER
Namibia conference. The result, BrachioGraph, our hands intrinsically fascinating. When you see a
Procida which sketches portraits and reproduces images pen moving around, it looks like it has a purpose”.
Daniele is head
of objects, was an instant hit, inspiring a fan Although servo motors can be used to drive
of engineering at following of keen makers. a device along straight lines, translating the
Canonical, and a Noting the contrast between the resources movements and hand-drawn lines on a page is
regular presenter at
typically available at conference events in the UK more about angles. The question, Daniele says,
Python conferences
around the world. and Europe and those in African host nations, was whether he could turn movements into lines
Daniele says: “It’s one thing doing things with on a page. “Of course you can, because your own
magpi.cc/
brachiograph robotics if you’ve got access to 3D printers, laser arm, if you’re drawing with a pen, also doesn’t
cutters, and off-the-shelf parts and components; have motors that go in straight lines. It just uses
quite another if you’re an undergraduate at the angles.” He began by modelling the design on
University of Namibia, or a high school student that of a pantograph, which faithfully mimics the
and probably have to share a laptop or computer.” movement of the human arm. A BrachioGraph,
Combined with Daniele’s own interest, but lack meanwhile is an ‘arm plotter’.
of experience in robotics, he decided “to do
something that was as affordable as possible, but Copycats encouraged
From bitmap to plot also meaningful and also accessible, that didn’t The BrachioGraph can be set up to run on its
via vectorisation, the
require an absolute minimum of materials and own, making it an ideal conference exhibit. “At
Prague Conservatory
concert hall knowledge and facilities.” one conference, I was very embarrassed because I
32 magpi.cc BrachioGraph
PROJECT SHOWCASE
Instructions received
and processed by
Raspberry Pi translate
to actions performed by
the pen, held securely
in place by a peg
built this thing, and it works, but that it’s amazed and
wanted their
BrachioGraph magpi.cc 33
PROJECT SHOWCASE
Herbie_Bot
Keeping weeds at bay is no easy feat – unless you have a robot to help you.
Rob Zwetsloot slaps on some suntan lotion and has a look
“
H
ave you ever lugged around the yard “These small battery-operated spray wands are
a gallon jug of lawn-safe herbicide versatile, and I thought it would be easy to fit
with a battery-powered spray wand?” into the robot. Unfortunately, my welder was
asks Russ Hall. He’s the creator of many lawn- stolen from me, so I used wood for the bracing
keeping robots, and now is battling against and construction, built on the steel rover chassis
pesky weeds. that I had from years ago.”
“After a while, the hands, arms, and eyes tire We actually quite like the look of the finished
of the repetition; it’s work!” Russ continues. “I product – it’s like a classic Rube Goldberg
Russ Hall
MAKER
remembered my yardbot/mowbot, and thought I machine you’d see in a cartoon, in its own way.
An electronic
could rig up a sprayer with a camera and AI.” Not many Rube Goldberg machines employ
technician for the Russ had previously built a mapping robot modern machine learning though.
US Postal Service, for inside his house using Raspberry Pi, and “This was my first AI project, so I had a lot to
servicing high-speed
decided to use that instead of the ZED camera learn,” Russ continues. “However, with the OAK
mail processing
machines. and Nvidia-powered computer. “Raspberry Pi camera and its Movidius chip, I felt it would work
was easier to work with, as well as being less well with Raspberry Pi, since the AI is handled in
magpi.cc/
herbiebot expensive,” he says. the camera. To start, I used a standard routine
in the Raspberry Pi to take photos of the lawn
Yard work and weeds by the robot, because it’s important
“Working with hardware is a fun challenge to me to train the AI with photos that are identical
and this robot was no different,” Russ explains. to the video stream that it will be expected to
process. I used Roboflow to prepare the images,
and YOLOv5 to do the AI training (on Google
servers), and it wasn’t too hard. Luxonis has a
neat conversion tool online, to make the software
blob that is loaded in the camera.”
Weeds: terminated
The video of Herbie in action can be viewed at
magpi.cc/herbiebot, and it looks great at work
– precisely targeting weeds and giving them a
quick spray.
“If the weeds are too heavy, it can’t hit them
all, of course, since the robot is constantly
moving forward,” Russ says. “Testing with blue
dye in the herbicide confirmed the accuracy
and proper operation. I used 6 VDC for the
sprayer servo so that it is quick. The 5 VDC for
the sprayer pump comes from the USB power.”
Currently, Herbie is not fully automated to cover
the yard, but it’s in the works. Maybe one day the
It’s much easier to get a robot to lug around a big bottle of herbicide all-in-one lawn-keeping robot will be reality.
34 magpi.cc Herbie_Bot
PROJECT SHOWCASE
Quick FACTS
Parts of the rover are
powered by a car battery, > Russ builds robots
This battery-powered with his kids
with several other battery
herbicide spraying
sources employed
wand is controlled > Herbie is powered
via Raspberry Pi by Robot Operating
System (ROS)
expected to process
Warning!
Power tools and
herbicides
This project involves
woodworking which can
be very dangerous, and
The spray wand herbicides that can be
is attached to poisonous to humans.
a servo that Exercise caution if you
Raspberry plan to work with both.
Pi moves to
Blue dye was used to test the accuracy of the model detected weeds magpi.cc/diysafety
Herbie_Bot magpi.cc 35
PROJECT SHOWCASE
CinePI
Using Raspberry Pi as a high-end film camera is not as
weird as it may sound. Rob Zwetsloot gets the shot
36 magpi.cc CinePI
PROJECT SHOWCASE
Quiet on set
The result not only looks very cool but is
incredibly functional, being able to record
RAW video at 50 fps and 12-bit colour depth –
remember that films run at 24 fps, so this makes
ou have full access to Raspberry Pi ports, as
Y
for an excellent working file. well as other specialist recording ports
CinePI magpi.cc 37
PROJECT SHOWCASE
ootage of an
F
aquarium has been
used in tests
ll the advanced
A
options are surfaced
for you to tweak with
38 magpi.cc CinePI
PROJECT SHOWCASE
CinePI magpi.cc 39
SUCCESS STORY
Yoto Player
The development possibilities of Raspberry Pi enabled
an appealing, child-focused audio player to take shape
THE RESULTS
The first Yoto Player met with success, launching
with a starter pack of stories, including ones by
Roald Dahl, as well as blank cards for kids to
record their own stories onto the player’s 8GB SD
card. Capturing the imagination of Roald Dahl’s
grandson early on – he’s now a Yoto board member
– cemented interest in the device’s concept, and a
whole slew of children’s publishers followed. Julia
Donaldson’s beloved The Gruffalo, as well as some
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 35% compared to stores
+
Subscribe for 6 Months
Free Pico W
6 issues of The MagPi
Free delivery to your door
£30 (UK) £35 (USA)
£35 (EU) £45 (Rest of World)
42 magpi.cc
SUBSCRIPTION
A brand new
RP2040-based
$6
Raspberry Pi Pico W
development board
SUBSCRIBE
on app stores
magpi.cc 43
FEATURE
LEARN TO
CODE WITH
PYTHON
Discover the joy of coding with our beginner’s
guide to Python 3 on Raspberry Pi
by Phil King
I
n this crash course, we’ll take you through
the key principles of Python programming on
Raspberry Pi.
For this guide, we’ll be doing all our coding
in the Thonny IDE (integrated development
environment) in Raspberry Pi OS. An IDE is a
program that is used to create other programs.
You can create programs in any text editor,
but using an IDE makes life easier (especially
for newcomers).
From the desktop applications menu, select
Programming > Thonny. The Thonny IDE starts
up in simple mode by default. Along the top are You can save the program by clicking Save and
Hello world: the
simplest of programs
large icons including Load, Save, Run, and Stop. entering hello_world.py in the Name field. is to print a message
to the Shell area
Variables can be set
to input from the print(128)
user; for neatness,
print("The MagPi" + " is " + "a magazine.")
include a space after
the text Click Run to print the integer 128 to the Shell.
We can also use standard mathematical operators Note the spaces around the word ‘is’. Other
(addition, subtraction, multiplication, and maths operators include ** for ‘to the power’, %
division) on numbers. For example: for modulo (division remainder), and // for floor
division (rounded down to the nearest integer).
For example:
e store numbers
W
print(2**4)
and strings in objects print(20%7)
print(22//7)
called variables
Which give the
results 16, 6, and 3
print(128+57) respectively.
x = 42
message = "The meaning of life is "
+ str(x)
print(message)
Testing multiple To switch between number types (or convert
conditions with if and a string comprising a number), we use the int()
elif statements; the
following indented
and float() functions.
line only runs if the
condition is true
COMPARISON
OPERATORS
Using a for loop
There are six comparison operators available to count down
in Python: from ten to one,
with a sleep delay
between numbers
Operator Meaning
The line after the if statement is indented by
four spaces and the indented code is executed
== is equal to only if the condition is true (i.e. the age variable
is between 13 and 19). An and logical operator
!= is not equal to is also used in this example to check that two
conditions are both true.
> is greater than We can add an elif (short for ‘else if’)
statement afterwards to perform another
< is less than comparison if none of the previous ones is true:
LOGICAL
<= is less than or equal to
OPERATORS
Note that you need to use == for comparisons,
not = (which is used to set a value). These are used for comparing multiple
conditions at once.
Operator Meaning
To define a variable, we choose a name for it and
use the = symbol to set its value. For example:
and both conditions are true
wings = 4
animal = "bee" or either (or both) condition
print("A", animal, "has", wings, "wings.") is true
Conditions
A key part of many programs involves comparing
variables and values to determine what step
is executed next. For this, we use an if
conditional statement.
A dictionary
comprises key and
value pairs separated
by a colon
Printing out the
values of tuples
This prints the digits 0 to 9, since the default
stored in a list starting value for the range() function is zero and
WHILE LOOP
An alternative to a for loop is to use while to test
a condition and only run the loop while it is true.
x = 1
print("Counting from 1 to 5…")
while x <= 5:
print(x)
x = x +1
RETURN VALUES
Instead of using print() in our addition function,
we could use return to send the result back to
the caller.
The Shell area shows any errors when running code; here, we
failed to give a function’s variable global scope
def add(a, b):
return a + b
from time import sleep
for x in range(10, 0, -1): result = add(138, 485)
print(x) print(result)
sleep(1)
names = ["Alex", "Brooke", "Chloe", rgb = [(255, 0, 0), (0, 255, 0), (0, 0,
"David", "Ed"] 255)]
print(names[1]) colours = ("red", "green", "blue")
for i in range(3):
Since Python starts counting at 0, the index of print("The RGB value for", colours[i],
1 (given in square brackets) selects ‘Brooke’ from "is", rgb[i])
the list.
Dictionaries
list will be used with a
A These are similar to lists except they contain
message()
WIZnet TOE
TCP/IP Offload Ethernet
Ap
pli
cat
ion
s
Ap
TC pli
P/I cat
P ion
s
Ful
ly H
ard
wir
ed TC
TO
E SWIZn
P/I
P
tac et
k
So
f
Tra tware
TCP di TC
t
/IP ion P/IP
Sta al
ck
wiznet.io
TUTORIAL
Beginning
Part 02
electronics:
Introduction to
Stewart
microcontrollers
MAKER
Watkiss Learn about microcontrollers using Raspberry Pi Pico. Build a motion sensor
Also known as which turns on LEDs whenever someone enters a room
Penguin Tutor.
Maker and YouTuber
I
that loves all things
Getting started with the Pico
Raspberry Pi and
Pico. Author of
n this project, you will learn how to detect
when someone enters a room using a PIR
02 To be able to insert the Pico onto a
Learn Electronics (passive infrared) motion sensor. You will breadboard you’ll need pins soldered to it. You can
with Raspberry Pi.
learn how to use MicroPython to carry out actions solder headers on yourself, or you can buy versions
penguintutor.com based on the PIR sensor. The code can make of the Pico with the pins pre-soldered. With the
twitter.com/ decisions and set an output. This can be used to headers in place, you can plug the Pico into a
stewartwatkiss turn on LEDs. You’ll also learn about schematic breadboard ready for adding other components.
circuit diagrams, making it easier to understand You’ll also need to install MicroPython onto
how a circuit works. the Pico. Download the appropriate UF2 file
from magpi.cc/micropython. Hold down the
You’ll Need BOOTSEL button whilst connecting the Pico to
your computer. Drag and drop the UF2 file to the
What is a microcontroller?
> B
readboard
magpi.cc/ 01 A microcontroller is an electronic device.
RPI‑RP2 drive that appears on your computer.
comes with male headers resistor and limiting to 12 mA gives 141 Ω, which
rounds up to 150 Ω. These should be wired as
shown in Figure 1 over the page.
connected to pin 3 on the Pico, the VCC (power)
pin to pin 40 on the Pico, and the OUT pin to pin
4 on the Pico. In the diagram (Figure 2), we’ve
Schematic circuit diagram
Figure 3 A schematic
used the horizontal power rails of the breadboard,
which makes adding additional components easier.
07 One of the challenges with the breadboard
circuit diagram does
not look the same
as how it does on
diagram is that as more components are added, a breadboard, but
it becomes harder to see where each of the device makes it easier to
see which wires
legs and wires go. connect where
Adding LEDs
05 The aim in this project is to create light
when the PIR sensor detects someone in the
room. Ideally this will turn on a bright light, but
that would need more power than the GPIO ports
can provide. So, for now you can use multiple
white LEDs.
One thing to be aware of is that the GPIO pins
can only provide a small current. According to the
RP2040 data sheet, the total across all the GPIO
pins is 50 mA. The highest current mode for an
individual pin is 12 mA. This is not the absolute
maximum, but the output voltage will decrease
when exceeding that current.
Power connections
09 The power supply connections are shown
through symbols. The arrows pointing upwards
are used to indicate the positive power connection
which is connected to 5 V from the Pico. These are
Figure 1 The all connected.
location of the port There is an alternative way of showing the The ground, or negative, connection is shown
numbers for the Pico
are shown in this circuit which is the schematic diagram. It involves as a small diagram with the label GND. They are
diagram. Many of
these can be used for
learning some new symbols and conventions, but all connected.
different functions makes it much easier when creating larger circuits. From the diagram, you can see the pins that are
The schematic diagram for this circuit is shown used on the Pico and how all of the components
in Figure 3 on the previous page. are wired together. For complex circuits, this is
much easier than trying to follow the wires on the
breadboard diagram.
T
he Thonny editor can be used to write MicroPython code directly
onto the Pico. Switch to standard mode to see all the options
DOWNLOAD
main.py THE FULL CODE:
> Language: MicroPython magpi.cc/picopir
Machine
learning-powered
private speech
transcriber
Keep your personal data private by carrying out
automated voice transcription on your own Raspberry Pi
S
K.G. peech recognition is massively useful, transcribers, it can get confused by cross-talk and
MAKER
Orphanides from providing accessibility features to indistinct enunciation. However, its performance
people with deafness and reduced hearing rivals that of many commercial services, and your
KG is a writer, to transcribing meetings, lectures, or personal data never leaves your hands.
developer audio notes. It’s also the technology that
and software
preservationist. underpins most personal digital assistants.
They’re sceptical of But between services that leverage cloud
Prepare your system
01
the AI-in-everything processing and those that phone home with
fad, but also don’t
telemetry data and voice samples for later Machine learning applications will
want a human
transcriber to hear analysis by humans, it’s hard to find transcription cheerfully use as much processor power as you
their audio diary. services that keep your personal recordings can throw at them - during cross-platform
magpi.cc/ fully private. So we’re going to build our own testing, we maxed out all 16 threads of a hefty
hauntedowlbear offline transcriber. AMD Zen CPU. Although Georgi Gerganov’s
Whisper.cpp isn’t perfect. It can’t distinguish Whisper port is optimised for efficiency, you
between different speakers and, like most can expect better results from more powerful
systems. We used a Raspberry Pi 400 with
4GB RAM. Unless you just want to transcribe
audio files, you’ll also need a microphone - we
used a Blue Yeti USB mic. For somewhat better
performance, you could use an 8GB Raspberry
Pi 4 running Raspberry Pi OS Lite to save on the
overheads of the GUI.
You’ll Need
> G
eorgi Gerganov’s
Use the source
Whisper.cpp port
magpi.cc/
02 There are no pre-compiled binaries
whispercpp for ARM platforms, so you’ll either have to
> A
microphone (for Although less accurate than ‘main’, if want to clone Whisper.cpp from its Git repository, or
make a hands-free note or have the text of a
live transcription) download a release version of the source code
meeting immediately available, you’ll find the
near-real-time ‘steam’ transcription tool useful from magpi.cc/whisperreleases. We’ve gone with
The --print-colors
option will show you how
The model
03 We’re going to use the recommended tiny
much confidence Whisper
has in the transcription of
Whisper model for Raspberry Pi, which requires each word
just 75MB of disk space and around 125MB RAM.
While, on paper, the larger and theoretically more
accurate base model might be assumed to work on
Raspberry Pi, in practice the processing overhead
resulted in breaks and delays in transcription, so
we’re going to keep it small.
./models/download-ggml-model.sh tiny.en
make -j tiny.en This command optimises for live transcription
make -j stream performance on Raspberry Pi’s modest hardware
by sampling the audio every four seconds with
the --step 4000 instruction. One second would
be --step 1000.
T here are no pre-compiled
binaries for ARM platforms
Transcribe to file
05 Displaying text on-screen after a short
When the build info is shown after making delay is undeniably useful, particularly if you have
stream, you’ll notice that the makefile difficulty hearing or following spoken lectures
automatically optimises for armv71, including or conversations. However, you’ll usually want
options such as neon-fp-armv8. to keep the transcribed text for future use. To
do this, append -f filename.txt to the end of
the command.
Top Tip
Press CTRL+C to end transcription.
Use the best
Take dictation
04 The stream tool is your live transcriber.
mic you can
Everything you say into the mic will be passed Microphone
Ride the wave
through Whisper and displayed on screen. At the
terminal, type:
06 You can also use Whisper.cpp to transcribe
quality makes a
huge difference
previously recorded files, making it a useful to the accuracy of
Whisper.cpp’s
./stream -m models/ggml-tiny.en.bin --step alternative to online AI transcription tools such as
live audio
4000 --length 8000 -c 0 -t 4 -ac 512 Temi and Otter.ai, with the benefit of knowing that transcription.
your recording never leaves your hands.
You can have the Currently, if you want to transcribe an audio You can have it transcribe multiple files using
transcriber output
an audio file to text, file, it has to be in 16-bit PCM WAV format. If wild cards:
making it easy to do your recorder outputs MP3 files, or even PCM files
further work on
at a different bit depth, you’ll need to convert ./main -m models/ggml-tiny.en.bin *.wav
them first. We can use ffmpeg for that at the --output-txt
command line.
Summoning Santa
09 We’re going to spin up Whisper.cpp’s
integrated AI chatbot and install the espeak speech
synthesiser, which is the default option for voicing
the bot’s speech. In Whisper’s main directory, at
Further ideas: Command station
11
the terminal, type: The subtitling tool
often does a better
If you’re hoping to use Whisper.cpp to build job than YouTube’s
integration closed
wget --quiet --show-progress -O models/ your own offline digital voice assistant, there’s a
captioner, but
ggml-gpt-2-117M.bin https://huggingface.co/ reference example called ‘command’ to get you it’s not optimised
for Raspberry Pi
datasets/ggerganov/ggml/blob/main/ggml-model- started. First, in the whisper.cpp directory: by default
gpt-2-117M.bin
sudo apt install espeak make command
make talk ./command -m ./models/ggml-tiny.en.bin -ac
./talk -mw models/ggml-tiny.en.bin -p Santa 768 -t 3 -c 0
This demo throws you into a conversation This launch string is optimised for Raspberry
with Santa, once you’ve provided an extra Pi. Once launched, command activates with the
prompt. It’s a bit slow on Raspberry Pi and the spoken instruction ‘OK Whisper, start listening for
conversation wasn’t very satisfying, or believable, commands’ and specifically listens for short trigger
on any system we tested it on. It’s rich ground phrases. Note that these aren’t actually assigned to
for experimentation using different models and any actions or responses in this sample tool.
prompts, but this mostly requires more processor We found that this short phrase detection
power than your average SBC has to offer. You behaviour was more susceptible to interference
can change the identity of your interlocutor by from background noise than stream’s
following the -p switch with a different name. continuous real-time transcription, but if you’re
after a framework to build your own voice
automation system from, this is certainly a good
place to start.
Extra features
10 Also included in Whisper.cpp’s examples
Binary clock
Keep track of time, and learn to count in 1s and 0s
B
inary is the key concept in how this particular project requires having an on-board
computers operate. If you drill real-time clock (RTC), so won’t work with all boards.
down far enough on any operation, We’re going to be using a Pico W, but it might work
transmission, or storage, you’ll find 1s on others that have both wireless networking and
and 0s, on or off, positive or negative. RTC hardware. Along the way, we’ll learn how to
This ability to build up to complex connect Pico W to the internet to get the time, and
Ben Everard behaviours from a simple distinction between, and how to use Pico’s Real Time Counter to keep track of
manipulation of two states, is what computing is the time in hours, minutes, and seconds. Let’s take a
@ben_everard
all about. look at this first.
Yet, despite this being absolutely fundamental to There’s a protocol for getting time on a network,
Ben's house is slowly
being taken over by 3D
the way computers work, it can be a bit alien to us and it’s unimaginatively named Network Time
printers. He plans to humans. We’re brought up in a world of ten digits, not Protocol (NTP). This actually does a few things around
solve this by printing an just two, so it can be hard to get an intuitive sense of synchronising time over a network with various
extension, once he gets
enough printers. binary, especially if you don’t use it very much. Our degrees of lag, but we don’t need to worry about
solution is to make a clock that displays time in binary. being a few milliseconds out, so we’re just going to
We're going to use MicroPython for this because grab the current time.
it's quick and easy to get started wirth, and has We’re also not going to worry about daylight
access to Pico's timekeeping features. While savings time. We’re doing all this in MicroPython, so
MicroPython is fairly standard across several boards, we’re going to take the simplest solution – twice a
if wlan.status() != 3:
raise RuntimeError('network connection
failed')
else:
print('connected')
status = wlan.ifconfig()
Left
print( 'ip = ' + status[0] ) Soldering resistors
in-line is an easy
way to build circuits
led.on() without a circuit board
simple_ntp.set_time()
year, you’ll connect to your clock and adjust the print(time.localtime())
offset manually. If you want, you could add a toggle led.off()
switch that flips back and forwards to adjust for
daylight savings. Obviously, you’ll need to put in your network’s SSID
We suspected that setting the time on an RTC and password, but other than that, it should just run.
via NTP might be a popular thing to do, so we At the end of it, it’ll print the result of time.localtime().
wrapped up the example code for NTP in a simple Firstly, we should note that this is a misleading name
library that does just this – you can get it from as it won’t print your local time, it’ll print the time in
hsmag.cc/SimpleNTP. GMT. Secondly, it won’t actually print the time in a
You’ll need to copy the simple_ntp.py file over usual format, it’ll print it as a list. The items are: [year,
to your device – you can do this by opening it in month, monthday, hour, minute, second, weekday,
Thonny, then selecting ’Save as’ and MicroPython yearday]. All of these should be set correctly.
device. Remember, it must have the same name on
the device.
We’ll shortly look at what’s in that file, but for now,
DIMMING
we’ll use it to grab the time and set the RTC. You can Our program turns the LEDs all the way on or all the
do this with the following code: way off. This is fine for us, and we can control the
brightness by picking the right resistor. However, you
import network can control the brightness of LEDs by flicking them
import socket on and off really fast. This is known as pulse width
modulation (PWM). Pico W does support PWM but is
import time
limited to just 16 pins, so we can’t use it in this project.
import struct We could create a PIO program that took in details of
from machine import Pin all the pins that should be on, and do a global PWM Below
The ground wires
import simple_ntp across all of them, but this is more than we need. connect across
all the LEDs
led = Pin("LED", Pin.OUT)
ssid = 'your_ssid'
password = 'your_password'
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
max_wait = 10
while max_wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print('waiting for connection...')
time.sleep(1)
”
There are three optional parameters here. The first is
offset, which is a number in seconds that you want We’ve used the classic 5 mm
to set your RTC’s time to – this is useful if you want
red LEDs that give a retro
to set it to a particular time zone. The second is delta,
which you can probably ignore most of the time, but feel, but 3 mm LEDs will give
”
it’s the difference between the way time is encoded
you a more compact design
in NTP. The final parameter is the NTP server. Again,
pool.ntp.org is probably a good choice for the vast
majority of cases. This isn’t a specific server but a You can use any LEDs that work with 3.3 V. They
domain that will resolve to an NTP server close to can be any colour and any form factor. We’ve used
your location. By being close to you, it should (in the classic 5 mm red LEDs that give a retro feel, but
theory at least) have a low latency and, therefore, 3 mm LEDs will give you a more compact design. You
you’ll get a more accurate time. However, for our could use surface-mount LEDs if you’re making it on
purposes, the difference between high- and low- a PCB. You could even get creative and use 3 V flex
latency servers should be irrelevant. LED ‘noodles’ to build a more abstract-looking clock.
Now we’ve got our time, we will need to create the We need five pins to display the hours (in 24-hour
hardware to display it. Here, it’s up to you what you format) and six each for minutes and seconds. That
want to do. We obviously need a lot of LEDs, but how means 17 LEDs in total on the GPIO pins 0 to 16.
you mount them depends on what you have and what We found it easiest to first solder the LEDs and
look you want to create. You could create a bare- resistors together, then put the LEDs in their holes,
and then solder the connectors to Pico W’s GPIO
pins and ground. One thing you need to be aware of
NEW TO MICROPYTHON? is making sure that there’s no risk of short circuits if
If you’ve not used MicroPython before, you have an exciting time ahead of you! It’s anything gets bent. We did this by covering the LED
a great way of programming Pico and Pico W with very little setup. It’s powerful, and positive leg and resistor in heat shrink. That way, all
user-friendly. There’s a quick guide to getting started at hsmag.cc/DocMicroPyth. For a the ground wires are exposed, but it doesn’t matter if
more in-depth guide, take a look at our book Get Started with MicroPython on Raspberry anything shorts between them. It would perhaps be a
Pi Pico, which you can download for free or buy in print at hsmag.cc/mpbook. bit more secure if the grounds were also protected –
it’s up to you how you set it up. If you don’t have heat
RASPBERRY PI 2 ND E D I T I O N
Retro Gaming with Raspberry Pi shows you how to set up a
Raspberry Pi to play classic games. Build your own games console
or full-size arcade cabinet, install emulation software and download
classic arcade games with our step-by-step guides. Want to make
games? Learn how to code your own with Python and Pygame Zero.
BUY ONLINE:
magpi.cc/store
English not your
mother tongue?
The MagPi is also available in German!
shrink, you could also cover it with electrical tape, but max_wait -= 1
given how much there is to do, it might be easier to print('waiting for connection...')
just get some heat shrink. time.sleep(1)
Now we’ve done the hardware, it’s time to turn our
attention back to the software. The main thing we if wlan.status() != 3:
need to do is convert the time as numbers into the raise RuntimeError('network connection
LEDs that we want to turn on and off. We’ve done failed')
this in a method called display_num. This method else:
takes two arguments: the number you want to print('connected') This tutorial is from
display, and a list of pins on which to display it. status = wlan.ifconfig() HackSpace magazine.
Each issue includes a
Converting a number to binary isn’t too hard. We’ve print( 'ip = ' + status[0] )
huge variety of maker
used enumerate(pins). This is a useful Python method projects inside and
when you want to loop through an iterable but still led.on() outside of the sphere
want a counter – as you can see, it returns both. simple_ntp.set_time() of Raspberry Pi, and
Each loop, we want to know if the number print(time.localtime()) also has amazing
remaining is greater than or equal to the current digit. led.off() tutorials. Find out
more at hsmag.cc.
If it is, we light that digit up and take the value of that
digit away from the number, if it’s not, we turn that def display_num(number, pins):
LED off and move to the next number. for counter, pin in enumerate(pins):
Since Pico W’s RTC can keep track of time, we can if number >= pow(2, len(pins)-
just grab the time when the computer boots up and (counter+1)):
let Pico W take care of the rest. number = number - pow(2, len(pins)-
Here’s our final code for the clock: (counter+1))
pin.value(1)
import network else:
import socket pin.value(0)
import time
import struct while True:
from machine import Pin display_num(time.localtime()[3], hour_pins)
import simple_ntp display_num(time.localtime()[4], minute_pins)
display_num(time.localtime()[5], second_pins)
led = Pin("LED", Pin.OUT) time.sleep(0.1)
ssid = 'your_ssid' This is a very bare-bones clock, but you can extend
Below
password = 'your_password' this basic timepiece in any way you like. You could We attached Pico W
add an alarm, a date function, a time control, or with hot glue, but you
could also use screws
hour_pins = [Pin(4,Pin.OUT), Pin(3,Pin.OUT), anything else you’d like to keep track of. in the mounting holes
Pin(2,Pin.OUT), Pin(1,Pin.OUT), Pin(0,Pin.OUT)]
minute_pins = [Pin(17,Pin.OUT),Pin(16,Pin.
OUT),Pin(15,Pin.OUT),Pin(14,Pin.OUT),Pin(13,Pin.
OUT),Pin(12,Pin.OUT)]
second_pins = [Pin(26,Pin.OUT), Pin(22,Pin.
OUT),Pin(21,Pin.OUT), Pin(20,Pin.OUT),Pin(19,Pin.
OUT),Pin(18,Pin.OUT)]
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
max_wait = 10
while max_wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
TOGRAPHY
ASTROPHO
aspberry Pi
with R
o ts o f th e c o s mos with your
h
Get stunning s ra M o d ule, and some
C a m e
Raspberry Pi, a g u id e Rob Zwetsloot
s te ll a r
smart code. By
L
ooking up at the night sky is something
we’ve been doing since ancient times,
with stars, planets, and moons shining
down from the cosmos to remind us that
there’s a whole universe beyond Earth.
Taking photos of the night sky to capture these
sights can be a little tricky, though.
This is where Raspberry Pi comes in. With
a range of excellent Camera Modules and
customisable automation, you can pretty easily
create a setup that will catch the wonders of
the night and the beauty of far-off celestial
bodies. It’s time to heed the call of the night.
y photography
Basic sk
h
smic shots wit
Get the best co
is-world tips
these out-of-th The HQ Camera
has a maximum
exposure time
of about
Y
Command-line code
ou can still get great shots without a
telescope, using just a Raspberry Pi HQ
03 With the right lens and knowledge
ten minutes
Camera, if you choose the right lenses and of exposure settings, we can start building a
program the shot in a specific way. command that works in libcamera. For
long exposures, we need to disable
some automatic control algorithms
for the best results. Overall, the
Choosing a lens
01 Without a telescope, you’ll probably be
command looks like this:
02 Exposure settings
A longer exposure
setting allows for more light to
Tip
be captured by the sensor. For
astrophotography, you normally The HQ Camera
want 15 to 30 seconds of exposure uses a C/CS-mount
so enough light data can be and M12 mounts for
captured. The libcamera library is lenses, so you can use
programmed in microseconds, so whatever lens you like,
this would be a value of 15,000,000 if it’s compatible
and 30,000,000 respectively.
ASTRO
68 Creating tos 70 Shoolescope
trail p h o a te
NAVIGATION
r trail photos
Create sta
d ti m e -l a p s e techniques
ure an
Use long expos ti fu l night shots
to cre a te b e a u
W
ith the basic setup, you’re able to
create a couple of kinds of classic
space shots – wonderful photos of
the night sky, or stylish star trails. With a
Python script, you can create the streaking star
effect created by the Earth’s rotation.
USB drive
Hardware T
aking a lot of
big pictures can
take up space
really fast
onal)
Screen (opti
i (any)
Raspberry P
i High
Raspberry P
era and lens
Quality Cam
You can use any
Raspberry Pi with
Power bank
a CSI port, which
means most
Raspberry Pi Zeros
and any standard
model. The newer
the better, though
S
ee the previous
page for tips on
what lens to get
– although the Y
ou’ll want to do
16 mm one will this outside, so
be more than a decent mobile
fine for this battery is essential
Software
s im p le P y th o n code that
Some
to ta k e a night full of
Tip
you can u s e
. P u t it o n y o ur USB drive
shots
Depending on how big
a USB drive you have
Setting up the software attached, you can always
01 For doing what is called a photo stack, star_trails.py increase the number of
photos and exposure time
we are going to be using the GNU Image
(up to 60 seconds), and
Manipulation Program (IMP) from gimp.org.
> Language: Python decrease the number of
Once you’ve installed that, you’ll also need seconds between shots!
a plug-in to create the stack. Grab this from
magpi.cc/starstack and follow the instructions. 001. #!/usr/bin/python3
002. import time
003.
004. from picamera2 import Picamera2
Get your photos 005.
02 Grab the USB drive with your photos and 006. picam2 = Picamera2()
put it into your PC. We suggest copying them to a 007. picam2.configure("still")
new folder on your PC to work with – make sure 008. picam2.start()
009.
Y ou might be able to 010. # Give time for Aec and Awb to settle, before disabling
them. Exposure time of 30 seconds
tailor the perfect shot 011. time.sleep(1)
012. picam2.set_controls({{"ExposureTime": 30000000,
you know where it lives! Once that’s done, open "AeEnable": False, "AwbEnable": False, "FrameRate": 1.0})
IMP, go to File > Create > Startrail. Set ‘Light 013. # And wait for those settings to take effect
Frames’ to the folder you put all the photos you 014. time.sleep(1)
want to use in, and click OK. 015.
016. start_time = time.time()
017. for i in range(1, 100): # 100 shots
018. r = picam2.capture_request()
More options 019. r.save("main", f"image{i}.jpg")
03 There are more options to play with, which 020. r.release()
you can find on the plug-in website, that can 021. time.sleep(300) # Five minute delay for timelapse
help you refine your photo. Take a look at them 022.
if you’re not satisfied with your result, and you 023. picam2.stop()
might be able to tailor the perfect shot.
LOCATION, You’ll obviously want to shoot at night, but where should you
shoot from? The best place is somewhere away from a city
LOCATION, or urban area where light pollution doesn’t affect the view
LOCATION
of the stars. The website gostargazing.co.uk has excellent
recommendations for places to visit.
h a telescope
Shooting wit
p h o to s o f d is tant objects
Get clear
le s c o p e a n d smart software
using a te
T
o take amazing photos of celestial
bodies, you need to be able to keep
them in view, which means moving
the camera. Luckily, with the right software,
hardware, and a Raspberry Pi, you can take
some amazing photos.
PiFinder
Hubble Pi A lot of modern telescopes can connect to
computers to help with tracking distant objects.
Student Santiago Rodriguez took a fairly Richard (aka ‘brickbots’) had been doing a
simple approach of setting up a telescope for lot of manual checking with paper and then a
astrophotography with Raspberry Pi – he merely commercial computer – he decided to build one
used an adapter for the eyepiece on a telescope based on Raspberry Pi.
so the HQ Camera could be plugged in. It uses a mixture of GPS positional data and
With that done, he created a special UI a visual feed from a HQ Camera to figure out
called AstroCam that allows him to point the exactly where the telescope is pointed, including
telescope at the right spot and then also control a custom interface so it can be controlled out in
some of the camera settings, like the ones the (literal) field.
we’ve previously discussed. It’s a lot cheaper “My hope is that other people will find this
as a result. combination of functionality useful, will build
“Most good USB cameras for astrophotography their own PiFinder, and help the whole project
start at about €200 and require a connected improve by making suggestions and potentially
computer at all times. Hubble Pi can also work contributing to the software. It’s a pretty easy
wirelessly, or as a standalone if needs be,” he build with off-the-shelf parts and beginner-
told us, when we interviewed him about it. friendly soldering,” Richard says on his website.
magpi.cc/hubblepi magpi.cc/pifinder
er
ophotography Autoguid
Astr
After spending many nights trying to get great
shots from stacked photos – and too many not
coming out very well – Joe Kutner decided to
program his own autoguider that could keep his
telescope pointing at the same celestial object.
magpi.cc/autoguider
EVENTS Sky has dates for all the major events in the
night sky. Take a look here: magpi.cc/astrocal.
Vizy
Pixy vizycam.com £280 / $259
SPECS
COMPONENTS:
Raspberry Pi 4 (2, This purpose-built AI camera combines Raspberry Pi
4, or 8GB RAM),
universal tripod with machine learning software. By Lucy Hattersley
mount, 32GB
V
microSD, 25 W
AC power supply, izy is an interesting camera product that A microSD card is pre-installed and all you need to
Vizy case (900 g; combines Raspberry Pi 4 with a Sony do is plug it in and press the button to turn it on.
10×15×10 cm)
camera and lens. This is housed inside a While there’s no fun in the build process, it
CAMERA: custom plastic case with heatsinks, a fan, and a is quick to get up and running. On first run, it
12-megapixel high-current I/O connection. uses Raspberry Pi’s Wi-Fi module to broadcast
Sony image Once it’s on your network, you can log in via a network, which you can join from another
sensor (IMX477),
a web browser pointing to vizy.local, and all the computer. You can also connect via an Ethernet
wide-angle,
3.25 mm M12 lens interaction takes place through this web-based cable, which was the approach we favoured.
(optional high- interface. Vizy has a laudable aim of making Once connected, you set up Vizy to automatically
quality 8-50 mm it easy for students and makers to explore AI- connect to a local wireless network so it connects
C/CS zoom lens), powered machine learning projects. whenever you boot up. Then, you can investigate
electronically
switchable IR-
the built-in software, divided into a range of apps
cut filter Vizy setup and examples.
Vizy comes self-assembled (you can choose Built-in apps include a Bird Feeder (identifies
I/O: between 2GB, 4GB, and 8GB Raspberry Pi inside). birds), MotionScope (captures the motion of
Digital I/O,
analogue I/O, objects), and Object Detector (detects
PWM, UART and logs classes with text alerts
serial; high- sent via Signal).
current output The examples are more simple,
(up to 1000 mA
including OpenCV Edge Detection,
per channel),
optional lighting Pet Companion, Pic Taker,
accessory TensorFlow Lite, and simple video
capture. You can investigate the
Python code for each example, to
help you start to build your own
apps. Detailed documentation
at docs.vizycam.com includes
a ‘Getting started’ guide, and
information about accessories and
applications, plus some simple API
information. You can access the
Python editor directly from the web
interface, or log into the Shell and
control Raspberry Pi directly.
These built-in programs
ensure Vizy is a great platform
for exploring machine learning
possibilities. We particularly liked
MotionScope, which captures the
Inside Vizy is a separate daughterboard offering I/O connections and a fan
to keep the unit cool movement of an object (such as a
72 magpi.cc Vizy
REVIEW
Vizy houses a
bouncing ball) and provides detailed x, y, and z
Raspberry Pi 4 and
co-ordinates as graphs and a data dump. We can camera inside a shell
with everything you
imagine this working incredibly well alongside need to get started
calculus learning. with machine learning
image projects
Meanwhile, the Object Detector and Bird Feeder
can be used to analyse and respond to scenes,
Verdict
the 1.5 m power lead to be a little short for some
setups, mainly when we tried to move out into
the garden for testing – although we note a Power
over Ethernet Splitter (£15/$18, magpi.cc/vizypoe) An interesting
camera that
that would work well in this setting. There is also
allows you to
an optional outdoor enclosure with IP66 rating quickly investigate
and a 4G LTE cellular network adapter. image recognition
Vizy provides you with a great introduction projects.
9
to image recognition that does a lot of the
heavy lifting, allowing you to focus on practical
Here, we are accessing Vizy to set up a pet detector
/10
projects. We think this would be ideal in a that sends alerts when a cat sits on the table (we are
classroom setting. using a stuffed teddy bear as a test unit)
Vizy magpi.cc 73
REVIEW
Meteor 10.1˝
IPS Capacitive
Touch Screen
Elecrow magpi.cc/meteor10 £91 / $110
SPECS
W
control
ith a trail of glowing RGB LEDs around Whether you appreciate the
PORTS & the edge and rear, the Meteor 10.1˝ RGB marquee lighting or not,
the screen quality is very good
CABLES: Touch Screen offers animated ambient
HDMI port, 2 ×
lighting with 19 selectable effects. It can prove
micro-USB
ports, HDMI
cable, micro-
a little distracting, though, so luckily there’s a
button to turn it off.
T here’s a mounting point
HDMI adapter,
2 × micro-USB
Another button enables adjustment of the on the rear to secure
backlight for the screen, which is plenty bright
to USB cables
enough at the higher settings. While 1200×800 Raspberry Pi to create an
OTHER: pixels for a 10.1-inch display might seem on the
Raspberry Pi low side (with a 143 PPI pixel density), in practice all-in-one unit
mounting point
it looks detailed enough, even when playing video.
with screws,
2 × plastic There’s no built-in speaker, though, so you’ll need rear to secure Raspberry Pi to create an all-in-one
stand legs a separate one connected to your Raspberry Pi. unit, complete with a two-part plastic stand.
One plus point is the full-size HDMI socket, so
you can easily plug in a Raspberry Pi using the Touch control
supplied cable – with a micro-HDMI adapter for Two micro-USB sockets need to be connected (via
Verdict Raspberry Pi 4. There’s a mounting point on the supplied cables) to Raspberry Pi’s USB ports to
supply power and enable touch control. An official
The RGB marquee PSU is advisable, otherwise the screen may be
lighting is a bit underpowered and keep switching off. In any case,
gimmicky, but the it shows ‘No signal’ at times while Raspberry Pi OS
picture quality is
is booting up, until the desktop appears.
good and touch
We found it fiddly to tap icons and window
control works well.
As a bonus, the controls, but this improved after changing the
screen can also be system default to ‘Larger screens’ to make
used with many them bigger. Pinch-zoom gesture control works
other devices. well enough, although a bit of jiggery-pokery is
8
needed in Raspberry Pi OS to enable right-clicking
with a long press. Unless you want to attach a
/10
physical keyboard, you’ll also need to install an
You can mount a Raspberry Pi on the rear
of the display using the supplied screws on-screen virtual one such as Onboard.
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
REVIEW
Alpakka
Input Labs magpi.cc/alpakka Free + cost of components
SPECS
LICENSES:
Open-source
A DIY controller that can be used like a mouse or a gamepad
firmware,
Creative
with extra buttons. Rob Zwetsloot get to grips with it
Commons
D
hardware
IY controllers are becoming more and being the final sandwiching of the parts to finish
INPUTS: more popular in the gaming space, the controller.
2 × gyro
especially when it comes to making Build quality is quite dependant on how you
sensors, 13 ×
face buttons, accessible controllers for folks with disabilities, print the controller, and also if you decide to
2 × sticks, 1 × and 3D printing has really made it easy to roll customise it before sending the STL over to your
scroll wheel, your own input system. printer. With all the electronic parts inside, it
6 × shoulder/
Alpakka has taken all this and gone a little does have a satisfying weight and, thanks to the
grip buttons
step further, creating a customisable controller compact design, it doesn’t feel loose and creaky
OTHER base for (mostly) free and showing you how to like other 3D-printed handhelds and controllers
FEATURES: put it together. We say mostly free because you we’ve used in the past.
Customisable, do have to buy some extra components and get
Raspberry Pi
Pico-powered
the PCB printed. However, even with a handful Game on
of components, you’re not spending more than a As for how it plays – if you’ve ever used
tenner, especially if you have a Raspberry Pi Pico 3D-printed controls before, you’ll know that they
lying around to power it. don’t afford as much comfort as other controllers
Ours came pre-assembled but the instructions with softer and smoother plastic. The right stick
are very clear, requiring you to flex only a few isn’t really supposed to act like a traditional right
soldering skills to put it together. stick, so it sits there as an awkward cube that
doesn’t give the best look in first- or third-person
76 magpi.cc Alpakka
REVIEW
basic, it is very good though. It’s great for more if you wanted to head down that route.
Verdict
We really like the
idea of Alpakka,
but if you want
to use it as a
main controller,
you will need to
start customising
7
it yourself.
/10
Alpakka magpi.cc 77
RESOURCES
10 Amazing:
Monitors
and displays
See what you’re doing with these
incredibly diverse add-ons
U
sing a Raspberry Pi without any sort of screen
is fairly common. However, if you want to show
something visually from Raspberry Pi, or even a
Raspberry Pi Pico, you’re spoilt for choice – not only in size Cosmic Unicorn
but also in type. Here are ten of our favourites.
IPS wide
touchscreen
Wide boy
If you need a display that is very wide
or very long, this 7.9˝ touchscreen with
a 16:5 aspect ratio is a great place to
start.
HyperPixel 4.0
4-inch touchscreen
What we consider to be the standard small display for a Raspberry Pi, the
HyperPixel 4.0 has been around for a while and is still top in its class.
Inky Impression
1.3˝ OLED
E-paper add-on
Tiny display This seven-colour display looks beautiful and uses very little power
to keep itself going. Great for more arty projects.
This tiny screen fits snugly atop a
Pico, with 64×128 pixels to play with.
It even has a couple of buttons!
magpi.cc/inkyimpression | From £50 / $60
Round LCD
Breakout
SPI colour screen
This tiny round screen attaches
to a Pimoroni Breakout Garden,
slotting into one of the many
ports in it.
magpi.cc/roundlcd
| £25 / $30
GFX HAT
Old-school charm
We have a soft spot for the Raspberry Pi Touch Display
GFX HAT, giving you a very
functional retro LCD display
Desktop ready
with six capacitive buttons
to boot. The official touchscreen slots into the DSI port on full-size Raspberry
Pi and can be made quite compact if needed.
magpi.cc/gfxhat
| £17 / $21 magpi.cc/touch | £69 / $83
FutureLearn
FutureLearn: FutureLearn is an online
AUTHOR
University programming, and is the online you are expected to apply what courses in web and games
equivalent to the most popular you’ve learnt by tackling a development, Python, and AI.
Price: module available to campus range of data sets in order to
Free attendees. The course is billed demonstrate your understanding
magpi.cc/cs50 as ideal for learning about of cybersecurity, cryptography,
“thinking algorithmically” and
solving problems efficiently. As
gaming, and forensics. Score
sufficiently highly on these
Websites
Places for advice and
additional prompts
STACK OVERFLOW
If your code is broken, or you
just can’t think of a way to
Trevor
Warren
An open-source advocate and community creator in Melbourne
W
e love High Altitude source growing up,” Trevor tells electronics into the hands
Ballooning (HAB) – us. “Linux was my gateway to of makers. Raspberry Pi
we’ve been covering learning more about computing did to the SBC market what
it in The MagPi basically as and how computers worked... the Arduino did to the
long as the magazine has been hardware was expensive and microcontroller market.
around. When Trevor emailed not really affordable in those “I have been lucky to
us about some launches he’d days, the only way to dabble have had some really great
been doing in Australia, we were with electronics was to build experiences growing up. These
keen to talk to him, finding everything yourself from scratch experiences have given me
out he’s set up several coding or use expensive commercial the skills, confidence, ability
and making-related volunteer platforms which cost an arm to build and grow community
groups over the years. and a leg. In many ways, organizations. I consider myself
“I have always been playing Arduino democratized [the] privileged to be able to set up
Preparng for launch with a
HAB filled just right around with Linux and open- learning of electronics, put and run these volunteering
groups (Melbourne Raspberry
Pi Makers Group, CoderDojo
Altona North, EMDRC High
Altitude Balloon Group) here in
Melbourne, Australia.”
MagPi
01
Monday
Amazing projects direct from our Twitter!
E
very Monday we ask the question: have you
02
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 – and remember to
follow along at the hashtag #MagPiMonday!
01.
The perfect gear for going clubbing with.
Your friends will always find you.
02.
We love these kind of upcycling projects –
and it’s a fun use of an old display!
03
03.
Infinity mirrors will always be fascinating
to us.
04. As well as looking cool, this is also a very
neat visualisation of how analogue
sticks work.
05. Always nice to give plants a fancy home.
06. This arcade stick looks great and, despite
its warnings, will not electrocute you.
07. A simple yet very useful project – we need
more little info screens in our life.
08. This soil moisture sensor project keeps
getting better.
09. Another happy robot-building customer.
05
04
06
08
07
09
Events in pictures
Raspberry Jams are back, and we have the photos to prove it
What better way to celebrate the birthday of Raspberry Pi than coding? The Astro Pi Kit gets a good workout here
What does the robot see? The meetups occur at the Docklands Makerspace & Library
88 magpi.cc Mondays
Coolest
This Month
Projects
are
infor
Raspberry
Pico
online! Pi
THIS MONTH IN RASPBERRY PI
Crowdfund this!
Raspberry Pi projects you can
crowdfund this month
UHF Reader
Raspled Digital Signage
“A Rain RFID module built into both models can scan up to 50 tags
per second within a 1.5-metres range. The Ultra-High Frequency Raspberry Pi is used in digital signage a lot – which is why you’ll
(UHF) band, which ranges from 840MHz to 960MHz, is where this sometimes see people post bemused pictures of a sign in an
device operates. One reader may interact with numerous tags at airport showing off its Raspberry Pi innards. Apparently, a lot make
once, fast, and within more than a metre of one another because of use of monthly fees for a very simple operation, which maker Angel
its wider read range than HF NFC scanners.” Rijo says won’t happen here.
kck.st/3SIgNYx kck.st/3ZFYvJr
N64 Digital
HDMI converter
Solar rover Train logger
Using older consoles with an analogue output
on modern TVs is fraught with various quality If there’s one way to explore the Australian User iHoller913 was interested to know if
issues. However, this amazing project uses a outback without being attacked by natural there was any pattern to the trains going by
Pico to convert the signal better than horrors, it’s through the safety of a video feed their home, resulting in this professional-
some solutions. attached to a remote-controlled robot. looking device.
Your
Letters
Raspberry Jams
I read about CamJam coming back and was wondering if the calendar
with all the Jams would be too? It helped introduce me to a few events Learn about
making interfaces
in my area a few years back, and was hoping I might find some more with Python with
if it came back. our excellent book
FREE
RASPBERRY PI
PICO W
Check out our astrophotography feature and
make amazing time-lapse photos like this
Contact us!
>
>
Twitter
Facebook
@TheMagPi
magpi.cc/facebook
Subscribe online:
>
>
Email
Online
[email protected]
forums.raspberrypi.com
magpi.cc/subscribe
Email: [email protected]
Price is charged at £35 sterling. The dollar price will depend on the exchange rate. Six issues and free
Pico W for £35 is also available in Canada and Europe. Subscription is for the next six issues and does
not renew automatically. This is a limited offer. 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…
01. Melbourne Raspberry Pi 03. Pi and More 13
Makers Group Meetup Saturday 22 April
Sunday 2 April Trier University of
Library at the Dock, Melbourne, Australia Applied Science,
magpi.cc/mrpmgm128 Trier, Germany
This meetup is open to everyone with an interest in magpi.cc/pam13
electronics, robotics, home automation, 3D printing, laser At Pi and More, beginners
cutting, amateur radio, high altitude balloons, space tech, and experts meet in a relaxed atmosphere for talks,
etc. Makers are invited to bring along their projects and workshops, and projects focusing on Raspberry Pi,
project ideas, and come embedded systems, and microcontrollers.
connect with other makers.
Get your questions answered, 04. Cambridge Raspberry Jam
show off the work you are Saturday 22 April FULL CALENDAR
doing, and get support to Makespace Cambridge, Cambridge, UK Get a full list of upcoming
community events here:
resolve nagging issues. magpi.cc/camjam128
CamJam is back! Cambridge Raspberry Jam (known as magpi.cc/events
02. Cornwall Tech Jam CamJam) is an event and meetup for those interested in
Saturday 15 April the Raspberry Pi family
Fraddon Village Hall, Saint Columb, UK of computing devices
magpi.cc/ctj128 and other technologies
Cornwall Tech Jams are run by volunteers working in IT which encourage
and education throughout Cornwall. They are supported making and education.
by Software Cornwall, its members and other local There will be a series
businesses. Our volunteers of talks, organised
give their own time and workshops for both the
expertise to plan each Raspberry Pi and Pico,
Cornwall Tech Jam and to the plus a ‘show and tell’
regular maintenance of all area for people to show
our equipment. off their projects.
04
03
02
RASPBERRY PI 01
STORE POP-UP
A
t this Raspberry Pi Store pop-up in
Southampton, you can experience
and buy Raspberry Pi products.
Explore some of the things you can do with
a Raspberry Pi, discover our accessories
04
and books, and get your hands on limited
edition exclusives.
If you’re lucky, you might spot Features
Ed. Rob!
02
magpi.cc/popup2023soton
SAVE UP
TO
ISSUE #65
OUT NOW
hsmag.cc
COMPETITION
WIN A
RETERMINAL
A product on our ever-
growing list of excellent
Raspberry Pi Compute
Module 4 products, reTerminal
is a hardened production
terminal for factories, or other
industrial-level monitoring. It’s
also modular, allowing you to
expand its functions.
Competition magpi.cc 95
AN INTRODUCTION TO
& GUI
PROGRAMMING
All you need to know
to write simple
programs in C and
start creating GUIs
Inside:
■ Create simple command-line C programs
■ Control flow with conditions and loops
■ Handle variables, strings, and files
■ Design graphical user interface
applications in C
■ Handle user input with buttons and menus
■ Use advanced UI features such as data
stores and dialogs
EDITORIAL
Editor
Lucy Hattersley
[email protected]
Features Editor
Rob Zwetsloot
[email protected]
Sub Editor
Nicola King
ADVERTISING
HOME
Charlotte Milligan
[email protected]
+44 (0)7725 368887
DESIGN
criticalmedia.co.uk
AUTOMATION
Head of Design
Lee Allen
Designers
Olivia Mitchell, Sam Ribbits
Illustrator
Sam Alder
WITH
CONTRIBUTORS
David Crookes, Ben Everard,
Rosemary Hattersley, Gordon
Hollingworth, Nicola King,
Phil King, KG Orphanides,
Eben Upton, Stewart Watkiss
RASPBERRY PI
PUBLISHING
Publishing Director
Brian Jepson
[email protected]
Director of Communications
Liz Upton
CEO
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
+44 (0)1293 312193
magpi.cc/subscribe
magpi.cc/subscribe
Raspberry Pi Ltd, Maurice Wilkes Building,
St. John’s Innovation Park, Cowley Road,
plays Doom
responsibility in respect of any omissions
or errors relating to goods, products, or
services referred to or advertised in the
Raspberry Pi
a Creative Commons Attribution-
fb.com/MagPiMagazine NonCommercial-ShareAlike
3.0 Unported
R
aspberry Pi is as much a events: Tech Jams, meetups, and computer is used for a wide range of
community as a computer, and maker space days. applications, from building robots to
I am utterly overjoyed to see running servers; playing retro games
the return of the brilliant Events Team huddle and automating your home. And, of
pages to this magazine (page 92). The Raspberry Pi community is a course, coding and computing for its
Rob Zwetsloot runs our vibrant place, where industrial own sake. I’m happy to mess around
community section and will be a makers, enthusiastic programmers, with some abstract concepts in
familiar face to most of you. Rob educators, and hobbyists all gather Visual Studio Code.
loves Raspberry Pi and our to discuss projects and share ideas. Perhaps the most important part
community and is – I’m sure – as This diverse group of people is of the Raspberry Pi community is the
happy as I am to see real-world brought together by a love of spirit of collaboration that brings
events taking place again. everyone together. Whether you’re a
Raspberry Pi itself is deeply T his diverse group total beginner or an experienced
connected with industry professional, everyone is welcome,
professionals and enthusiasts, and a of people is brought and everyone is encouraged to share
new Events section can also be their knowledge. This supportive
found on Raspberry Pi’s website together by a love atmosphere is reflected in the many
(magpi.cc/events). online forums, blogs, and social
Here, you’ll find Raspberry Pi at of computing and media groups that are dedicated to
industry trade shows and hobbyist
events. Kicking off with Embedded
the idea that making the Raspberry Pi and the projects
that can be built with it.
World 2023, where you can meet
Raspberry Pi makers. Eben Upton
makes the world a We’re currently in the midst of
our #MonthOfMaking event, but you
will be talking about “Raspberry better place can share whatever you’ve made
Pi: past, present, and future” with The MagPi team using
at the University of Cambridge computing and the idea that ‘making #MagPiMonday. Your build could
(magpi.cc/camfest), and we will makes the world a better place.’ make it into these hallowed pages.
be at the Write the Docs festival This love manifests itself via
in Portland, OR. You can also Raspberry Pi, because it’s the best
Lucy Hattersley
AUTHOR
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