[go: up one dir, main page]

0% found this document useful (0 votes)
583 views100 pages

Diy Home Automation: With Raspberry Pi

This magazine article discusses using Raspberry Pi for DIY home automation projects. It provides tutorials on installing home assistants, smart sensors, motorized mechanisms, and setting up a Raspberry Pi home security camera system. It also includes articles on using Raspberry Pi for fitness tracking and building a chatbot.

Uploaded by

Mark Penlington
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
583 views100 pages

Diy Home Automation: With Raspberry Pi

This magazine article discusses using Raspberry Pi for DIY home automation projects. It provides tutorials on installing home assistants, smart sensors, motorized mechanisms, and setting up a Raspberry Pi home security camera system. It also includes articles on using Raspberry Pi for fitness tracking and building a chatbot.

Uploaded by

Mark Penlington
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 100

BUY IN PRINT WORLDWIDE MAGPI.

CC/STORE

+UUWG /C[ OCIRKEE 6JGQHƓEKCN4CURDGTT[2KOCIC\KPG

DIY HOME AUTOMATION


WITH RASPBERRY PI
Install Home Assistants, Smart Sensors,
Moving Mechanisms and more! PICO
GARAGE
DOOR

KEEP FIT WITH


RASPBERRY PI

GET STARTED
WITH CAMERA
MODULE

CHATGPT:
BUILD A
CHATBOT!
magpi.cc/store

40 PAGES OF TUTORIALS & PROJECTS


WELCOME

WELCOME
to The MagPi 129

C
omputers should be put to work, and we think Home
Automation is a fun way to get our little computers
to do some heavy lifting. Our resident home-hacker,
PJ Evans, has put together a great feature about getting Lucy

EDITOR
Hattersley
Raspberry Pi to open the curtains, manage the garage door,
and turn the lights on (page 34). Lucy is editor of
The MagPi and is
Meanwhile, Rob Zwetsloot has written an excellent article currently arguing
the merits of good
on Getting Fit with Raspberry Pi (page 66). It’s the perfect wine over beer
to a massively
way to combine Raspberry Pi’s mental stimulation alongside unreceptive bunch
of techies. She’s
looking out for your physical health. I’ll leave you to it. almost been run
out of the company.
Meanwhile, we’ve got some amazing projects this month. Anyway, beer
next month!
KG Orphanides is on-the-ball with a tutorial on how to set up
magpi.cc
ChatGPT API on Raspberry Pi (page 42), there’s also a LEGO
brick that plays DOOM (page 16), and a Clamshell BlackBerry
Cyberdeck (page 18).
This issue is as packed as ever, and it’s been an absolute
pleasure to make. I hope you enjoy it as much as we do.
GET A
RASPBERRY PI
PICO W
Lucy Hattersley Editor PAGE 28

magpi.cc 03
CONTENTS

Contents
> Issue 129 > May 2023

Cover Feature

34 DIY Home 34
Automation
Regulars

30 Case Study: Freight Farms


90 Your Letters
92 Community Events Calendar
97 Next Month
98 The Final Word

Project Showcases
08 Shiloh Studios
12 ClippyGPT 18
16 Doom on a LEGO brick
18 Clamshell BlackBerry cyberdeck
22 Greening the Spark
24 Bugg.xyz acoustic monitoring

16

Doom on a LEGO brick Clamshell BlackBerry cyberdeck

The MagPi is published monthly by Raspberry Pi Ltd, Maurice Wilkes Building, St. John’s Innovation Park, Cowley Road,
Cambridge, CB4 0DS, United Kingdom. Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701, is the mailing
agent for copies distributed in the US and Canada. Application to mail at Periodicals prices is pending at Williamsport, PA.
POSTMASTER: Send address changes to The Magpi, c/o Publishers Service Associates, 2406 Reach Road, Williamsport, PA, 17701.

magpi.cc 05
CONTENTS

Tutorials 50 54
42 Build your own GPT Chatbot
46 Introduction to inputs and outputs
50 Bluetooth music visualiser
54 Camera Module: Getting Started Create a Bluetooth Camera Module:
60 RFID spells fun music visualiser Getting Started

The Big Feature 74


66

PicoBricks

)GVƓVYKVJ4CURDGTT[2K 84
Reviews
72 Compute Blade
74 PicoBricks
77 10 amazing browsers
81 Learn Sense HAT

Community
84 Brian Jepson interview
88 This Month in Raspberry Pi Brian Jepson interview

WIN GLOBAL SHUTTER 95

1 OF 5 CAMERA MODULES
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
QER]SJXLIXSTMGWMR8LI2EK5MQEKE^MRIEVIHMǺIVIRXFIX[IIRGSYRXVMIWERHEVIEP[E]WWYFNIGXXSGLERKI=SYEVIVIWTSRWMFPIJSVYRHIVWXERHMRKXLIVIUYMVIQIRXWMR]SYVNYVMWHMGXMSR
and ensuring that you comply with them. Some manufacturers place limits on the use of their hardware which some projects or suggestions in The MagPi magazine may go beyond. It is
your responsibility to understand the manufacturer’s limits.

06 magpi.cc
PROJECT SHOWCASE

Shiloh
Lights can be controlled
from the touchscreen in
the control room and in

Studios
the individual rooms

Upgrading a professional music


studio can be as easy as pie
with Raspberry Pi. Rob Zwetsloot
books a session

Michael Peters

W
MAKER

hen you need to add remote control and


Michael has been automation that is easily customisable,
an IT executive, as readers of The MagPi, you’ll
TSPMGISǽGIVERMQEP understand the desire to do it with Raspberry Pi,
GSTQYWMGMERERH
QYWMGTVSHYGIV
which is what Michael Peters of Shiloh Studios
ʭR`]POZ`__ZZ
“Shiloh Studios is a Dante-based audio
production facility which leverages the latest
technology best practices and solutions to ensure
the highest-quality experience and outcomes Pi’s ecosystem when I need to solve problems
for its clients,” Michael says. “As the studio _SL_L]PYɪ_]PLOTWdLOO]P^^POMdLYZʬ_SP^SPWQ
project design was unfolding, several challenges hardware solution, or it doesn’t make sense to
were encountered. After extensive research and implement costly proprietary control systems.”
assessment of numerous potential solutions,
Darrell Raspberry Pi hit all the marks as the answer.”
I gravitate toward Raspberry
MAKER

Lehman ?SPOTʬP]PY_=L^[MP]]d;T^ZW`_TZY^bP]P[`WWPO

&YHMSVIGSVHMRK
ZʬMd/L]]PWW7PSXLYLW^ZZQ>STWZS>_`OTZ^bSZ Pi’s ecosystem when I need
has been making Raspberry Pi-based projects
IRKMRIIV&:1
W]WXIQWMRXIKVEXSV QZ]ZaP]ʭaPdPL]^LYOSL^MPPYbZ]VTYRbT_S to solve problems
ERHQYWMGMER-I electronics for over 25 years.
EPWSWIVZIWMRVSPIW
EWETLSXSKVETLIV
“I’ve completed a lot of prior projects on Musical fruit
ZMHISKVETLIV Raspberry Pi with touchscreens, [Power over There’s four main ways that Raspberry Pi is used
ERHRIX[SVO Ethernet], TouchOSC, and Node-RED, so at Shiloh Studios. First of all, as a lot of things
EHQMRMWXVEXSV Raspberry Pi was a familiar and easy choice,” are connected via Ethernet, a Raspberry Pi helps
shilohstudios.us Darrell explains. “I gravitate toward Raspberry monitor those connections.

08 magpiGG Shiloh Studios


PROJECT SHOWCASE

The main control screen is


mounted on an arm so it can be
moved around the control room

Quick FACTS
> )ERXIRIX[SVOMRKMW
EWXYHMSWXERHEVH

> …that can have


 &
 GYWXSQMRXIVJEGI ^IVSPEXIRG]
MWYWIHJSVXLIPMKLX SZIVc*XLIVRIX
GSRXVSPW[MXLXLIWXYHMS
ZIVWMSRFIMRKXLI
QEWXIVGSRXVSPPIV > *XLIVRIXMWYWIH
XLVSYKLSYX
XLIWXYHMSEWE
WXERHEVHGSRRIGXSV

> 1MKLXWMRXLIWXYHMS
YWI7,'1*)WWS
GERGLERKIGSPSYV

> 8LIVIQSXI
WGVIIRWEVI
MRHITIRHIRX
FYXXLIVIMWE
QEWXIVVIQSXI

Shiloh Studios magpiGG 09


PROJECT SHOWCASE

Building remote controllers

Installing a Raspberry Pi and a PoE HAT into


01 the back of a touchscreen allows for minimal
cabling needed to get everything running.

 8LIWGVIIRWMRWXEPPIHMR There’s also a system for full remote control


XLIHMǺIVIRXVSSQWGER
EGXMRHITIRHIRXP]SJ over the lighting systems, with remote screens
XLIQEMRWGVIIR in multiple rooms. Similarly, there’s remote
NZY_]ZWZQ=/7OPaTNP^TYaL]TZ`^^_`OTZ]ZZX^^Z
performers can listen to audio live.
The last main way is a USB to Ethernet
connected keyboard, as Michael explains: “to
Once each is set up, custom Node-RED
02 code is created to work with TouchOSC, facilitate the composer client’s needs, a Native
so everything communicates properly between Instruments S88 keyboard was placed in the
remotes and the lights. NZY_]ZW]ZZXM`_T_LW^ZYPPOPO_ZMPʮPcTMWd
deployable to allow relocation to other studio
spaces as needed. The S88 requires a USB
connection to the DAW [Digital Audio Workstation]
PC. Twisted pair to USB converters were not
]PWTLMWd^`ʯNTPY__Z_SPNL`^P7ZYR@>-NLMWP^

Apparently, the hardest step was wall


03 brackets, although they ended up quite
 *
 ZIV]XLMRKMWZMWMFPIFYX
simple in this case anyway. HSIWRSXFPSGOXLIZMI[
SJSXLIVMRXIVJEGIW

10 magpiGG Shiloh Studios


PROJECT SHOWCASE

 8LIOI]FSEVH
GSRRIGXMSRQEOIW
YWISJFIXXIV*XLIVRIX
GSRRIGXMSRWSZIVE
PSRK9'GEFPI

posed a similar liability. Raspberry Pi 4 with a


PoE HAT provided the right solution by enabling a
rock-solid USB to Ethernet connection.”
“I would say construction was probably the
easiest part of the project because Raspberry Pi
has such a great ecosystem of add-ons available
online,” Darrell tells us. “And for each accessory
that I needed, I had options to choose from.
The most challenging part of the construction
bL^ʭR`]TYRZ`_SZb4bLY_PO_ZM`TWO_SP
wall brackets.”

I would say construction


was probably the easiest
part of the project
On tour
On a digital tour of the studio, the various The latency over Ethernet is very impressive –  8LIQSRMXSVWERH
VIQSXIWFIMRKXIWXIH
Raspberry Pi implementations had a great three milliseconds for the keyboard connected over ERHTVSKVEQQIH
[]ZQP^^TZYLWʭYT^SLYO_SP@4N]PL_POQZ]_SPWTRS_ Ethernet even – and Raspberry Pi is able to help FIJSVIHITPS]QIRX

remote looked and worked just like we’d expect control over 256 interfaces around the studio.
from tablets with apps, or touchscreen products Perhaps the next step will be an entire DAW
^[PNTʭNLWWdXLOPQZ]_SL_`^P made with Raspberry Pi.

Shiloh Studios magpiGG 11


PROJECT SHOWCASE

ClippyGPT
Clippy is back! And this time we’re really glad to
see and hear from Microsoft’s iconic character,
as David Crookes explains

T
rying to think of something to write can be
hard (a fact that feels very much true right
YZbRTaPY_SL__ST^T^_SPʭQ_S^_LML_
penning an intro!). But imagine how much harder
writing would be if you had a peppy paper clip in
dZ`]PdPWTYPNST][TWdZʬP]TYRSTY_^LYO_T[^ɭ/Z
dZ`YPPOL^^T^_LYNPɮT_bZ`WO^LdL^^ZZYL^dZ`
^ZX`NSL^_L[[POL^TYRWPWP__P],YOTQdZ`OTOYɪ_
David
MAKER

YPPOSPW[]TRS_L__SL_XZXPY__SPYT_ɪOMP^`]P
Packman _ZL^VdZ`LRLTYWL_P]
David Packman is 1Z]`^P]^ZQ8TN]Z^ZQ_ɪ^:ʯNP$"_ST^MPNLXP
a former Microsoft L]PLWT_dNZ`]_P^dZQLYɩTY_PWWTRPY_ɪ`^P]TY_P]QLNP
program manager NLWWPO.WT[[dbSTNST_ɪ^QLT]_Z^Ld^[WT_Z[TYTZY
responsible for
-`_PaPY_SZ`RS?480XLRLeTYP]PNVZYPOT_bL^
chatbots, virtual
assistants, and AI ZYPZQ_SP bZ]^_TYaPY_TZY^ZQLWW_TXP_SP]P
copilot projects, SLaPMPPY]PaTaLW^4YQLN_L^bPWWL^MPTYRLMWP
who builds Fishing line connected to
_Z]PWTaP_SPXPXZ]TP^ZQ.WT[[daTLL^_TNVP][LNV
companion robotics a couple of servo motors is
in his spare time. QZ]8TN]Z^ZQ_?PLX^dZ`NLYYZbLW^ZPYUZdL
used to move the eyebrows
RZZOZWOYL__P]bT_S_SPNSL]LN_P]_SLYV^_Z/LaTO
magpi.cc/
clippygpt ;LNVXLYLYOL=L^[MP]]d;TNZX[`_P]
-dNZXMTYTYR.WT[[dbT_S.SL_2;?_SP,4
NSL_MZ__SL_T^^_TWW_LVTYR_SPbZ]WOMd^_Z]X
/LaTOSL^M]Z`RS_8TN]Z^ZQ_ɪ^NSL]LN_P]MLNV_Z
WTQPTYL[Sd^TNLWQZ]XLYORTaPY`^P]^_SPLMTWT_d
_ZSZWOLNZYaP]^L_TZYbT_ST_?SP]P^`W_T^L NZX[ZYPY_^_SL_SL^MPPYSL]O_ZTX[WPXPY_T^
OT^_TYN_TaPQ`Y,4[ZbP]POOTRT_LWL^^T^_LY_ɭ,WW Z[PYPYOPONZYaP]^L_TZYLWNL[LMTWT_dɮSP^Ld^?Z
_SPXPXP^LMZ`_.WT[[dMPTYR.SL_2;?TYOT^R`T^P _SL_PYOSPɪ^QZ`YOT_NSLWWPYRTYR_ZSL]ONZOPL
NZYaTYNPOXP_SL__SPʭ]^_.SL_2;?PX[ZbP]PO XLY`LWWdN`]L_PONSL_MZ_TY_ZL]ZMZ_TNM`TWOM`_
NZX[LYTZYMZ_4^SZ`WOM`TWObZ`WOMPLOP^V_Z[ ^Ld^.SL_2;?bL^_SPLY^bP]
.WT[[dɮ/LaTO^Ld^ ɭ.ZYaP]^L_TZYLWWL]RPWLYR`LRPXZOPW^WTVP
.SL_2;?L]PLRLXPNSLYRP]P^[PNTLWWdQZ]
Chatty man ^ZNTLW]ZMZ_TN^^Z4bL^VPPYWdTY_P]P^_POTY
/LaTOSL^WZYRMPPYTY_P]P^_POTY]ZMZ_TN^LYO TY_PR]L_TYR_ST^YPb_ZZWTY_ZL]ZMZ_TN^M`TWOɮ
NSL_MZ_^ɭ4ɪaPMPPYM`TWOTYR]ZMZ_^L^L^TOP SP^Ld^ɭ4bLY_PO_Z`^PT_L^L_P^_NL^P_ZʭYO
[]ZUPN_bT_SLQZN`^ZYNZX[LYTZYZ]^ZNTLW _SPMP^_L[[]ZLNSQZ]OZTYR_ST^ZYLM`ORP_
]ZMZ_TN^QZ]LQPbdPL]^YZbLYOZYPZQ_SPVPd 4_LWW^_PX^Q]ZXXdOP^T]P_ZN]PL_PSPW[Q`W

12 magpi.cc ClippyGPT
PROJECT SHOWCASE

Quick FACTS
> Microsoft’s Clippy
was formally
called Clippit

A 3D-printed speech > .X[EWIǺIGXMZIP]


bubble surrounds the E\IHEJXIVǻZI
5-inch HDMI display years, in 2001

> David’s build cost


about $125 in parts

> His version of


Clippy moves
and talks...

> ...but he shows how


to make a non-
moving version

Raspberry Pi connected
to an Adafruit Crickit
HAT sits inside the base

]ZMZ_^_SL_NLYSPW[[PZ[WPbSZSLaPOTʯN`W_d
^ZNTLWT^TYRZ]NLYYZ_WPLaPSZXPO`P_ZTWWYP^^Z]
Z_SP]^T_`L_TZY^ɮ
;L]_ZQ_ST^O]TaPT^[P]^ZYLW-PTYRLMWP_ZRTaP
[PZ[WP_SPLMTWT_d_ZXLVPQ]TPYO^Z]N]PL_P]ZMZ_^
_SL_NLYSPW[bT_S_L^V^NZ`WOMPZQL^^T^_LYNP
_ZST^^ZYbSZSL^^[PNTLWYPPO^LYOʭYO^
^ZNTLWT^TYROTʯN`W_ɭ4ɪaPLWbLd^bLY_PO_ZSPW[
STXXLVPQ]TPYO^ɮ/LaTO^Ld^ɭ,NZYaP]^LY_
NSL_MZ_`^TYRLYTYPc[PY^TaP,;4]PLWWdLOaLYNP^
_SL_LTX^Z4SLO_ZʭR`]PZ`_SZbLYO_SPY^SL]P
What’s behind the eyes? Among the components
_SL_bT_SZ_SP]^ɮ is a spring from a retractable pen, cut in half

ClippyGPT magpi.cc 13
PROJECT SHOWCASE

As this shot from


behind shows, the
Say it again
audio is emitted from ,__SP]ZMZ_ɪ^SPL]_T^L=L^[MP]]d;T8ZOPW-
the base box.
NZX[`_P]bSTNSSP_ZZVQ]ZXLYZWOP]]ZMZ_
M`TWOVYZbTYR_SL_T_bL^NZX[L_TMWPbT_SZ_SP]
NZX[ZYPY_^SPZbYPO:YP^`NSLOOZYbL^_SP
,OLQ]`T_.]TNVP_3,?_SL_PYLMWP^_SPN]PL_TZYZQ
]ZMZ_Q]TPYO^`^TYR;d_SZYMdLWWZbTYRXZ_Z]^
^P]aZ^Z]^ZWPYZTO^_ZMPNZY_]ZWWPOɭ?SP]PbP]P
^ZXP^ZQ_bL]PWTM]L]dOP[PYOPYNTP^_SL_XLOPT_ PdPM]Zb^bSTNSSPW[_ZM]TYR_ST^]P_]ZN`W_`]LW
PL^TP]_Z`^P=L^[MP]]d;T:>L^bPWWɮSPLOO^ TNZY_ZWTQP
?ZSLYOWP^[PPNS/LaTO_`]YPO_Z8TN]Z^ZQ_ ɭ?SPLYTXL_]ZYTN^L]P[]P__d^TX[WT^_TN
,e`]Pɪ^^[PPNS^P]aTNP^?ST^LWWZbPOSTX_Z LW_SZ`RST_bL^LMT_ZQLMZORP_ZRP__SPPdPM]Zb
NZYaP]_^[PPNS_Z_Pc_LYOaTNPaP]^LbT_S/LaTO XPNSLYT^X_ZbZ]V^TYNP_SPOT]PN_TZYLWQZ]NP
ʭYOTYR_SPQ]PP_TP][]ZaTOPOLWW_SPNL[LMTWT_d SL^_ZbTYO_S]Z`RS^ZXPN`]aPO[L^^LRP^
SPYPPOPO_Z[]ZaTOPL^[PPNSTY_P]QLNPbT_S
.SL_2;?ɭ4_LW^ZSL^_SPMPYPʭ_ZQ]PNZRYT^TYR
LYZʰTYPbLVPbZ]OɮSP^Ld^ɭ>ZYZ_STYR The animatronics are
T^]PNZ]OPOZ]^PY_ZaP]_SPTY_P]YP_`Y_TW4
^[PNTʭNLWWdLN_TaL_PT_ɮ pretty simplistic
/LaTOLW^ZXLOP`^PZQ_SP:[PY,4;d_SZY
WTM]L]d_Z]`Y_SP.SL_2;?\`P]TP^ɭ?SP:[PY,4 TY^TOP.WT[[dɮ/LaTO^Ld^ɭ4Y_SPPYO4`^POL
,;4NLWW^L]P_SPZYWdPc[PY^PM`_T_ɪ^[]P__d _PNSYT\`P_SL_bP`^P_ZM`TWO/[]TY_POL^^T^_TaP
NSPL[QZ]LM`TWOWTVP_ST^ɮSP^Ld^ OPaTNPSLYO^bSTNST^ʭ^STYRWTYP
ɭ:YPOLdZQSPLad`^LRPbL^ ɭ?ZNZ`Y_P]_SP[`WWZQ_SPWTYP^4LW^ZSLO
ZYWdPTRS_NPY_^,W^Z_SP;d_SZY _ZOP^TRYL^[]TYRXPNSLYT^X_Z]P_`]Y_SP
>[PPNS=PNZRYT_TZYWTM]L]dT^ XZaPXPY__ZL^_L]_[Z^T_TZYLQ_P]_SP^P]aZ^
WL]RPWdM]ZVPY^ZT_bL^L ]PWPL^P_SP_PY^TZYZY_SPWTYP^4NZ`WOYɪ_`^P
very appealing alternative with MLYO^^TYNP_SL_bZ`WO[`WW_SPXPNSLYT^XZ`_
Pc_]LMPYPʭ_^ɮ ZQ_SP^ZNVP_^TY_SPMLNV^Z4]P^Z]_PO_Z_SPZWO
^_LYOMdZQ`^TYRNZX[]P^^TZY^[]TYR^Q]ZXZWO
Getting animated ]P_]LN_LMWPTYV[PY^1]ZXLNZOTYR[P]^[PN_TaP
,VPd[L]_ZQ_SPbSZWPM`TWOSL^ LOOTYRXZaPXPY__Z_SPNZYaP]^L_TZYLWL^[PN_T^
MPPY_SPLYTXL_]ZYTN^BSTWP.WT[[dɪ^ ]PWL_TaPWdPL^dɮ
^[PPNST^Z`_[`__PO_ZL^[PPNSM`MMWPP^^PY_TLWWd
You can download all
SJXLI81ǻPIWERH L/[]TY_PONL^P^`]]Z`YOTYRL TYNS3/84 Looking ahead
ERSǾMRI[EOI[SVH 4YLWW_SPM`TWO_ZZV/LaTOLbPPV_ZNZX[WP_P
OT^[WLdʭ__PObT_SL^LWaLRPO^[PLVP]Q]ZXLY
training table from
David’s Hackster page ,XLeZY0NSZ/Z__SP[L[P]NWT[SL^bTRRWTYR 3PbL^LMWP_ZOZ_ST^bT_SL^TYRWP;d_SZY^N]T[_

14 magpi.cc ClippyGPT
PROJECT SHOWCASE

Bringing Clippy to life

Once the keyword is recognised (this


01 ĜŸϱųųĜåÚŅƚƋŅÿĜĹåƚŸĜĹč±ĩåƼƵŅųÚ
recognition routine and a locally stored training
model table), a speech recognition routine runs
and Clippy gives its eyebrows a wiggle! It’s
ųå±ÚƼƤƋŅƤĘåĬŞú

ɭ,YO4OTOT_TYLbLd_SL_XLOPT_]PLWWdPL^d What’s behind those


eyes? A close-up of
_ZTY_PR]L_PTY_ZLYd[]ZUPN_TYZ]OP]_ZM`TWO XLIǻXXMRKW
^ZXP_STYR_SL_bL^XZ]PPYRLRTYRLYO[P]^ZYLMWP
_SLYU`^_LNLYYPO^[PLVP]bT_SLXTN]Z[SZYPɮ
/LaTO^Ld^SPT^YZbTY_PR]L_TYR_SP_PNSYT\`P^
TY_ZXZ]PNZX[WPc]ZMZ_TNM`TWO^^`NSL^L Once everything is
connected, a USB
NZYaP]^L_TZYLWNZX[LYTZYMZ_ML^POZY-8:Q]ZX
microphone is slotted
_SP.L]_ZZY9P_bZ]Vɪ^Adventure Time animated into the front of the case
_PWPaT^TZY^P]TP^LYOLNZ`Y_P]_Z[VT_NSPY]ZMZ_
After listening to what is spoken until there
NLWWPOBST^V]e 02 is a pause in the speech, there are more
ɭ?SL_bTWWTYNW`OP^ZXPXLNSTYPaT^TZY_ZSPW[ movements to let the user know the question has
TOPY_TQdTYR]POTPY_^^`RRP^_TYR]PNT[P^ZYbSL_ been heard. The speech is transformed into text and
dZ`^SZbT_LYOOZ^TX[WP_L^V^^`NSL^XTcTYRɮ the speech recognition stops listening.
/LaTOLOO^ɭ4ɪaPWPQ__SPM`TWO^TX[WP^Z_SL_
T_ɪ^PL^dQZ]Z_SP]^_ZLOU`^_LWWZbTYR_SPX_Z
XLVPXZ]PNZZW_STYR^bT_ST_?SP]PL]PWZ_^ZQ
TX[]ZaPXPY_^_SL_NLYMPXLOPML^POZYbSL_
dZ`YPPOɮ

The text is sent to ChatGPT as a prompt and


03 the text answer is sent to the next routine.
The text is then fed into the Text-To-Speech routine
which displays the response on the screen and
ųåŞĬ±ƼŸƤĜƋƤ±Ÿ±ƚÚĜŅţ

ClippyGPT magpi.cc 15
PROJECT SHOWCASE

Doom on a LEGO brick


If you have an appreciation of both LEGO and 1990s video games, read on.
Nicola King digs out her glasses to admire a minuscule make

W
e’ve seen portable games projects rear panel has just enough room for a micro USB
before, but nothing quite this small! socket. The other three panels have castellated
Maker James Brown took on the huge edges to provide “the mechanical and electrical
challenge of embedding a playable game of the NZYYPN_TZYLYONLYMPOP^TRYPOL^L^TYRWPʮL_
NWL^^TNʭ]^_[P]^ZY^SZZ_P]/ZZXTYL702:M]TNV circuit which is later chopped up to make the
powered by Pico’s RP2040 chip and featuring a 3D frame.”
tiny OLED screen. Once James had assembled the circuit, he put it
James makes clear that it was an iterative in a silicone mould to be encapsulated with epoxy
James Brown
MAKER

[]ZNP^^ZaP]XLYdXZY_S^?SPʭ]^_aP]^TZY resin. The biggest headache was getting the resin


(XLR[TNNʭ]^_WPRZM]TNV) was “very simple and layer over the screen just right: “It needs to be
James lives in
YZ_[L]_TN`WL]WdbPWW[WLYYPO4ʭR`]PO4ɪOXLVP aP]d_STYL]Z`YOXXMZ_STYZ]OP]_Zʭ_TY
Wellington, New
Zealand, has a L_TYdNZX[`_P]L__LNSLť:70/bSTNSU`^_ the space between the outer surface and the studs
background in ZYWdU`^_ ʭ_^TY_SPQLNPZQL702:^WZ[PM]TNV of the bricks below, but also to be clearly visible.”
games and graphics and somehow encapsulate it in resin to look like
programming, and
creates interactive
the original. So, I drew up a PCB as big as I Doom’s day
exhibitions. could go without it sticking out, populated it with Sparked by questions from social media as to
_SP^XLWWP^_XTN]ZNZY_]ZWWP]4NZ`WOʭYOTY^_ZNV whether his LEGO creation could run Doom,
magpi.cc/ancientj
at JLCPCB (jlcpcb.comLYO^PY_T_Zʬ_Z James investigated the possibility but had initial
be manufactured.” issues running video on the screen. After some
After the project garnered a positive response, tinkering, he “took advantage of the RP2040’s
he sought to make it accessible to more people. second core to update the screen fast enough to
The question was, how could he create a version
that could support a USB connection and be
reprogrammed interactively? “RP2040 ticked
The biggest headache was
all the boxes,” he shares, “and (crucially!) getting the resin layer over
was available.”
the screen just right
3D construction
James ended up with a 3D PCB structure, taking create greyscale images (magpi.cc/ugrey).” With
bSL_SPɪOWPL]Y_Q]ZX_SPʭ]^_T_P]L_TZYLYO Doom now a practical proposition, James looked to
improving it: “By soldering together a complete Graham Sanderson’s “amazing” work on a Doom
frame of PCBs, I get a very precisely machined port, did a “horrible quick hack” and it now runs
brick shape, contacts for the battery, and a USB MPL`_TQ`WWd_TNVTYRZʬɭLYZ_SP]PY_]dZYɩ_STYR^
port tucked away inside.” that run Doom’.”
The frame consists of four panels, with the Seeking to improve the pocket-sized project
front one containing the driving forces including further, he’s now working on adding an internal
_SP=;L8-ʮL^SNST[N]d^_LWZ^NTWWL_Z] battery. “I found some rechargeable cells which
LYOť>;4:70/^N]PPYɭ1Z`]W`R^ZY_SP NZ`WOʭ_M`_ZYWdTQ4]PXZaP_SP@>-[Z]_LYO
front panel provide the physical mounting I’m still looking for a neat solution for this.”
points,” explains James, “as well as the electrical As well as making a test board to try out the
connections to the rest of the panels – two for battery and charging circuit, James has copy-
power, two for data.” pasted the LEGO brick’s computer module onto it
With 9 V contact strips on the side panels, along “to make a wearable ring (magpi.cc/doomring)
with a voltage regulator and some diodes, the which can run all the same code as the bricks.”

16 magpi.cc Doom on a LEGO brick


PROJECT SHOWCASE

As well as tilt
control, there are
two capacitive touch
buttons in the studs

The tiny monochrome


OLED screen has a Quick FACTS
72×40 resolution
> James made this
video showing
the build process:
magpi.cc/
Based around RP2040, brickassembly
the 3D PCB frame
base is cast in epoxy > The project took
resin to form the brick “a good four
months of failures
and iteration”

> He built a lot of


little jigs to place
the parts precisely
during the build

> The LEGO brick is


currently powered
externally via USB

> Game controls


comprise
capacitive touch
studs and an
accelerometer

The main PCB panel with RP2040 (left), which


is built with the others into a 3D frame (right)

Doom on a LEGO brick magpi.cc 17


PROJECT SHOWCASE

Clamshell
BlackBerry
cyberdeck The HyperPixel screen is
powered via Raspberry Pi 4’s
GPIO pins – a critical factor
that helps keep everything
Keeping things as compact as possible drove extremely compact

the design of this hinged Raspberry Pi 4-based


tiny computer, discovers Rosie Hattersley

A
^dZ`XTRS_TYQP]Q]ZXLbZ]O[]PʭcPO
with ‘cyber’, cyberdecks have their origins
TY_SPbZ]WOZQ$#^^NTPYNPʭN_TZY
This particular version, however, harks back to
the early 2000s when PDAs were a must-have
business accessory, but the iPhone (and as such,
smartphones) had yet to launch. Maker Michael
Klements chose a clamshell version of a BlackBerry
Michael
MAKER

and paired it with Raspberry Pi 4 for maximum


Klements
computing power, aiming for “a functional
Michael is a desktop computer with a GUI”.
mechanical engineer Michael has tackled a fair few Raspberry Pi and
who often shares other microcontroller projects over the years.
his inventive ideas
and Raspberry Pi As well as the sheer number of projects that can
creations on his be undertaken, he notes the helpfulness and
YouTube channel. knowledge of the Raspberry Pi community when a
magpi.cc/ build proves especially challenging. The BlackBerry
michaelklementsyt clamshell cyberdeck project provided the sort
of learning opportunity he enjoys and, while he
would probably have chosen it anyway for its
computing chops, this project became a Raspberry
Pi one by default since the HyperPixel 4.0 display
he would need for the upcycling challenge
currently works only with our favourite single-
board computer. Michael realised there was a real computer that vaguely resembled a tiny laptop,
advantage to using the HyperPixel 4.0 screen, as Michael set about sourcing a suitable keyboard.
it could be powered entirely via Raspberry Pi’s “Most keyboards, even compact and foldable ones,
GPIO pins. This had space-saving advantages, L]P_S]PP_ZQZ`]_TXP^MTRRP]_SLY_SPʭYLWM`TWO
since there would be no need for an external power size that I was going for – and you’d still need to
supply or to connect to a DSI or HDMI port. add a mouse to that,” he explains. A Tindie store
selling keyboards from old BlackBerry mobile
Fruitful enterprise phones, paired with a custom carrier board so the
Having solved the screen and power conundrum, trackpad and keyboard act as a USB connected
for what he hoped would be an all-in-one mouse and keyboard, proved a winning purchase

18 magpi.cc Clamshell BlackBerry cyberdeck


PROJECT SHOWCASE

Quick FACTS
> Michael previously
designed a
Lattepanda
clamshell
cyberdeck

> The BlackBerry


cyberdeck’s
plywood case is
just 3 mm thick

> This helped trim


ZMXEPQMPPMQIXVIWSǺ
its dimensions

> Design and laser


cutting took about
six hours…
A veteran builder of
Raspberry Pi cases, Michael > Helped by the
pushed the boundaries by fact Michael
making this one from 3 mm has repurposed
thick plywood BlackBerry
cases before

Michael sourced an old


BlackBerry keyboard on a
custom carrier board that had
been repurposed to act as a
USB keyboard and mouse

since they worked with Raspberry Pi. The setup much larger than the components themselves.
[]ZaTOPOɭ_SP[P]QPN_ʭ_QZ]XdM`TWOL^_SP Designing the hinges also “took a bit of work”
keyboard footprint is smaller than the display’s, to get the extent to which they would open just
and still allows you to get full mouse and right. Michael wanted to limit the clamshell’s
keyboard functionality.” opening travel to have the display at about a
20-degree angle. “This makes it easier to use as
Laser-like focus a handheld device and lets it sit on a desk like
Michael designed and laser-cut parts, using a small laptop would.” The plywood parts were
Inkscape open-source software to create a case as glued together before the Raspberry Pi-based
small as possible, so the overall package wasn’t components, HyperPixel display, and repurposed

Clamshell BlackBerry cyberdeck magpi.cc 19


PROJECT SHOWCASE

Having installed
Raspberry Pi OS,
it’s time to test
the cyberdeck’s
BlackBerry keyboard

Michael designed
the case in Inkspace
before laser-cutting
the parts

20 magpi.cc Clamshell BlackBerry cyberdeck


PROJECT SHOWCASE

Cyberdeck style-up

Sites such as Tindie feature sellers who


01 ƚŞÏƼÏĬåŅĬÚĬ±ÏĩåųųƼĩåƼÆŅ±ųÚŸ±ĹÚĀƋ
them to a custom board for use with a Raspberry Pi.
Just add a mini USB keyboard.

BlackBerry Pi keyboard were inserted. Bezels to The HyperPixel 4.0


HMWTPE]WLS[WSǺ
VPP[PaP]d_STYRTY[WLNPbP]P_SPYʭ__POLYO videos and games,
such as Big Buck
glued on both halves of the clamshell case. 'YRR]XSKVIEXIǺIGX
Getting the angle of the screen just right took
a couple of attempts, but Michael has created
several laser-cut Raspberry Pi cases before, and
is used to working with their dimensions and the
NWPL]LYNP^TYaZWaPO?SPʭYT^SPOM`TWOSL^NL`RS_
the imagination of many makers who follow his
Use Michael’s step-by-step instructions at
blog and YouTube channel, with several requests 02 magpi.cc/diycyberdeck to create a suitable
for a 3D-printed version. Raspberry Pi case (laser-cut or 3D-printed) and
carefully assemble and glue it together.

There was a real


advantage to using the
HyperPixel 4.0 screen
For anyone keep to replicate the project, full
build details can be found on Michael’s blog:
(XLR[TNNOTdNdMP]OPNV). It can be used to
make a portable travel computer for a range of
tasks – portable NAS, VPN, travel router, mobile
programming platform etc. Michael, himself, is
Add Raspberry Pi 4 and attach the HyperPixel
already looking into adding a portable battery 03 screen using the GPIO pins, then insert and
pack and plotting further cyberdeck designs. attach the BlackBerry keyboard and other parts.
@YWTVPBTWWTLX2TM^ZYɪ^^NTʭZ]TRTYLW8TNSLPW FĹŸƋ±ĬĬ±ŸŞÆåųųƼ{Ĝk„±ĹÚÏŅĹĀčƚųåƋĘåŸÏųååĹƚŸĜĹč
doesn’t seem to be intending to use his cyberdeck Pimoroni’s instructions.
as a human brain-to-cyberspace interface!

Clamshell BlackBerry cyberdeck magpi.cc 21


PROJECT SHOWCASE

Greening the Spark


How does green energy work? One maker decided to create an interactive
museum piece to teach people. Rob Zwetsloot investigates

W
hat do you want to do when you retire?
Some might want to relax, others might
like to travel. Carl Nicholson had a
OTʬP]PY_TOPL
“When I retired and moved back to the UK,
I wanted to do something that would raise
awareness of climate change and help people
understand the ideas behind green energy,” Carl
Carl Nicholson
MAKER

tells us. “I also wanted an excuse to do electronics,


Carl used to be maths, coding, and making physical models
technical director and equipment.”
of Cyberdrome The result of this was Greening the Spark, a
Enterprises, as The graphical version of the control panel is used to set up
“simulator of a National Grid designed as a hands-
well as being the game
responsible for on museum exhibit which can also be played as a
simulators used to game,” as Carl describes it.
train astronauts for
the ISS. He’s
Carl comes from a background of making Renewable interest
now retired. and simulators, working in space operations in Why did Carl choose Raspberry Pi, though?
8`YTNS_]LTYTYRL^_]ZYL`_^LYOʮTRS_NZY_]ZWWP]^ “I wanted a small but powerful single-board
cornucopia.co.uk
on the Columbus module of the International computer with Wi-Fi and sound, a wide range of
Space Station, and also being the technical director Zʬ_SP^SPWQ_ST]O[L]_dSL]ObL]PLYO^ZQ_bL]P
ZQ_SPNZX[LYd_SL_XLOP_SPʭ]^_NZXXP]NTLW and a suitable well-supported language and IDE to
Crystal Mazes. code it with,” Carl says. “Raspberry Pi and Python
turned out to be the perfect combination.”
Building it took a while, and was apparently very
hard, as everything else was designed and built
from scratch using the Red Robotics RedBoard+, an
add-on robotics controller for Raspberry Pi. It does
quite a lot, though.
“There are software models of renewable
electricity sources (wind and solar) driven by a
weather model, non-renewables (fossil fuels and
nuclear) which are controllable, storage devices
(batteries and pumped hydro), and consumer
demand,” Carl explains. “There is a working model
of a wind farm (with three turbines) and a sunlamp.
The idea is to control the fossil fuel and nuclear
power to meet demand without blackouts or surplus
and to keep the storage devices close to half-full.
The control box “There is an operator control panel to monitor
is custom-made
and control the grid, and a visitor control panel to
with custom
electronics inside set up a game. There are three ‘characters’ who

22 magpi.cc Greening the Spark


PROJECT SHOWCASE

This control panel helps


simulate the use of energy
on the National Grid and
VYRWSǺ7EWTFIVV]5M

A live tally is used to


let you know how your
resource usage is doing

9WMRKXLIORSFWLIPTWQEMRXEMRXLIIRIVK]
grid depending on demand. Careful use
KVERXWEKSSHWGSVIFYX]SYRIIHXSQEOI
sure you’re delivering enough

Quick FACTS
> Carl has been
working on this for
over two years

> There are currently


help visitors understand what is going on with
spoken messages: a robotic system voice and two
I’m also keen to develop 11,500 lines of code

S`XLYR`TOP^L^bPWWL^^Z`YOPʬPN_^LYOX`^TN both the hardware > Due to complexity,


to add ambience.” it makes use of
As it’s a game, players get a result which is and software GPIO expanders
uploaded to a dedicated website, including a
^`XXL]dZQbSL_dZ`OTOLYOLNP]_TʭNL_P]PWL_PO > There are three
model wind
_ZdZ`]ʭYLWɩ^NZ]Pɪɭ4YLX`^P`XTY^_LWWL_TZY “I’m hoping to interest museums of science and
turbines for the
there will also be a themed landscape with physical technology, energy supply companies and possibly
energy farm
mock-ups of the various elements,” Carl adds. the National Grid itself, as well as schools and diorama
universities,” Carl says. “I’m also keen to develop
Futuristic energy both the hardware and software to make it more > Four high-
The project is still ongoing, although is already modular, generic, smarter, and connected. It would brightness 12 V LED
quite impressive. Carl has ideas for what he’d like be nice to use live data streamed from the National arrays are used to
to do with it, though. Grid and some AI in the control system.” emulate solar

Greening the Spark magpi.cc 23


PROJECT SHOWCASE

Bugg.xyz
acoustic monitoring
Soundscapes can provide a valuable insight into the health of a habitat.
A Raspberry Pi can help conservationists listen in, explains Rosie Hattersley

T
he louder the dawn chorus and the =L^[MP]]d;TbZ`WObZ]VbT_ST_M`_XZ]PL]Z`YO
cacophony of wildlife, the better the locale _SPʭPWOWZRT^_TN^ZQXZ`Y_TYRZYPTYLQZ]P^__Z
and, by extension, life for the creatures withstand temperature swings, humidity swings,
_SL_ObPWW_SP]P?ST^T^L^TX[WTʭPO_LVPZY_SP and long duration deployment.”
importance of acoustic monitoring, as conducted Helpfully, Sarab’s PhD supervisor had set up
by Bugg.xyz using a Raspberry Pi-based system. SAFE (Stability of Altered Forest Ecosystems),
Bugg wildlife traps record the sounds of the
forest, and are AI-trained to listen to the quietest
Sarab
MAKER

creatures, as well as those that broadcast their


Sethi
whereabouts to all and sundry. In fact, it’s more
Dr Sethi is a post- of an acoustic census, creating detailed records
doctoral research of the particular soundscapes of contrasting
fellow in Cambridge habitats, noting changes that may indicate
University’s
Department of
deforestation or a natural disaster leading
Plant Sciences. to depleted biodiversity. Dr Sarab Sethi, an
bugg.xyz environment research scientist at Imperial College
London, developed the Bugg acoustic monitoring
system, which is now being used to record the
sounds of forests from Norway to Taiwan, as well
as Bali and Borneo.

Sound and vision


>L]LMN]PL_POST^-`RRVT_SLaTYR]PLOLMZ`_ʭPWO
XZYT_Z]TYROPaTNP^M`TW_`^TYRZʬ_SP^SPWQ
components and based around a Raspberry Pi and
which featured a microphone, a USB audio card,
a plug-in internet dongle, and a weather sensor.
Suitably inspired, Sarab set about designing “a
continuous, long-term fully autonomous acoustic
XZYT_Z]TYROPaTNPɮ_SL_NZ`WO^PYOOP_LTW^MLNV
to the lab for analysis and which was robust
The team in Norway enough to be placed and remotely monitored
retrieves the Bugg in a variety of habitats. With price as well as
boxes each winter,
since there’s little the hardiness of the components to consider,
wildlife activity then
Raspberry Pi was an obvious choice: “The bigger
and deep snow
hampers recording questions weren’t so much about whether a

24 magpi.cc Bugg.xyz acoustic monitoring


PROJECT SHOWCASE

Bugg’s injection-moulded
case provides robust
[IEXLIVTVSSǻRKERH
can be securely lashed
to a tree in even the most
I\TSWIHcIRZMVSRQIRX

Acoustic monitoring using a


microphone, attached to Raspberry Quick FACTS
Pi 3B or above, helps further our
understanding of humans’ impact > ;IEXLIVTVSSǻRK
JSVXLIǻVWX'YKK
monitoring kit
was rustic…

> A gardener’s dry-


box was used to
protect cables

> Later versions are


3D-printed and
injection-moulded

> DC power
SPEVGLEVKMRKMWWYǽGMIRX
correction
to power Raspberry Pi, the
compensates for
microphone, and 3G/4G
erratic electricity
mobile module so sounds can
supplies
be sent and processed as soon
as they’re recorded
> Solar panels
power the devices
throughout all
seasons bar winter

Bugg.xyz acoustic monitoring magpi.cc 25


PROJECT SHOWCASE

a rainforest degradation monitoring project in


Borneo (acoustics.safeproject.net), which formed
the ideal proving ground for the Bugg acoustic
monitoring system.
“Whenever we’re setting up an ecological
Pc[P]TXPY_bPɪ]PWZZVTYRL_R]LOTPY_^ɮ^Ld^
Sarab. The SAFE Project questions how habitat
degradation in Bali and tropical forest scenarios
LʬPN_MTZOTaP]^T_d>LX[WP^L]P_LVPYQ]ZX
pristine virgin untouched forests to lightly logged
and heavily logged forests and then ultimately,
_SPZTW[L]_XZYZN`W_`]P^ɭDZ`NLYLW^ZWZZV
at machine learning embeddings of the audio or
ʭYRP][]TY_RZLYO^`]aPd_PY^T_P^_SPYʭR`]P
Sarab [rear] and out which soundscapes correspond to what types
colleague install of biodiversity and what type of habitat quality.”
Bugg boxes in the
Borneo rainforest, By going to ten more sites, or visiting the same
which is subject ^T_PZY_PYOTʬP]PY_OLd^>L]LMNLY`^P-`RR_Z
to man-made
degradation that infer “just based on that minute of audio, what
EǺIGXWFSXL[MPHPMJI
and the forest itself
the habitat quality or the biodiversity or stability
of that system is.”
Field recordings of
insects, invertebrates, In the event, Bugg more than held its own
and birds can be against the various moth-trapping and bug-
viewed and heard on
the SAFE Acoustic detecting traps, and neatly complemented
site, along with maps
studies into how forest fragmentation and
showing habitat
health variations QZ]P^_OPR]LOL_TZYLʬPN_MTZOTaP]^T_d?SP

26 magpi.cc Bugg.xyz acoustic monitoring


PROJECT SHOWCASE

Get bugging

Sarab shares the project setup and


results were published in the journal Methods This schematic shows
how data is continuously 01 ĵ±ƋåųĜ±ĬŸƤĜĹüŅųĵ±ƋĜŅĹŅĹĘĜŸƵåÆŸĜƋå
in Ecology and Evolution, plus a website that captured from an
ecosystem and uploaded
(magpi.cc/ecosystemmonitoring). You’ll need
details how to go about building your own device Raspberry Pi, a microphone, USB audio card and a
to a remote server
(magpi.cc/ecosystemmonitoring). Unfortunately, ±ĵåų±aŅÚƚĬ娱Ƶ±ƋåųŞųŅŅüϱŸåƋŅĘŅƚŸåĜƋرĹÚ±
LNZ`^_TNXZYT_Z]TYR^ZXP_TXP^]PaPLW^LWLNV ĵå±ĹŸŅüŞŅƵåųĜĹčåƴåųƼƋĘĜĹčţ
of wildlife and, what appears from photos to be
healthy rainforest, is actually an empty forest.

Anyone home?
?SPZ[PY^Z`]NP-`RRVT_^L]PYZb`^POQZ]
X`W_T[WPXZYT_Z]TYR_L^V^BSTWPaPRP_L_TZY
^LX[WTYRTYaZWaP^_LVTYR^LX[WP^LYOXPL^`]TYR
_]PP^>L]LMɪ^-`RRXZYT_Z]_LVP^LXZ]PSZWT^_TN
approach, “using soundscapes as a whole to
infer habitat health.” Once the microphone in
one of the Bugg devices detects sounds, they are
_]LY^XT__POZaP]LXZMTWPYP_bZ]VQZ]XLNSTYP

FĹŸƋ±ĬĬƋĘåŸŅüƋƵ±ųåĜĵ±čåŞųŅƴĜÚåÚŅĹƋĘå
02
A rainforest degradation monitoring project :ĜƋBƚÆĬĜĹĩƋұĵĜÏųŅ„%ϱųÚŅü±ƋĬ屟ƋƐƖ:
capacity. Connect the microphone, camera, audio

in Borneo formed the ideal proving ground card, and other components to Raspberry Pi.

for the Bugg acoustic monitoring system


WPL]YTYRML^POTOPY_TʭNL_TZYLYOLYLWd^T^Md
^NTPY_TʭN]P^PL]NSP]^-`RRT^RPYP]LWWd`^PO_Z
[TNV`[_SP^Z`YO^ZQ[L]_TN`WL]TY^PN_^Z]MT]O
^[PNTP^^Z_SP=L^[MP]]d;TML^POVT_NLYMP
trained to recognise and almost instantly identify
bSL_ɪ^XLVTYRPLNS^Z`YOMPT_XTR]L_Z]d
MT]OʮZNV^ZaP],]N_TN9Z]bLdZ]LY_^TYLY
4YOZYP^TLY]LTYQZ]P^_>ZXP[]ZUPN_^WZZVL_L
eč±ųÚåĹåųűŸÚųƼěÆŅƻĵ±ĩ埱ÚåÏåĹƋ
particular habitat in great detail over time, as is 03 Ƶ±ƋåųŞųŅŅüĘŅƚŸĜĹčţ‰±ŞåƋĘåĵĜÏųŅŞĘŅĹåƋŅ
the case in Borneo, with four distinct gradients of
ƋĘåŅƚƋŸĜÚåŅüŅĹååĹÚØ±ĹÚųƚĹϱÆĬåŸüŅųƋĘåŞŅƵåų
degraded forest, while in Norway there’s a focus ±Ú±ŞƋåųŠĜüƚŸĜĹčšƋŅƋĘåŅƋĘåųţ„űŞƋĘåĬĜÚĜĹƋŅŞĬ±Ïå
on multiple sites with the aim to get a detailed ±ĹÚĬ±ŸĘƋĘåÆŅƻƋұŸåÏƚųåŞŅŸƋŅųƋųååØŅƚƋŅü
overview of bird life and habitat choice across the ʱųĵűŸƵ±Ƽţ
whole country (thesoundofnorway.com).

Bugg.xyz acoustic monitoring magpi.cc 27


SUBSCRIPTION

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

Exclusive Offers
Great gifts, offers, and discounts

Great Savings
Save up to 35% compared to stores

Subscribe for £10


Free Pico W
3 issues of The MagPi
Free delivery to your door
£10 (UK only)

+
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)

Subscribe by phone: 01293 312193


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

28 magpi.cc
SUBSCRIPTION

SUBSCRIBE TODAY AND GET A


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

A brand new
RP2040-based
$6
Raspberry Pi Pico W
development board

Learn to code with


electronics and build
your own projects

Make your own


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

Buy now: magpi.cc/subscribe

SUBSCRIBE
on app stores

magpi.cc 29
SUCCESS STORY

SUCCESS STORY magpi.cc/success

Freight Farms
Raspberry Pi 4-powered vertical hydroponic farms let customers
grow and monitor fresh produce anywhere. By Rosie Hattersley

W ith food insecurity increasing, and


global temperatures rising, two
graduates from the Massachusetts
Institute of Design began working on a business
idea to address how to increase food production
THE CHALLENGE
Turning a lofty ideal into a successful business
plan and making good on the promise that early
investors anticipated is a challenge for any startup.
However, it was clear from the outset that container
in non-agricultural settings, beginning with QL]XTYRSLO[Z_PY_TLW1]PTRS_1L]X^ɪʭ]^_ZʬP]TYR
rooftop gardens in Boston. Their idea was to – the Leafy Green Machine, launched in 2013 –
increase “local food access and create a replicable featured a climate-controlled seeding section and a
model and a product that could be used to grow main growth area where vertical crop columns saw
food anywhere, all across the world.” Backed with LaL]TP_dZQWPLQdaPRP_LMWP^ʮZ`]T^S?SPNZY_LTYP]
a modest amount of seed funding, which they put QL]X^QPL_`]POSTRSPʯNTPYNd70/^`^PO]PWL_TaPWd
towards a Kickstarter campaign, co-founder and WT__WPPYP]RdLYOPʬPN_TaPWdʭW_P]POLYO]PNdNWPO
current president John Freeman and co-founder the water they consumed, making them particularly
Brad McNamara came up with the innovative idea PʯNTPY_bT_S_ST^P^^PY_TLW]P^Z`]NP?SPdbP]P
ZQ]P_]Zʭ__TYR^ST[[TYRNZY_LTYP]^L^WZNL_TZY^QZ] able to produce up to four tons of food per year.
vertical hydroponic farms. Sensors would monitor /P^[T_PL__]LN_TYRSTRS[]ZʭWPN`^_ZXP]^
pH levels, nutrients, light, temperature, air, and 1]PTRS_1L]X^bL^VPPY_ZTX[]ZaP_SPPʯNTPYNd
soil moisture, while cameras checked on plant of its container farms along with the range of crops
growth. Container availability and relative ease that could be grown, and thus boost their appeal
of shipping, given their original purpose, plus a to a wider range of customers. Both would help
temperature-controllable environment, meant the unlock the business’s potential beyond the US and
self-contained farms could be delivered and set up beyond its original base of campus and community
almost anywhere. organisations. Freight Farms set about creating
[]PNZYʭR`]POQL]X^XL]VP_POL^_`]YVPd[]ZO`N_^
that could be set up remotely by the customer and
would be seen as a practically fail-safe investment.
Accordingly, Freight Farms has spent the past
few years “honing what a container farm looks
like, improving the tech behind it and the yields”
in order to demonstrate its validity as a grow-
anywhere option, explains supply chain manager
Meaghan Holmes. Yields had the potential to be a
particular challenge, since certain crops are very
OTʯN`W__ZR]ZbZ]_Z[]ZaTOP_SP]TRS_NZYOT_TZY^
for, especially as a location’s climate changes.
“One of our goals – and our farmers’ goals – is
to make the most use of a small amount of space
by growing as much as possible,” says Holmes.
Monitoring improvements required an increased
focus on IoT and the in-house development of
LNLXP]LbT_SLX`NSbTOP]ʭPWOZQaTPbbSTWP
customers were also keen to be able to check on

30 magpi.cc Freight Farms


SUCCESS STORY

their container farm remotely, necessitating an app


for remote viewing.

THE SOLUTION
Freight Farms recently launched its Raspberry
;T[ZbP]PO2]PPYP]d>ʮLR^ST[XZOPW,^bPWW
as using the top-of-the-line Raspberry Pi, this
container farm features a bespoke camera unit.
;]TZ]_Z_ST^1]PTRS_1L]X^SLO`^POZʬ_SP^SPWQ
security cameras to monitor plants. “These were
WTXT_POTY_P]X^ZQ^P_`[LYONZYʭR`]LMTWT_dLYO
did not have enough resolution or FOV in a small
enough package to embed inside the walls of the
farm,” explains Jake Felser, CTO at Freight Farms.

Raspberry Pi-powered “The cameras take us to that next level of the


farm really being foolproof,” adds Holmes, while
Greenery S container farms the app helps the crop grower to notice problems
promptly. It gives them access to high-quality
offer a 30% improvement photographs in which symptoms such as
yellowing foliage are clear to observe, so they can
in yield between the top up the container farm’s nutrient supply, or

original Leafy Green adjust environmental factors such as temperature


or humidity.
Machine and the current WHY RASPBERRY PI?
Greenery container farms By the time Freight Farms was successfully
crowdfunding, Raspberry Pi was becoming a
success story in its own right. With a great
His team designed their own camera to reputation among the engineers and computer
overcome these issues. Along with demanding technicians tasked with creating Freight Farms’
performance requirements, these must be small ‘turnkey’ growing containers, it was an obvious
PYZ`RS_Zʭ_TY^TOP_SP[LYPW^ZQ_SPQL]X& choice of hardware.
Raspberry Pi provides the small form factor that Jake Felser outlines the reasons for choosing
Freight Farms requires in the computers to Raspberry Pi: “ease of development, open-
which the cameras connect, along with the source traceability, and driver availability at
necessary compatibility with these bespoke, high- an unbeatable cost for the performance.” This
quality devices. was coupled with a stable supply chain and a
large support base. “We also looked at some
microcontroller solutions as well as other SBCs,
but nothing came close to the performance at the
given cost,” he concludes.
Meaghan Holmes maintains a close
relationship with Freight Farms’ engineering
and manufacturing team, ordering critical items
such as Raspberry Pi units, sensors, and lights to
measure and monitor plant growth and health.
She praises Raspberry Pi’s reliability, its user-
friendliness, and the reassurance of it being so
widely known – a platform with which almost all
of the company’s engineers were already familiar.
For a business-critical component, “you wouldn’t
want something super-obscure”, she points out,

Freight Farms magpi.cc 31


SUCCESS STORY

a dedicated support team available by email or


phone, has meant the Freight Farm concept has
been embraced by non-farmers who perhaps
speculatively invest in a single container farm, as
well as leisure resorts where agricultural expertise
is in short supply but where the restaurants
[]TOP_SPX^PWaP^ZYZʬP]TYRQ]P^SWZNLWWdR]ZbY
produce. They are particularly proud of working
with community kitchens, food banks, and non-
[]Zʭ_Z]RLYT^L_TZY^^`NSL^7Z_`^3Z`^PTY8TLXT
which supports women and children who have
while the engineering team knew that Raspberry experienced homelessness.
Pi has “a really high measure of success in terms Core crops grown in the container farms include
of support.” varieties of lettuce, leafy greens such as kale and
chard, herbs, beans, and root vegetables. Some
THE RESULTS customers have even begun experimenting with
Freight Farms’ Raspberry Pi-powered Greenery S MP]]TP^LYOPOTMWPʮZbP]^
NZY_LTYP]QL]X^ZʬP]_SPXZ^_[]ZO`N_TaP There are now more than 200 Freight Farms
PYaT]ZYXPY_^TY_SPT]ʭPWObT_SL running productively in over 50 countries. “The
improvement in yield between the original Leafy Covid-19 pandemic brought into sharp relief, for
Green Machine and the current Greenery container some remote islands, how dependent they were
farms. A thorough onboarding programme in which on imports, not just for discretionary goods and
potential sites are checked for appropriate electrical services, but for food access,” says Meaghan
voltage, robust plumbing, and water access kick- Holmes. Freight Farms’ customers include a large
starts each new customer relationship. number of island nations that were previously
The straightforward management of each dependent on regular shipments to supply food
farm, with ‘recipes’ for growing each crop, plus staples that could not be grown locally.

32 magpi.cc Freight Farms


Full-Code

No-Code / Configure Design

now with a

No-Code WEB UI Designer

Analyze

P RO FES S I O N A L CO N T RO L SYS TE M D E V E LO P M E N T TOO L

Home projects made easy.


CDP Studio, a great software development tool for your home projects. Build
systems for Raspberry Pi, use C++ or NoCode programming, open source libraries,
out of the box support for GPIO, I2C, MQTT, OPC UA and more. Create beautiful user
interfaces. Built for industrial control system development, 
.

 

Tel: +47 990 80 900 • info@cdptech.com


CDP Technologies AS // Hundsværgata 8, 6008 Ålesund, Norway
FEATURE

DIY HOME
AUTOMATION
WITH RASPBERRY PI
Revolutionise your abode with Raspberry Pi:
affordable, customisable automation for your house
and home! By PJ Evans

W
elcome to the marvellous world
of Raspberry Pi-powered home
automation, where your humble house
transforms into a technological utopia!
Get ready to shake hands with Home Assistant,
your faithful digital butler, and explore cool
automation ideas that’ll make the Jetsons
green with envy. Prepare to dive into the MQTT
]PLWXbSP]PPʯNTPYNd]PTRY^^`[]PXPLYO
communication is king. Finally, create your very
own smart garage door, an ingenious guardian
that’ll open and close at your beck and call.
So, strap in and let’s high-tech your home!

34 magpi.cc DIY Home Automation with Raspberry Pi


FEATURE

Home Assistant’s dashboards are


made up of cards. These can be
switches, sliders, graphs, images, or
video. You can also design your own

Getting Started
with Home
Assistant
Take control of your home, and your
You can access Home
privacy, with this amazing home Assistant in any web browser.

automation tool for Raspberry Pi A popular project is to create


a control panel using the
Raspberry Pi touchscreen

H
ome automation is not only useful but
can also be a great deal of fun, setting up
NZZWL`_ZXL_TZY^Z]NZYYPN_TYROTʬP]PY_
devices together in new ways. It also can help
Write the Home Assistant image
bT_SPYP]RdPʯNTPYNdLYO^PN`]T_d?SP]PL]PL
wealth of practical reasons to start experimenting
02 Luckily for us, you can write the latest
with this technology. Although there are stable Home Assistant image directly from the
OTʬP]PY_aPYOZ]^[PNTʭNL`_ZXL_TZY^d^_PX^ Raspberry Pi Imager (magpi.cc/imager). Using
out there, we prefer one that doesn’t ‘lock’ you a fast SD card 32GB or more in size, insert it
into one provider. One such platform is Home into your computer. In Imager, select Choose OS
Assistant (home-assistant.io), a free open- ):_SP]^[PNTʭN[`][Z^P:>)3ZXPL^^T^_LY_^
^Z`]NPZ[P]L_TYR^d^_PXOP^TRYPObT_SʮPcTMTWT_d and home automation> Home Assistant > Home
PJ Evans
MAKER

and independence in mind. Home Assistant is a Assistant OS 9.5 (RPI 4/400 or RPI 3, as needed).
huge topic, but here we’ll look at the basics of You’ll now get a ready-to-boot image. PJ is a writer,
setting up a server to get you started on your Insert the card into your Raspberry Pi, make software engineer,
and home
automation journey. sure you’ve got a wired network connection and
automation
power up. After a few minutes, try to connect to enthusiast. He has
http://homeassistant:8123 in your web browser. no idea why his
lights keep changing
colour at 3.15 pm
Prepare your Raspberry Pi
01 Although Home Assistant (HA) isn’t
every day, but it’s
probably his fault.
Initial setup
strictly an operating system in its own right,
it is available as a Raspberry Pi image that
03 Time to grab yourself a favourite beverage.
mrpjevans.com

^TRYTʭNLY_Wd]PO`NP^_SPbZ]VL`^P]SL^_ZOZ You’ll see an initial setup screen stating that it


to get up and running. HA is intended to run on will take about 20 minutes before you can proceed.
a Raspberry Pi as the sole service. It is possible >ZZYT_bTWWMPL`_ZXL_TNLWWd]P[WLNPObT_S_SPʭ]^_
to run HA alongside other apps and services, but stage of setup. Provide your name, username, and
we’re keeping to the true path here. HA works choice of password. On the next screen, there will
with Raspberry Pi 3, but we strongly recommend be some questions about the server’s location. It’s
using a Raspberry Pi 4 for the best performance. important to set this accurately if you want to take
You should also use a wired Ethernet connection advantage of sun-up/down times. Finally, HA will
for setup and to ensure reliability. HA is headless, ‘look’ around your network for any existing smart
so no monitor or keyboard is needed. devices and let you know what it’s found. Don’t

DIY Home Automation with Raspberry Pi magpi.cc 35


FEATURE

You’ll Need

> Wired internet


connection

> Good-quality case


(recommended)
magpi.cc/
argonone
> At least one
compatible
smart device
(recommended)
home-assistant.io/
integrations Combine devices to create clever energy-saving automation.
Got solar panels? When it’s sunny, switch the washing machine
and all the lights on

ons. Integrations include lights, security devices,


media centres, printers, and mains power
controllers and you can even make your own. At
this point, it’s best to start exploring.
Replace your porch light with a smart light bulb and you
can trigger it at sundown all year round

worry if something doesn’t appear, it will probably


Customisation
U`^_YPPOXLY`LWNZYʭR`]L_TZYWL_P]ZY
05 One of Home Assistant’s greatest strengths
is customisation. The Dashboard system
(‘Lovelace’) allows you to arrange your device
Add integrations
04 Home Assistant refers to smart platforms
control and set automations just how you like.
By default, HA automates the layout, but we
as ‘integrations’. For instance, if you have Philips recommend you disable that. Click the three
Hue or IKEA Trådfri smart lights, it will add dots in the top-right of the screen followed by
an integration for them and then a ‘device’ for ‘Edit dashboard’. You’ll be asked if you want

Top Tip PLNSWTRS_T_ʭYO^4_bTWWLW^ZN]PL_PLOPQL`W_


dashboard for you based on what’s been found.
to take control of layout. Do so and now you
can create your perfect layout. You can resize,
Not all integrations can be found automatically, restyle, add graphs, tabs, and badges. Don’t be
Beginning so you can browse available integrations and intimidated; start small and build things up as
automations add them yourself or install third-party add- you become familiar.

Home Assistant
knows your
local sunrise
Next steps
and sunset
times. A great 06 Congratulations, you now have a running
ĀųŸƋ±ƚƋŅĵ±ƋĜŅĹ Home Assistant server. The capabilities of this
project is
service can seem overwhelming at times but
switching a porch
ĬĜčĘƋŅűĹÚŅý±Ƌ
with a little reading on home-assistant.io and
the right times. some digging around the menus, you’ll soon
be taking control of your home. Once you’ve
LOOPO_SPLMTWT_d_Z^bT_NSOPaTNP^ZYLYOZʬ
or monitor things like printer ink levels, move
As your confidence on to Automations. These allow certain actions
and knowledge to happen based on events. For example, you
grow, you can create
more complex can have a motion sensor turn on certain
dashboards. You can
lights around the house. Check out Settings >
even incorporate
video feeds Automations and have a play.

36 magpi.cc DIY Home Automation with Raspberry Pi


FEATURE

Cool Home
Automation Ideas
Looking for inspiration for your home automation project?
Here are some incredible ideas!

H
ome automation has such a broad
scope that it is only limited by your
imagination. Most people start by
Home environment
controlling lights, but soon you can be monitoring :`]SZXP^L]PʭWWTYR`[bT_S^XL]_OPaTNP^BPNLYNZY_]ZW
LWWVTYO^ZQ_STYR^]P^[ZYOTYR_ZOTʬP]PY_TY[`_^ temperature, monitor for smoke, use motion-activated cameras and
creating scenes and more. So here are some of our more. Home Assistant adds value by allowing these devices to be
favourite types of smart devices and suggestions linked to others in a way that may not be supported out of the box.
on what you can do with them. Everything here Integrations are available for popular platforms Ring and Nest.
will work with Home Assistant.

Voice control
?SP]PL]PXLYdOTʬP]PY_aZTNPNZY_]ZW
platforms available. The most popular are
Amazon’s Alexa, Google Assistant, and
Apple’s Siri. Home Assistant has direct
support for Alexa and Google Assistant
via integrations so you can control your
devices or trigger automations by voice.
For Siri, you create a link to HomeKit and
create voice-activated short cuts. Smart lights
A starting point for most home automation
newbies. Home Assistant has support for
a wide range of lights, notably the Philips
Hue and IKEA Trådfri range. Once you have
a gateway hub in place, Home Assistant
will detect it automatically. You also get
ʭYPR]LTYPONZY_]ZWZQNZWZ`]^M]TRS_YP^^
and colour temperature.

DIY Home Automation with Raspberry Pi magpi.cc 37


FEATURE

Cool Home
Automation Ideas
»»»
Raspberry Pi Your phone
Connect sensors, switches, displays, 4Y^_LWWTYR_SPZʯNTLW3ZXP,^^T^_LY_
or simply LEDs, then use MQTT to app unlocks several cool features. If you
send and receive status messages. bT^ST_ɪ^L[]TaLNdʭ]^_XZOPWdZ`]
Home Assistant’s MQTT plug-in makes app can update your Home Assistant
adding Raspberry Pi quick and easy. The server with your location and also
`W_TXL_PʮPcTMWP^XL]_OPaTNP.SPNV (depending on the phone) other metrics
out the Remote GPIO integration for such as steps, messages received, and
codeless monitoring of inputs and output so on. Location can be used to trigger
(magpi.cc/homeassistantgpio). events, such as switching the lights on
when you’re near home.

Installing the official Home Assistant


app unlocks several cool features

Cars
Cars are getting cleverer too. Many newer
models feature mobile communication
allowing us to access information by app
and sometimes be able to start the car or
turn on air conditioning remotely. Many
manufacturers are supported by Home
Assistant, so you can see how your EV
charge is getting on direct from your
HA dashboard.

38 magpi.cc DIY Home Automation with Raspberry Pi


FEATURE

Introducing
MQTT
Using a message broker system
makes building your home
automation system easier and
more flexible. Here’s how it works

O
Testing the MQTT server
nce you’ve begun your home automation
journey, it’s only a matter of time before
02 Clients of an MQTT broker are either
you come across MQTT. 4_XLdL_ʭ]^_ publishers (sending data) or subscribers (receiving
^PPXLWT__WPNZYQ`^TYRLYOdZ`XLdʭYOdZ`]^PWQ data). The data streams are known as ‘topics’ and a
wondering why you need it. MQTT is a simple, broker can have any number. This way subscribers
lightweight messaging protocol whose purpose can pick just the information they are interested in.
T^_ZM]PLV_SPOT]PN_WTYV^MP_bPPYOPaTNP^BP To try it out, make sure you have the mosquitto-
NLWW_ST^ɩWZZ^PNZ`[WTYRɪBSdT^_ST^LRZZO clients package installed on your local machine and
idea? Let’s say you have a temperature sensor. By open two terminal windows. In one, run:
sending its data to the MQTT server instead of,
say, a display, this means we can have any number mosquitto_sub -h <IP address of MQTT broker>
of devices ‘listening’ to the sensor and taking -t "test"
action. The sensor’s code doesn’t need to change
if new requirements come along. Devices that send In the second, run:
information are ‘publishers’ and those listening
are ‘subscribers’. Publishers don’t care where the mosquitto_pub -h <IP address of MQTT broker>
information is going and subscribers don’t care -t "test" -m "Hello subscribers"
where it is coming from.
3LaPLWZZVL__SPʭ]^_bTYOZbdZ`^SZ`WO^PP
that the subscriber has received the message.

Setting up an MQTT server


01 To achieve the loose-coupled model we
Add Home Assistant as a subscriber
YPPOLNPY_]LWS`M_SL_LN_^L^LVTYOZQ[Z^_ZʯNP
for messages. This is the MQTT server or more
03 To bring the power of MQTT to Home
commonly ‘broker’. Luckily for Raspberry Pi users, Assistant, go to Settings > Devices & Services > Add
there is a simple lightweight broker available called Integration and then search for MQTT. Provide the
‘mosquitto’. If you are setting up a dedicated MQTT IP address of your server and you’re done. To create
server, installation is as simple as running these automations based on data coming into topics,
commands from the terminal: go to Settings > Automations and create a new
automation. Set the trigger to MQTT, add the topic
sudo apt update && sudo apt upgrade name you’re interested in and, optionally, the data
sudo apt install mosquitto mosquitto-clients value you want (e.g. ‘true’). You can then trigger
any device supported by Home Assistant. For
If you want to install an MQTT broker on a Home example, a motion sensor can send a message to
Assistant installation, it can be installed as an add- the ‘kitchen/motion’ topic and the Home Assistant
on in Settings > Add-ons > Add-on store. can trigger an automation that turns the lights on.

DIY Home Automation with Raspberry Pi magpi.cc 39


FEATURE

Make a
smart garage door
Is your garage door not pulling its weight? Add some smarts
with this home automation tutorial and take control

You’ll Need

> Raspberry Pi Pico W

> SB Electronics Relay


for Pico
magpi.cc/relaypico
> Bell wire (length
depends on your
installation)

> Motorised garage


door
We’ve exposed our
> Home Assistant
Pico W so you can
server
see how it connects
> MQTT broker to the operator’s This box contains the circuitry
trigger terminals and machinery to control the
garage door. There are many
HMǺIVIRXX]TIW

Test the trigger


02 Once you are 100% sure you have
the correct terminal and safe voltage (use
a multimeter if you’re not sure), using an

Top Tip appropriate length of bell or speaker wire, connect


LbT]P_ZPLNS_P]XTYLWBSPYdZ`UZTY_SPZ_SP]
end together, the door should close or open. Make
Add a sensor Make a (safe) plan
01 This project is aimed at garage doors with
sure you have your remote on you just in case!
Finally, think about where you are going to place
Use a simple
an operator, a motor that opens and closes the dZ`];TNZBLYOPY^`]PdZ`SLaPPYZ`RSZQ_SP
contact (or reed)
switch, like those door via a remote control. Most operators have bell wire to make a connection between it and the
used in alarm their control box near the ceiling in the centre of garage operator.
systems, to detect the garage. Typically, there’s a light embedded in
whether the door there too. Nearly all models have two terminals
is open or closed. inside the box for a button to be connected.
Then you can
Prepare your Pico W
ŸåĹÚŸŞåÏĜĀÏ
‘open’ or ‘close’
Research your model of operator and check the
manuals for such terminals. Normally they are
03 Even if the connection terminal is zero-
instructions rather zero-voltage and safe to use. Most operators run voltage, we still don’t want a direct link between
than a toggle. at 24 V but check, check, and check again you are _SPZ[P]L_Z]LYOdZ`];TNZBL^TY_P]QP]PYNP
not going to interface with anything above that. and other factors could cause problems. So,

40 magpi.cc DIY Home Automation with Raspberry Pi


FEATURE

DOWNLOAD
THE FULL CODE:
magpi.cc/garagedoorbotgit

message when a button


is pressed. On the Home
Assistant dashboard, click
the three dots in the top-
right corner, then ‘Edit
Dashboard’. Now ‘Add
Card’ and select ‘Button’.
Here’s
a close-up Click ‘X’ to remove the
of the Pico W default entity chosen. Set
with the relay HAT
installed. Note the the name to anything you
three connectors. We use
like and choose an icon. Set
NO and COM
‘Tap Action’ to ‘Call Service’ Danger!
we are going to use a relay and select ‘MQTT:Publish’ as the
Electricity
board. Relays are switches that ^P]aTNPBSPY[]ZX[_PO^P__SP_Z[TN All garage door
can be electronically triggered without to ‘garage/dooroperator’ then click STIVEXSVWEVIHMǺIVIRX
Ensure you only connect
connecting directly to the thing being ɩ>LaPɪ4QLWWT^bPWWdZ`];TNZB^SZ`WO to safe or zero-voltage
^bT_NSPOBPɪaPNSZ^PYLY>-0WPN_]ZYTN^]PWLd operate its relay whenever you click the button. electrical terminals.

HAT designed for Pico that can handle a wide magpi.cc/


electricalsafety
range of voltages. The HAT sits underneath
;TNZBLYOYPPO^SPLOP]^^ZT^NZX[L_TMWP
Install
bT_S_SPB3aL]TLY_Z]dZ`ɪWWYPPO_ZLOO^ZXP
yourself. Add the HAT, using its USB connector
06 Once you’re happy the relay is working,
image as a guide. you can connect it up to the operator. Cut the
wire to the length you need and connect the wires
as before to the two terminals. You’ll notice the
relay has three connectors. The middle one is
Add the code
04 Now add the code in main.py (from the
the ground (COM), so connect that to the ground
(black) terminal on the operator. Connect the
GitHub repo) using your preferred method, being other wire to the NO side of the relay, not NC.
careful to update the variables at the beginning These stand for ‘Normally Open’ and ‘Normally
with the correct values for your setup. You also .WZ^POɪBPbLY__SPNZYYPN_TZY_ZMPɩZ[PYɪ`Y_TW
need to add the umqtt library, which you can T_T^_]TRRP]PO8LVP^`]PdZ`];TNZBT^^LQPWd
download from magpi.cc/umqttsimplepy. The away from the elements and dust.
NZOPNZYYPN_^_ZdZ`]BT1TYP_bZ]VLYO_SPY
to your MQTT server. It’s a subscriber, so it will Here’s how the setup in Home Assistant should look. The
button calls the MQTT service and ‘pings’ the topic which is
sit and listen for messages for the given topic. sent to the Pico W
BSPYPaP]LYPbXP^^LRPT^OPWTaP]PO_Z_SP_Z[TN
_SP;TNZBbTWWXZXPY_L]TWdLN_TaL_P_SP]PWLd4Q
you have Mosquitto Utilities installed, you can use
this command to test the setup:
Top Tip
Always
moquitto_pub -h <IP address of MQTT broker>
be there!
-t 'garage/dooroperator' -m 0
Never open or
You should hear the relay click as it closes and close a garage
opens again. without being
able to see it.
You might give
someone a
nasty surprise or
Add to Home Assistant
05 Now we can add an automation script
inadvertently trap
a pet or wildlife.
to Home Assistant that will send the MQTT

DIY Home Automation with Raspberry Pi magpi.cc 41


TUTORIAL

Build your own


Part 01

GPT Chatbot
Use Python and OpenAI’s API to talk to a GPT-3.5
powered chatbot on your Raspberry Pi

I
K.G. n this tutorial, we’ll be creating a simple whether you access them via the web or the API.
MAKER

Orphanides chatbot interface in Python using OpenAI’s API calls are very cheap, but free credits expire
GPT-3.5 Large Language Model (LLM) to after three months.
KG is a writer, create a local interface and instructions (a
developer ‘prompt’) for a chatbot that behaves similarly to
and software
preservationist. OpenAI’s famous ChatGPT.
Keepers of the key
They’d like to see
fewer chatbot
You’ll need an OpenAI account to use the
gpt-3.5-turbo model required by this tutorial.
02 Next, we’ll generate an API key so you can
prompts about the
You’ll also need to keep Raspberry Pi connected call OpenAI’s LLM models in your own code. Go
meaning of like,
and more about to the internet as the models we’ll be using have to platform.openai.com/account/api-keys, then
adventure on the to be accessed via an API that communicates click the ‘Create new secret key’ button. After a
high seas.
with OpenAI’s servers, both because of their couple of seconds, a pop-up will appear with the
magpi.cc/owlbear proprietary nature and to give Raspberry Pi the _T_WP,;4VPdRPYP]L_PO?ST^T^dZ`]ʭ]^_LYOWL^_
extra processing power necessary to run a viable opportunity to copy the key that’s shown in the
GPT-3 chatbot. pop-up’s selectable text box. Copy it, and save it
You’ll Need
somewhere safe. We’ll be using this later. If you
> An OpenAI account do lose your key, there’s no way of recovering it,
openai.com but you can always generate a new one.
Create an OpenAI account
> Thonny 01 Go to platform.openai.com/signup and
> An internet follow the instructions to create an account.
connection
First steps
Users must be over 18. You don’t need to enter an
organisation name, but if you do, your account
03 Open a terminal and type:
Remember to note will be named after it. New users currently get
down the API keys $5 in free credits. If you use the same number pip install openai
you generate. The
encrypted notes to verify more than one account, subsequent git clone https://codeberg.org/
ǻIPHSJETEWW[SVH
manager is a
LNNZ`Y_^LQ_P]_SPʭ]^_bZYɪ_]PNPTaPQ]PPN]POT_^ MightyOwlbear/simple-chatbot-gpt-3.5-turbo
good place You’ll need credits to use any of OpenAI’s models,
This will clone our sample code and install
OpenAI’s Python library and our sample scripts. If
you’ve previously installed the openai package, put
--upgrade at the end of the pip install command
to update it.
The Thonny Python IDE comes pre-installed in
Raspberry Pi OS. If it launches in Simple mode,
click the link at the top right of the toolbar that
reads ‘Switch to regular mode’ and restart the
program. Your interactions with the chatbot will
take place in Thonny’s Shell, which is a major

42 magpi.cc Build your own GPT Chatbot


TUTORIAL

convenience when tweaking your scripts. You can The messages parameter for
run them from the terminal, if you prefer. ChatCompletions in OpenAI’s gpt-3.5-
turbo API (magpi.cc/opeaichat) allows
you to send prompts – questions or
instructions – to the remote AI model

Meeting the API


04 While OpenAI’s own API reference
(magpi.cc/openaiintro) and cookbook
(magpi.cc/openaicookbook) provide useful
code snippets and explanations, the extensive
annotation makes the code a little hard to parse.
From the git repository you cloned in the
previous step, open openai-sample-code.py
in Thonny and paste your own OpenAI API key
between the quotes in the openai.api_key = line.
This sample code is based on OpenAI’s Chat
completion docs. In it, we import the OpenAI
WTM]L]dOPʭYP_SPXZOPWbPbT^S_Z`^PR[_ 
turbo), and use the ChatCompletion routine to
send a prompt and print the response it returns.
Because we’re appending each
question and response to our
messages array, our chatbot
A two-way
Addressing the model 06 conversation
remembers the instruction we
05 We’ve provided a ‘user message’ - a prompt If we want to have an actual
gave it to behave like a pirate
from one question to the next
for the LLM to respond to. This can be anything conversation, we’ll need to
you like: we asked the AI to pretend to be a expand on this a little. Open
sentient Raspberry Pi simple-chatbot.py and you paste your API key in.
You can also write chatbot personality prompts If you run this script, you’ll have a conversation
L^Lɩ^d^_PXXP^^LRPɪ[]PʭcPOMd"role": with a captain from the golden age of piracy. We’re
"system", "content": . OpenAI warns that using Python’s input() function to store anything
its gpt-3.5-turbo model doesn’t treat system the human participant in the conversation types as
messages as strong prompts, but we’ve generally a string and format it into an appropriate prompt,
found them functional and will be using one in the which goes into an array called messages. The API
next example. sends this back and returns a similarly structured
We’ve also set the model’s ‘temperature’ to 0.2. response, which we then print. Note that
?SPSTRSP]_SP_PX[P]L_`]POPʭYPOZYL^NLWP responses can take a while if OpenAI’s systems are
between 0 and 1, the more random the model’s experiencing high demand.

Top Tip
responses will be. Finally, we print the output
of ‘response’, which extracts the reply sent via
the API.
Remember me Mutually
07 If you want to have an ongoing conversation incompatible
with a chatbot, you’ll have to give it a memory.
The gpt-3.5-
In simple_chatbot.py, we’re doing this with
turbo and text-
Python’s append function. Every time the user davinci-003
enters a question, it’s stored in the user_input APIs don’t use
variable, formatted as a compliant message object, compatible
and appended onto the end of the messages array. syntax, so you’ll
The LLM’s responses are also added to the array. need to rewrite
your bot scripts
This means that every subsequent question can be
if you want to
answered in the context of the prior conversation switch from one
and long-term instructions can be followed. to the other.
Detailed usage stats allow you to see how much credit or
money you’re using. Paying users can set spending limits However, there are limits to this.

Build your own GPT Chatbot magpi.cc 43


TUTORIAL

Maximum word count Get on the web


08 OpenAI breaks text input into ‘tokens’
11 Talking to your bot through Thonny’s Shell
(magpi.cc/counttokens) – chunks of around four is functional, but not pretty. For a more attractive
NSL]LN_P]^/TʬP]PY_XZOPW^SLaPOTʬP]PY__ZVPY approach, Rohit Prasan Mandal’s example uses
limits: gpt-3.5-turbo can handle a maximum of Gradio to create and host a browser-based chatbot.
4096 tokens, or about 3000 words in English. Open a terminal and type:
Anything longer and you’ll get an error asking
you to reduce the length of your messages. OpenAI pip install gradio
also charges by the token, both sent and received, git clone https://github.com/xiaowuc2/
but these rates are inexpensive: gpt-3.5-turbo ChatGPT-Python-Applications.git
works out at one US cent for every 375,000 words. cd ChatGPT-Python-Applications/chatbot
In the future, we’ll get longer conversations and
text prompts: The new GPT-4 models, currently in Edit fantastic-chatbot-gradio.py and add the
beta (magpi.cc/gpt4model), have extended limits line import yaml to the top of the script. In the
of between 8192 and 32,768 tokens. same directory, open pass.yml and paste your
OpenAI API key into the indicated space.
If your pre-installed version of NumPy is below
1.20, preventing the script from running, open a
The art of prompting
09 A lot of the trick to getting the desired
terminal and type:

behaviour out of an LLM chatbot comes down to sudo apt update && sudo apt upgrade
how you word the prompts. For example, to get apt remove python3-numpy
our bot to consistently write as though it’s a pirate sudo apt install libatlas3-dev
pip install numpy

OpenAI breaks text input Run the script and click the link in Thonny’s
Shell to open a browser-based chatbot interface.
into ‘tokens’

Black holes and confabulations


captain, we tell it to “Present yourself as a captain
from the golden age of piracy in all subsequent
12 LLMs are exposed to vast amounts of text
responses. Use colourful language and talk like a and trained by having them select the most likely
pirate.” That “in all subsequent responses” bit is next word in a sequence until they can accurately
important, otherwise it’ll go back to its default AI predict the kind of word structures used in
NSL_MZ_[P]^ZYLWT_dLQ_P]T_^ʭ]^_]P^[ZY^P meaningful, human-readable text.
They’re designed to be good at text-generation,
with gpt-3.5-turbo in particular trained for
conversation. It can produce lucid statements in
Politeness and conversation
10 structure
correct English, but has no real ability to analyse
the content or accuracy of its statements.
There are a few more things you can do to make If you give ChatGPT a passage of original text
Top Tip your chatbot seem more approachable. Our
repository includes variations on the script that
and ask the bot to summarise it, it might cherry-
pick some phrases from the passage but fail to
Out in the open have the bot introduce itself at the beginning of register its title or the gender of the protagonist.
the conversation and which listen for keywords The models also have no access to new
OpenAI is indicating that the conversation has ended. In information. They can’t go and look something up
aggressively simple-chatbot-with-intro.py, we request a online and their knowledge is frozen at the time
proprietary, but for ]P^[ZY^PQ]ZX_SPXZOPWZYʭ]^_]`YL^LY of their data set’s creation - September 2021 in
an open-source
immediate response to out initial prompt, and in the case of GPT-3.5 and GPT4. If you ask about
alternative to
simple-chatbot-with-intro-and-outro.py, we later events, your bot has no alternative but to
its LLMs, check
out GPT-J-6B WZZVQZ]^[PNTʭNVPdbZ]ONZXMTYL_TZY^^Z_SL_bP NZYQLM`WL_PLʭN_TZY?ST^LW^ZSL[[PY^TQdZ`
(magpi.cc/gptj6b). can automatically end the chat after the bot has L^VLMZ`_^ZXP_STYR_SL_ɪ^TY^`ʯNTPY_WdbPWW
said goodbye in response to the user. represented in its training data.

44 magpi.cc Build your own GPT Chatbot


TUTORIAL

simple-chatbot.py DOWNLOAD
THE FULL CODE:
> Language: Python magpi.cc/simplechatbotcode

001. # import the OpenAI Python library for calling the OpenAI API
002. import openai
003.
004. # Your openAI API key does here:
005. openai.api_key = "PasteYourKeyHere"
006.
007. # the model we'll be using
008. MODEL = "gpt-3.5-turbo"
009.
010. # your chatbot's name
011. botname = "Captain"
012.
013. # The initial prompt. Tell the chatbot how you want it to behave.
014. messages=[
015. {"role": "system", "content": "Present yourself as a captain from the golden
age of piracy in all subsequent responses. Use colourful language and talk like a
pirate."}
016. ]
017.
018. # we want to run some commands once when we start the program, so we'll use this
flag
019. first_run = True
020.
021. # our chat routine
022. while True:
023.
024. # Show the user instructions and introduce the chatbot by name.
025. if first_run == True:
026. print("Type exit to leave the chat. Initialising chatbot: "+str(botname)+".")
027. first_run = False
028.
029. user_input = input("You: ")
030. # exit on command
031. if user_input == 'exit':
032. exit()
033.
034. prompt = {"role": "user", "content": user_input}
035. messages.append(prompt)
036.
037. # Example OpenAI Python library request - defines the model we wish to use, and
uses the ChatCompletion routine to send a prompt.
038. response = openai.ChatCompletion.create(model=MODEL, temperature=0,
messages=messages)
039.
040. # extract and print the response
041. print(str(botname)+': '+str(response['choices'][0]['message']['content'])+'\n')
042. messages.append(response['choices'][0]['message'])

Build your own GPT Chatbot magpi.cc 45


TUTORIAL

Raspberry Pi Pico
Part 03

inputs and outputs


Create a buzzer game whilst learning about how
to use inputs and outputs on Raspberry Pi Pico

I
nputs and outputs are the ways that a in it sometimes being high and sometimes low.
Raspberry Pi Pico can interact with the To avoid this, we need to use pull-up or pull-
Stewart
MAKER

outside world. In this tutorial, you will learn down resistors.


Watkiss about pull-up and pull-down inputs and how to
connect arcade buttons to a Raspberry Pi Pico.
Also known as
Penguin Tutor. You will also learn about driving a buzzer using a
Pull-up and pull-down resistors
Maker and YouTuber
that loves all things
MOSFET transistor.
You will then learn how you can swap the
02 Pull-up and pull-down resistors are a
Raspberry Pi and
Pico. Author of
MOSFET for an integrated circuit to create an way to set a default value on the input pin. If it’s
Learn Electronics interactive game to play with friends. pull-up, that means that with no other input the
with Raspberry Pi. value will be high; with pull-down, it means that
penguintutor.com the default value will be low.
To change the value, you need to apply a
twitter.com/
Switches as inputs
stewartwatkiss
01 The digital GPIO pins on Pico can have
stronger input that overrides the pull-up or
pull-down resistor. For a pull-up, you provide a
_bZOTʬP]PY_aLW`P^:YPT^LSTRSTY[`_bSP]P connection to ground; for pull-down, you provide
You’ll Need the input is at, or near, 3.3 V. The other is a low a connection to 3.3 V.
value when the input is at, or near, 0 V. What 1Z]PcLX[WPNZYYPN_LVŧ]P^T^_Z]MP_bPPY
> 6 V buzzer
magpi.cc/buzzer6v about if the pin isn’t connected to anything? a GPIO pin and the 3.3 V source on pin 36. This
You may think that without any input then it sets the input high. Connect a button switch
> Arcade buttons with
would be low, but that isn’t necessarily the case. from the same pin down to ground. Whenever
5 V LED
magpi.cc/ 4Y^_PLO_SPTY[`_T^_]PL_POL^ɩʮZL_TYRɪBT_SL you press the button, the lower resistance in the
arcadebuttons ʮZL_TYRTY[`_T_NLY[TNV`[^_]Ld^TRYLW^Q]ZX switch results in the voltage being dropped across
passing radio signals or static electricity resulting the resistor and no voltage across the button
> 2N7000 MOSFET
magpi.cc/2n7000 providing a low input. This is shown in the
Figure 2 wiring diagram.
> ƋERHOƋ
resistors
magpi.cc/
575resistorkit
Pull-up and pull-down inside Pico
> PCB switch
magpi.cc/
03 For most circumstances, you don’t need
tactileswitchbuttons to use external resistors and you can instead
> ULN2803 integrated
use internal resistors within the Pico. This is
circuit achieved by using the pull argument when you
magpi.cc/uln2803 OPʭYP_SP[TY
> Various wires, including To enable a pull-up resistor, use:
crimp connectors Figure 2 Pull-up example circuit showing a
pull-up resistor and switch connecting to ground button1 = Pin(16, Pin.IN, Pin.PULL_UP)

46 magpi.cc Raspberry Pi Pico inputs and outputs


TUTORIAL

The third parameter enables a pull-up


resistor for that pin. You can now remove the
external resistor.
The same can be done for pull down by using
the value Pin.PULL_DOWN.
To detect if the button has been pressed,
use the following line:

button1.value()

This will return 1 if the input is high


(button not pressed) and 0 if the input is low
(button pressed).
With so many wires, it is hard to Each of the arcade buttons
see where each wire goes, so we has an push switch and a
also use a schematic diagram built-in LED

Handling outputs
04 Using the GPIO ports as an output gives a Some other types of buzzers, such as a piezo Figure 1 The wiring
diagram for the quiz
OTʬP]PY_[]ZMWPX?SP2;4:[TY^NLYZYWd[]ZaTOP buzzer, need to have a rapidly changing signal, buzzers system
around 12 mA from each of the pins. This is enough which would need to be included in the code.
to pass a signal on to another device and can also The buzzer uses 25 mA, which is too much for
be used to light up a standard LED, but it cannot Pico’s GPIO pins, but within the range for the
switch large currents needed by a buzzer, high-
power LED, or many other devices.
2N7000 MOSFET. It also needs to be powered
from a 5 V power supply. This can be taken from
Top Tip
A common way of switching larger loads is with the VBUS connection on pin 40 of your Pico, MOSFET
a MOSFET transistor. which is connected to the 5 V connection on the pinouts
USB connector.
%ĜýåųåĹƋ
ak„8)‰„ϱĹ
N-channel MOSFET ʱƴåÚĜýåųåĹƋ
05 Wiring up the MOSFET ŞĜĹŅƚƋŸţĘåÏĩ
A MOSFET is a semiconductor device which
is a type of transistor. It is like a switch which
07 /TʬP]PY_8:>10?^NLYSLaPOTʬP]PY_
ƋĘåÚ±Ƌ±ŸĘååƋüŅų
ƼŅƚųak„8)‰üŅų
is controlled by an electrical signal instead of pinouts. The 2N7000 is in a TO-92 package. With ĵŅųåÚåƋ±ĜĬŸţ
pushing it down. The MOSFET has three pins: a _SPʮL_[L]_ZQ_SP8:>10?L__SPQ]ZY__SP^Z`]NP
drain and source, which is where the main current is on the left (connected to ground), the gate is in
bTWWʮZbLYOL_ST]O[TYVYZbYL^_SPRL_PbSTNS the middle (connected to the output from the GPIO
NZY_]ZW^bSP_SP]_SP8:>10?T^_`]YPOZYZ]Zʬ pin), and the drain is on the right (connected to
For the N-channel MOSFET, if a positive voltage is the buzzer’s negative terminal).
L[[WTPO_Z_SPRL_P_SPYN`]]PY_NLYʮZbQ]ZX_SP The breadboard layout for the
drain to the source. circuit can be seen in Figure 4.
MOSFETS can be used to switch bigger loads A resistor is used between the
than integrated circuits are capable of. An example
of a MOSFET is a 2N7000, which can switch up to
200 mA. See the schematic symbol and pin layout
in Figure 3.

Making noise with a buzzer


06 The buzzer used is a self-contained
Figure 4 The
MOSFET allows
Pico to control
miniature buzzer designed for 5 or 6 V. This type circuits with a higher
voltage or current
of buzzer is the easiest to use and will make a requirement. The
buzzing noise whenever a voltage is applied to it. buzzer needs more
than a standard GPIO
pin could provide

Raspberry Pi Pico inputs and outputs magpi.cc 47


TUTORIAL

ʭaP8:>10?^LYOʭaP]P^T^_Z]^_ZNZY_]ZWLWW_SP
LEDs. This would also take up a lot of space on the
breadboard. An alternative is to use an integrated
circuit that combines these into a single chip. A
suitable integrated circuit is the ULN2803. This is
Figure 3 Circuit
symbol and pin actually a Darlington driver chip, which is based
layout for a 2N7000 around a bipolar transistor – see the schematic
MOSFET. The gate
acts like an electronic in Figure 5. The ULN2803 has eight Darlington
version of the button
drivers (as shown in Figure 6) and can also be
on a switch
used to replace the MOSFET for the buzzer.
GPIO pin and the gate of the MOSFET. The reason
QZ]_ST^T^_SL_bSPYL8:>10?T^ʭ]^__`]YPOZY
_SP]PNLYMPLYTYT_TLWTY]`^SN`]]PY_ʮZbTYRTY_Z
Connecting the buttons
the gate. Once the MOSFET is fully turned on, the
N`]]PY_bTWWMPaP]d^XLWW,"ŧ]P^T^_Z]]PO`NP^
10 These arcade buttons have four pins, two
the inrush current. of which are for the switch and two are for the
LED (see the datasheet or supplier information
to identify which is which). The buttons and
their LEDs have spade connectors. These can be
Making some noise
08 With the wiring complete, the buzzer can
connected using pre-made wires, or you can create
your own using a crimp tool (see magpi.cc/crimp).
be activated by setting the output of the GPIO For the arcade buttons, the switch pins should
pin high. A simple while loop can be used which be connected between the GPIO pin and ground.
detects if the button is pressed: For the LED, connect the +5 V terminal to the
5 V power supply and the ground terminal to the
if button1.value() == 0: appropriate pin on the ULN2803.
The wiring is shown in Figure 1, but the number
And if so, then turn the GPIO output pin high. of crossing wires makes it hard to see. A better
diagram is the schematic in Figure 7.
buzzer = Pin(15, Pin.OUT)
buzzer.value(1)

Programming the arcade buttons


11 ?SPZ`_[`_^QZ]_SP70/^L]POPʭYPOTY_SP
Using an integrated circuit
09 To create the game, you need to add arcade
same way that the buzzer is. Rather than creating
ʭaP^P[L]L_PaL]TLMWP^QZ]_SPTY[`_^LYOʭaPQZ]
buttons with built-in LEDs. Many arcade buttons the LEDs these have been combined into lists.
are designed for 12 V, but to use with Pico’s power,

Top Tip you need ones designed for 5 V.


The button LEDs could be controlled through
a MOSFET as described above. This would need
Darlington
driver
‰Ęå%±ųĬĜĹčƋŅĹ
ÚųĜƴåųƚŸåŸƋƵŅ
Ƌų±ĹŸĜŸƋŅųŸ
ÏŅĹĹåÏƋåÚ
ƋŅčåƋĘåųţ‰ĘĜŸ
čĜƴ埱ƴåųƼĘĜčĘ Figure 5 The
č±ĜĹØ±ĬĬŅƵĜĹč± Darlington driver
uses two bipolar
ĵƚÏĘĘĜčĘåų transistors paired
ŅƚƋŞƚƋÏƚųųåĹƋ together. Used with
ÏŅĵޱųåÚƋŅ a digital circuit,
they can utilised in Figure 6 The ULN2803 has eight Darlington drivers, which share a
ƋĘåĜĹŞƚƋţ the same way as a common ground. These can be used for eight separate devices. The
single MOSFET large triangle symbols represent each Darlington driver

48 magpi.cc Raspberry Pi Pico inputs and outputs


TUTORIAL

Figure 7 The schematic


diagram makes it easier to see
which components are wired
together. To avoid crossing
lines, labels have been used;
labels with the same name are
connected together

quiz-game.py DOWNLOAD
THE FULL CODE:
> Language: MicroPython magpi.cc/arcadebuttonsgit
A for loop is used to go through each of the pin
numbers and assign them to the buttons list for 001. ## Quiz game
the inputs and the leds list for the outputs. 002. # Detects the first to press their button
The code provided allows for the buttons to be 003. # Sounds the buzzer for 1 second and lights the
`^POTYLɩʭYRP]ZY_SPM`eeP]ɪ\`TeRLXP0LNSZQ 004. # button pressed for additional 2 seconds
the buttons’ elements are checked and, if a button 005. from machine import Pin
is pressed, then the LED is turned on and the 006. import utime
buzzer sounds. 007.
008. buzzer = Pin(15, Pin.OUT)
009. # Red, Green, Yellow, Blue, White
010. button_pins = [16, 17, 18, 19, 20]
Finishing the game
12 You can play the game with the players
011.
012.
led_pins = [6, 7, 8, 9, 10]
buttons = []
holding the switches in your hand, or you can 013. leds = []
create an enclosure to hold the circuit and 014.
mount the switches. If you have a 3D printer, 015. for i in range (0, len(button_pins)):
_SPYdZ`NLYOZbYWZLO_SP>?7ʭWPQ]ZX 016. buttons.append (Pin(button_pins[i], Pin.IN,
magpi.cc/penguinquizgame. If not, you can create Pin.PULL_UP))
your own by drilling appropriate holes into a 017. leds.append (Pin(led_pins[i], Pin.OUT))
plastic storage box. 018.
?SP]PL]POTʬP]PY_RLXP^_SL_NZ`WOMP[WLdPO 019. while (1):
by changing the code. The code included here is 020. button_pressed = False
QZ]L\`TeRLXPM`eeP]4YLOOT_TZY_SP2T_3`M 021. # check for which buttons pressed
repository also includes a reaction game. 022. for i in range (0, len(buttons)):
023. if buttons[i].value() == 0:
024. print ("Button {} pressed".format(i))
025. leds[i].value(1)
026. button_pressed = True
027. else:
028. leds[i].value(0)
029. if button_pressed:
030. # Sound buzzer for 1 second
031. buzzer.value(1)
032. utime.sleep(1)
033. buzzer.value(0)
034. # Leave LEDs on for 2 more seconds
035. utime.sleep(2)
036. # Reset all buttons
037. for i in range (0, len(buttons)):
Figure 88LIǻRMWLIHKEQIGERFIMRWXEPPIHMRXSER
enclosure. This one is 3D-printed, but you could just
038. buttons[i].value(0)
use a plastic storage box and drill holes for the buttons

Raspberry Pi Pico inputs and outputs magpi.cc 49


TUTORIAL

Create a Bluetooth
music visualiser
Use a Pico W-powered LED matrix display as a
Bluetooth speaker with real-time visual effects

A
Flash firmware to Pico W
Phil King
s the French trio Stardust once sang,
02
MAKER

“music sounds better with you”. It also 9ZbdZ`SLaP_SP@1ʭWPT_ɪ^_TXP_ZʮL^S


sounds better when you have an audio it to your display board’s Pico W, situated on the
A long-time
aT^`LWT^P]N]PL_TYRNZZWWZZVTYRZY_SPʮd ]PL],^`^`LWNZYYPN_T_aTL@>-_ZdZ`]NZX[`_P]
contributor to The
MagPi, Phil is a WTRS_TYRPʬPN_^]PLN_TYR_Z_SP^Z`YO?SPRZZO bSTWPSZWOTYR_SP-::?>07M`__ZYZY;TNZB
freelance writer and news is that you can turn a Pimoroni Galactic Release the button and it should show up on your
editor with a focus or Cosmic Unicorn LED matrix display into a NZX[`_P]ɪ^ʭWP^d^_PXL^LO]TaPNLWWPO=;4=;
on technology.
-W`P_ZZ_S^[PLVP]bT_S]PLW_TXPaT^`LWPʬPN_^ >TX[WdO]LR_SPblunicorn.uf2ʭWPTY_Z_SP
@philkingeditor While you can easily run the ‘Blunicorn’ music =;4=;O]TaP_ZʮL^ST__Z;TNZB
aT^`LWT^P]MdOZbYWZLOTYR_SPʭ]XbL]PLYO
ʮL^STYRT__Z_SP@YTNZ]Yɪ^TY_PR]L_PO;TNZB
bPɪWW^SZbdZ`SZb_ZPOT_ZYPZQ_SPPʬPN_^LYO
Bluetooth pairing
LOOLYPc_]LZYPMdPOT_TYR_SPNZOPZY2T_3`M
03 :YNP_SPʭ]XbL]PT^ʮL^SPO[]P^^_SP
Reset button on the rear of your Galactic or Cosmic
@YTNZ]Y_Z]P^_L]_T_4_bTWWL`_ZXL_TNLWWd^_L]_
Download Blunicorn firmware
01 ?SP2LWLN_TNLYO.Z^XTN@YTNZ]YOT^[WLd^
]`YYTYR_SP-W`YTNZ]Yʭ]XbL]PbSTNSXLVP^T_
LaLTWLMWPL^L-W`P_ZZ_SOPaTNP
You’ll Need NZXPbT_S;TXZ]ZYTɪ^ZbYN`^_ZX;TNZʭ]XbL]P :YdZ`]NZX[`_P]Z]L^XL]_[SZYP_`]Y
pre-installed with an automatically running -W`P_ZZ_SZYLYOʭYOɩ2LWLN_TN@YTNZ]YɪZ]
> Cosmic Unicorn or []ZR]LX_SL_WP_^dZ`NSZZ^PQ]ZXQZ`]OPXZ^ ‘Cosmic Unicorn’ in the available Bluetooth
Galactic Unicorn But you’ll need to replace this with the special OPaTNP^>PWPN_T__Z[LT]bT_ST_ZY-W`P_ZZ_S4Q
(Pico W Aboard)
-W`YTNZ]Yʭ]XbL]P_ZN]PL_PL-W`P_ZZ_S using a computer, make sure its audio output is
magpi.cc/cosmic
magpi.cc/galactic X`^TNaT^`LWT^P] also set to Galactic or Cosmic Unicorn rather than
Head to the Releases page in the GitHub repo _SPTY_P]YLW^[PLVP]^
> 'PYRMGSVRǻVQ[EVI
magpi.cc/ (magpi.cc/blunicorndl) and download the UF2
blunicorndl ʭ]XbL]PQZ]dZ`]MZL]O%PT_SP]_SPɩNZ^XTN
MW`YTNZ]YɪZ]ɩRLWLN_TN`YTNZ]YɪʭWPTYE4;Z]2E
> Laptop, tablet, or
Use visualiser effects
smartphone with
Bluetooth
QZ]X:YNPT_ɪ^OZbYWZLOPO_ZdZ`]NZX[`_P]
extract it to create a folder with the relevant
04 With your computer or smartphone
blunicorn.uf2ʭWPTY^TOP connected to your Unicorn display via Bluetooth,

50 magpi.cc Create a Bluetooth music visualiser


TUTORIAL

=SYGERW[MXGLIǺIGXWF]TVIWWMRK
XLIFYXXSRWSRXLIVIEVSJXLIPIJX
WMHISJXLI9RMGSVRFSEVH

The music visualiser features a


spectrogram that reacts to the
audio frequencies in real-time

T_ɪ^_TXP_Z_P^_T_Z`_5`^_^_L]_[WLdTYR^ZXP a locally downloaded version – although you can


music or other audio, and you should hear it ^_TWWOZ_SL_MdNWZYTYR_SP]P[Z_ZdZ`]NZX[`_P]
_S]Z`RSdZ`]@YTNZ]YMZL]Oɪ^]PL]^[PLVP]4QYZ_ You’ll need to sign up for a free GitHub
make sure you have the volume turned up on your LNNZ`Y_TQdZ`OZYɪ_SLaPZYPLW]PLOd?SPYaT^T_
NZX[`_P]Z][SZYP the Blunicorn repo (actually named ‘galactic-
?SP@YTNZ]YOT^[WLd^SZ`WOLW^Z^_L]_^SZbTYR bluetooth-audio’) at magpi.cc/blunicorn.WTNV_SP
L]LTYMZb11?QL^_1Z`]TP]_]LY^QZ]XPʬPN_Md Fork option at the top right of the page to create a
NZ[dZQ_SP]P[ZTYdZ`]ZbY2T_3`MLNNZ`Y_DZ`

Make sure you have the NLYYZbLW_P]_ST^_ZdZ`]SPL]_ɪ^NZY_PY_

volume turned up on your


computer or phone 06 Edit an effect
While you could clone the GitHub repo to
default, with a spectrogram reacting in real-time your computer and edit the code locally, you
_Z_SPWPaPW^ZQaL]TZ`^Q]P\`PYNTP^TY_SPX`^TN need quite a lot of extra bits installed to build
You can press the B button on the Unicorn to
^bT_NS_ZLɩNWL^^TNɪ11?PʬPN_bSTNS^SZb^_SP
LYPb@1ʭWPZY_SPNZXXLYOWTYPTYNW`OTYR
_SP;TNZ>/64_ɪ^QL]PL^TP]_ZPOT__SPNZOP
Top Tip
main spectrogram frequency levels in green and OT]PN_WdZY2T_3`MLYO_SPY`^P2T_3`M,N_TZY^
_SP[PLV^TY]PO _ZL`_ZXL_TNLWWdM`TWOLYPb@1ʭWP
Restore firmware
?]dOTʬP]PY__d[P^ZQX`^TNLYOLW_P]_SP :[PY_SPPʬPN_ folder and click on
If you want to later
output volume on your connected device for NWL^^TNJʬ_N[[ to edit the code for the Classic restore the standard
STRSP]Z]WZbP][PLV^ 11?PʬPN_BPɪ]PRZTYR_ZXLVPL^TX[WP {ĜĵŅųŅĹĜĀųĵƵ±ųå
NSLYRP_ZLW_P]_SPPʬPN_ɪ^NZWZ`]^NSPXP to your Galactic or
which is set in the forWZZ[ZYWTYP^"!_Z# Cosmic Unicorn,
download the
?SPhaL]TLMWPOP_P]XTYP^_SPS`P
relevant version
Fork GitHub repo
05 ?Z^_L]_POT_TYRLYPʬPN_T_ɪ^LRZZOTOPL_Z
?SPX`W_T[WTP]ZYWTYP"#^P_^_SP
NZWZ`]^bPP[]LYRPbSTWP_SPZYWTYP
from magpi.cc/
pimoronipicoreleases
fork the GitHub repository so you can experiment "$OP_P]XTYP^_SPZʬ^P__ZXL[_ZL^[PNTʭN ±ĹÚā±ŸĘĜƋƋŅ{ĜÏŅœţ
with altering the code directly via GitHub rather on [Z]_TZYZQ_SPS`PbSPPW-dOPQL`W__ST^

Create a Bluetooth music visualiser magpi.cc 51


TUTORIAL

Add a new effect


09 9Pc_bPɪWWO`[WTNL_PLYPcT^_TYRPʬPN_ʭWP
POT_T__SPYL^^TRYT__ZLY`Y`^POM`__ZY.
 &QSHMǻIH(PEWWMG ]P^`W_^TYR]PPYQ]P\`PYNdWPaPW^LYO]PO[PLV^-d :[PY_SPNWL^^TNJʬ_N[[ʭWPTY2T_3`M_SPYNWTNV
++8IǺIGXSRXLI
Cosmic Unicorn, LOU`^_TYR_SPZʬ^P__Z!!!QZ]TY^_LYNPdZ`NLY _SP.Z[dTNZY2ZMLNV_Z_SPPʬPN_ folder, click
with a greater NSLYRP_SPNZWZ`]^_ZMW`PLYOR]PPY ZYɩ,OOʭWPɪ_SPYɩ.]PL_PYPbʭWPɪ;L^_P_SP
range of colour and
EPXIVIHSǺWIX code you copied, then edit it however you want

Compile new UF2


Experiment with changing
07 :YPZQ_SP[]Z^ZQbZ]VTYRTY2T_3`MT^_SL_ the range and offset values
it can be used to easily rebuild the project’s UF2
ʭWP^bSPYdZ`NSLYRP_SPNZOP.WTNVZY2T_3`M PR_ZLW_P]_SPNZWZ`]^NSPXPL^MPQZ]P.SLYRP
,N_TZY^LYO_SPYQZ]ɩ.8LVPML^PO[]ZUPN_^ɪNWTNV _SPTY^_LYNP^ZQ_SPQ`YN_TZYYLXPɩ.WL^^TN11?ɪ_Z
_SP.ZYʭR`]PM`__ZY_ZN]PL_PLD,87ʭWPQZ]T_ ɩ.WL^^TN11?ɪ9LXP_SPʭWPTY_SP_Z[ʭPWOPR
?SP.8LVPbZ]VʮZb^SZ`WO_SPY]`Y NWL^^TNJʬ_N[[LYONWTNVɩ.ZXXT_NSLYRP^ɪ

Top Tip automatically every time you commit a change


_Z_SP]P[ZTQYZ_XLVP^`]P_SPbZ]VʮZbT^
DZ`YPPO_ZN]PL_PLYPb.WL^^TN11?NWL^^TY
the PʬPN_^S[[ʭWP.Z[dLYO[L^_P_SP.WL^^TN11?
PYLMWPO4_`^`LWWd_LVP^LNZ`[WPZQXTY`_P^ NWL^^WTYP^$ɧ""_SPYNSLYRP_SPYPbNWL^^ɪ^
Make it _ZNZX[WP_P_SP_L^V&@1ʭWP^QZ]2LWLN_TNLYO TY^_LYNP^ZQɩ.WL^^TN11?ɪ_Zɩ.WL^^TN11?ɪ
another way Cosmic Unicorn versions will then appear in the DZ`LW^ZYPPO_ZN]PL_PL.8LVPʭWPQZ]_SP
If you clone the ,]_TQLN_^^PN_TZYQZ]_SL_bZ]VʮZb]`Y PʬPN_1ZWWZb_SPLMZaP[]ZNPO`]P_ZNZ[d_SP
GitHub repo, you code from NWL^^TNJʬ_NXLVPTY_ZLYPbʭWP
can use CMake to
build the project
on the command Flash and test
ĬĜĹåţ¥ŅƚűĬĬĹååÚ 08 Download the relevant newly created UF2
the Pico-SDK,
pico-extras
ʭWPQZ]dZ`]@YTNZ]YXZOPWLYOʮL^ST__Z;TNZB
library, and GCC L^[]PaTZ`^Wd_SPY]P^P_.ZYYPN__Z_SP2LWLN_TNZ]
ARM embedded Cosmic Unicorn via Bluetooth from another device
ƋŅŅĬÏʱĜĹţ„åå again and then press the B button on the rear to
ŸåÏƋĜŅĹƖţŎŅüƋĘå ^PP_SP.WL^^TN0ʬPN_bT_SdZ`]YPbNZWZ`]^NSPXP
Getting started
MW`P^SLOP^LYOR]PPY[PLV^TYZ`]PcLX[WP
with Raspberry
0c[P]TXPY_bT_SNSLYRTYR_SP]LYRPLYOZʬ^P_
Pi Pico guide:
magpi.cc/ values for the haL]TLMWPTY_SPPʬPN_NZOP_ZRP_
getstartedpicoţ OTʬP]PY_NZWZ`]^4QdZ`SLaP.^VTWW^dZ`NLY
The rear of the board features a mini speaker that plays
LW^Z_]dLW_P]TYRZ_SP]L^[PN_^ the audio; you could connect a bigger speaker to the port

52 magpi.cc Create a Bluetooth music visualiser


TUTORIAL

DOWNLOAD
THE FULL CODE:
magpi.cc/blunicornmod
The Rainbow FFT
called NWL^^TNJʬ_NXLVPDZ`ɪWWYPPO_ZPOT__SP classic2_fft IǺIGXSRXLIWQEPPIV
NZOPTYT__ZNSLYRP_SPTY^_LYNP^ZQɩNWL^^TNJʬ_ɪ Galactic Unicorn
display, reacting to
_ZɩNWL^^TNJʬ_ɪ ?ZTYNW`OP_SPPʬPN_`YOP]WTYP!LOO% Bluetooth music
being played

include(effect/classic2_fft.cmake)

Effect additions
10 BPɪWWYPPO_ZLOO_SPYPbPʬPN__Z_SP
9ZbNWTNVɩ.ZXXT_NSLYRP^ɪ

button handling list in M_^_LNVJL`OTZJ[TNZN[[


in the srcQZWOP]@YOP]WTYP#LOO_ST^NZOP_Z
Download and test
L^^TRY_SP_ST]OPʬPN__ZM`__ZY.%
12 .SPNV_SP2T_3`M,N_TZY^[LRPLYOdZ`ɪWW^PP
if (!gpio_get(Display::SWITCH_C)) { _SPYPbbZ]VʮZbTY[]ZR]P^^DZ`NLYNWTNVZYT_
current_effect = 2; and then either Cosmic Unicorn or Galactic Unicorn
} _Z^PP_SPaP]MZ^PZ`_[`_LYONSPNVQZ]LYdP]]Z]^
:YNP_SPbZ]VʮZbSL^NZX[WP_PO^`NNP^^Q`WWd
OZbYWZLO_SP]PWPaLY_@1ʭWPQ]ZXT_^,]_TQLN_^
4Y_SP^LXPʭWP_SPPʬPN_^L]P[`^SPO_Z_SP WT^_LYOʮL^ST__ZdZ`]@YTNZ]YMZL]OL^MPQZ]P
-W`P_ZZ_S^_LNVZYWTYP^ ɧ @YOP]YPL_SLOO% Reset the board, connect via Bluetooth, and try By changing the
hue range and
[]P^^TYR_SP.M`__ZY_Z^PP_SPYPbPʬPN_DZ` SǺWIXZEPYIWMRXLI
classic_fft.cppIǺIGX
effects.push_back(&classic2_fft); NLYYZb^bT_NSMP_bPPY_S]PPPʬPN_^ZYdZ`]
code, we can alter
X`^TNaT^`LWT^P] the colours used
?ZLOOLYTY^_LYNPQZ]_SPPʬPN_LOO_ST^LQ_P]
WTYP"%

ClassicFFT2 classic2_fft(display, fft);

BSPYOZYPNWTNVɩ.ZXXT_NSLYRP^ɪ

Append CMake list


11 ?ZRP_.8LVP_ZM`TWO_SP_ST]OPʬPN_
^`NNP^^Q`WWdTY_ZLYPb@1ʭWPdZ`ɪWWYPPO_Z
make a couple of additions to the .8LVPWT^_^_c_
ʭWP1T]^_WP_ɪ^WTYVT__Z_SP[]ZUPN_&`YOP]
WTYPLOO%

Create a Bluetooth music visualiser magpi.cc 53


TUTORIAL

Camera Module:
Part 01

Getting Started
Getting to know Raspberry Pi Camera Module options,
setting up, and testing a camera with Raspberry Pi

I
Raspberry Pi Camera Module
n this tutorial, we’ll introduce you to the
]LYRPZQOTʬP]PY_=L^[MP]]d;TNLXP]L^LYO
01 =L^[MP]]d;Tɪ^ʭ]^_ZʯNTLWNLXP]LbL^
_LWVdZ`_S]Z`RS_SP[L]_TN`WL]QPL_`]P^LYO WL`YNSPOTYLYO[]ZO`N_TZYNPL^POTY"
David MPYPʭ_^ZQPLNSZYPBPɪWW^SZbdZ`SZb_Z L^_SP^PY^Z]ZYbSTNS_SPNLXP]LT^ML^POT^YZ
MAKER

Plowman NZYYPN__SPX_Z=L^[MP]]d;TLYO_P^__SL__SPd WZYRP]LaLTWLMWP,Y`XMP]ZQ_ST]O[L]_d^PWWP]^


L]PbZ]VTYRNZ]]PN_Wd1TYLWWdbPɪWWʭYT^SbT_S NZY_TY`P_Z^PWWaZ]aNZX[L_TMWPNLXP]L^LYO
David is an engineer LNZ`[WPZQ^TX[WPPcLX[WP^_Z^SZbdZ`SZb_Z LWW=L^[MP]]d;T^ZQ_bL]PNZY_TY`P^_Z^`[[Z]_T_
at Raspberry Pi with
NL[_`]PdZ`]ʭ]^_[SZ_ZZ]aTOPZ ?SPNLXP]LT^L 8;OPaTNPTYLʭcPO
a special interest
in camera software ?ST^T^_SPʭ]^_[L]_ZQL^P]TP^ZQ_`_Z]TLW^ QZN`^XZO`WPbT_SLXLcTX`X]P^ZW`_TZYZQ
and algorithms, and _SL_bTWW_LVPdZ`_S]Z`RS=L^[MP]]d;TNLXP]L^  $Ÿ$[TcPW^LYO`^P^_SP:XYTaT^TZY
image processing Q]ZXLM^ZW`_PMPRTYYP]_ZLOaLYNPO=L^[MP]]d;T :A !"TXLRP^PY^Z],_WZbP]]P^ZW`_TZY^
hardware.
TXLRTYR_PNSYT\`P^ T_T^NL[LMWPZQ`[_Z!Q]LXP^[P]^PNZYO
raspberrypi.com =L^[MP]]d;TSL^XLOPʭaPOTʬP]PY__d[P^ZQ 4_T^^`T_LMWPQZ]^_TWWTXLRP[SZ_ZR]L[SdLYO
NLXP]L^ZQbSTNSLWWM`__SPZ]TRTYLWaNLXP]L aTOPZ]PNZ]OTYR
L]PN`]]PY_WdTY[]ZO`N_TZY>ZXPZQ_SPXNZXPTY AP]^TZY^ZQ_ST^NLXP]LbT_S_SP4=TYQ]L]PO
_bZZ]XZ]POTʬP]PY_aL]TLY_^.ZX[L_TMWPNLXP]L ʭW_P]]PXZaPOSLaPMPPYLaLTWLMWPQZ]^[PNTLWT^PO
XZO`WP^L]PLW^ZXLOPMdLY`XMP]ZQ_ST]O[L]_d `^PNL^P^
^`[[WTP]^_SZ`RSbPNLYɪ_NZaP]LWWZQ_SZ^PTY_ST^
_`_Z]TLWLYOQZ]LYd\`P^_TZY^ZQ^`[[Z]_T^^`P^
]PWL_PO_Z_SPXdZ`XTRS_SLaP_ZRZMLNV_Z_SP
^`[[WTP]bSP]PdZ`MZ`RS__SPNLXP]L
?SPZʯNTLW=L^[MP]]d;TNLXP]LXZO`WP^L]P%
• =L^[MP]]d;T.LXP]L8ZO`WP
• =L^[MP]]d;T.LXP]L8ZO`WP
• =L^[MP]]d;T3TRS<`LWT_d.LXP]L
• =L^[MP]]d;T.LXP]L8ZO`WP
• =L^[MP]]d;T2WZMLW>S`__P].LXP]L

You’ll Need
> Raspberry Pi
Raspberry Pi Camera Module 2
> Camera Module
magpi.cc/
02 =L^[MP]]d;T.LXP]L8ZO`WPbL^
cameramodule TY_]ZO`NPOTY#_Z]P[WLNP_SPZ]TRTYLW.LXP]L
> Raspberry Pi OS 8ZO`WPLYOT_NZXP^TYL^TXTWL]^XLWWQZ]X
magpi.cc/imager QLN_Z]4_ZʬP]^M]ZLOWd^TXTWL]QPL_`]P^LYO
^WTRS_WdTX[]ZaPO[P]QZ]XLYNP

54 magpi.cc Camera Module: Getting Started


TUTORIAL

.LXP]L8ZO`WPT^LY#8;[TcPWOPaTNPNL[LMWP
ZQZ`_[`__TYRTXLRP^L_LXLcTX`X]P^ZW`_TZYZQ
#Ÿ![TcPW^4_T^NL[LMWPZQ`[_ZQ]LXP^
[P]^PNZYOL_LA2,]P^ZW`_TZYLYOT^ML^POZY
>ZYdɪ^48C$TXLRP^PY^Z]
7TVP_SPZ]TRTYLWNLXP]LT_`^P^LʭcPOQZN`^ Camera Modules connect
WPY^bSTNST^XLY`LWWdLOU`^_PO`^TYRL^`[[WTPO directly to Raspberry Pi
_ZZW_ZTYN]PL^P_SP]LYRPZQL[[WTNL_TZY^QZ]bSTNS boards via a ribbon cable
T_NLYMPOP[WZdPO

Raspberry Pi
03 High Quality Camera
=L^[MP]]d;T3TRS<`LWT_d.LXP]LTY_]ZO`NPO
TYT^LWL]RP]OPaTNP_SL_^`[[Z]_^ Camera Module 3
TY_P]NSLYRPLMWP.LYO.>XZ`Y_WPY^P^?SP is a high-resolution
TXLRP^PY^Z]^ST[^bT_SZ`_LYTYNW`OPOWPY^ addition to Raspberry Pi
with an autofocus lens
=L^[MP]]d;T]PNZXXPYO^LbTOPLYRWP!XX.>
and the opportunity to
XZ`Y_WPY^LYOLYL]]ZbP]ʭPWOZQaTPb!XX
capture HDR images
.XZ`Y_WPY^&MZ_SL]PWZbNZ^_LYO^`T_LMWPQZ]L
bTOP]LYRPZQ`^PNL^P^1Z]^[PNTʭNL[[WTNL_TZY^
`^P]^XLdbLY__Z^PWPN_XZ]PL[[]Z[]TL_PWPY^P^
,YLW_P]YL_TaPaP]^TZYZQ_SP3<.LXP]L_SL_
LNNP[_^8WPY^P^bL^]PWPL^POTY
?SP3TRS<`LWT_d.LXP]LQPL_`]P^L8;^PY^Z] The sensor is quite capable
ZʬP]TYRLXLcTX`X]P^ZW`_TZYZQŸ
[TcPW^LYOMPNL`^PZQT_^[Sd^TNLWWdWL]RP]^PY^Z] for still photography, but
^TePT_NLYMPPc[PN_PO_Z[]ZO`NP
MP__P]TXLRP\`LWT_d shines particularly for video
_SLY_SP.LXP]L
8ZO`WP4_XLVP^
recording applications
`^PZQ>ZYdɪ^48C""
TXLRP^PY^Z]LYO !%$]L_SP]_SLYL%L^[PN_]L_TZ-PNL`^PZQ_SP
T^LW^Z^`T_LMWPQZ] ^[PNTLWYL_`]PZQ_ST^^PY^Z]_SP3/=QPL_`]PT^
NL[_`]TYRaTOPZ,_ YZ_LaLTWLMWPL__SPXLcTX`X]P^ZW`_TZYM`_ZYWd
WZbP]]P^ZW`_TZY^T_ L_L]P^ZW`_TZYZQŸ$![TcPW^
NLY]`YL_`[_Z ?SP^PY^Z]T^\`T_P Top Tip
Q]LXP^[P]^PNZYO NL[LMWPQZ]^_TWW
[SZ_ZR]L[SdM`_ NoIR
^STYP^[L]_TN`WL]Wd
QZ]aTOPZ]PNZ]OTYR Current Camera
Raspberry Pi Camera Module 3 Module devices
04 4Y_]ZO`NPOTY_SP.LXP]L8ZO`WP
L[[WTNL_TZY^
P^[PNTLWWdbSP]P
are available
without the IR
T^LYZ_SP]^XLWWQZ]XQLN_Z]NLXP]L_SL_T^\`T_P 3/=T^MPYPʭNTLW
ŠĜĹüų±ųåÚšĀĬƋåųţ
^TXTWL]_Z.LXP]L8ZO`WP4_ZʬP]^TYN]PL^PO ,_LYL[[]Z[]TL_P These are able
]P^ZW`_TZYTYLbTOP]L^[PN_]L_TZLYL`_ZQZN`^ ]P^ZW`_TZYT_bTWW to record better
WPY^LYO_SPZ[[Z]_`YT_d_ZNL[_`]P3/=3TRS ^`[[Z]_aTOPZNL[_`]P in low light
/dYLXTN=LYRPTXLRP^ L_`[_ZQ]LXP^ conditions (but
daylight images
?SPL`_ZQZN`^NLY]`YTYNZY_TY`Z`^XZOPZ] [P]^PNZYO
have curious
MP_]TRRP]PO[]TZ]_ZTXLRPNL[_`]PLNNZ]OTYR_Z ?SPNLXP]LXZO`WPT^
ÏŅĬŅƚųŸšţ‰ĘåŸå
_SP^ZQ_bL]PMPTYR`^PO ML^POZY_SP>ZYd48C"# models are
?SPXLcTX`X]P^ZW`_TZYZQ_SP^PY^Z]T^ ^PY^Z]4_T^[LNVLRPOTY_Z ĵ±ųĩåÚ±ŸůcŅFűţ
!#Ÿ $[TcPW^_SP]PQZ]PYZ_P_SL_T_SL^L QZ`]OTʬP]PY_aL]TLY_^%

Camera Module: Getting Started magpi.cc 55


TUTORIAL

Using interchangeable lenses


• .LXP]L8ZO`WP?SP]PR`WL]aP]^TZYbT_SLY
4=ʭW_P]LYOWPY^bT_S_SP^_LYOL]OʭPWOZQaTPb
06 ?SP3TRS<`LWT_dLYO2WZMLW>S`__P]
• .LXP]L8ZO`WPBTOP,aP]^TZYbT_SLY4= .LXP]L^MZ_S`^P_SP^LXPQZ]XL_^ZQ
ʭW_P]M`_]P[WLNTYR_SP^_LYOL]OWPY^bT_SL TY_P]NSLYRPLMWP.XZ`Y_LYO.>
bTOPLYRWPZYP XZ`Y_WPY^P^,YLOL[_P]QZ]
• .LXP]L8ZO`WP9Z4=,aP]^TZYbT_SZ`_LY4= 8WPY^P^T^LW^ZLaLTWLMWP
ʭW_P]M`_bT_S_SP^_LYOL]OʭPWOZQaTPbWPY^ Raspberry Pi
• .LXP]L8ZO`WP9Z4=BTOP,aP]^TZYbT_SZ`_ ^`[[WTP^LWZb
LY4=ʭW_P]LYObT_S_SPbTOPLYRWPWPY^ NZ^_bTOP
LYRWP!XX
.>XZ`Y_
WPY^LYO
LWL]RP]
!XX
.XZ`Y_
WPY^?SPT]
`^LRPT^TOPY_TNLW
PcNP[__SL__SP!XX
.XZ`Y_WPY^bTWW]P\`T]P_SP
..>LOL[_P]_ZMPʭ__POʭ]^_

Raspberry Pi Global
05 Shutter Camera
?SP2WZMLW>S`__P]2>NLXP]LTY_]ZO`NPOTY
`^P^L\`T_POTʬP]PY__PNSYZWZRd_Z_SP
Z_SP]NLXP]L^BSP]PL^T_ɪ^YZ]XLWTY_ST^XL]VP_
^PRXPY__Z`^P]ZWWTYR^S`__P]NLXP]L^_SP2>
NLXP]LPX[WZd^LRWZMLW^S`__P]
4Y_ST^NLXP]LLWW_SP[TcPW^TYLNL[_`]PO
TXLRPL]PPc[Z^POL_PcLN_Wd_SP^LXP_TXP]L_SP]
_SLY_SP]ZWWTYR^S`__P]NLXP]LbSP]P[TcPW^L]P 6.1 Fitting the C-CS adapter
NL[_`]POWTYPMdWTYP4Y[]LN_TNP_ST^T^R]PL_ 4QdZ`YPPO_SP..>LOL[_P]PY^`]P_SL_T_T^
QZ]NL[_`]TYRXZ_TZYɧ_SPM`^bSTeeTYRMdTY ʭ__PO_ZdZ`]!XXWPY^?SPWPY^P^SLaPLWZYRP]
dZ`]aTOPZbTWW]PXLTYL]PN_LYRWPbT_S_SPRWZMLW MLNVQZN`^_SLY_SP!XXWPY^LYO_SP]PQZ]P
^S`__P]NLXP]LbSP]PL^]ZWWTYR^S`__P]^PY^Z]^ ]P\`T]P_SPLOL[_P]
bTWWLWW_`]YT_TY_ZL[L]LWWPWZR]LX
?SP2WZMLW>S`__P]NLXP]LT^ML^POZY>ZYdɪ^
48C$!TXLRP^PY^Z]2WZMLW^S`__P]NLXP]L^L]P
PWPN_]ZYTNLWWdXZ]PNZX[WPc^Z]P^ZW`_TZY^L]P
RPYP]LWWdWZbP]4Y_ST^NL^P_SP2WZMLW>S`__P]
NLXP]L[]ZO`NP^ !Ÿ##[TcPW^_SZ`RSZY_SP
`[^TOP_SPPc_]LTY_P]YLWNZX[WPcT_dXPLY^_SL_
_SP[Sd^TNLW[TcPW^L]PWL]RP]XLVTYR_SPNLXP]L
XZ]P^PY^T_TaPLYOMP__P]L_WZbWTRS_TXLRTYR
?SP2WZMLW>S`__P]NLXP]L`^P^_SP^LXP
XZ`Y_TYRLYOWPY^P^L^_SP3TRS<`LWT_d.LXP]L
^ZQZ]XZ]PTYQZ]XL_TZYZY`^TYRLYO^bL[[TYR
WPY^P^[WPL^PNSPNVZ`__SPQZWWZbTYR^PN_TZYZY
TY_P]NSLYRPLMWPWPY^P^

56 magpi.cc Camera Module: Getting Started


TUTORIAL

6.2 Fitting the lens to the camera


=Z_L_P_SPWPY^LYO..>LOL[_P]TQ[]P^PY_
NWZNVbT^PLWW_SPbLdTY_Z_SPMLNVQZN`^
LOU`^_XPY_]TYR

6.3 Back focus adjustment ring and


lock screw
?SPMLNVQZN`^LOU`^_XPY_]TYR^SZ`WOMP^N]PbPO
TYQ`WWd@^P_SPMLNVQZN`^WZNV^N]Pb_ZXLVP

6.5 Focus
An adapter for M12 lenses ?ZLOU`^_QZN`^SZWO_SPNLXP]LbT_S_SPWPY^

is also available QLNTYRLbLdQ]ZXdZ`?`]Y_SPQZN`^]TYR


WLMPWWPOɩ90,=')1,=ɪLY_TNWZNVbT^P_ZQZN`^ZY
LYPL]MdZMUPN_?`]YT_NWZNVbT^P_ZQZN`^ZYL
^`]PT_OZP^YZ_XZaPZ`_ZQ_ST^[Z^T_TZYbSPY OT^_LY_ZMUPN_DZ`XLdʭYOdZ`YPPO_ZLOU`^__SP
LOU`^_TYR_SPL[P]_`]PZ]QZN`^ L[P]_`]PLRLTYLQ_P]_ST^

Connecting and
07 testing your camera
DZ`]=L^[MP]]d;TLYONLXP]LL]PNZYYPN_PO`^TYR
LʮL_]TMMZYNLMWP?SP]PL]PLN_`LWWd_bZ_d[P^
ZQNLXP]LNZYYPN_Z]%_SP^_LYOL]OZYPbSTNS
bPʭYOZYLWW_SPNLXP]LMZL]O^LYOZYɩWL]RPɪ Top Tip
=L^[MP]]d;TNZX[`_P]^=L^[MP]]d;TLYO
?SPY_SP]PT^L^WTRS_WdYL]]ZbP]aP]^TZYZQ_ST^ Removing IR
NZYYPN_Z]bSTNSbPʭYOZYɩ^XLWWɪ;TNZX[`_P]^
=L^[MP]]d;TEP]ZLYOEP]ZLYOLW^ZZQ_PYZY Some users have
=L^[MP]]d;Tɪ^4:MZL]O_SL_RZP^bT_S_SPaL]TZ`^ removed the IR
ŠĜĹüų±ųåÚšĀĬƋåų
.ZX[`_P8ZO`WP^
from the High
.Z]]P^[ZYOTYRWd_SPNLMWP^XLdSLaPMZ_SPYO^
}ƚ±ĬĜƋƼ±ĵåų±ţ
6.4 Aperture _SP^LXPZ]dZ`NLYLW^ZRP_NLMWP^bT_SZYP The operation
?ZLOU`^__SPL[P]_`]PSZWO_SPNLXP]LbT_S_SP YL]]ZbPYOLYOZYPbTOP]PYO requires some
WPY^QLNTYRLbLdQ]ZXdZ`?`]Y_SPTYYP]]TYR :YZYP^TOPZQ_SPNLMWP_SPPWPN_]TNLW skill and will void
NWZ^P^__Z_SPNLXP]LbSTWPSZWOTYR_SPNLXP]L NZYYPN_TZY^aT^TMWPL^YL]]Zb^TWaP]Z]RZWOPY any warranty
and there’s a
^_PLOd?`]YNWZNVbT^P_ZNWZ^P_SPL[P]_`]PLYO ^_]T[P^bTWWMPaT^TMWP:Y_SPZ_SP]^TOP_SPd
ŸĜčĹĜĀϱĹƋųĜŸĩ
]PO`NPTXLRPM]TRS_YP^^?`]YLY_TNWZNVbT^P L]PNZaP]POMdLNZWZ`]POZQ_PYM`_YZ_LWbLd^
of permanently
_ZZ[PY_SPL[P]_`]PBSPYSL[[dbT_S_SPWTRS_ MW`P[TPNPZQ[WL^_TNBPɪWW]PQP]_Z_SP^PL^_SP destroying
WPaPW_TRS_PY_SP^N]PbZY_SP^TOPZQ_SPWPY^_Z ɩPWPN_]TNLWɪLYOɩTY^`WL_POɪ^TOP^ZQ_SP]TMMZY ƼŅƚųϱĵåų±ţ
WZNV_SPL[P]_`]PTY_Z[Z^T_TZY NLMWP]P^[PN_TaPWd

Camera Module: Getting Started magpi.cc 57


TUTORIAL

Connecting to Raspberry Pi
09 ?SPWL]RP=L^[MP]]d;TMZL]O^SLaP_SP
^LXPNZYYPN_Z]L^dZ`bTWWʭYOZY_SPNLXP]L
LYOdZ`NLYZ[PYLYONWZ^PT_TY_SP^LXPbLd
9Z_P_SL__SP]PL]P_bZTOPY_TNLWNZYYPN_Z]^ZY_SP
MZL]O^MP^`]P_Z`^P_SPZYPWZNL_POYPL]_SP
0_SP]YP_LYO@>-[Z]_^LYOYZ__SPZYPZY_SPQL]
^TOPZQ_SPMZL]O?SP]TMMZYbZ`WOʭ_SP]PM`__SP
NLXP]LbTWWYZ_Q`YN_TZY
Connecting to the camera
08 ,__SPMZ__ZXZQPaP]dNLXP]LMZL]OT^L
,^QZ]Z]TPY_L_TZY_SPTY^`WL_PO^TOPZQ_SP
]TMMZYNLMWPX`^_QLNP_ZbL]O^_SP0_SP]YP_LYO
NZYYPN_Z]QZ]_SP]TMMZYNLMWP,__SPPORP^dZ`ɪWW @>-[Z]_^^Z_SPPWPN_]TNLW^TOPbTWWQLNP_ZbL]O^
MPLMWP_ZR]T[_SPMZ__ZX[L]_ZQ_SPNZYYPN_Z] _SP[ZbP]NZYYPN_Z]
LYO[`WWT_^WTRS_WdZ`_:YNPdZ`ɪaPOZYP_ST^dZ` =L^[MP]]d;TEP]ZMZL]O^SLaPLYL]]ZbP]
^SZ`WOMPLMWP_Z[`^S_SP]TMMZYNLMWPTY1TYLWWd aP]^TZYZQ_SPNZYYPN_Z]LYO_SP]PQZ]PLW^ZYPPO
[`^S_SZ^PPORP^ZQ_SPNZYYPN_Z]SZXPLRLTY^Z L]TMMZYNLMWPbT_S_SPYL]]ZbP]PYO?SP^PL]P
_SL__SP]TMMZYNLMWPT^SPWOʭ]XWd aP]d^TXTWL]ZYWd^XLWWP]LYOZ[PYLYONWZ^PTY
:YLWW=L^[MP]]d;TNLXP]LMZL]O^_SP]TMMZY _SP^LXPbLd-`_OZ_LVPNL]PL^_SPdL]PXZ]P
NLMWPX`^_MPTY^P]_PO^Z_SL__SPPWPN_]TNLW^TOP Q]LRTWPLYOM]PLVXZ]PPL^TWd
ZQ_SPNLMWPQLNP^QZ]bL]O^>ZTQdZ`_`]Y_SP BSPYdZ`TY^P]__SP]TMMZYNLMWPXLVP^`]P
NLXP]LMZL]O_Z[ZTY_LbLdQ]ZXdZ`^Z_SL_dZ` _SL__SPTY^`WL_PO^TOPZQ_SPNLMWPT^QLNP`[?SL_
NLYɪ_^PP_SPLN_`LWNLXP]LWPY^_SPYdZ`^SZ`WO T^bSPYdZ`NLY^PP_SPNST[^LYONZYYPN_Z]^ZY
^PP_SPTY^`WL_PO^TOPZQ_SP]TMMZYNLMWP _SP_Z[ZQ_SPMZL]OdZ`NLYLW^Z^PP_SPTY^`WL_PO
?SPNLXP]L]TMMZYNLMWP^L]P^SZ]_QZ]L]PL^ZY ^TOPZQ_SPNLMWP
_SPdNLYZ_SP]bT^PMP[]ZYP_ZTY_P]QP]PYNP
LYO_]LY^XT^^TZYP]]Z]^BPbZ`WORPYP]LWWd
]PNZXXPYOLaZTOTYRWPYR_S^R]PL_P]_SLYLMZ`_
Raspberry Pi Zero boards
NX_SZ`RS[PZ[WPSLaPSLO^`NNP^^bT_SWZYRP] have a narrower version of
NLMWP^_ZZ
the connector
>ZXPZ_SP]MZL]O^^`NSL^_SP4:MZL]O
=L^[MP]]d;TXLVP^QZ].ZX[`_P8ZO`WP^SLaP
LOTʬP]PY_aP]^TZYZQ_SPYL]]ZbNZYYPN_Z]?ST^
ZYPT^STYRPONL]PQ`WWd[]T^P_SPPORPZQT_`[
?SP]TMMZYNLMWP^SZ`WOMPTY^P]_PObT_S_SP
PWPN_]TNLW^TOPQLNPOZbY?SPSTYRPO[L]_ZQ_SP
NZYYPN_Z]^SZ`WOYZbMP^YL[[PO^S`_ZY_Z[ZQ
_SPTY^`WL_PO^TOPZQ_SPNZYYPN_Z]

Test your camera


10 ?Z_P^__SL_dZ`]NLXP]LT^NZ]]PN_Wd
NZYYPN_POLYObZ]VTYRdZ`bTWWYPPO_Z
TY^_LWW=L^[MP]]d;T:>:[P]L_TYR>d^_PX
ZY_ZdZ`]MZL]O@^TYR=L^[MP]]d;T4XLRP]
XLR[TNNTXLRP]b]T_P_SPOPQL`W_Z[_TZY
=L^[MP]]d;T:>MT__ZLXTN]Z>/NL]O
4Y^P]__ST^TY_ZdZ`]=L^[MP]]d;TLYO[ZbP]T_
ZY7P_T_[P]QZ]XLWW_SPYPNP^^L]d`[OL_P^bSPY
T_ʭ]^_MZZ_^LYO_SPYʭYLWWd]PMZZ_T_LRLTY
1Z]_SZ^PWP^^QLXTWTL]bT_S=L^[MP]]d;T
NZX[`_P]^bPbZ`WO]PNZXXPYO[P]QZ]XTYRdZ`]

58 magpi.cc Camera Module: Getting Started


TUTORIAL

TYT_TLW_P^_TYRbT_SLVPdMZL]OLYO^N]PPYL__LNSPO
OT]PN_Wd_ZdZ`]=L^[MP]]d;T@^TYR_SP=L^[MP]]d
XPY`Z[PY_SP,NNP^^Z]TP^NL_PRZ]dLYONWTNVZY
_SP?P]XTYLWM`__ZY4Y_Z_SP?P]XTYLWbTYOZbT_
^SZ`WOMP^`ʯNTPY__Z_d[P%

libcamera-hello

?ST^bTWWZ[PYLNLXP]L[]PaTPbbTYOZb
LYOOT^[WLd_SPNLXP]LTXLRP^_SP]PQZ]LMZ`_
ʭaP^PNZYO^
4QdZ`OZYɪ_^PP_SP[]PaTPbbTYOZb[WPL^P
NSPNV_SL_% XTWWT^PNZYO^_SP[]PaTPbbTYOZb]`Y^MPQZ]P_SP Camera Module
3 attached to
• DZ`L]POT]PN_WdNZYYPN_PO_ZdZ`]=L^[MP]]d;T TXLRPT^NL[_`]PO>Z_ZNL[_`]P_SPTXLRPLQ_P] Raspberry Pi 4
bT_SL^N]PPYLYOVPdMZL]O _PY^PNZYO^ZQ[]PaTPb`^P% board via the CSI
(Camera Serial
• DZ`L]P]`YYTYR_SPZʯNTLW=L^[MP]]d;T Interface) connector
^ZQ_bL]PLYO_SL_T_T^Q`WWd`[_ZOL_P4QdZ` libcamera-still -t 10000 -o picture.jpg
SLaPXLOPLYdNSLYRP^_ZdZ`]=L^[MP]]d;Tɪ^
NZYʭR`]L_TZY[WPL^PNZY^TOP]]PaP]_TYRMLNV
_Z_SP^_LYOL]O`YLW_P]PO=L^[MP]]d;T:>Md
]Pb]T_TYRdZ`]XTN]Z>/NL]OTQYPNP^^L]dLYO
_]dTYRLRLTY
The camera ribbon cables
• ,WWdZ`]NLMWP^L]P_SP]TRS_bLd]Z`YOLYO are short for a reason
^PL_PONZ]]PN_Wd
• DZ`L]P`^TYRLYZʯNTLW=L^[MP]]d;TNLXP]L
9ZYZʯNTLWNLXP]L^L]P^`[[Z]_POM`_XLd DZ`NLYaTPbdZ`][TN_`]P^MdOZ`MWPNWTNVTYR
YPPO^ZXPPc_]LNZYʭR`]L_TZYbSTNS_SPXZO`WP ZY_SPʭWP^dZ`ɪaP^LaPOTY_SP1TWP8LYLRP]BPɪWW
aPYOZ]bZ`WOSLaP_Z^`[[Wd WPL]YLMZ`_XLYdXZ]PZQWTMNLXP]L^_TWWɪ^Z[_TZY^
• DZ`SLaPLRZZO\`LWT_d[ZbP]^`[[Wd TY_SP_`_Z]TLW^_SL_QZWWZb
=L^[MP]]d;T[ZbP]^`[[WTP^L]P]PNZXXPYOPO
MPNL`^P_SPdL]PVYZbY_Z^`[[Wd^`ʯNTPY_
[ZbP]_Z=L^[MP]]d;TLYO_SPNLXP]L
Capturing your first video
• ;WPL^PNSPNVZ`_=L^[MP]]d;Tɪ^.LXP]L1Z]`X
QZ]XZ]P_T[^TQdZ`ɪ]PSLaTYR_]Z`MWP
12 ?SP]Pɪ^LYZ_SP]NZXXLYOWTYP_ZZWQZ]
NL[_`]TYRaTOPZ^&_ST^_TXPT_ɪ^NLWWPOWTMNLXP]L
aTODZ`NLY`^P_SP-oLYO-t Z[_TZY^L^dZ`OTO
MPQZ]P_SZ`RS_ST^_TXP-t^[PNTʭP^SZbWZYR
Capturing your first photo
11 =L^[MP]]d;T:>NZXP^bT_SLY`XMP]
LRLTYTYXTWWT^PNZYO^_SPaTOPZWL^_^?Z^LaPL
_PY^PNZYOaTOPZ`^P%
ZQNZXXLYOWTYP`_TWT_TP^QZ]NL[_`]TYRTXLRP^
TYaL]TZ`^OTʬP]PY_bLd^BPɪaPLW]PLOd^PPY libcamera-vid -t 10000 -o video.h264
WTMNLXP]LSPWWZbSTNSbP`^PO_Z_P^__SL_
_SPNLXP]LbL^bZ]VTYR?SPYPc_ZYPT^ 9Z_P_SL__SPʭWPYLXPPYO^bT_SS!
WTMNLXP]L^_TWW?ST^Z[PY^`[LNLXP]L[]PaTPb bSTNSTOPY_TʭP^_SPQZ]XL_ZQ_SPaTOPZʭWP
bTYOZbU`^_WTVPWTMNLXP]LSPWWZOTOM`_ZYNP @YQZ]_`YL_PWdYZ_LWWaTOPZ[WLdP]^bTWW[WLd_SP
T_ɪ^]`YQZ]ʭaP^PNZYO^T_bTWWNL[_`]PLSTRS S!QZ]XL_NZ]]PN_Wd^ZbPbZ`WO]PNZXXPYO
]P^ZW`_TZY^_TWW[SZ_ZR]L[SL^L5;02ʭWPLYO_SPY `^TYRL`_TWT_dWTVPʬ[WLd?Z[WLddZ`]aTOPZʭWP
\`T_?Z`^PT_WTVP_ST^PY_P]% bT_Sʬ[WLdPY_P]%

libcamera-still -o picture.jpg ffplay video.h264

9Z_PSZb_SP-oZ[_TZY^[PNTʭP^_SPYLXP BPɪWWWPL]YWL_P]SZb_Z^LaPOTʬP]PY_QZ]XL_^ZQ
ZQ_SPʭWP_ZbSTNS_SPTXLRPT^^LaPO?SP]PT^ aTOPZL^bPWWL^XZ]PZQWTMNLXP]LaTOɪ^LOaLYNPO
LW^Z_SP-tZ[_TZYbSTNS^[PNTʭP^SZbWZYRTY QPL_`]P^TY_SP_`_Z]TLW^_SL_QZWWZb

Camera Module: Getting Started magpi.cc 59


TUTORIAL

RFID spells fun


Make a fun card-matching game using RFID readers and a Pimoroni Pico LiPo

K
ids love to play and learn, but RFID systems are everywhere. They’re in your
playing games to practice new phone, on the packaging for your parcels, on the
skills like reading, mathematics, or food in supermarkets, in your debit card, and maybe
even simple baking is something even on the door to your office or gym. Looking at its
that parents associate with either list of applications in modern society, it’s easy to see
one-on-one interaction or with the technology as a very ‘suited and booted’ security
Dr Andrew Lewis tablet computers. It doesn’t have to be that way, and business-rooted phenomenon. It’s a technology
and while computers do have their place, it’s for stock control, security, and access control. But
Dr Andrew Lewis is a nice to present a child with a more tactile with origins that lead back to the theremin, it’s a
specialist fabricator
and maker, and is the interactive experience. In this project, you’ll see technology that deserves to be seen in projects with
owner of the Andrew how to assemble a simple game board with radio a lighter, less business-focused theme.
Lewis°>orkshop
frequency identification (RFID) readers to make a Making a simple game board isn’t rocket science.
spelling game for young children. The game uses You’ll just need a shallow box that you can use as a
letter cards and picture cards. Using the letter cards board, and some creative inspiration to decorate it.
to spell the word that matches the picture makes You could hand-cut a box from thin plywood or
the board play a simple tune (see Beep Boop box, cardboard, laser-cut one in acrylic, or even reuse
overleaf). You can also use the game to program an old pizza box. The important part of this project is
new picture cards by activating a hidden reed switch the electronics, and getting the position of the RFID
on the board. readers inside your game board correct.

60 magpi.cc RFID spells fun


TUTORIAL

Left
The Pimoroni Pico
LiPo board is a little
more expensive
than the vanilla
Raspberry Pi Pico, but
it comes with some
additional LiPo battery
management and
extra memory

YOU’LL NEED
Pimoroni
Pico LiPo
(shop.pimoroni.
com/products/
pimoroni-pico-lipo)

1 × LiPo battery
pack
(shop.pimoroni.
com/products/lipo-
battery-pack)

6 × RC522
13.56MHz RFID/
NFC module
(amazon.co.uk/
AOICRIE-RFID-
Kit-Compatible-
Raspberry/dp/
B09H6PLM1C/)

40 × 13.56MHz
RFID/NFC cards,
DATA LOADING with 1kB of
memory (also
There has been a lot of talk here about reading and writing write access. By default, these cards are usually delivered called MIFARE
RFID cards, but very little about what that actually means. with the access keys set to hex FFFF. Some card sectors cards)
(shop.pimoroni.
RFID cards come in a variety of different standards, using are safe to edit, others sectors are protected. If you try to com/products/rfid-
a number of different frequencies and protocols. This mess around with these blocks and sectors and don’t know card-10-pcs)
project uses an RC522 reader, which works at a frequency what you are doing, you can trigger security features that
of 13.56MHz and is used with classic MIFARE-type cards will ruin a card permanently. The datasheet for MIFARE ISD1820 audio
that have 1kB of memory. These are the sort of cards that Classic 1K cards (hsmag.cc/MIFARE_Classic1K) gives you record module
you find used as travel passes or printer/photocopier the full breakdown on exactly how this works and which with mic and
credit cards. The memory is arranged into 16 sectors, each areas are safe to work with, but for now, you just need speaker
(amazon.co.uk/
of which contains four blocks of 16 bytes. The first three to understand that the areas used in the project files are HALJIA-ISD1820-
blocks are data blocks that are used for storage, but the ‘safe’ to use, and if you want to start messing around with Recording-
fourth block is an access control block, which defines how other areas, you should read around the subject a little bit Playback-
the information in that sector can be accessed. Writing to before you experiment. Loudspeaker/dp/
this block incorrectly can permanently break the card. In One other thing to note is that the configuration of the B06XD96N4J/
ref=asc_df_
addition to the writeable areas, there is a 4-byte long read- MIFARE card’s memory as 16 sectors containing four
B06XD96N4J)
only ID burned into the card. This ID cannot be changed, blocks each is not actually reflected in the MicroPython
and it lets you identify a particular tag if you need to. In code. In the Python examples, the code is represented A reed switch
order to read or write information on a MIFARE card, the more simply as 64 sectors of 16 bytes. This means that the (Normally
card must be authenticated using one of two keys. The access control blocks are actually every fourth sector. The open type)
multiple keys can be programmed to allow different access sectors begin numbering at 0, so sectors 3, 7, 11, 15, 19…63
A shallow box, or
levels to the information stored on the card. As an example, are all control blocks, and writing to them accidentally a piece of wood
Key A could allow read-only access, while B would allow would most likely wreck the card. or card to use as
a game board

RFID spells fun magpi.cc 61


TUTORIAL

BEEP BOOP
Detecting cards is part of the game, but so is creating
some meaningful feedback for the user. LED lights and
buzzers are one option, but you can also use a sound
Warning! module like the ISD1820 or ISD1932 to make the game
Hot solder more distinctive. These modules allow you to record
sounds using a microphone, and play them back in part,
Soldering irons get or in full, by triggering a pin high. The exact recording
very hot, and stay hot time and number of different sounds stored will depend
for a long time after
they’re unplugged. on the version of the chip and the configuration that
Make sure that you put you’re using, but you can easily record several sounds
the iron in the stand to reward your players. One consideration with these
when you’re not using
it and don’t touch the modules is that they aren’t very loud, so you will need
metal parts – even after an amplifier if you want big sounds for your game.
it’s unplugged.

magpi.cc/soldering

Some RFID modules (particularly the cheapest of the


‘buy 20 for the price of a coffee’ varieties) don’t have
the best range, and will only work if your card or tag
is a couple of centimetres away from the reader in
open air. Different materials will reduce this range
by different amounts, and anything that can interfere
with electromagnetic waves (like iron) will probably
Above
While this project looks pretty simple as a schematic, it’s actually stop the signal completely. Getting your players to
quite a workout to solder quite so many wires in one go unless you’re place their cards in the right place is key to making
used to doing it professionally. @ou might also Änd that you’re going
to be reusing the same wire colour for different purposes in the same your game work well. Most RFID modules use
circuit, which is never ideal. If you’re feeling the strain, split the job similar circuits and control chips, and it is possible
into several sessions, and keep track of which wires you’ve already
soldered by marking your schematic at the end of each session to adjust the gain of most readers to increase their
effective range. However, increasing the range
too far could mean that multiple cards interfere
SERIAL PERIPHERAL INTERFACE with each other and give unexpected readings –
it’s unlikely, but possible, that this could cause a
The RC522 RFID reader modules use the SPI interface to communicate with the Raspberry Pi
problem for your board game if the card readers are
Pico. SPI is a popular and well-established protocol that lets you connect multiple devices
together on a single bus to reduce the overall number of lines used to communicate with placed too close together.
the processor. Although some devices can be daisy-chained to reduce the number of The game you are creating will use RFID readers
connections going to the master device, many (including the RC522 modules used in this to read letter cards and picture cards, so you will
project) are independently wired, with each connection being connected to the same pin need at least four RFID readers to spell simple three-
on the next board. The SPI interface needs several connections to function properly, some letter words (three letters, one picture). The readers
of which are shared between boards. These are usually labelled MISO, MOSI, and SCLK.
connect to a Raspberry Pi 2040-based board. In the
MISO stands for Master In Slave Out, and is the connection that sends information from the
board game shown in this article, a Pimoroni Pico
slave device (our RC522) to the master device (the Raspberry Pi Pico). MOSI is the reverse
of this, standing for Master Out Slave In, sending information from the master device to the LiPo has been used because the board has a LiPo
slave). As you might have already guessed, SCLK is a clock signal that keeps everything in battery charging circuit built in. If you want to use
sync. In addition to these shared pins, you also need a dedicated pin to indicate which board AA batteries with your project or power the project
should be active, and this is usually labelled SS or CS for Slave Select or Chip Select. On straight from USB, you could easily use a Raspberry
Some RC522 boards, this pin might be labelled SDA. This pin goes straight to the master and Pi Pico or Raspberry Pico W instead.
does not get shared with the other slave boards, which means that you’ll need one free pin
To interface the RC522 devices with the Raspberry
on your Raspberry Pi Pico for each device on your SPI interface. Although the RC522 board
has several other pins, these are the only pins that relate to the SPI interface directly. The Pi Pico, you are going to use MicroPython, and Dan
remaining pins deal with power (3.3 V and GND), a device reset pin (RST), and an IRQ pin, J. Perron’s micropython-mfrc522 library, which you
which triggers when the slave detects a card. While it would be possible to use this pin to can find here: hsmag.cc/DanJPerron. If you’ve
trigger the Raspberry Pi Pico, it provides no significant advantage over simply polling each never used MicroPython on the Raspberry Pi Pico
reader in sequence, and would require several extra wires to be connected to the board. before, you can follow the instructions at
hsmag.cc/Get_Started_Pico to get started.

62 magpi.cc RFID spells fun


Internet Offload co-Processors for IoT

TCP/IP Offload Ethernet

Much Faster, Safer, and Stable than Software TCP/IP Stack


Reduces resources of CPU and Memory
Easy integration to any MCU and does not require OS

Ap
pli
catio
ns

Ap
TC pli
P/I catio
P ns

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
T H AT M A D E

OUT
“The Computers That Made Britain
is one of the best things I’ve read
NOW
this year. It’s an incredible story of
eccentrics and oddballs, geniuses and
madmen, and one that will have you
pining for a future that could have been.
.YѣXZYYJWQ^࣢FXYTSNXMNSLѧ
- Stuart Turton, bestselling author
and journalist

Available on

Buy online: wfmag.cc/ctmb


TUTORIAL

QUICK TIP
If you’re having
problems with
the position of the
cards not triggering
an RFID reader,
you could create a
slight recess in the
board so that your
cards fit in exactly
the right place.

Left
The RC522 RFID
modules use the SPI
interface, sharing
several wires
between each board.
GPIO pin 15 serves as
a trigger that starts a
recorded celebratory
tune playing

Download the library and copy the mrfc522.py file


onto your Raspberry Pi Pico. You will also need to STICK HERE
copy the project’s main.py file onto the Raspberry
Decorating your RFID cards is a little bit trickier than
Pi Pico when you are ready to run the game, but
you might expect. Normal RFID cards are made from
first there is some work to do setting up the cards PVC or similar materials that give off toxic fumes if they
for the game. At the moment, your game cards are burnt, and do not absorb ink from regular inkjet
have not been programmed. They have no data printers. Dedicated card printers use a sublimation
stored on them beyond that which came from the dye that transfers onto the card using heat, but these
factory. Ideally, you want to make at least one full printers and their consumables are usually very
expensive. You can dye the cards with synthetic fabric
set of letters A–Z, and extras to deal with words
dye and acetone, or use dedicated PVC paints, but
that have double letters (sheep, pool, egg, etc.…),
these aren’t particularly easy or forgiving techniques
and you’ll also need to make several picture cards to work with. You could choose to use RFID stickers
that are programmed with the word represented instead of cards, and attach them to cards of your own This tutorial is from
by the picture on their face. Letters and words are creation, or you could print designs onto sticky-backed HackSpace magazine.


inkjet paper and trim them to the exact shape of the Each issue includes a
cards once they are stuck in place. This method might huge variety of maker
You want to make at least one sound quite amateurish, but it’s a low-cost solution, and projects inside and
the results are actually quite respectable. It also makes outside of the sphere
full set of letters A–Z, it easier to peel off damaged designs and refresh of Raspberry Pi, and
the cards in future. You can also experiment with
and extras to deal with words
also has amazing


alternatives to paper, like synthetic felt or EVA foam. tutorials. Find out
that have double letters more at hsmag.cc.

written to the cards at the same location in the card


using ASCII. To write the information to the cards,
the project uses two Python files: Pico Alphabet Left
The most time-
Program.py and Pico Word Program.py. The first consuming part of
this project is making
of these files lets you program the entire alphabet all of the cards. The
A–Z automatically one card after another. Each quickest way is to
print on paper and
card scanned gets the next letter of the alphabet glue onto cards. If you
written to it. The second program allows you to can afford to spend a
little bit extra on parts,
write a whole word or a single letter to the card, by you could use RFID
typing the word into the console in Thonny and then stickers instead of
cards and save a
pressing the RETURN key. little bit of time

RFID spells fun magpi.cc 65


FEATURE

Get fit
with
Raspberry Pi
Hack yourself together some superior smart fitness devices

ou can do pretty

Y much anything with


a Raspberry Pi or
Raspberry Pi Pico, even try
LYOTX[]ZaPdZ`]ʭ_YP^^ 
Whether you’re tracking your
ʭ_YP^^XZ]PNWZ^PWdRP__TYR
LXZ]PPʯNTPY_bZ]VZ`_TY
Z]U`^_XLVTYRL_]PLOXTWWL
WT__WPXZ]PPY_P]_LTYTYR_SP]Pɪ^
OPʭYT_PWd^ZXPbLddZ`NLY`^P
L=L^[MP]]d;T_ZTX[]ZaPdZ`]
ʭ_YP^^UZ`]YPd
BPɪaPRL_SP]PO^ZXPZQZ`]
QLaZ`]T_P[]ZUPN_^_ZRP_SP]_Z
SPW[dZ`RP_dZ`TY_T[_Z[
^SL[P2]LMdZ`]_]LTYP]^LYO
WP_ɪ^XLVP^ZXPRLTY^

66 magpi.cc ,IXǻX[MXL7EWTFIVV]5M
FEATURE

Fitness
basics
What to consider before exercising

here are many things

T to keep in mind when


starting to work out,
and the information can be a
lot to parse as well. BPSLaP
^ZXP_T[^_ZRP_dZ`RZTYR
M`_XLVP^`]P_ZOZdZ`]
ZbY]P^PL]NS

Health and fitness Perspective Enjoy your time


DZ`VYZbdZ`]MZOdMP__P] ;PZ[WP_]PL_XLYdXP_]TN^L^ /ZYɪ_RP_^_]P^^POLMZ`_dZ`]
_SLYLYdZYP^ZTQdZ`SLaP []ZZQZQSPLW_SLYOʭ_YP^^9Z_ PcP]NT^TYR 8LVTYRT_Q`YT^L
LYdSPLW_ST^^`P^Z]NZYNP]Y^ PaP]dMZOdT^_SP^LXP_SZ`RS R]PL_bLd_ZVPP[T_`[QZ]L
dZ`^SZ`WONZY^TOP]_SPX ^ZXLVP^`]PdZ`OZYɪ_MPL_ WZYRP][P]TZOZQ_TXP
MPQZ]PPcP]NT^TYR dZ`]^PWQ`[QZ]YZ_ʭ__TYR
NP]_LTYNL_PRZ]TP^ › >P_^XLWWLNSTPaLMWPRZLW^
› >PPVXPOTNLWLOaTNPTQdZ`ɪ]P › 0aP]dZYPSL^_Z
YZ_^`]P › BPTRS_T^YZ_LWbLd^LNZ]]PN_ ^_L]_^ZXPbSP]P
› 7T^_PY_ZdZ`]MZOd XPL^`]PZQSPLW_S8`^NWPT^ › 6PP[LYPdPZYdZ`]OTP_
› /ZYɪ_[`^SdZ`]^PWQ XZ]POPY^P_SLYQL_ M`_OZYɪ_ZM^P^^ZaP]T_
_S]Z`RS[LTY › ?LVP-84-ZOd8L^^4YOPc
› 8LVP^`]P_Z]P^_[]Z[P]Wd ]P^`W_^L^aP]d]Z`RSR`TOLYNP
› >_]P_NSMPQZ]PLYO › /TʬP]PY_MZOTP^]PLN_
LQ_P]PcP]NT^TYR OTʬP]PY_Wd_ZbZ]VZ`_^?SP]P
T^YZZYPbLd_ZRP_ʭ_

,IXǻX[MXL7EWTFIVV]5M magpi.cc 67
FEATURE

Exercise
This works with
any old exercise
bike – and we
HScQIERSPH
bike mod
Breathe new life into that old exercise bike

ne of the newer [POLWWTYRLYO_]LY^WL_P_SL__Z

O trends with exercise


bikes these days is
to have your cycling power
a video of a wonderful
aTOPZ[WLdMLNVZ]TY_ST^NL^P
R]L[STNRPYP]L_TZY
?ST^[]ZUPN_Md[LOOdbbZZQ
`^P^L3LWWPʬPN_^PY^Z]_ZVPP[
environment that you could be _]LNVZQ_SP^[PPOZQ_SPMTVP
The graphics cycling through if you had the QPPOTYRTY_ZL;d_SZY[]ZR]LX
QE]FIEPMXXPI ability to do so. ?SP_PNSYTNLW _SL_]PYOP]^VL]^_QUZ]O^LYO
WMQTPMWXMGFYX
]SYGEREP[E]W ^TOPZQT_T^QLT]Wd^TX[WPɧbT_S LW[TYPPYaT]ZYXPY_^L^dZ`
YTKVEHIXLIQSV ^ZXPVTYOZQNZOP]Z]^PY^Z] [POLW4_ɪ^PL^dPYZ`RS_ZPOT_
have it control a
video’s speed dZ`NLY_]LNVSZbX`NSdZ`ɪ]P dZ`]ZbYXL[^TQdZ`SLaP_SP
_TXP_ZZ
>ZXPZQ_SPTY^_]`N_TZY^L]P
QZ]L^WTRS_WdZWOP]aP]^TZYZQ
=L^[MP]]d;T:>LYO_SP;d_SZY
_SL_NZXP^bT_ST_3ZbPaP]T_
^SZ`WO^_TWWbZ]VU`^_ʭYP

magpi.cc/bikemod

68 magpi.cc ,IXǻX[MXL7EWTFIVV]5M
FEATURE

 8
 LIW]WXIQ

HIIT Workout XVEGOW]SYVFSH]


QSZIQIRXWXSWII
LS[EGGYVEXIP]
]SYƶVILMXXMRKXLI
right poses

Trainer
Data analytics for your fitness

uring 2020, when ^LX[WTYR]L_P_ZQ]LXP^

D a lot of people
were working from
home, James Wong decided
to improve his workout
[P]^PNZYO
?SPNZOPT^Z[PY^Z`]NPLYO
T^]PLOTWdLaLTWLMWPZY2T_3`M
(magpi.cc/hiitpigit5LXP^
routine. 3PLW^ZbLY_PO_Z MPWTPaP^T_^SZ`WOMPPL^TWd
NZXMTYPT_bT_SST^]P^PL]NS LOL[_LMWP_ZZ_SP]^[Z]_^Z]
TY_ZXLNSTYPWPL]YTYR bZ]VZ`__d[P^ɧdZRL^[]TYR^_Z
ZY=L^[MP]]d;T3PYNP XTYObSPYT_NZXP^_Z_]LNVTYR
NZXMTYTYR344?STRSTY_PY^T_d MZOdXP_]TN^
TY_P]aLW_]LTYTYRbT_S
=L^[MP]]d;T_Z_]LNVST^ magpi.cc/hiitpi
bZ]VZ`_LYORTaPSTX`^PQ`W
OL_LZYT_
3ZbT^dZ`]OL_L`^PO*?Z
^NZ]PdZ`]^PWQLRLTY^_Z_SP]^
 8LIWIXYTMWJEMVP]
YL_`]LWWd_LVTYRLOaLY_LRPZQ WMQTPIVIUYMVMRKE
NZX[P_T_TaP^_]PLV^_ZRP_dZ` Raspberry Pi and a
(EQIVE2SHYPIƳE
TX[]ZaTYR_SPPʯNTPYNdZQ TPU really helps
SYXXLSYKL
dZ`]bZ]VZ`_,.Z]LW0ORP?;@
T^`^PO_ZLTOTY_SPXLNSTYP
WPL]YTYR[L]_TX[]ZaTYR_SP

Pico fitness tracker


This kit makes use of TinyML, a low-power machine
Ĭå±ųĹĜĹčĬ±Ĺčƚ±čåƋŅÏųå±Ƌå±ĀƋĹ域Ƌų±ÏĩåųƋʱƋųƚĹŸ
on a Pico or RP2040 board of your own design. It has a
pulse rate monitor, among other sensors, and can be
built into wearable workout gear. Take a look at it here:

magpi.cc/picofit

,IXǻX[MXL7EWTFIVV]5M magpi.cc 69
FEATURE

IPIGX]SYV
character and
]SYGERIZIR
JMRHWSQIWXEXW

Pi Fighter SRJMKLXW

Here comes a new challenger

amifying your Z]/L]_SALOP],^TX[WP70/

G workout has
its upsides and
downsides. However, having
a target to beat, both in terms
^N]PPYT^`^PO_ZWP_dZ`VYZb
SZbX`NSXZ]PʭRS_TYɪdZ`ɪWW
YPPO_ZOZ
7TVPLWWRZZORLXP^_SP
of a high score and pop culture OTʬP]PY_NSL]LN_P]^TYN]PL^PTY
characters to focus on, can [ZbP]XPLYTYRdZ`ɪWWMPbZ]Y
make a workout much more Z`_Md_SP_TXPdZ`_LVPOZbY
fun. 8LVTYR`^PZQ_SPVTYOZQ _SP/L]V7Z]OZQ_SP>T_S:]
_PNSYZWZRd`^POMd4aLY/]LRZY XLdMPdZ`ɪWWYPPO_ZQLNPSTX
in Rocky IVZ]PaPY[`YNS _bTNPɧOP[PYO^SZb^_]ZYR
XLNSTYP^L_L]NLOP^ dZ`L]P
=L^[MP]]d;TLN_^L^LY
LNNPWP]ZXP_P]_ZXPL^`]P magpi.cc/pifighter
_SP[ZbP]ZQdZ`][`YNS_Z
NLWN`WL_PSZbXLYdST_[ZTY_^
3;L]P_LVPYZʬ_SPNSL]LN_P]
dZ`ɪ]PʭRS_TYRɧTY^ZXPNL^P^
_ST^XPLY^7`VP>VdbLWVP]

&TVSTIVTYRGLMRK
bag will be
RIIHIHMJ]SY
really want to
go at it

Simple entertainment
Some very modern treadmills have built-in screens so you
ϱĹƵ±ƋÏĘŸƋƚýĜĹƋĘåčƼĵţœåűƴåĹŅƋŸååĹƋĘåĵ
everywhere yet though so, with a simple
Kodi-powered Raspberry Pi tablet,
you can take your media anywhere
ƋŅƵ±ƋÏĘƵĘĜĬåƼŅƚģŅčŅųÏƼÏĬåţœå
recommend using a SmartiPi Touch 2
to build it:

magpi.cc/smartipi2

70 magpi.cc ,IXǻX[MXL7EWTFIVV]5M
FEATURE

The Balance

DIY smart Board has


FYMPXMRWGEPIW
XLEX]SYGER
QEOIYWISJ

scales
An encouraging weight tracker for those who need it

ii Fit was a ?SPBTT-LWLYNP-ZL]O

W revolution for
ʭ_YP^^aTOPZ
games, spawning loads of
motion-controlled workouts. 4Q
NZYYPN_^aTL-W`P_ZZ_SX`NS
WTVPBTTXZ_P^LW_SZ`RSdZ`ɪWW
YPPOLMT_ZQN`^_ZXNZOP_Z
VPP[T_[LT]PO[P]XLYPY_Wdɧ
dZ`OZYɪ_]PLWWdWTVP_Z`^PdZ`] TYNW`OPObT_S_SP]P^_ZQ_SP
-LWLYNP-ZL]OX`NSLYdXZ]P NZOPQZ]_ST^[]ZUPN_4_OZP^
The scales text dZ`NLYSLNVT__ZMPL[LT]ZQ ]P\`T]PdZ`_Z[]P^^LM`__ZY
]SYYTHEXIWSR
^XL]_^NLWP^`^TYRL=L^[MP]]d `YOP]YPL_S_SP-LWLYNP-ZL]O
]SYVTVSKVIWW[MXL
IRGSYVEKMRKQIWWEKIW ;TLYOL[PYNTW _SZ`RSLNSTPaPOMd_SP[PYNTW
bPXPY_TZYPOMPQZ]PɧL
^TX[WP^ZW`_TZY_SL_bZYɪ_YPPO
X`NSXLTY_PYLYNP
:YNPdZ`^_P[ZYT_ 
XPL^`]PXPY_^L]P_LVPY_Z
N]PL_PLYLaP]LRPO`P_Z
PWPN_]ZYTNYZT^PLYOT__SPY
^PYO^_SPTYQZ_ZLY4Z?^P]aTNP
NLWWPO4YT_TLW>_L_PbSTNSOZP^
_SP_]LNVTYR4_LW^Z^PYO^dZ`
_Pc_^_ZWP_dZ`VYZbdZ`]
[]ZR]P^^TYNW`OTYRPYNZ`]LRTYR
XP^^LRP^L^bPWW

magpi.cc/95

,IXǻX[MXL7EWTFIVV]5M magpi.cc 71
REVIEW

Compute Blade
Compute Blade computeblade.com £54 / $65
SPECS

INPUT/
OUTPUT: Putting Raspberry Pi Compute Module onto a blade for a
Gigabit
Ethernet, low-cost and energy-efficient alternative to a rack-based
USB-A, USB-C,
HDMI, UART, server. Lucy Hattersley weighs up the benefits
Compute
blade headers,

C
microSD card ompute Blade is a fascinating product There are security advantages to separating
slot, hardware
developed by Ivan Kuleshov at Uptime Lab ^P]aTNP^aTLMWLOP^L^T_]PO`NP^_SP^`]QLNPL]PL
switchable
Wi-Fi, BT, and (uplab.pro) that puts a Compute Module in for a hacker to gain access to the system. To this
EEPROM write- a rack-mountable carrier board to create a high- PYO.ZX[`_P-WLOPNLYQPL_`]PL?;8NST[
protection density server for industrial or home use. (Trusted Platform Module) to store cryptographic
Blade servers are the current type of format keys and encrypt your date.
SUPPORT:
Raspberry popular amongst server systems. A traditional ,MZaPLWW_SZ`RSMWLOP^P]aP]^L]PXZ]P
Pi Compute rack-mounted server houses a single computer PYP]RdPʯNTPY__SLY_]LOT_TZYLW^P]aP]^
Module 4, inside a wide chassis (like a tray). Thanks to its Energy costs are always important for server
NVMe SSD
^XLWWQZZ_[]TY_dZ`NLYʭ_`[_Z.ZX[`_P TYQ]L^_]`N_`]PLYO_ST^SL^ZYWdMPNZXPXZ]PZQ
up to 22100,
TPM 2.0 Blade devices into a rack space. an issue recently with higher energy costs. The
.ZX[`_P-WLOP[`_^LWWZQ_SPNZX[ZYPY_^ ,]XNST[^QZ`YOZY=L^[MP]]d;TNZX[`_P]^L]P
POWER: ^_Z]LRP=,8LYONZX[`_P]ZYL^TYRWP;.-4Y XZ]PPYP]RdPʯNTPY__SLY_SPT]]TaLW^
Power over
_SPNL^PZQ.ZX[`_P-WLOPT_`^P^L=L^[MP]]d;T There’s a lot here that’s interesting and we’re
Ethernet
IEEE 802.3at .ZX[`_P8ZO`WPL^_SPXLTYNZX[`_P] OPWTRS_PO_SL_4aLY6`WP^SZa]LT^POZaP]LXTWWTZY
(PoE+) up to DZ`NLYLW^ZOPOTNL_PPLNSMWLOP_ZL^[PNTʭN P`]Z^ZY6TNV^_L]_P]_ZM]TYR_SP[]ZUPN__ZWTQP
30 W (normal _L^V%bPM^P]aTYRʭWP^P]aTYRPXLTW^`[[Z]_ 4aLY^PY_`^_bZ.ZX[`_P-WLOP/PaMZL]O^LQLY
operation
aT]_`LWT^L_TZYLYO^ZZY>Z_LVTYRZYP_L^VZʰTYP LYOLQZ`]MZL]OPYNWZ^`]PQZ]_P^_TYR
2–8 W)
for maintenance leaves the rest up and running.
Check it Blade
.ZX[`_P-WLOPT^L^TYRWP;.-_SL_NLY
SZ`^PL=L^[MP]]d;T.ZX[`_P8ZO`WP
(magpi.cc/computemodule?ST^]LNVXZ`Y_LMWP
;.-XPL^`]P^ XXŸ XXŸ" XXbT_S
=L^[MP]]d;T.ZX[`_P8ZO`WPNZYYPN_Z]^LYO
PoE (Power over Ethernet), so you can power and
_]LY^QP]OL_LQ]ZXL^TYRWP0_SP]YP_NLMWP
BP`^POL?;7TYV?7;Z0 >QZ]^P_`[
testing (magpi.cc/poeinjectorLYOʭ__PO_SP_bZ
.ZX[`_P-WLOPMZL]O^_Z_SPXLTY=L^[MP]]d;T
]LNV^P]aP],WZYR^TOP0_SP]YP_^T_L@>-.LYO
@>-,[Z]_bT_SL^bT_NS_ZXZaPMP_bPPY_SP
The two Compute _bZLY3/84[Z]_@,=??;8XTN]Z>/NL]O
Blade boards we had in
[Z]_88VPdQZ]LY9A8P>>/`[_Z
for testing mounted in
our server rack space LYOLQLY`YT_NZYYPN_Z]?SP/Pa`YT_bP_P^_PO

72 magpi.cc Compute Blade


REVIEW

If you are looking to build The bare Compute


How sharp is it?
an Arm-based server, this 4_ɪ^LbZYOP]Q`WWdOP^TRYPO[TPNPZQVT_LYObP
Blade board and a Dev
version with Compute
Module 4, heatsink, and
is our recommendation MPWTPaPT_ɪOMPLbZ]_SdLOOT_TZY_ZLYd^P]aP]
space. The question for us is what would a non-
an M.2 drive attached

^P]aP]LOXTYT^_]L_Z]OZbT_SL]LNVZQ.ZX[`_P
QPL_`]P^LYLYZOTePOSPL_^TYV^PN`]PObT_S?"SPc -WLOP^*4_bZ`WOXLVPLR]PL_NW`^_P]NZX[`_P] Verdict
^N]Pb^>_]P^^_P^_TYR]PXLTYPOMPWZb! {. QZ]_P^_TYRLYOPc[P]TXPY_L_TZY]`YYTYRdZ`]
?SP]PL]P70/^QZ]>>/;ZbP]LYO,N_TaT_d ZbY^XLWW^P]aP]PYLMWP^dZ`_ZOP[WZd[P]^ZYLW Compute Blade is
a wonderful piece
_SP^PNLYMPOT^LMWPOTY^ZQ_bL]PLYOL cloud services (much more privacy), or it could
of design that
[]ZR]LXXLMWP0ORP-`__ZYZY_SPQ]ZY_[LYPW XLVPLR]PL_;TSZWPLOMWZNVP]LOOT_TZY_ZdZ`]
combines the low-
?ST^M`__ZYLN_^L^L[`WW_LMLYONLYMPNWTNVPO YP_bZ]VDZ`NZ`WOLW^ZOP[WZdL=L^[MP]]d;TTY cost availability of
bSTWP_SPMWLOPT^XZ`Y_POTYLNSL^^T^DZ`NZ`WO _SPSZXPZYdZ`]YP_bZ]VQZ]LYdLaLTWLMWPNZOTYR Compute Module
`^PT__Z[P]QZ]XL]P^_L]_QZ]PcLX[WPZ]N`^_ZX or scripting tasks you want. We set ours up as a with storage,
^N]T[_T_T^NZYYPN_PO_Z2;4: N`^_ZX2;?NSL_MZ__SL_bPNLYWZRTY_ZLYd_TXP PoE networking,
?S]PPXZOPW^L]PLaLTWLMWP%-L^TN?;8 bT_SZ`_OP[PYOTYRZY_SP:[PY,4bPM^T_P and a blade
format. Perfect for
LYO/PabSTNSbPL]P_P^_TYRSP]P?SP .ZX[`_P-WLOPXZ]P_SLYOZ`MWPOT_^
building your Arm
.ZX[`_P-WLOP/ZN`XPY_L_TZYbPM^T_PSL^ 6TNV^_L]_P]Q`YOTYRLYO_SPPYO]P^`W_T^[]P__d cluster or
XZ]PTYQZ]XL_TZYZY_SPaL]dTYR^[PNTʭNL_TZY^ bPWWM`TW_Q]ZXZ`]_P^_TYRLYOOPXLYOT^ server solution.

10
(docs.computeblade.com?SP6TNV^_L]_P] NP]_LTYWdZ`__SP]P4QdZ`L]PWZZVTYR_ZM`TWOLY
NLX[LTRYZʬP]POYZOPNW`^_P]NL^P^TYNS ,]XML^PO^P]aP]_ST^T^Z`]]PNZXXPYOL_TZY

/10
]LNVNW`^_P]^LYO$TYNS]LNVNW`^_P]^bSTNSdZ` and we think it’s a neat product to have on your
NLY/[]TY_QZ]dZ`]]LNV home network.

Compute Blade magpi.cc 73


REVIEW

PicoBricks Base Kit


The Pi Hut magpi.cc/picobricks £49 / $49
SPECS

FEATURES: This neat educational electronics kit eliminates


Raspberry Pi
Pico, 10 × snap- cable clutter and soldering. By Phil King
off electronics
modules,

A
protoboard area,
reset button imed mainly at STEM educators, as well with Grove connectors (ten supplied). The beauty
as makers in general, PicoBricks is a of this is that they can subsequently be reused
CONNECTIONS: project development kit based around ^P[L]L_PWdQZ]Z_SP][]ZUPN_^ZYNPdZ`ɪaPʭYT^SPO
20 × Grove
connectors, 2 × Raspberry Pi Pico. going through the ones in the PicoBricks e-book.
20-pin breakout ,^^`NST_NZXP^^`[[WTPObT_SL^_LYOL]O
headers, battery Raspberry Pi Pico board already slotted into Electronic learning
connector headers in the middle of the kit. This is The 234-page e-book takes learners through 25
EXTRAS: surrounded by ten assorted modules (the ‘bricks’) electronics projects of increasing complexity,
10 × Grove cables, including sensors, LEDs, potentiometer, motor from blinking an LED to setting up a mini smart
10 × male-male driver, relay, and a mini OLED display (see ‘The greenhouse. Each project features an introductory
jumper wires,
bricks’ box for details). explanation, wiring diagram, and step-by-step
micro-USB to
USB cable, two- There’s also a protoboard area, rather than a programming guide using the MicroBlocks visual
piece wooden breadboard (so the holes aren’t already connected programming system (microblocks.fun), akin
stand, battery in rows), although a mini breadboard is also to Scratch, which can be run on any type of
holder (2×AAA), ^`[[WTPO,YZ_SP]YTNP_Z`NST^_SPML__P]d connected computer – either in the browser or
mini breadboard
NZYYPN_Z]QZ]_SP^`[[WTPOŸ,,,ML__P]dSZWOP] `^TYRLYZʰTYPL[[,;TNZ-]TNV^WTM]L]dNLYMP
so you can power the kit away from a computer. installed via its menus.
4Y_P]P^_TYRWd_SP_PYXZO`WP^L]PLW]PLOd ,W_P]YL_TaP[]ZUPN_NZOPT^LW^Z[]ZaTOPOTY_SP
NZYYPN_PO_Z;TNZɪ^2;4:[TY^aTLLQ]LXPbT_S PMZZVTY8TN]Z;d_SZYLYO,]O`TYZ4/0..
solder joints. So, you can use them all straight form, albeit without any explanation as to how it
away without having to do any wiring. works. There are also links to the code, although
,W_P]YL_TaPWddZ`NLY^YL[_SPXZO`WP^ T_^ZXP_TXP^OTʬP]^^WTRS_WdQ]ZXbSL_ɪ^TY
ZʬLYObT]P_SPX_Z;TNZ the book.
There are some fun and interesting

Verdict projects to complete with the PicoBricks


Base kit, including a reaction game, magic
While the Base kit 8-ball, music player with speed control,
is missing a few thermometer, alarm clock,
components for and colour-matching game.
some projects, it Many of them make good
ŅýåųŸ±ƴ±ĬƚåěüŅųě `^PZQ_SPXTYT:70/,QPb
ĵŅĹåƼ±ĹÚƵåĬĬě
community-made projects
organised way
are also available from the
for newcomers
ƋŅĬå±ųűÆŅƚƋ PicoBricks GitHub repo
electronics and (magpi.cc/picobricksgh).
programming.

8
Missing components
Perhaps the biggest

/10
downside is that around
half of the projects in the

74 magpi.cc PicoBricks Base Kit


REVIEW

e-book require extra components – such as a 2WD


robot car and smart greenhouse kit – that are only
TYNW`OPOTY_SPXZ]PPc[LY^TaP4Z?0c[P]_!$
Z]EP]Z_Z3P]Z$$aP]^TZY^ZQ_SP;TNZ-]TNV^
kit, available direct from robotistan.com.
,W_P]YL_TaPWddZ`NZ`WO^`[[WPXPY__SP-L^PVT_
with standard components already in your toolbox
(or buy them separately), such as servos, motors,
LYO`W_]L^ZYTNOT^_LYNPLYO;4=^PY^Z]^?SP^PNLY
be connected with jumper wires to the full female

Alternatively, you can


snap the modules off
and wire them to Pico
with Grove connectors
2;4:M]PLVZ`_SPLOP]^ʮLYVTYR;TNZZ]_Z_SP
Grove connectors.
The PicoBricks kit
4YLOOT_TZYTY^_PLOZQ`^TYR_SPZ[_TZYLW ǻXWRIEXP]MRXSE
Wi-Fi and Bluetooth boards (that connect to the QSYPHIHTPEWXMGXVE]

;TNZ-]TNV^4Z?XZO`WPdZ`NZ`WOLWbLd^]P[WLNP  LI5MGS'VMGOWOMXWEVI
8
the kit’s removable Raspberry Pi Pico with a EMQIHQEMRP]
EXIHYGEXSVWFYX
Pico W. Either way, once you’ve learnt the basics, GERFIYWIHJSV
LSQIPIEVRMRK
_SP]Pɪ^_SP[Z_PY_TLW_ZPc[P]TXPY_bT_S4Z?
projects not fully explored in the e-book.

The bricks
The PicoBricks kit features ten 3. LED & BUTTON 7. IOT BOARD
7IH1*)ERHTYWLFYXXSR Connections for optional ESP8266
electronics modules that can ;M+MERH-('PYIXSSXLQSHYPIW
used in situ or snapped off 4. TEMPERATURE & HUMIDITY
SENSOR 8. BUZZER
XERHEVH)-8WIRWSV Active piezo buzzer for making
1. 0.96-INCH OLED WMQTPIcWSYRHW
128×64 monochrome display to 5. RELAY
show text, sensor readings, and Relay switch with two terminal 9. LIGHT SENSOR
WMQTPIcKVETLMGW FPSGOcGSRRIGXMSRW Light-dependent resistor (LDR) for
HIXIGXMRKPMKLXPIZIPW
2. RGB LED 6. MOTOR DRIVER
Addressable WS2812 RGB multicolour Dual H-bridge for connecting two 10. POTENTIOMETER
1*)[MXLSYXTYXGSRRIGXSV )(QSXSVWSVcWIVZSW :EVMEFPIVIWMWXSV[MXLVSXEV]ORSF

PicoBricks Base Kit magpi.cc 75


200 PAGES OF RASPBERRY PI
QuickStart guide to setting up The very best projects built by
your Raspberry Pi computer your Raspberry Pi community

Updated with Raspberry Pi Pico Discover incredible kit and


and all the latest kit tutorials for your projects

Buy online: magpi.cc/store


RESOURCES

10 Amazing:
Browsers
The best ways to surf the web Tor
on Raspberry Pi
Ultimate privacy

T
FüƼŅƚĹååÚƋŅÆųŅƵŸåƵĜƋĘÏŅĵŞĬåƋåÏŅĹĀÚåĹÏåŅüƼŅƚų±ĹŅĹƼĵĜƋƼ؉Ņų
here are many, many browsers available on every ųŅƵŸåųƚŸåŸƋĘå‰ŅųĹåƋƵŅųĩƋұĹŅĹƼĵĜŸåƼŅƚųĬŅϱƋĜŅűĹÚF{ţ
kind of operating system, and Raspberry Pi and
T_^:>T^YZOTʬP]PY_ We’ve got the lowdown on torproject.org
ten of the best browsers you can use on Raspberry Pi,
whether you’re using Raspberry Pi as a desktop, or for a
fun project.
Firefox
Open-source darling
‰ĘåÆųŅƵŸåųƋʱƋŸƋ±ųƋåÚƋĘåčųå±Ƌ
ĵŅƴå±Ƶ±ƼüųŅĵFĹƋåųĹåƋ)ƻŞĬŅųåų
has a special version for Raspberry
{ĜƋʱƋĜĹÏĬƚÚåŸĵ±ĹƼŅüƋĘå
ĹŅųĵ±ĬƴåųŸĜŅĹűŸüå±ƋƚųåŸţ

‫ܪ‬WJKT]HTR

Luakit
Chromium Fast and customisable
šåųƼŧƚĜÏĩ±ĹÚƴåųƼÏŅĹĀčƚų±ÆĬåØ
Default browsing
Xƚ±ĩĜƋĜŸ±ÆĜƋŅü±ĵĜĹĜĵ±ĬĜŸƋ
It’s the browser you have installed on Raspberry Pi OS by default! It’s browser that power users
ƴåųƼŸŅĬĜÚ±ĹÚʱŸŸŞåÏĜĀÏŅŞƋĜĵĜŸ±ƋĜŅĹŸüŅų±ŸŞÆåųųƼ{Ĝk„ţ ĵ±ƼŞųåüåųţ

chromium.org luakit.github.io

Browsers magpi.cc 77
RESOURCES

Midori
Lightweight excellence
aĜÚŅųĜĜŸ±ƴåĹåų±ÆĬåĬĜčĘƋƵåĜčĘƋÆųŅƵŸåų±ĬƋåųűƋĜƴåƵĘĜÏĘĹŅƵʱŸåƻƋų± Vivaldi
ŸåÏƚųĜƋƼ±ĹÚ±čųå±ƋeĹÚųŅĜÚŸŞĜĹěŅýţ
Opera reborn
magpi.cc/midori
eĵƚÏĘĹåƵåųÆųŅƵŸåųƋʱƋųåϱŞƋƚųåŸĵ±ĹƼŅüƋĘåüƚĹÏƋĜŅĹŸŅü
ŅĬÚåųkŞåų±ÆųŅƵŸåųŸţFƋűŸĵŅŸƋĬƼŅŞåĹěŸŅƚųÏåƋŅŅţ

Lynx vivaldi.com

Who needs graphics?


FüƼŅƚĀĹÚƋĘåĜĹƋåųĹåƋĜŸƋŅŅÆĬұƋåÚ Dillo
ƵĜƋĘĜĵ±čåŸØƋĘåĹƋĘĜŸƋåƻƋěÆ±ŸåÚ
ÆųŅƵŸåųĵ±ƼÆåüŅųƼŅƚţ
Retro minimalism
RFLUNHHQ^S] %åŸĜčĹåÚüŅųŅĬÚåųŸƼŸƋåĵŸØ%ĜĬĬŅ
ĜŸ±ĹĜĹÏųåÚĜÆĬƼĵĜĹĜĵ±ĬĜŸƋĜÏÆĜƋŅü
ŸŅüƋƵ±ųåƋʱƋĜŸ±ÆŅƚƋ±ŸŸĵ±ĬĬ±Ÿ±
ÆųŅƵŸåųϱĹÆåƵĘĜĬåŸƋĜĬĬƵŅųĩĜĹčţ

dillo.org

5YǽR(PSYH1IEVRMRK
Kweb
Cloud rendering
Kiosk web browsing
‰ĘĜŸƚĹĜŧƚåÆųŅƵŸåųųåĹÚåųŸÏŅĹƋåĹƋŅĹåĹÏųƼŞƋåÚÏĬŅƚÚŸåųƴåųŸƵĘĜÏĘ
±ųåƋĘåĹŸƋųå±ĵåÚƋŅƋĘåƵ寯ųŅƵŸåųţFƋϱĹÆåĵƚÏĘü±ŸƋåųƋʱĹ eűĬƋåųűƋĜƴåƋŅƋĘåÚåü±ƚĬƋÆųŅƵŸåųƋŅƋƚųűŸŞÆåųųƼ{ĜĜĹƋұƵåÆ
ųåčƚĬ±ųÆųŅƵŸåųŸţ ĩĜŅŸĩØŞåųüåÏƋüŅųŞƚÆĬĜÏŞĬ±ÏåŸţ

UZK‫ܪ‬SHTR magpi.cc/kweb

78 magpi.cc Browsers
English not your
mother tongue?
The MagPi is also available in German!

Subscribe to the German edition of


The MagPi and get a Raspberry Pi Pico
with headers and a cool welcome box
FOR FREE!
Use the coupon code 115PicoDE
on www.magpi.de/115
Your FREE guide to
making a smart TV

BUILD A RASPBERRY PI
MEDIA PLAYER
Power up your TV and music system

FROM THE MAKERS OF THE OFFICIAL RASPBERRY PI MAGAZINE

magpi.cc/mediaplayer
RESOURCES

Learn: Sense HAT


This sensor-packed board helps you
explore the world, says Rosie Hattersley

Sense HAT
Raspberry Pi The Raspberry Pi Sense to send Raspberry Pi
AUTHOR

HAT is an add-on board for computers to the


Price: the Raspberry Pi, designed International Space
free to provide a range of Station (ISS) for
magpi.cc/sensehat environmental sensors and educational purposes.
input/output capabilities. It Start out with the Raspberry
was originally developed for the Pi Sense HAT product page. Here links to
Astro Pi mission, a project by the dZ`bTWWʭYOXZ]PTYQZ]XL_TZY Astro Pi, the
Raspberry Pi Foundation and the on the components, a link to Python library, and the Sense
European Space Agency (ESA) buying a Sense HAT, along with HAT Product Brief.

Projects
RASPBERRY PI SENSE marble (in the guise of coloured

Movement and LED-based HAT PONG LEDs) is travelling in this tricky maze
Paying homage to the original puzzle. Have fun following the setup
projects to try for yourself computer game, this walkthrough guide, before setting a timer and
on how combine a Sense HAT and challenging your friends to escape
Raspberry Pi, plus some Python the maze in the fastest time.
code to create classic Pong, is magpi.cc/sensehatmarble
bound to appeal to retro gamers.
There’s even a link to a video of the NIGHT CLOCK
original game being played on Lorna Jane’s tutorial shows you how
an oscilloscope. the LED matrix can be used as a
magpi.cc/sensehatpong useful and quirky display that can be
used as an at-a-glance bedside time
SENSE HAT MARBLE MAZE check, without having to turn on the
Orientation sensors on the Sense light or phone display.
HAT detect which way the virtual magpi.cc/sensehatnightclock

Learn: Sense HAT magpi.cc 81


RESOURCES

Raspberry Pi YouTube
Sense HAT Videos
Raspberry Pi Now we’ve whetted your Easy setup guides
AUTHOR

Foundation appetite about things a you can watch at


Sense HAT can do, head your leisure
Price: to this useful guide to
free
set up. As this guide
magpi.cc/
explains, the Sense HAT Astro Pi project, there’s little the
gettingstartedsensehat
contains a number of on-board Sense HAT can’t do.
sensors to measure temperature, This tutorial walks you
humidity, colour, movement, through displaying text, images,
and orientation, and also has an and measuring the orientation RASPBERRY PI SENSE
LED grid to display the results of the Sense HAT device, before HAT PIXEL TUTORIAL
of your investigations. With detecting movement using the Carrie Ann Philbin shows how
its origins as a sensing device joystick for input, and putting it to set up the pixel display on
destined to go into space with all together to create your own your Sense HAT and create a
the European Space Agency, and projects that sense and react to pixel pet. The avatar pet moves
as a teaching aid as part of the their surroundings. when you shake the device,
demonstrating one of its many
sensing capabilities.
magpi.cc/
sensehattutorialyt

Sense HAT ELLORA JAMES –


SENSE HAT

Documentation Ellora James is a great video


blogger who explains clearly
how to go about setting up a
Raspberry Pi ?SPZʯNTLWOZN`XPY_L_TZY OTʬP]PY_NZX[`_P]WLYR`LRP^ IRWI-&8JSVXLIǻVWXXMQI
AUTHOR

will walk you through some of including C++ as well as and provides a video tutorial
Price: the more advanced aspects of Scratch and Python. Each of that follows the instructions
free
Sense HAT and how to use this the sensors (gyroscope and and code on the Raspberry
magpi.cc/sensehatdocs
Raspberry Pi accessory with magnetometer and barometric Pi website. It’s ideal viewing
pressure sensor among them) is MJ]SY[ERXXSXEOI]SYVǻVWX
covered, along with calibration steps into using HATs. Ellora
for the magnetometer and also has plenty of other useful
LNNPWP]ZXP_P]?SPZʯNTLW Raspberry Pi YouTube guides.
documentation also covered magpi.cc/sensehatej
reading and writing the EEPROM
data. Also take a look at the
corresponding Sense HAT THE RASPBERRY PI
Python documentation, linked to SENSE HAT IS AWESOME!
Q]ZX_SPZʯNTLWOZN`XPY_L_TZY ETA Prime takes you through
3P]PdZ`bTWWʭYO;d_SZY,;4 the LED matrix and all the
examples and the Sense HAT sensors, focusing on the parts
API reference guide, ideal for all and capabilities of Raspberry
your coding needs: Pi Sense HAT.
magpi.cc/sensehatAPI. magpi.cc/sensehateta

82 magpi.cc Learn: Sense HAT


RETRO GAMING WITH

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.

Set up Raspberry Pi for


retro gaming
Emulate classic
computers and consoles
Learn to code your
own retro-style games
Build a console,
handheld, and full-size
arcade machine

BUY ONLINE:
magpi.cc/store
INTERVIEW

Brian
Jepson
A long-time programmer, maker, and tinkerer,
meet the new publishing director for Raspberry Pi

> Name Brian Jepson > Occupation Publisher


> Community role Maker > URL jepstone.net


I
grew up in the smallest maker interests ended up getting
state in the US (Rhode pushed to the side as I spent
Island) during the golden more time with computers.
age of Radio Shack,” Brian Immediately preceding my
Jepson tells us. He’s the new time at university, and really
publishing director here at throughout my life, I fell in with
Raspberry Pi Towers, but he’s an an unjuried, uncensored arts
old hand at making. organisation (as220.org) that
“I’ve been a lot of things over very much embraces the DIY
the years, but if we go back spirit. In those years, I made
to the beginning, I’d say I’m zines, posters, performance art,
a computer programmer and but very little visual art outside
tinkerer,” Brian continues. “I of printed works. I went away
got my start programming on a to New York for a few years,
somewhat customised Atari 400 came back, and stayed involved
with Atari BASIC, Forth, and a with AS220 as a volunteer and
smattering of 6502 assembler. I occasional board member.
kept up with that kind of thing Over time, AS220 itself has
over the years, and ended up grown a lot, and now operates
programming for a time, then three mixed-use buildings
writing, and eventually editing in downtown Providence, RI,
and publishing, but always supporting everything from
with a dash of programming on live-work studios to a vibrant
the side.” youth program.
His previous work in In the past several years, I’ve
publishing includes O’Reilly become involved in the Rhode
Media and Make Magazine – he Island Computer Museum, which
even helped run a Maker Faire in has allowed me to fuse my
his native Rhode Island. interest in computers (especially
old computers) with making.
What is your history
with making? Where did you learn about
I had one of those 150-in-1 Raspberry Pi?
project kits where you connected Raspberry Pi was such big news
wires using spring terminals. when it launched that a better
I was terrible with a soldering question would be ‘where didn’t
Brian helps out at the Rhode Island Computer Museum iron until I was much older. My I learn about Raspberry Pi’?

84 magpi.cc Brian Jepson


INTERVIEW

A custom
Raspberry Pi
MIDI synthesizer

Working on the Make books Pi with mt32-pi, which turns with Atari STs. In addition to
portfolio at the time meant this a Raspberry Pi into a MIDI the many games that use MIDI,
was huge news. We managed synthesizer that works just like there are many music apps for
to get a book out by January the Roland MT-32, and various the Atari ST that work with
2013, co-written by Raspberry General MIDI synthesizers that MIDI, such as Steinberg Cubase
Pi’s own Matt Richardson, as can be used with old games and and C-Lab Notator. Many of
well as Shawn Wallace. Shawn other software. I have built two these old music apps hold up
is a fellow Rhode Island maker/ mt32-pi boards and use them pretty well to this day.
artist who has been part of
my adventures going back to
the campus daily and literary I rely heavily on Raspberry Pi to keep
magazine, through AS220 (where
he was the founding director of old computers up and running
the Providence Fab Lab), and
into nearly every Rhode Island
maker event I’ve been part of.

What are some of your favourite


things you’ve made with
Raspberry Pi? Credit: Carolyn Fahm, of Greenwich Meantime Photography
I rely heavily on Raspberry Pi
to keep old computers up and
running. I recently got a Mac
Quadra up and running, and I
wouldn’t have been able to do it
without PiSCSI, a combination
of hardware and software that
allows a Raspberry Pi to emulate
a variety of SCSI devices. It’s a
much quieter hard drive than
what was originally in the Mac,
LYOT_ɪ^PL^d_ZXZaPʭWP^_ZLYO
from the disk images, mostly
eliminating the need to fuss with
ʮZ[[TP^4LW^Z`^PL=L^[MP]]d An early Rhode Island Mini Maker Faire, circa 2011.

Brian Jepson magpi.cc 85


THIS MONTH IN RASPBERRY PI

01

MagPi
Monday
03

02

Amazing projects direct from our Twitter! 04

E
very Monday we ask the question: have you
made something with a Raspberry Pi over
the weekend? Every Monday, our followers
send us amazing photos and videos of the things
they’ve made.
Here’s a selection of some of the awesome
things we got sent this month – and remember to
follow along at the hashtag #MagPiMonday!

01. Classic computer maintenance is essential


to keep them running for preservation
02. This is a great looking case to use for a fun 06
sounding project
03. Tiny 4WD has evolved into a smaller, more
compact form 05
04. Another excellent robot test here with Aula
05. A plush fortune cookie may be less tasty
but it is just as wise
06. The most custom way to build a keyboard
– 3D-print it
07
07. This looks great in motion – we love
all the projects we’ve seen using the
Galactic Unicorn

86 magpi.cc MagPi Monday


THIS MONTH IN RASPBERRY PI

#MonthOfMaking
Y’all got making online in March. Here’s some of the cool stuff we saw

01. Raspberry Pi has been pretty high but rarely under 01


its own power. 550 metres is very impressive
02. Kevin brought back a classic Raspberry Pi project,
this time powered by Pico
03. 10 March is Mario day (Mar10 in US notation), and
Igor celebrated by… dismembering him?
02
04. 5IXIVLEWFIIRJYVXLIVVIǻRMRKLMWTPERXIV[EXIVMRK
system over the #MonthOfMaking
05. Another excellent plant watering system, this one
using multiple Pico
06. Some very retro tech here getting the upcycling
treatment – we love it
07. We really like this visualisation of joystick
movement Dr Footleg has been working on.
;IƶHPSZIXSWIIMXETTPMIHEXXLI*:4ǻKLXMRK
game tournament

03

07

04

06

05

#monthofmaking magpi.cc 87
THIS MONTH IN RASPBERRY PI

Events in pictures
Community and official events in the wild

T ABOUT
N EX T
his month, a Raspberry Pi pop-up store
D O U T A ND
opened in Southampton, and we went along FI N EV EN TS
N T H ’S
to see just how it went down. According to
MO ON
_SP^SZ[^_LʬOTʬP]PY_L]PL^_PYO_ZM`dOTʬP]PY_ POP-UP
92
kinds of products at the pop-ups, with Raspberry
Pi 400 kits and Debuggers going down very well. PAGE

The queues, before the store opened,


wrapped around a large portion of West Quay!

Visitors told us all about the amazing projects they’d be making

A Raspberry Pi 400 was set up


to let people try out coding The modest stock selection went very quickly

88 magpi.cc Events in pictures


THIS MONTH IN RASPBERRY PI

Best of the rest!


Other great things we saw this month

Cheap Oscilloscope
Internet/Local Network
Ed Mikkelsen emailed us about this cool project. “I wanted to
build my own oscilloscope with inexpensive parts, and do my own
Monitoring Service
ŞųŅčų±ĵĵĜĹčţF±ĬŸŅƵ±ĹƋåÚƋŅŸååĘŅƵü±ŸƋFÏŅƚĬÚĵ±ĩåĜƋţFĀųŸƋ
programmed the oscilloscope in C++ using GTK for the graphics and A great network monitoring setup was sent to us by John Loop, which
achieved a conversion rate of 8 usec. I also programmed it Python with he described as such: “Completely self-contained performance
a considerably slower conversion rate because Python is a scripting monitoring setup. Does not rely on third party servers. GREAT use
language. With C++ I have also added a second trace, zero crossing for an older Raspberry Pi 3B/3B+ lying around. All it requires is
detection, and automatic refreshing. All in all, loads of fun.” downloading the image and burning an SD card. Comes up running.”

magpi.cc/github129 magpi.cc/imonitorg

Together we can
make a difference
Give young people the opportunity
to learn about technology

The Raspberry Pi Foundation enables young


people to realise their full potential through
the power of digital technologies, but we can’t
do this work without your help. Your support
helps us give young people the opportunities
they need in today’s world. Together we can
offer thousands more young people across
the globe the chance to learn to create with
digital technologies.
Generous donations from organisations and DONATE NOW
individuals who share our mission make our
work possible.

Donate today to make a difference: rpf.io/magpidonate


YOUR LETTERS

Your
Letters
Readall solution
In the latest The MagPi correspondence, Marian asked “you could print articles on the
following: gpio readall - the installation of and usage of as a means of checking the status of
inputs and outputs.”
When WiringPi was deprecated, I wrote a Python replacement for gpio readall. I have since
written versions for many of the popular libraries (including my own pi_gpio).
This has the advantage of displaying the ACTUAL programmed GPIO function (if changed)
and pulls (on Raspberry Pi 4).
I have been playing recently with the gpiochip interface (included in recent kernels) and
realised that the raspi-gpio debug tool actually has all the details needed. raspi-gpio
should be included in all recent Raspberry Pi OS, but if not you can install raspi-gpio from
the repository.
This version of my program (which I call gpioreadall)
reformats the output of raspi-gpio into a user-friendly
format, similar to the WiringPi gpio readall.
This produces output identical to Figure 1, but is
independent of any other libraries/daemons.
The code can be downloaded from here:
magpi.cc/gpioreadall.

Ian via email

This is a fantastic script and, yes, raspi-gpio is included


on all Raspberry Pi OS installs. For Marian last week, and
anyone else who wants to keep an eye on their GPIO pins,
this is a great bit of code to use!

Figure 1: An example of
how the script displays
GPIO readings

90 magpi.cc Your Letters


USA SPECIAL!
6 ISSUES
Pop-up stock
Unfortunately I live a bit too far away from
Cambridge to head to the Raspberry Pi Store there,
but I will be able to get to some of the pop-ups
this year! What kind of stock should I expect to
FOR $45
see at the pop-ups?

Mahiru via Twitter

A lot of Raspberry Pi hardware is available at the


pop-ups. However, each pop-up seems to sell
Z`_ZQ^[PNTʭNT_PX^QL^_P]_SLYZ_SP]^6T_^bT_S
Raspberry Pi 4 and Raspberry Pi Zero 2 W can be
found in the pop-ups, along with Raspberry Pi
400 and desktop kits, add-ons like the Camera
Modules, some of our books, and loads of other
accessories and general Raspberry Pi merch!

FREE
RASPBERRY PI
PICO W
If you miss stock of a particular product on one day,
the pop-ups try and restock the following day!

Contact us!
>
>
Twitter
Facebook
@TheMagPi
magpi.cc/facebook
Subscribe online:
>
>
Email
Online
magpi@raspberrypi.com
forums.raspberrypi.com
magpi.cc/subscribe

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. Exeter Pi Jam 03. Cornwall
Saturday 6 May Tech Jam
Exeter Central Library, Saturday 20 May
Exeter, UK FibreHub, Pool, UK
magpi.cc/exeterjam129 magpi.cc/ctm129
First Saturday of every month, Cornwall Tech Jams
a group of enthusiasts of all are run by volunteers
ages bring their projects or working in IT and education throughout Cornwall. They
just come along to make, are supported by Software Cornwall, its members, and
learn, and talk. There is a range of equipment for people other local businesses. Our volunteers give their own time
to try or use to work though projects. Come and see, and and expertise to plan each Cornwall Tech Jam and to the
have a chat. regular maintenance of all our equipment.
FULL CALENDAR
02. Melbourne Raspberry Pi Meetup 04. Hybrid Raspberry Pint Get a full list of upcoming
Sunday 7 May Tuesday 30 May ÏŅĵĵƚĹĜƋƼåƴåĹƋŸƤĘåųå×

Docklands Makerspace and Library, Microsoft Reactor London, London, UK magpi.cc/events


Melbourne, AUS magpi.cc/pint129
magpi.cc/mrpm129 Raspberry Pint is a meetup for sharing digital making
This meetup is open to experiences. Most presentations are about building
everyone with an interest personal or professional projects with Raspberry Pi and
in electronics, robotics, other maker technology. You can also learn skills and
home automation, 3D techniques such as website design, PCB design, software
printing, laser cutting, development, 3D printing, and soldering.
amateur radio, high altitude
balloons, space tech, etc.
Makers are invited to bring along their projects and project
ideas, and come connect with other makers. Get your
UYIWXMSRWERW[IVIHWLS[SǺXLI[SVO]SYEVIHSMRKERH
get support to resolve nagging issues.

92 magpi.cc Community Events Calendar


EVENTS

RASPBERRY PI 02
STORE POP-UP

9JGTGECP[QWƓPF
Raspberry Pi next?
> Next location Raspberry Pi Store pop-up Birmingham
> Where Bull Ring, Birmingham, UK
> When Friday 28 May and Saturday 29 May

A
t this Raspberry Pi Store pop-
up in Birmingham, you can
experience and buy Raspberry
04 Pi products. Explore some of the things
you can do with a Raspberry Pi, discover
our accessories and books, and get your

01 03 hands on limited edition exclusives.

magpi.cc/popup2023bham

Community Events Calendar magpi.cc 93


SUBSCRIBE AND

SAVE UP
TO

35% on the cover price

ISSUE #66

OUT NOW
hsmag.cc
COMPETITION

WIN ONE OF FIVE


RASPBERRY PI
GLOBAL SHUTTER
CAMERAS

The new Raspberry Pi Global


Shutter Camera is perfect for
taking photos of fast action for
sports photography, or even
computer vision applications that
need to take accurate photos fast.
;ILEZIǻZIXSKMZIE[E]

Head here to enter: magpi.cc/win


Learn more: magpi.cc/globalshuttercam

Terms & Conditions


Competition opens on 26 April 2023 and closes on 25 May 20235VM^IMWSǺIVIHXSTEVXMGMTERXW[SVPH[MHIEKIHSVSZIVI\GITXIQTPS]IIWSJ7EWTFIVV]5M1XHXLITVM^IWYTTPMIV
XLIMVJEQMPMIWSVJVMIRHW;MRRIVW[MPPFIRSXMǻIHF]IQEMPRSQSVIXLERHE]WEJXIVXLIGSQTIXMXMSRGPSWIW']IRXIVMRKXLIGSQTIXMXMSRXLI[MRRIVGSRWIRXWXSER]TYFPMGMX]
KIRIVEXIHJVSQXLIGSQTIXMXMSRMRTVMRXERHSRPMRI5EVXMGMTERXWEKVIIXSVIGIMZISGGEWMSREPRI[WPIXXIVWJVSQ8LI2EK5MQEKE^MRI;IHSRƶXPMOIWTEQTEVXMGMTERXWƶHIXEMPW[MPP
VIQEMRWXVMGXP]GSRǻHIRXMEPERH[SRƶXFIWLEVIH[MXLXLMVHTEVXMIW5VM^IWEVIRSRRIKSXMEFPIERHRSGEWLEPXIVREXMZI[MPPFISǺIVIH;MRRIVW[MPPFIGSRXEGXIHF]IQEMPXSEVVERKI
HIPMZIV]&R][MRRIVW[LSLEZIRSXVIWTSRHIHHE]WEJXIVXLIMRMXMEPIQEMPMWWIRX[MPPLEZIXLIMVTVM^IVIZSOIH8LMWTVSQSXMSRMWMRRS[E]WTSRWSVIHIRHSVWIHSVEHQMRMWXIVIHF]
SVEWWSGMEXIH[MXL.RWXEKVEQ+EGIFSSO8[MXXIVSVER]SXLIVGSQTERMIWYWIHXSTVSQSXIXLIWIVZMGI

Competition magpi.cc 95
AN INTRODUCTION TO

&
PROGRAMMING
All you need to know
to write simple
programs in C and
start creating GUIs
Inside:
QCreate simple command-line C programs
Q.ZY_]ZWʮZbbT_SNZYOT_TZY^LYOWZZ[^

Q3LYOWPaL]TLMWP^^_]TYR^LYOʭWP^

Q/P^TRYR]L[STNLW`^P]TY_P]QLNP

applications in C
Q3LYOWP`^P]TY[`_bT_SM`__ZY^LYOXPY`^

Q@^PLOaLYNPO@4QPL_`]P^^`NSL^OL_L

stores and dialogs

£10 with FREE


worldwide delivery

Buy online: magpi.cc/cgui


EDITORIAL
e Editor
in
x &nd L
Lucy Hattersley

AL
lucy@raspberrypi.com
u
n a
Li m
Features Editor

Co
m
CI Rob Zwetsloot

E
rob@raspberrypi.com
e
Th
SP
Sub Editor
Nicola King

ADVERTISING
Charlotte Milligan
charlotte.milligan@raspberrypi.com
+44 (0)7725 368887

DESIGN
criticalmedia.co.uk

Head of Design
Lee Allen
Designers
Olivia Mitchell, Sam Ribbits
Illustrator
Sam Alder

!
CONTRIBUTORS

M o n t h David Crookes, PJ Evans,


Rosemary Hattersley, Nicola
King, Phil King, Andrew Lewis,
David Plowman, KG Orphanides,
Stewart Watkiss

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

DISTRIBUTION
Seymour Distribution Ltd
2 East Poultry Ave,
London EC1A 9PT

with Raspberry Pi
+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

THE MAGPI #130 magpi@subscriptionhelpline.co.uk

ON SALE 25 MAY This magazine is printed on paper sourced


from sustainable forests and the printer
operates an environmental management

Plus! DON’T MISS OUT!


system which has been assessed as
conforming to ISO 14001.
The MagPi magazine is published by

Move to an magpi.cc/subscribe
Raspberry Pi Ltd, Maurice Wilkes Building,
St. John’s Innovation Park, Cowley Road,

open-source GPT Cambridge, CB4 0DS. The publisher,


editor, and contributors accept no
responsibility in respect of any omissions

Replica vintage or errors relating to goods, products, or


services referred to or advertised in the

computers @TheMagPi magazine. Except where otherwise noted,


content in this magazine is licensed under
a Creative Commons Attribution-
fb.com/MagPiMagazine
Crack the NonCommercial-ShareAlike
3.0 Unported

command line magpi@raspberrypi.com (CC BY-NC-SA 3.0).


ISSN: 2051-9982.
THE FINAL WORD

Taking a break
Resting can be important, even when it comes
to making, says Rob Zwetsloot

T
his issue, I wrote a feature times when a bit of engineering and/ they’re a little harder to do anyway.
LMZ`_RP__TYRʭ_bT_S or code have stumped me until It means I’m doing them much
Raspberry Pi and it reminded I looked at it with fresh eyes the less though.
XPZQ_SPʭ_YP^^NZYNP[_ZQSZb next morning.
]P^_T^P\`LWWdTX[Z]_LY_L^LN_`LWWd 0aPYb]T_TYR^_`ʬQZ]_SPXLRLeTYP On hiatus
working out. In terms of your body, NLYMPYPʭ_Q]ZXLM]PLV>ZXP_TXP^ As well as short breaks, sometimes
exercising depletes you of resources an angle or a subject isn’t quite dZ`YPPO_ZU`^__LVP_TXPZʬL
LYOOLXLRP^X`^NWPʭM]P^ɧ]P^_TYR making sense and that little bit of hobby. Burnout is very real, whether
allows you to get your energy back, time apart helps focus my thoughts. it’s with work or with something
and for the muscles to repair And in terms of focus, the Pomodoro you’re doing for fun, and you don’t
stronger than before. method of 30 minutes of work with a want to ruin your relationship with
On a basic level, making sure to ʭaPXTY`_PM]PLVLW^Z]PLWWdSPW[^ your favourite hobby because you
take breaks while making can be a forced yourself to keep doing
safety precaution. Nobody should be something. When taking breaks from
soldering while they can barely stay
awake, after all. More importantly,
As well as short one hobby in the past, I’ve focussed
on another hobby instead. Flexing a
sometimes you need to put some breaks, sometimes OTʬP]PY_[L]_ZQdZ`]XTYOLYOZ]
space between yourself and a project skill set is always good for growth
to allow your brain to rest. you need to just ɧLYONLYPaPYLTOdZ`TYZ_SP]
Constantly hitting it against a hobbies. Although, sometimes, you
problem you’re having is hardly a take time off a have that con crunch and need to get
good way to solve it.
hobby. Burnout is your prop working by any means
necessary. Just make sure not to do
Sleep on it very real any soldering in the hotel room; I
I once read a (possibly apocryphal) speak from experience. It’s not a very
story about how a scientist fell asleep suitable space.
bSTWP_]dTYR_ZʭR`]PZ`_SZb_SPd me. We had a project about making
RZ_^ZXP^[PNTʭN]P^`W_^ɧbSTWP your own Pomodoro timer in issue
Rob Zwetsloot
AUTHOR

asleep they dreamt about a solution 103 (XLR[TNN) which I should


and, after waking up, found out it make. However, I’ve just been using
Rob actually currently has a decent
was correct. my phone and its Focus feature. hobby balance for the moment,
I’ve never quite had a eureka At the other end of the spectrum, although there’s always one project
moment in my dreams like that all-nighters really are overrated I being neglected...

myself, but there have been plenty of feel, although as I near my fourties, magpi.cc

98 magpi.cc Taking a break


The new case from the HiPi.io team

Rapid tool-free assembly and disassembly Secure microSD card cover


Large internal volume for HATs VESA mount support
Compatible with Pi 2/3/4 Molding-configurable output ports
Multiple lid options customizable for volume orders
Passive & Active Cooling options Printed logo for your branding

Available at these great Pi stores:

Contact your favorite Pi store if it’s not listed here


.BOBHFZPVSTFSWFSTPS
XPSLTUBUJPOTSFNPUFMZ

"DPTUFŗFDUJWFTPMVUJPOGPSEBUBDFOUFST 
*5EFQBSUNFOUTPSSFNPUFNBDIJOFT

1J,7.)"5
GPS%*:BOEDVTUPNQSPKFDUT 1SF"TTFNCMFEWFSTJPO

3FBMUJNFDMPDLXJUISFDIBSHFBCMFTVQFSDBQBDJUPS0-&%%JTQMBZ#PPUBCMFWJSUVBM$%30.
ŚBTIESJWF4FSJBMDPOTPMF0QFOTPVSDF"1*JOUFHSBUJPO0QFOTPVSDFTPGUXBSF

$YDLODEOHDWWKHPDLQ5DVSEHUU\3LUHVHOOHUV

3FTFMMFSTVHHFTUJPOTBOEJORVJSJFT
XIPMFTBMF!IJQJJP

You might also like