HackSpace Magazine - Issue 57

Download as pdf or txt
Download as pdf or txt
You are on page 1of 116

hsmag.

cc August 2022 Issue #57

Robot Beer
Roundup RASPBERRY PI BBQ
Make your Turn a keg into

PICO W
Raspberry Pi move an outdoor grill

PROJECTS
Aug. 2022

BEAM
Issue #57 £6

Make internet-connected
builds with the NEW $6
Machine
Time-lapse microcontroller board Robotics
Photography powered b
y the
Watch life on fast forward sun’s rays

LASER CUTTING KNITTING WELDING DOGSwww.dbooks.org


WELCOME EDITORIAL
Editor
Ben Everard
[email protected]

Welcome to Features Editor


Andrew Gregory
[email protected]

HackSpace magazine Sub-Editors


David Higgs, Nicola King

DESIGN
When Pico came out in January 2021, there was one feature Critical Media
requested more than any other – wireless networking. The criticalmedia.co.uk

Head of Design
problem is, while there was some spare space on the Pico Lee Allen
board, there wasn’t really enough for wireless. There also Designers
weren’t any spare GPIOs that could be used to connect the Sam Ribbits, Olivia Mitchell,
Ty Logan
wireless controller. These two obstacles didn’t stop the Photography
Raspberry Pi engineers, who ploughed on regardless. Brian O’Halloran

The result of their CONTRIBUTORS


Jo Hinchliffe, Marc de Vinck,
This month, we’re putting the Pico W through hard work is the Andrew Lewis, Mike Bedford,
Nicola King, Rosie Hattersley,
Pico W. It’s (almost)
its paces with three projects to get you started Jack Spiggle, Rob Miles
pin and form factor PUBLISHING
on your own connected projects compatible with Pico Publishing Director
Russell Barnes
– the only changes [email protected]

being moving the debug pins and a change to the LED. This Advertising
Charlie Milligan
month, we’re putting the Pico W through its paces with three [email protected]

projects to get you started on your own connected projects.


DISTRIBUTION
Whether you want to build an IoT device, control a robot, or Seymour Distribution Ltd
just flash some lights, we can help. 2 East Poultry Ave,
London EC1A 9PT
+44 (0)207 429 4000
BEN EVERARD
SUBSCRIPTIONS
Editor [email protected]
Unit 6, The Enterprise Centre,
Kelvin Lane, Manor Royal,
Got a comment,
Crawley, West Sussex, RH10 9PE

44
question, or thought To subscribe
about HackSpace
PAGE
01293 312189
magazine?
hsmag.cc/subscribe

get in touch at FREE PICO Subscription queries


hsmag.cc/hello WHEN YOU [email protected]

SUBSCRIBE
GET IN TOUCH
This magazine is printed on
hackspace@ paper sourced from sustainable
raspberrypi.com forests. The printer operates an
environmental management system
h
 ackspacemag which has been assessed as
conforming to ISO 14001.
h
 ackspacemag HackSpace magazine is published
by Raspberry Pi Ltd, Maurice Wilkes
Building, St. John’s Innovation
ONLINE Park, Cowley Road, Cambridge,
CB4 0DS The publisher, editor, and
hsmag.cc contributors accept no responsibility
in respect of any omissions or
errors relating to goods, products or
services referred to or advertised.
Except where otherwise noted,
content in this magazine is licensed
under a Creative Commons
Attribution-NonCommercial-
ShareAlike 3.0 Unported (CC BY-NC-
SA 3.0). ISSN: 2515-5148.

3
www.dbooks.org
Contents 112

06 SPARK 31 LENS
06 Top Projects 32 Pico W Projects
Beautiful builds made by humans Build connected projects with the new board from Raspberry Pi

18 Objet 3d’art 46 How I Made: Solar tracking head


It’s amazing what you can do with hot plastic Free-form soldering meets solar power in a BEAM robot

20 Meet the Makers: EMF Camp 52 Interview: Andrew Sink


Our report from the Glastonbury of makers Photogrammetry, printing, and all things 3D

26 Letters 60 Improviser’s Toolbox Barbed wire


People love rockets. Fair enough… From the spiky came forth sweetness

28 Crowdfunding 64 In the workshop Beer keg BBQ


A tiny Linux computer that Prince would have loved A metalwork project that combines two of our favourite things

Cover Feature Tutorial


Knitting

PICO W
PROJECTS 78 Turn programmatically stored
information into physical patterns

Make internet-connected
builds with the NEW $6
microcontroller board

104
32
4
CONTENTS

96

18
06
How I Made
BEAM robotics

20
Interview
Andrew Sink

46 Create a very simple AI with


brass and capacitors

69 FORGE 52 That’s one way to defeat face-


recognition technology

70 SoM Welding helmet


Pimp your PPE with budget-friendly add-ons

74 SoM Raspberry Pi
Time-lapse photography on a Raspberry Pi

78 Tutorial Knitting
Knitting: it’s like coding, but with fabric

84 Tutorial Laser cutter


How to calibrate your newly improved K40
103 FIELD TEST 70
90 Tutorial Infrared photography 104 Best of Breed
Another way to enjoy the wonders of nature The best robotics add-ons for Raspberry Pi

96 Tutorial Printing camera 112 Review Waveshare SX1262


Relive the glory days of Polaroid, with Python Add LoRa capabilities to a Raspberry Pi Pico

Some of the tools and techniques shown in HackSpace 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. HackSpace Magazine is intended for an adult audience and some projects may be dangerous for children. Raspberry
Pi Ltd does not accept responsibility for any injuries, damage to equipment, or costs incurred from projects, tutorials or suggestions in HackSpace Magazine. Laws and regulations covering many of the topics in
HackSpace Magazine are different between countries, and are always subject to change. You are responsible for understanding the requirements in your jurisdiction and ensuring that you comply with them. Some
manufacturers place limits on the use of their hardware which some projects or suggestions in HackSpace Magazine may go beyond. It is your responsibility to understand the manufacturer’s limits. HackSpace mag-
azine 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. Application to mail at Periodicals prices is pending at Williamsport, PA. Postmaster please send address changes to HackSpace magazine c/o Publishers
Service Associates, 2406 Reach Road, Williamsport, PA, 17701.

5
www.dbooks.org
Top Projects

REGULAR

(Freddie) Mercury
thermometer
By TurboSnail hsmag.cc/FreddieMercuryThermometer

H
as there ever been a more captivating rock front
man than Freddie Mercury? No, of course there
hasn’t. That’s what makes this custom temperature
display so awesome. Well, that and the custom
PCB that forms the display, and the custom
microcontroller based on an Arduino Uno that forms
the guts of the build (along with a low-power servo and an Adafruit
AHT20 temperature/humidity sensor).
All together now: DAAAA-OOOOOOOOH!

Right
Freddie points at the
temperature with his
resin-printed arm

6
SPARK

7
www.dbooks.org
Top Projects

REGULAR

RFID Record Player


By Ibrahima, Scott, Antoine & Arthur hsmag.cc/RFID_RecordPlayer

W
hen teacher Jean Noël showed his students
a record player upgraded with an Arduino
to read RFID tags on record sleeves, we
can only imagine their befuddlement. Kids
these days don’t use physical media; they
don’t even download anymore. At least, that’s
what we’re told. We don’t actually know any kids.
The students in question – Ibrahima, Scott, Antoine, and Arthur
– did recognise that the underlying technology is RFID, and they’re
working on making their teacher’s project even better, upgrading
the user interface to make it easier to use. Most significantly,
instead of uploading a new Arduino sketch to update the playlist
(something that requires coding skills), the user will be able to do
it by renaming MP3 files on the SD card (something that does not
require coding skills).
The students eventually plan to make the improvements scalable
as a kit form that they will be able to sell on Tindie. Bonne chance!

Right
Other improvements
in the pipeline
include an RGB
LCD screen to give
information to the
user and show some
cool light animations

8
SPARK

9
www.dbooks.org
Top Projects

REGULAR

Mini Router Plane


By WOmadeOD hsmag.cc/RouterPlane

W
orkshop Heaven, the online emporium of
woodworking delights, has listed among
its wares a hand plane going for £10,560.
It’s a beautiful tool, but is it more beautiful
than this handmade router plane built out of
scraps of wood in the maker’s workshop?
We’d say not. This build, by Instructables user WOmadeOD
comprises a chunk of hardwood, a square of steel plate, a nut, and
a bolt, which is shaped, hardened, and sharpened until it can take
off thin slivers of wood.

Right
To adjust the depth
of the plane, just turn
the bolt a fraction
of a turn

10
SPARK

11
www.dbooks.org
Top Projects

REGULAR

Raspberry Pi TV
simulator
By Pakéquis Pakequis.com.br

I
n this age of LED everything, it’s hard to imagine the tiny
CRT televisions that were once marketed as ‘travel’ TVs.
That’s what this is, only this has been retrofitted to include a
Raspberry Pi playing a selection of old black-and-white films.
Even better, when you change the channel, it produces an
authentic screen of white noise, just like TVs used to do.

Right
Movies are stored on
the Raspberry Pi’s
SD card, and there’s
an Arduino Pro Mini
to provide voltage
that the TV can use

12
SPARK

13
www.dbooks.org
Top Projects

REGULAR

3D-printed
bike light
By Kevr102 hsmag.cc/BikeLight

A
fter ‘do not crash’, our one golden rule of
riding a bike is that you can never have too
many lights. That’s what inspired Kevr102 to
design and build this auxiliary bike light for when
his existing front light runs out of battery. It’s a
3D-printed enclosure for a Kitronik 5 V LED lamp
kit, with the addition of a buck converter to drop the 6 V from the
AA batteries down to the 5 V required by the LEDs. And as the
maker notes, the square version “looks a bit like the weapon the
Predator has on its shoulder”.

Right
Kevr102 designed
this bike light in
Fusion 360

14
SPARK

1
5
www.dbooks.org
Top Projects

REGULAR

3D-printed
power loom
By Fraens hsmag.cc/PowerLoom

T
his issue, we’ve gone into the coding behind
knitting and crochet, and raised a hat to the
Jacquard loom, which took instructions that
could’ve been programmed anywhere, by anyone. It
wasn’t Turing-complete, but it was, almost, a computer.
This 3D-printed model pays tribute to the power
looms that laid the way for the Industrial Revolution and, indirectly,
computer science.
Fraens has made the STL files available on Printables and
Thingiverse, and there’s a full list of materials used on his YouTube
page, including screws, ball bearings, and a 12 V motor. Apparently,
one of the hardest things to get right was the weight of the shuttle:
too heavy and it won’t move; too light and it gets snagged easily.

Right
The Luddites would
never have smashed
a machine they
could have printed
themselves

16
SPARK

17
www.dbooks.org
Objet 3d’art

REGULAR

Objet 3d’art
3D-printed artwork to bring more beauty into your life

M
ost of the time, it’s a
pleasure to mow one’s lawn.
It’s a moment of communing
with the outdoors, of exerting
your mastery over nature.
Mowing the lawn is a lovely job – unless
you’re stricken with hay fever. Or, you have
extensive grounds that you just can’t be
bothered to look after (admittedly, this
would be a nice problem to have).
In these situations, a robotic mower
comes into its own – and TGD Consulting
has come up with a 3D-printed, Raspberry
Pi-controlled solution: PiMowBot. Like the
BEAM project featured on page 46, it takes
power from the sun, so the whole top panel
is a solar panel. You can get the design files
from Cults3D below.

hsmag.cc/PiMowBot

18
SPARK

19
www.dbooks.org
Electromagnetic Field 2022

REGULAR

Electromagnetic
Field 2022
Our roving reporter visits the UK’s biannual maker festival

E
very two years, the British summer is
lit up by Electromagnetic Field (also
known as EMF Camp). This maker
festival brings people together to show
off makes and talk about the things
they’ve been doing. Since 2018, this has
been held in Eastnor Castle just outside Ledbury in
Herefordshire (a county forever blighted by Robert De
Niro’s mispronunciation in the film Ronin: for our
international audience, it’s pronounced approximately
hair–re–ford–shire).

” For some, it’s about how they built a particular


project; for others, it’s about a technology


they’ve been working with

The bulk of the festival is taken up by talks. Across


three stages, people from the makersphere give talks
about almost any topic. For some, it’s about how they
built a particular project; for others, it’s about a
technology they’ve been working with. Others are,
well, about almost anything. To give you a bit of a
flavour, here are some that we went to see:

20
SPARK

21
www.dbooks.org
Electromagnetic Field 2022

REGULAR

Above
Sam Battle valiantly
pressing on
through some
technical hiccups

Solarpunks assemble Being YouTubers


Terence Eden talked us through his experiences James Bruton and Matt Denton (Ruth Amos was
running domestic solar setups on three of the houses meant to join in as well, but had to cancel at the last
he’s lived in, what’s worked well, and why he thinks minute due to Covid) talked us through their
we should all be running domestic solar setups. experiences building YouTube audiences, and
bonding over their different builds of BB-8.
Wearable fire art
After being invited to join a fire art group at Burning Rewilding human-computer interaction
Man, Jeff Gough decided to build a flaming top hat. Artist Tim Murray-Browne thinks that the way we
Jeff talked us through the process of designing and work with computers has become too sanitised.
making something that’s small enough to fit on your While he didn’t provide an ultimate solution, he’s
head, but also safe and fun. He wore the result – a been working with dancers to create a movement-
hat that emitted occasional puffs of burning gas based interface. In this interface, machine learning
throughout the talk. (ML) translated movements into sound in a non-

22
SPARK

BADGE
Every attendee got a programmable electronic badge.
Known as ‘TiDAL’, this featured an ESP32 processor Above
(with WiFi and Bluetooth), a small TFT screen, joystick, The Mammoth Beat
two buttons, three-axis accelerometer, three-axis Organ mechanical
modular instrument
magnetometer, and a battery. in action
You can create and install MicroPython apps from
the App Store. You can see the available software at
2022.badge.emfcamp.org. Options include a very basic
oscilloscope, some games, and a weather forecast.
The choice of MicroPython and an online editor
meant you didn’t have to install any software to
linear way. A simplistic movement (such as waving create your own apps. Just plug in your badge (which
featured a USB-C socket that slotted straight into a
an arm) doesn’t in itself result in a particular sound.
USB port on a computer – no cable needed), point
Instead, the computer tracks a range of movements
your browser to editor.badge.emfcamp.org, and you
and converts them into sound using a dancer- were ready to start coding.
specific ML model. This toolchain-less setup made it much easier to
Alongside these talks were workshops where start creating things while on site.
people could learn to solder, build, sew, blacksmith,
and other maker skills. The workshops took place
in ‘villages’ – these are self-organising groups of through the camping field stood a tower of button-
attendees. Anyone can start a village where they activated flaming torches, and more lasers than had
and others can camp together. Some villages any right to be in a field, lighting up the sky across
included larger tents and gazebos which were the whole event. Inside was a curious mash-up of
used as meeting places and general areas to relax nightclub, market, escape room, and interactive
and chat. art display. Oh, and there was a scanning electron
Standing apart from the rest of the main festival microscope as well. It’s the sort of place that defies
was Null Sector. At the end of a track that leads you easy categorisation.

23
www.dbooks.org
Electromagnetic Field 2022

REGULAR

Right
We’re slowly
building up the
skills to make our
own Hacky Racer

BY GEEKS FOR GEEKS


EMF Camp is unashamedly a festival run by geeks –
the organisers and setup crew are all volunteers.
Nowhere is this more obvious than in the
infrastructure. There’s power available to your tent,
and WiFi coverage across the entire site. This alone
would be quite impressive, but it doesn’t stop there.
There’s also a DECT phone network that allows you
to use a regular wireless phone – not a mobile, but
the handset of a landline. There’s an analogue phone
network that lets you use regular landlines, as well as
fax machines and dial-up modems. It’s not just
old-fashioned tech, though. There was also an
experimental 4G cell.
If you’re wondering what use a DECT network, or a Speaking of old equipment, there was an arcade
fax-compatible analogue phone network is, then machine full of games of yesteryear. A personal
you’re missing the point entirely. None of this is highlight was a 1979 version of Asteroids running on
essential, and certainly not in a grassy field in a vector display. Vector displays mostly came and
Herefordshire. There is no need to have dial-up went before I reached the age of arcades, so this was
internet when WiFi is everywhere. But then WiFi the first one I’d been able to play. While I’ve played
doesn’t go gruuuuhhhh, hurrrrrrrrr, badoing, badoing, many raster re-creations of this game, I was
kruuurrrrr when you connect, and that noise is, for a genuinely blown away by the vector graphics in a way
certain generation of geek, the sound track of our I wasn’t expecting. I think that perhaps my eyes have
childhood. EMF Camp is a biannual chance to dust out come to expect and ignore slight pixelation, so when
the old computing equipment, don some rose-tinted greeted with a truly straight line from a cathode ray,
glasses, and remember how things used to be. my brain struggled to process the reality.

24
SPARK

THANKS!
EMF Camp is
the product of
hundreds of
volunteers. The
people who give
the talks, the
people who run
the bar and shop,
and even the
event organisers
are volunteering.
It’s the passion
that these people
bring that makes
the event special.
We’d like to
I was invited by race organiser Mark Mellors to give a heartfelt
have a go in the ‘Rule Zero’ fire engine. The racing thanks to all who
vehicles have a maximum width of 90 cm and length helped make this
of 150 cm, which results in quite a snug fit. After event great.
If you’re
wriggling in, I set about a few laps of the empty track.
thinking of
RACE-READY It was great fun. In the two weeks that I’ve been back attending in 2024,
One of this author’s personal highlights this year was home since EMF Camp, I’ve already bought two please consider
Hacky Racers. This is where people (or teams of broken ‘hoverboards’ to salvage motors from in order volunteering,
people) build small novelty electric go-carts and race to build my own. Look out for more on the build in whether that’s
them around a field. It’s broadly based on the Power future issues of HackSpace magazine. by giving a
talk, running a
Racing Series in the USA. Points are awarded for It’s difficult to sum up an event like EMF Camp in a
workshop, or
style as well as speed on the track, so designs few pages, but hopefully we’ve given you a flavour of
doing a shift in
included a giant Meccano vehicle, a cut-and-shut what it was like. If you’ll be in the UK in 2024, and are the bar.
Little Tikes car, and an Only Fools and Horses yellow interested in technology or making things, we highly
three-wheeler that appeared to be stuck in reverse. recommend you go.

25
www.dbooks.org
Letters

REGULAR

Letters ATTENTION
ALL MAKERS!
If you have something you’d
like to get off your chest (or
even throw a word of praise
in our direction), let us know at
hsmag.cc/hello

SUSTAINABLE MAKING
Alex Glow makes some very good points in
your interview with her last issue. Whenever I
make anything, I must go through a few
iterations before I get anything to work – that
means multiple PCBs made (with multiple
boards shipped from the factory), multiple
loads of solder, components, and, even when
they do work, everything needs a battery, with
all the pollution their production entails, and
that battery needs electricity. That all sounds
a bit grim, but one thing Alex said stands out:
“It’s not our fault, but it is our responsibility”.
We can try to do better without feeling guilty
about the 60–70 years of oil extraction and
plastics waste, because it’s overwhelmingly
the fault of a handful of companies. All we
can do is try to do better, and not let the
perfect be the enemy of the good.

James
Sunderland

Ben says: Alex has put together a great


resource for makers who want to minimise
their contribution to the forthcoming
environmental apocalypse — green-ee.com.
We’ve found it was worth a browse, even if
you don’t have a project in mind, as it’s
helped steer our thinking without our even
realising it. It’s easy to feel helpless, but
small changes gather momentum.

26
SPARK

ROCKET GLIDER
The swing-arm rocket glider that your writer made last issue was brilliant, and
gave a perfect example of how the judicious application of 3D-printed parts to a
more traditional build can be so much better than trying to 3D-print the whole
thing. Dare I ask if we can hope to see more rocketry projects in the near future?

David
Germany

Ben says: As luck would have it, our Rocketry Correspondent, Jo Hinchliffe, is
right now working on a flat-pack rocket as a tutorial for the magazine — readers
are invited to think of a fake Swedish name for it, were it ever to arrive on the
shelves of IKEA.

PICO W
My MagPi subscription just dropped
through my door – and there’s a
microcontroller attached to it! Now I just
need someone to come up with a load of
projects for me to copy. Can anyone out
there help me?

Lucy
Bedfordshire

Ben says: It was our pleasure to give away


the Raspberry Pi Pico to our subscribers
when it launched in January 2021; now
there’s another version of this affordable
microcontroller board, but with added
internet connectivity. And yes — as you’ll
have discerned by now, there’s a heap of
ideas for you to make with your new Pico
W, starting on page 32. Have fun!

27

www.dbooks.org
Crowdfunding now

REGULAR

CROWDFUNDING
NOW
ShaRPiKeebo
The little computer with big battery life

From $150 hsmag.cc/ShaRP Delivery: November 2022

B
uilding a portable computer is easier it’s mostly text-based – this is a great choice. The
than it’s ever been. With tiny single-board 400×240 pixel resolution might be a little small for
computers such as Raspberry Pi, you just graphical use beyond simple games, but for text-
need to find a small keyboard and screen based things, it looks like a great choice.
in the form factor you want, strap on a As well as a low-power screen and a 56-key
battery, and you’re ready to go. keyboard, the ShaRPiKeebo comes with a 433MHz,
However, there’s a big difference between long-range radio for sending data between devices.
building a computer and building a good computer, You can get these modules separately, so it should
and that comes down to be possible to build your


understanding your own hardware that can
needs and picking send data to your
The ShaRPiKeebo
exactly the right ShaRPiKeebo, making it
components for the job. looks like a great an interesting option for
The ShaRPiKeebo option for a battery- controlling hardware


is small and packs a across a long (circa 1 km)
long battery life. The powered handheld range. However, the
former is thanks to the module currently used
Raspberry Pi Zero W (the RFM95) is not
(or Zero 2 W), and the latter is thanks to the SHARP CE-marked, so can’t be shipped to the EEA.
Memory Display. This display is almost like a cross Overall, the ShaRPiKeebo looks like a great option
between e-paper and an LCD screen. It takes very for a battery-powered handheld, as long as you’re
little battery, and is just a single colour (like e-paper), mostly interested in working with a command-line
but has much faster update times (like an LCD interface, and we look forward to trying it out in
screen). For on-the-go computing – particularly if real life.

28
BUYER
BEWARE !
When backing a crowdfunding
campaign, you are not purchasing
a finished product, but supporting
a project working on something
new. There is a very real chance
that the product will never ship
and you’ll lose your money. It’s
a great way to support projects
you like and get some cheap
hardware in the process, but if
you use it purely as a chance to
snag cheap stuff, you may find
that you get burned.

Left
The SharRPiKeebo is
small enough to fit in
one hand

29
www.dbooks.org
enviro Flexible Power
Pico W Aboard
Alkaline NiMH Micro-USB LiPo

goes
Wireless, standalone boards

Long Battery Life Run for weeks or months on batteries

wireless
Human Friendly Working examples and custom libraries

Real Time Clock Efficient sleep and scheduled readings

https://pimoroni.com/envirow

Automation 2040 Your seven colour E Ink pal who's fun to be with

RELAY AND IO CONTROL UP TO 40V WIRELESSLY


FOR HOME, OFFICE AND INDUSTRIAL AUTOMATION

Informal yet informative

A B C D E

https://pimoroni.com/inkyframe

https://pimoroni.com/auto2040w PIMORONI
LENS
HACK MAKE BUILD
Uncover the technology that’s powering the future
CREATE

PG

46
HOW I MADE:
PG
32
BEAM ROBOT
Analogue, solar-powered
robotics – and it looks as cool
as it sounds PICO W
52
PG
PROJECTS
INTERVIEW: Add wireless power to your
Raspberry Pi Pico projects
ANDREW SINK
3D printing, photogrammetry,
and why you should print all
the Baby Yodas you like

PG
PG

60 64
IMPROVISER’S TOOLBOX: IN THE
BARBED WIRE WORKSHOP
It’s strong and spiky, but it’s also Summer is here, so
bendy – why barbed wire should it’s time to cook meat
be in your toolbox over a hot fire

www.dbooks.org
Pico W Projects

FEATURE

PICO W
PROJECTS

32
LENS

T
he Pico W is, rather
predictably, a Raspberry
Pi Pico but with added
wireless networking. For just
$6, you get a dual-core Arm
Cortex M0+ microcontroller
running at up to 133MHz with 264kB of RAM
and 2MB of flash storage, and on top of this is
an Infineon CYW43439 which adds wireless
networking (the chip also supports Bluetooth
Classic and Low Energy, but at present there’s
no firmware support for this).
All the things we’ve come to know and love
from the original Pico are still there. There’s
still a huge bundle of input and output options,
including Programmable I/O. In fact, the only
slight change is that the on-board LED is now
attached to the wireless chip rather than the
main microcontroller (see box on page 35).
Not only does it have all the old features, but
Pico W is in the same form factor as Pico, so
adding networking to a project is usually just a
case of swapping a Pico for a Pico W.
In this article, we’re going to take a look at
some great projects to help you get started and
get the most out of Pico W.

33
www.dbooks.org
Pico W Projects

FEATURE

JOIN THE ONLINE


COLOUR-CHANGING
LED COMMUNITY
Add some light to your electronics

W
hile Pico W is very similar to Pico, over, the drive will disappear and Pico W will reboot
you will need to get the special into MicroPython.
wireless version of the MicroPython We recommend Thonny for working with
firmware. You can download this from MicroPython (though you can connect over serial as
hsmag.cc/DocMicroPyth. well). If you haven’t already got this, you can download it
Make sure that you select the version for Pico W, as from thonny.org – it works on Windows, Mac, and
the version for the regular Pico won’t work. You should Linux (including Raspberry Pi). Open up Thonny and it
have a UF2 file, and this can be loaded onto Pico W. should automatically detect and connect to MicroPython
First, make sure that Pico W is unplugged from USB, running on Pico W. In the bottom box, you should see a
then hold down the BOOTSEL button and plug Pico W line something like this confirming it:
into your computer using a micro USB to USB cable,
Below MicroPython v1.19.1-88-g99c258977 on 2022-06-30;
The Thonny MicroPython then release the button. You should notice a new USB
IDE makes it easy to Raspberry Pi Pico W with RP2040
drive appear on your computer. You can drag and drop
program and transfer
files to your Pico the UF2 firmware file onto this drive. Once it’s copied If you see that, then you’re all set up and ready to go.
For our first internet-connected project, we’re going to
create a CheerLight. The idea of this is to have a
colour-changing LED linked into a global system of
setting colours. You can set the colour by tweeting
@cheerlights and including a colour name in the tweet.
This will change LEDs across the world to the colour you
name. In an increasingly divided world, having an LED
change colour is just a little reminder of how we’re all
connected. This can sit in the corner of your office and
remind you, in a small way, that you’re not alone. You’re
part of a worldwide community of makers.
We’ll be using WS2812B LEDs (also known as
NeoPixels) as our light. These can be programmed to
display a wide range of colours. These LEDs come in a
few different forms, but most commonly strips. You can
use any form you like.
First, let’s wire it up. Your LEDs should have three
inputs, usually in the order 5 V, Data In, and GND. 5 V and
GND should be connected to VBUS and GND on Pico W,

34
LENS

Left
You can program
Pico W from most
computers, including a
Raspberry Pi 400

ON-BOARD LED
The original Raspberry Pi Pico makes use of all the GPIO
pins. However, some are now needed to attach the wireless
module. One solution was to reassign GPIO 25. On Pico, this
while Data In should be on GPIO 18 (you can use another is attached to the on-board LED, but on Pico W, it’s attached
GPIO pin if you like, but you’ll need to change it in the to the wireless module.
code). You can solder these on or connect them with The LED remains, but now it’s controlled by the WiFi
jumpers and crocodile clips. module rather than the main microcontroller. Fortunately,
much of this is hidden by MicroPython, and there is a
pseudo pin called ‘LED’. You can blink the LED with:
CODING IT UP
We need to connect Pico W to the wireless network. import machine
Obviously, this needs an SSID (network name) and import time
password. You can put these directly in your MicroPython led = machine.Pin("LED", machine.Pin.OUT)
code, but this can be a bit inconvenient because it means while True:
you have to be a bit careful about uploading your code to led.toggle()
an online code repository, and it means you have to type time.sleep(0.5)
the details into the code each time you take them from a
repository onto your device. Instead, we’re going to use This pin should behave as any plain pin does, but it can’t
be used with PIO, PWM, or other special functions.
a secrets file. In this, we’ll put all the things that we don’t
want to be publicly known. It’ll include the WiFi login
details, as well as secret keys for things we’ll be using in
from machine import Pin
other examples.
from secrets import secrets
secrets = { import machine
'ssid': 'XYZ', import neopixel
'password': 'XYZ',
'aio_key': 'XYZ', ssid = secrets['ssid']
'aio_username': 'XYZ', password = secrets['password']
'ifttt_key':'XYZ',
} print("starting connection")
wlan = network.WLAN(network.STA_IF)
Enter that in Thonny and press Save, select
‘MicroPython device’, and call it secrets.py.
wlan.active(True)
Now, let’s connect to the network:

import network print("connecting ...")


import urequests wlan.connect(ssid, password)
import json
import time wait = 10

35
www.dbooks.org
Pico W Projects

FEATURE

Right
WS2812B LEDs come
in all sorts of shapes
and sizes, but they’re
all controlled in
the same way

OTHER LANGUAGES
We love MicroPython because it lets us get projects up while wait > 0:
and running really quickly. However, there are times when if wlan.status() < 0 or wlan.status() >= 3:
another language is more appropriate. break
wait -= 1
C/C++ The official C/C++ SDK is available at: print('waiting for connection...')
hsmag.cc/PicoSDK. time.sleep(1)
This supports networking through the LWIP networking
stack and gives you the ability to work with the networking
# Handle connection error
at a very low level. There are some examples to help you get
started at hsmag.cc/PicoExamp. if wlan.status() != 3:
At the time of writing, this is the only other language to raise RuntimeError('wifi connection failed')
support the wireless networking. However, we expect there else:
to be other options very shortly. print('connected')

Arduino Since the Arduino port of Pico includes the C/C++


status = wlan.ifconfig()
SDK, it should be possible to use this with WiFi once the new
SDK is brought in. However, at the time of writing, we were print( 'ip = ' + status[0] )
not able to test this. We also need a bit to set up our LEDs:
CircuitPython Adafruit’s flavour of Python for small pixels = neopixel.NeoPixel(machine.Pin(18), 10)
devices typically gets new features quickly, so we would
expect WiFi on Pico W to work very soon. It’s likely to be Now that we’re online, we need a way of grabbing the
based on the requests module, which is functionally very colour. There’s a back-end system that grabs colour
similar to urequests, which we use here. changes from Twitter and posts them to the URL
api.thingspeak.com/channels/1417/field/2/last.json
Rust Pico has proved popular with the embedded version in JSON format. We just need to download this and
of this memory-safe language, and there is an active
community working with this.
extract the ‘field2’ data. This is hex encoded, so we need
to extract the red, green, and blue values from this and
set our LED accordingly.

36
LENS

else:
As long as we’re connected to the internet, we can
return None
use the urequests module to do just this, and the json
except Exception as e:
module will convert a JSON string to a Python dictionary.
print(e)
The following code grabs the latest colour from the URL
return None
and returns a colour:
return colour
def get_colour():
We have to do a bit of string manipulation to get the
url = "http://api.thingspeak.com/channels/1417/
colours out of the string. First, we use slicing to get the
field/2/last.json"
two hexadecimal digits that relate to the colour, then we
try:
add ‘0x’ to the start of these two digits. The ‘0x’ lets
r = urequests.get(url)
Python know that the string contains hexadecimal
print(r.status_code)
characters, so we can then use int() to convert this new
if r.status_code > 199 and r.status_code <
string into an integer.
300:
Finally, we just need a loop that checks the colour
cheerlights = json.loads(r.content.
every minute and updates the LED.
decode('utf-8'))
print(cheerlights['field2']) while True:
red_str = '0x' + cheerlights['field2'] print("getting colour")
[1:3] colour = get_colour()
green_str = '0x' + cheerlights['field2'] if colour is not None:
[3:5] pixels.fill(colour)
blue_str = '0x' + cheerlights['field2'] pixels.write()
[5:7] time.sleep(60)
colour = (int(red_str), int(green_str),
You can get the full code at hsmag.cc/cheerlight.
int(blue_str))
Load it up to your Pico and you should see the LED
occasionally change colour. Alternatively, tweet to
r.close()
@cheerlights and send a message to lots of devices –
return colour
including some Pico Ws – to change colour.

Left
Find out more about
CheerLights at
cheerlights.com

37
www.dbooks.org
Pico W Projects

FEATURE

DO SOMETHING
BUTTON
Use Pico W to control the cloud

N
ow that we’ve got data from the internet, The first part of this is to create an applet in IFTTT
let’s send some to it and create a button which we will trigger from Pico. Head to ifttt.com,
that sends a message to the internet to create a free account (if you don’t already have one), and
do something. Do what, you ask? Well, do sign in. You can then press Create to create a new
almost anything! The magic glue in this project is If This applet. The first part to configure is the If This part. Press
Then That (IFTTT), an online service that connects causes Add and search for webhooks. Inside this option, select
to events. This means that you can create a thing that Receive a Web Request, then give it an event name
triggers a huge range of possible events. In this example, (you’ll need to enter this in the program later on). Press
we’ll use it to control our heating using a Hive Create Trigger to finish the first part.
thermostat. However, IFTTT works with a huge range of Second, we create the Then That part. Again, click on
different web-connected devices, so you can easily Add. Here, you can configure your applet to do whatever
modify this to work with any device that’s supported. you want. We’ve configured ours to send us an email,
Take a look here for a full range of supported systems: but you might want to browse through the list of options
ifttt.com/explore/services. to see if there’s some particular service you’d like
If This Then That lets you create very simple programs to trigger.
without having to program anything. The programs are Now, let’s take a look at the Pico W side of things.
known as ’applets’ and all need to have the form ‘If this The only wiring is to connect a button. One side of this
event happens, then trigger this action’. There’s support should go to 3 V and the other side to GPIO pin 0.
Above
This code also works for lots of different possible events and actions. The We need to update our secrets file with a couple of
with the user button on particular event that we’ll be using is known as ‘Maker bits of information for IFTTT: the event name and key.
the Kitronik Autonomous
Robotics Platform for Pico Webhooks’. These create a URL that, if you visit it, will Technically, the event name doesn’t have to be secret,
trigger an ‘If This’. but the secrets file is a good place to put it.

38
LENS

Add the following inside the secrets dictionary in the


secrets file:

'ifttt_key': 'XXXX',
'ifttt_eventname': 'web_button',

You can find out your key by going to the URL


ifttt.com/maker_webhooks/settings. There, you
should see a section like:

URL
https://maker.ifttt.com/use/<your key here>

Where we’ve written <your key here>, you’ll find


your key and you can copy and paste that into the
secrets file.
You can see the full code at hsmag.cc/picow_ifttt.
To start, it’s exactly the same as the previous
example, as we just need to connect to the internet.
if r.status_code>199 and r.status_code<300: Above
Webhooks are triggered by visiting a particular You can get the code from
r.close()
URL. You can also attach up to three bits of data hsmag.cc/picow_ifttt
return 0
to your webhook. We can do this by adding "?value1=<d Below
else: Take a look at the
ata>&value2=<data>&value3=data" to the end of the URL.
r.close() available services on
We won’t actually use this in our example, but you may IFTTT to see if there are
return -1 any that you use already
want it if you use this function in your own code.
except:
def ifttt_webhook(event, key, values=None): r.close()
url="https://maker.ifttt.com/trigger/"+event+"/ return -2
with/key/"+key
As you can see, this builds up a URL with the
if values is not None:
relevant values for event and key. You can also submit
url = url + '?'
up to three values in a list, and these will also be passed
for counter, value in enumerate(values,
to the webhook (IFTTT doesn’t permit more than three).
start=1):
This uses the same urequests module that we used in
if counter < 4:
the previous project.
if counter > 1:
Finally, we just need a bit of code to trigger this when
url=url+'&'
a button is pressed.
url=url+"value"+str(counter)+"="+val
ues[counter-1] button = machine.Pin(0, machine.Pin.IN, machine.Pin.
try: PULL_DOWN)
r = urequests.get(url)
current_state = 0
while True:
new_state = button.value()
if new_state != current_state:
if new_state == 1:
ifttt_webhook(secrets['ifttt_
eventname'], secrets['ifttt_key'], values=None)
current_state = new_state
time.sleep(0.5)

This project is surprisingly powerful because of the


range of integrations available from IFTTT. Exactly what
you can use it for depends entirely on what online
services you use. Potentially, you can use it to log
particular events, control your heating, send alerts, even
open doors and turn lights on.

39
www.dbooks.org
Pico W Projects

FEATURE

WEB SERVER
ROBOT
Control a buggy from the web

S
o far, we’ve looked at getting data from the data to Adafruit IO and another to read data from the
internet and sending data to the internet, but same feed. Doing this is reliable and you can keep a trail
in both cases, we connected to an external of data, should you need to restart one of the machines.
server. However, there are times where we However, it’s also slow, and there are times when you
don’t want to send data to an external system, but use might not want to trust your data to the internet.
a wireless connection to send data from one computer Fortunately, there is a solution. Hypertext Transport
to another. Protocol (HTTP) – the protocol that the web is built
In this case, you can go via the internet on – is actually a very simple text-based protocol.
– for example, use one A client sends a request to a server which
machine to send returns a response. The sort of web
servers that power most websites
are complex bits of software, but
this complexity comes from
performance and the features
that allow you to automatically
place dancing baby GIFs
on your web pages
and suchlike.
We can do away with all
that and have a really simple
web server that just controls
a buggy. We want it to serve
up the same web page
whatever address the user
puts in (which displays a
simple remote control), and if
they visit /buggy/forward, the
buggy will move forward. If they
visit /buggy/left, the buggy will go
left, and if they visit /buggy/right, the
buggy will go right.
We’ve used a Kitronik Pico Buggy for this,
but it should work with any robot that you have
Right a MicroPython library for.
There’s far more hardware
than we’ve used – you can The first part of the code is the same WiFi connect
add extra servos, an extra code that we’ve used in previous examples, but we’ve
distance sensor, and even
a pen for drawing added in a few LED flashes on the buggy’s four RGB

40
LENS

Left
This robot was
designed for Pico,
but since Pico W is
pin-compatible, it slots
right in and works fine

print("connecting ...")
LEDs so that we can see what’s going on when we’re
wlan.connect(ssid, password)
not plugged into a computer.

import network buggy.setLED(3, buggy.YELLOW)


import socket buggy.show()
import time
from machine import Pin # Wait for connect or fail
from secrets import secrets
from PicoAutonomousRobotics import wait = 10
KitronikPicoRobotBuggy while wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
print("starting buggy") break
buggy = KitronikPicoRobotBuggy() wait -= 1
print("started buggy") print(wait)
if (wait % 2 == 0):
buggy.setLED(0, buggy.YELLOW) print("here")
buggy.show() buggy.setLED(0, buggy.BLUE)
else:
ssid = secrets['ssid'] buggy.setLED(0, buggy.RED)
password = secrets['password'] buggy.show()
print('waiting for connection...')
print("starting connection") time.sleep(1)
wlan = network.WLAN(network.STA_IF)
# Handle connection error
buggy.setLED(1, buggy.YELLOW) if wlan.status() != 3:
buggy.show() raise RuntimeError('wifi connection failed')
else:
wlan.active(True) print('connected')
buggy.setLED(0, buggy.GREEN)
buggy.setLED(2, buggy.YELLOW) buggy.setLED(1, buggy.GREEN)
buggy.show() buggy.setLED(2, buggy.GREEN)
buggy.setLED(3, buggy.GREEN)

41
www.dbooks.org
Pico W Projects

FEATURE

Right
Power comes from four
AA batteries, which
means this can run
without any cables

buggy.show() We won’t go into HTML in detail here as we


are focusing on the Pico W, but links are between
status = wlan.ifconfig() <a href=link> and </a>.
print( 'ip = ' + status[0] ) You might also notice the final line with The next
# Open socket object in front is at %s. Our buggy has an ultrasonic
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1] distance sensor that we can use. In Python, we can
Next, we need a variable that holds a string with the use %s to mark a point in a string where we want to
HTML response. We’ve kept this really short and include another string. We’ll take a look at how to do
simple, but it could easily be made more aesthetic, or that in a little bit.
include more information, if you want. HTTP runs on top of Transport Control Protocol
(TCP). TCP has a range of numbered ports that we can
response = """<!DOCTYPE html>
bind to using the socket module.
<html>
Once we’ve created a socket object and bound it to
<head> <title>Pico W</title> </head>
a port and an address (since a device can in theory
<body> <h1>Pico W</h1>
have multiple IP addresses, sockets are defined by
<p><a href="/buggy/forward">forward</a><br>
both IP address and port), we can wait for an external
<a href="/buggy/left">left</a></br>
device to make a TCP connection.
<a href="/buggy/right">right</a></p>
TCP connections themselves are really just a two-
<h2> The next object in front is at %s</h2>
way text stream. You can use them to send and receive
</body>
all sorts of data in much the same way that you can
</html>
use the serial port. However, with HTTP, we use it in
"""
a very specific way. The client makes a request that is

42
LENS

cl.send('HTTP/1.0 200 OK\r\nContent-type:


text in a very specific format defining what page they
text/html\r\n\r\n')
want to access, as well as some details about the
cl.send(response % str(buggy.
client and its capabilities. Again, we won’t go into this
getDistance("f")))
in depth.
cl.close()
The important thing for us is that we take a look at
the request, see if it’s for the pages /buggy/forward,
except OSError as e:
/buggy/left, or /buggy/right, and if it is, set the
cl.close()
motors appropriately, then whatever page the user
print('connection closed')
requested, returns the same HTML response defined
above. The code for all this is: As you can see, we first have to accept a
TCP connection, then we can receive data. Our
def check_and_move(request, find_str, buggy, left_
check_and_move function takes the stringified version of
motor, right_motor):
the request as well as the page location we want to
request = str(request)
check and details of the motor settings. If it finds the
if (request.find(find_str) == 6):
find_str at position 6 in the request, then it knows that
buggy.motorOn("l","f",left_motor)
this is the page that the user requested. It turns the
buggy.motorOn("r","f",right_motor)
motors by the specified amount, waits for one second,
time.sleep(1)
then stops the motors.
buggy.motorOn("l","f",0)
buggy.motorOn("r","f",0)

# Listen for connections OUR BUGGY HAS


AN ULTRASONIC
while True:
try:
cl, addr = s.accept()
print('client connected from', addr)
request = cl.recv(1024)
DISTANCE SENSOR
print(request) THAT WE CAN USE
request = str(request)
check_and_move(request, '/buggy/forward',
After this has happened, the main loop then sends the
buggy, 100,100)
HTML to the client. Notice that it first sends a header
check_and_move(request, '/buggy/left',
line that has a bit of information about the data. This is
buggy, 100,0)
required by HTTP. We can insert the distance into our
check_and_move(request, '/buggy/right',
HTML with the line:
buggy, 0,100)
cl.send(response % str(buggy.getDistance("f")))

The % command is used to substitute the %s in the


original string with a new string – in this case a readout
STARTING AUTOMATICALLY from the distance sensor.
The only thing left to do is close the connection. You
You probably want your buggy to automatically start the
have to do this in order to free up memory – you’ll
program when you turn it on – it’d be a bit of a faff if, every
time, you had to plug it into your computer and start Thonny quickly run out of memory if you don’t.
just to launch the control program. Fortunately, it’s really Once this is loaded on your Pico and running, you can
easy to do this in MicroPython – just save your code to the point your web browser to the IP address given in the
MicroPython device and call it main.py. If you do that, when console when you load the file (typically it’ll stay the
you turn it on, it’ll automatically start the code. same between reboots, but it’s not guaranteed to). Then
You still need to know what IP address the machine’s
you can click on forward, left, and right to move the
on. Generally, routers will assign the same IP address to a
device when it reattaches to the network, so you can run it buggy around.
once tethered and then try this again. If this fails, you’ll need Our little robot web app is obviously very simple, but
to log into your router to see what IP address is assigned – you can take this technique and expand it in different
take a look at your router’s documentation for details. ways to let you connect to and control all manner of
different Pico W-powered devices.

43
www.dbooks.org
SUBSCRIBE
TODAY
FOR JUST £10
Get three issues plus a
FREE Raspberry Pi Pico
delivered to your door
hsmag.cc/FreePico
UK offer only. Not in the UK?
Save money and get your
issue delivered straight to your
door at hsmag.cc/subscribe.
See page 66 for details.

Subscription will continue quarterly unless cancelled


SUBSCRIPTION

SUBSCRIBE
on app stores
From £2.29
Buy now: hsmag.cc/subscribe
Free Pico with print subscription only

MAKE BUILD HACK CREATE


hsmag.cc August 2022 Issue #57

Robot Beer
Roundup BBQ
RASPBERRY PI TECHNOLOGYTurn
SAVE
hsmag.cc July 2022 Issue #56 IN YOUR HANDS hsmag.cc June 2022 Issue #55
Make your a keg into

PICO W
Raspberry Pi move
Vinyl cutting an outdoor grill

44% PROJECTS
Get started with a
Cricut EasyPress

Aug. 2022
+ make a robotic h
wit
drawing machine co
Jason
Coon
Lube
BEAM
Issue #57 £6

Everything you
Raspber ry Pi Pi The Evil Geniu
s
Fibonacci LE of
wanted to know but Ds
were afraid to ask
tle,

Machine
Like the space shut
Make internet-connected
but smaller
Hydraulics
builds with the NEW $6 Move mountains with
Jun. 2022
Issue #55 £6
Jul. 2022
Issue #56 £6

Sending data quickly


Time-lapse microcontroller board
water power
RoBot
Photography powered by ics
3D PRINTING POLYHEDRA SUBLIMATION FIREFLIES GUITARS / LASERS
su
thE / 3D PRINTING / ARDUINO
Watch life on fast forward n’s rAys

LASER CUTTING KNITTING WELDING DOGS

www.dbooks.org
A solar-powered robot from old fashioned parts

FEATURE

HOW T
he term ‘BEAM robotics’ is
one that would have been
familiar to many makers in
the early 2000s, but has faded

I
into obscurity in recent years
with many of the old BEAM blogs and
forums lost to time. ‘BEAM’ does not
necessarily describe a specific form or
function of any robot, but rather an ethos
which is described in part by the name.
By Jack Spiggle The most widely recognised meaning of
the acronym BEAM is Biology, Electronics,
Aesthetics, and Mechanics. To me, two
further elements define BEAM electronic
design: the use of recycled components

MADE
(which I personally no longer do these
days, as new components are so cheap
and readily available), and the simplicity of
the circuits. These simple circuits are the
most striking difference between BEAM and
modern robots as BEAM robots lack any sort
of microcontroller. That’s right, we’re talking
analogue robots!
BEAM robots utilise a lot of passive
components and other fundamental
components like CMOS inverters, but
lack any kind of microcontroller. The most
complex BEAM robots are made up of
blocks that mimic neurons. That is, once
a certain stimulus threshold is met on
the input of each block, an action occurs.

A SOLAR-POWERED
ROBOT FROM OLD
FASHIONED PARTS
A design inspired by biology

46
LENS

Valentino Braitenberg’s early thought


experiments into artificial intelligence (and
I mean 1980s early) showed how complex
behaviours can arise from a robot created
with just a few of these artificial neurons.
Such neurons can easily be simulated on
a microcontroller, yes, but they can be
made even more simply with just a CMOS
inverter. This also means that the input
and threshold voltages remain entirely
analogue. Perhaps this is why I still find
BEAM circuits so endearing today: the
entire system is built from the ground up,
there is no abstraction of signals with 1s
and 0s, and no abstracting of logic with
high-level code. It really feels like you are
manipulating electrons at the lowest level
in order to create an intelligent, almost
life-like system. I think that all of this is
secondary to my robot’s main function,
which is to look pretty. I definitely consider
my BEAM circuits to be more sculpture
than robot, and few BEAM roboticists (bar
Mark Tilden, the father of BEAM) ever
created such complicated robots.

THE ROBOT
Enough with the philosophy, let’s talk about
the robot. What does it actually do? It sits
in a glass bell-jar from IKEA, charging via
the large solar panel and turning to face

47
www.dbooks.org
A solar-powered robot from old fashioned parts

FEATURE

and my favourite two tools, a jeweller’s


saw and needle files. I absolutely adore
working with brass: it is easy to cut/bend,
readily available in all shapes and sizes,
solders well, and looks beautiful!
The solar panel is housed in a frame
made from square brass tubing (most of
the brass is from K&S Precision Metals).
This brass frame was very important as
everything builds off it both mechanically
and electrically. Because I didn’t want to
damage the solar panel while building, I
made the frame such that one side can
be removed for the panel to slide out.
the brightest light source. Wherever possible, I tried to make the

“ I ABSOLUTELY
It spends most of the day robot dismantlable in favour of permanent
sitting rather stationary, connections, in the hopes that the robot
only to move about quickly, will still be serviceable decades from now.

ADORE WORKING like an excited dog, when


in direct sunlight or when ELECTRONICS

WITH BRASS ”
you pass your hand over Onto the electronics, and the circuitry
it. Sitting on my desk, it can be broken down into three major
generally wakes up around sections: the solar charging, the motor
8–10:00 in the morning control, and the whistle/dance circuit. A lot
and stops anywhere from of the robot was based on BEAM circuits
5–10:00 in the afternoon. To make it more originally designed by Wilf Rigter in the
interactive, I also added a circuit that early 2000s with a lot of modifications and
makes the robot do a little dance when you adjustments. The full circuit is much too big
give it three whistles. and nuanced to fully cover here, but there
is an Instructable and a half-hour YouTube
MECHANICS video overviewing the circuit in more detail.
The mechanical assembly of this robot The circuit is entirely free-formed,
is centred around the motors and the meaning that there is no PCB. Connections
solar panel. The motors are common N20 between components are created in
gear motors which were chosen for two three-dimensional space using bent brass
reasons: 1) if the robot is still operating wire, which I think looks stunning and
decades from now and a motor breaks, creates a kind of electronic, steampunk
there will likely be replacements available, vibe (BEAMpunk?). The process of free-
and 2) a wide variety of gear ratios were forming feels very similar to routing a PCB,
available to experiment with. In hindsight, and I find it quite therapeutic as long as
I wish I had chosen a higher-quality motor nothing goes wrong. Indeed, lots of testing
as the N20 motors are noisy and have was done throughout assembly to ensure
backlash that made the robot very hard to everything worked and a little confidence
tune. The motor mounts and other brass soldering goes a long way.
components were all made by hand using Interestingly, this robot actually took me
tools like a hacksaw, drill, soldering torch, longer to prototype and breadboard than

48
LENS

high-efficiency monocrystalline panel that


boasts up to 25% efficiency and, more
importantly, responds to a wide enough
range of light to be effective indoors.
Even still, the datasheet says to expect
anywhere from 100–500 times less power
when used indoors. Evidently, power is
a big hurdle, but luckily we have plenty
of BEAM tricks we can use in order to
it did for me to build/free-form! Without squeeze everything we can from this panel.
code, any changes to the robot’s behaviour Indoors, the panel outputs <100 μA
must be made by physically altering the on a cloudy day and 5–10 mA on a sunny
circuit, which is significantly easier to do day, but the motors draw around 20 mA
on a breadboard than on the eventual free- each! Clearly, the panel alone would never
formed robot. be able to power the robot, which is a
problem that many solar-powered BEAM
SOLAR-CHARGING CIRCUITRY projects face. This problem is solved with
Starting the circuit explanation with power, a ubiquitous BEAM circuit known as a
the broad goal is to be able to run the robot ‘solar engine’. The goal of a solar engine
solely off the solar panel. However, if you is to allow the panel to charge a storage
have ever played around with solar panels capacitor until there is enough energy to
before, you might have noticed that they do useful work, at which point the solar
are immensely less efficient when out of engine turns on the rest of the circuit.
direct sunlight and I wanted this robot to Simple solar engines are robust and easy
live on my desk all year round. The solar to implement, but are not always the most
panels generally found on indoor devices efficient. Hence, I have used a clever Wilf
like calculators are amorphous panels. circuit, dubbed the Dual Slope Sampling
These are different to the polycrystalline Solar Engine (DSSSE). This DSSSE samples
and monocrystalline panels used outdoors, the storage capacitor voltage for only a
and output lower power for their area. The Above
short moment every five seconds or so and
ANYSOLAR panel used in this project is a The frame before free-forming only draws significant power during that

49
www.dbooks.org
A solar-powered robot from old fashioned parts

FEATURE

sample time. The solar engine on this robot MOTOR CONTROL CIRCUITRY
turns on at around 3.5 V and turns off again The motor control circuitry is really elegant
at around 2.5 V. When off, only the charging and was also (surprise, surprise) originally
is connected, and when on, the motor designed by Wilf. He called this circuit the
controller and microphone circuit turn on Power Smart Head (PSH), and one PSH
alongside a blue standby LED. is used for each of the robot’s axes. The
The DSSSE actually charges two PSH uses a modified CMOS oscillator to
capacitors: one is a smaller 330 mF create what I would describe as a PWM-
supercapacitor and the other is a larger based, proportional controller, with a large
7.5 F supercapacitor. The circuit starts by dead-band. The oscillator has two resistor/
charging the 330 mF capacitor so that, in capacitor (RC) pairs. The first RC pair
the morning, it takes much less time for dictates the oscillator frequency, and the
the robot to initially turn on and face the duty cycle of this oscillator is altered by a
sun. Once locked onto the sun, the panel pair of photodiodes that act as the robot’s
begins charging the 7.5 F capacitor until it ‘eyes’. This creates the PWM. The second
matches the 330 mF capacitor voltage, and RC pair creates the dead-band so that the
the two capacitors act as one. robot does not just constantly move and

50
LENS

waste power. The interesting thing here


is that from controller input (the voltage
between the eyes) to the motor output
(the PWM duty cycle), the signals remain
entirely analogue!

WHISTLE/DANCE CIRCUITRY
The microphone circuit is based on yet
another Wilf design that he called ‘BEAM
Sonics‘. It consists of preamplification,
followed by some BEAM-style logic, again
mostly made of inverters and RC pairs. This
logic ensures that the whistles are of the
correct length, and that there is a distinct
pause between each whistle. Once it

“ THE SECOND
RC PAIR CREATES motors to locomote toward
light. Although the obvious
Above
The completed

THE DEAD-BAND”
solution is often to slap solar logic

a microcontroller onto
projects, there may be times
where simpler analogue
circuits make more sense. In
counts three suitable whistles, it triggers a fact, in recent years, analogue computers
circuit to make the robot dance and another are once again being considered for use in
to lock the whistle circuit for 20 minutes artificial intelligence!
so that the robot is not dancing too often Even without building a BEAM solar
and wasting power. The microphone circuit engine, the principle of storing charge from
has three LEDs: one green that flashes a solar panel in a capacitor until there is
for every whistle, one amber that flashes enough energy to do something useful can
when the circuit activates, and one red that be applied to many
remains on while locked. solar-powered projects.
The dance circuit is simply three I hope this article might
oscillators, two of which force the motors have inspired you to
to oscillate and the other to make a pink, consider solar power
hexagonal LED flash. for future projects, or
perhaps to try free-
CLOSING THOUGHTS forming, which can be
While BEAM circuits may take a little a fun way to bring a
more effort to build and are nowhere near little more artistry to
as powerful as a microcontroller, I would any project.
encourage anyone interested to do some
research, and give these old BEAM circuits
a look (the Wayback Machine might be your
friend here). If you are keen to build any,
I think that the best circuits to start with
are ‘pummers’ that charge during the day
Right
and slowly flash at night, and ‘photovores/ The two Power
photopoppers’ that hop about using two Smart Heads

51
www.dbooks.org
nd
Andrew Sink

INTERVIEW

A
HackSpace magazine meets…

Andrew Sink

in
3D printing professional, evangelist, and GoldenEye fan

A
ndrew Sink is a shining
evangelist for 3D
printing. He was there
during the 3D printing
boom of 2014, and
kept the faith while
the buzzwords died down and people
refocused on what the potential of the
technology was. He’s written software
to make design for 3D printing more
accessible to new users, and his work is
on the shelves of big retailers, without
you even realising it’s 3D-printed. He’s
on a mission: to bring 3D technology
to the world in a way that people can
understand intuitively. We’re very lucky
to have got a few minutes’ worth of his
insights to share with you here.

52
drew LENS

nkwww.dbooks.org
Above
Andrew SInk,
wearing a mask
of his own face.
Thankfully this
is the version
without makeup

53
nd
Andrew Sink

INTERVIEW

A
HackSpace: You’re obviously not just a college; we had one in the engineering lab, such a limitless technology. And it’s also
guy who uses 3D printing from time to and I saw it and instantly felt that this is very much in its infancy, and we’re still
time: you’re an evangelist. What excites the thing that I’m going to do for the rest of figuring out what it’s good for.
you about 3D printing? my life – it was such a very clear and One of my favourite books is Timeline
amazing technology. by Michael Crichton. It doesn’t discuss 3D
Andrew Sink: So, first of all, in my day job, I The applications were just immediately printing directly, but it talks about people
am a senior applications engineer for apparent. I was taking a class on who accumulate these things called

n
Carbon (carbon3d.com). Carbon is a 3D SOLIDWORKS as a 3D CAD program at the transcription errors, where they’re
printing technology company based same time; taking a model out of essentially turned into digital data
outside San Francisco. So my job is SOLIDWORKS, and then sending it to the streamed into a different area, and then

i
primarily interfacing with customers and printer and then holding it in my hands re-materialised as physical objects. And
designing parts for additive that same day was an absolute revelation. over time, veins don’t line up all the way,
manufacturing specific to the Carbon It absolutely just tied together all the work bones are slightly misaligned… you
process. I work on a team that’s primarily that I was doing in the digital world to the accumulate these errors over time. When I
involved with lattice structures, so I spend physical world. And it was immediately started getting involved in 3D scanning, I
a lot of time thinking how to design apparent to me that it was just such an just immediately thought of that book,
something that used to be a uniform block untapped technology. because it really breaks down a lot of these
of material, as a conformal lattice, core concepts really well. With


rather than a solid shape. photogrammetry, the thing you’re
I was just at an expo in Detroit, I saw it and scanning is going to be the thing
Michigan, and I actually brought a you’ve scanned, but it’s going to be
bicycle with us to our booth. And
instantly felt that different. It can be its own, you
it’s got a 3D-printed seat, which this is the thing know, tangible item. The questions
was designed by people on the that I’m going to you get asked all the time with 3D
team that I work on. And it’s scanning are, ‘how do I scan a
designed for mechanical response;
do for the rest of boat?’ And that’s a very different


it’s designed for comfort, it’s my life workflow from ‘how do I scan a
designed for printability. screw’, where you’re talking about
Thousands of pages of thought precision on the magnitude of
have been dialled into this lightweight microns versus metres. 3D scanning, just
bike seat, and then you look at it and go HS: And do you still have that same sense like 3D printing, means a lot of different
‘Oh, that’s pretty neat’. of wonder now that you use it day in, things to a lot of different people. So,
But what’s really exciting about working day out? where I spend a lot of my time is on the
at Carbon for me is I went into a bike shop accessibility and early entrance, so I think
to pick up that seat fairly recently. And it AS: I can’t walk by a 3D printer. I’ll stop a lot about somebody who’s never heard of
occurred to me that is the first 3D-printed and watch them for a couple of minutes. 3D scanning before. They’re going to go to
part I’ve seen on a store shelf, that was a My house is filled with printers. It’s just Google and type in ‘3D scanning’; what’s
retail product. And when I was in Detroit fascinating to see the industry evolve so the first thing that they’re going to see?
with my wife, for the expo, we stopped in rapidly in ten years – materials, software, And how is that going to be applicable to
at a Dick’s Sporting Goods [a big sports hardware. And it’s just, it’s a really them? So I’ve spent a lot of time making
shop in the USA]. And they had the Adidas cool experience. videos showing the process of
3D-printed midsoles, so they had shoes photogrammetry. How do you stitch
that have a 3D-printed sole. And so I HS: You’ve also been experimenting with photos into a model? How do you use a
bought my wife a pair. It’s cool to be able to photogrammetry, which goes one step LiDAR scanner to use sensors to detect
walk into a store and buy something that further – taking an object from the real how a model exists in space, and really try
was 3D-printed. world, putting it into the computer, then and break it down in a way where
taking it back out again. What are the somebody with no practical experience
HS: What got you into 3D printing in the applications for that? can solve their particular problem?
first place?
AS: The application of photogrammetry is HS: Photogrammetry sounds like
AS: I’ve been involved in additive hard. You could be sitting in a room something that’s really expensive to get
manufacturing for about a decade now. I looking at the first camera and saying, into. Do you need to have access to a lot of
first used a 3D printer when I was in ‘Well, what are we gonna do with it?’ It’s specialist gear?

54
drew LENS

nkwww.dbooks.org
Above
Incredibly, this isn’t
a drawn model,
it’s a scan of the
dragon shown on
page 58
nd
Andrew Sink

INTERVIEW

A
AS: Historically, it’s been very mirror: you don’t really get a picture of the HS: You have a YouTube channel where
expensive. But that’s because it’s been mirror, you just get a picture of everything you talk about 3D technology; you’ve also
computationally expensive. The hard in front of it. written some software to make it easier to
part is the software. That’s where the create 3D models, haven’t you?
industry has really lagged behind. A big HS: Did you use an iPhone when you
part of that is conflicting messages from made the mask of your own face? AS: Yeah, so I’m a big fan of low poly art. I
users, you know: I want to scan really grew up with GoldenEye, on the Nintendo

n
small parts, very detailed, and I also AS: That was actually done using a fairly 64. So, I have a very deep appreciation for
want to fly a drone around my house high-end industrial 3D scanner. A friend doing more with less. You look at the
and make a 3D model. Those two use of mine did it while we were at a trade textures of these models, and it’s like a guy,

i
cases are going to accumulate different show and we had a bit of extra time. I sat and that guy has a, you know, a texture on
amounts of data, and those are going to be on it for a while – what are you gonna do him. So if you see a face, it’s the eyes and
processed differently. with a scan of your face? And early in the the nose. And then he moves his head,
Right now, there are apps on the App pandemic, a company launched a bounty you’re like, oh, it’s kind of a rectangle
Store that are under $10, that you can use programme on a facial recognition spoof. shape, you know?
on pretty much any iPhone, a lot of It was something like $10,000 if you could One of the things I found was that there
Android phones, and create a 3D model beat their biometric verification, and I weren’t a lot of really intuitive workflows
within minutes. There’s this really great thought, well, I’ve got a really nice-looking for creating low poly art without using
picture – my wife and I were in scan of myself, it probably wouldn’t be a programs like Blender, which is very
Chinatown in Boston. And it was a perfect stretch to try and beat this thing. That powerful, but not very intuitive, so it’s very
day for 3D scanning – it was overcast, so became my Covid quarantine project. I difficult for beginners. I set out with a goal
the light was very diffused – typically, you was at home. I had some time on my to design a web-based app to make low
get really harsh directional light poly models. So the URL is


from the sun, which makes it hard lowpoly3d.xyz – the whole thing is
to scan stuff without adjusting the written in JavaScript. And you can
aperture settings on your camera.
This technology is so basically upload a 3D model and
And it’s just, it’s kind of a mess. accessible now then you can select the destination
We got this picture taken with that it took me maybe amount and remove a certain
us. I saw the statue right next to us, number of edges, and it collapses
and I was like, ‘Oh, that would be
ten minutes to the model into a low poly model,
a great 3D scan’. And it is, without walk around and which you can then download.


a doubt, one of the best scans get the photo set One of the reasons that I wanted
I’ve ever made; you can make out to work on the low poly site was
individual teeth on the sculpture. just because at this point,
This technology is so accessible hardware has pretty well
now that it took me maybe ten minutes hands. And so I thought, what would a outstripped software in 3D printing. We
to walk around and get the photo set, normal person do? I will make a hyper- have very, very well-made machines that
and then maybe another five minutes realistic mask of my face. are made very inexpensively across a
after it finished rendering to clean up the I was going back and forth to make-up wide range of technologies. But, on the
base. So, photogrammetry has absolutely stores to get all kinds of different products design side, you kind of have two options:
gotten to a point where it’s affordable, it’s to try and bring out highlights in the professional parametric CAD, and then
usable, and you can get up and running model. I was putting paint on the lips and more sculpting programmes, like ZBrush,
very quickly. stuff. It was creepy. It was absolutely or Maya. Those both have pretty steep
For photogrammetry, it’s really hard to awful. It worked in the sense that Google learning curves. So I wanted to create a
get pictures of shiny stuff: bronze, for Photos will recognise the mask as a tool that was easy to use, where
example, is terrible. Because it goes picture of me. So it will automatically tag somebody could say, ‘Hey, I downloaded a
between dark and very bright, there are me, which is cool. I’m able to set up an model, and I’m going to reduce the poly
almost no gradients in bronze. You’re iPhone with the fake mask, but I’m not counts. And now I’m going to print it out,
either looking at, like, gold, or you’re able to unlock it, so, whatever Apple uses and then it’s done.’ That was the goal. And
looking at black. And so a marble statue for face ID does recognise it as a face, but I’m always excited to see what people are
on an overcast day is just perfect. It’s it won’t recognise it as the same face making with it.
worked out great. 3D scanning shiny twice. Google recognising it as a face And then there’s also the STL to ASCII
objects is sort of like taking a picture of a though, that was a huge win. generator. Again, if you grew up

56
drew LENS

nkwww.dbooks.org
Above
Upload any 3D
image to Andrew’s
andrewsink.github.
io/STL-to-ASCII-
Generator to
generate ASCII art

57
nd
Andrew Sink

INTERVIEW

A
around the time that GoldenEye was out, commoditised at this point. You can buy consumers will be more incentivised
you’ve probably seen ASCII art as well. a printer that’s mechanically sound for to try them. There was this big boom in
You can upload a 3D model, and it’ll about $200. That part’s really easy, I think. like 2014, where every newspaper had a
basically apply a filter on top of that The improvements will come in the form think-piece like ‘is this the dawn of 3D
model that shows up as ASCII art. It’s of ease of use and quality of life upgrades. printing’? And it turned out that nobody
pretty cool. They’re both designed to be as So things like: can the printer tell you knew how to design for 3D printing, so
approachable as possible: you nobody was actually making their

n

just drag a model and start own stuff. For the last eight years
hitting buttons, you really can’t We’re still not or so, we’ve seen that hardware just
mess up. And I think that’s very continuously gets improved. A lot
really at a place

i
encouraging for beginners; of the slicing software has seen
maybe they’ve got a 3D printer where the design incremental improvement, but we’re
for Christmas and they want to software is still not really at a place where the
learn more about the modelling
matching that speed design software is matching that


side, but they don’t have access speed of improvement. So I think
to expensive or difficult-to- of improvement on the consumer side, as those
learn tools. quality of life features start to make
their way down, the less expensive
HS: What do you see as the future, when it’s out of filament? Can the printer printers and the software becomes more
or possible futures, in the 3D detect when it’s not actually printing? intuitive. I think that’s going to really help
printing multiverse? Those features are available right now drive adoption.
on more expensive machines, and I
AS: Let’s split this into two separate parts. think, as those become more prevalent, HS: And how about the industrial side?
On the hobbyist side, I think hardware is printers will become easier to use, and
AS: As the technology gets faster, the
materials become more durable, and have
better mechanical properties, you’ll get
to a point where you’re going to buy a
car, and your shifter knob is going to be
3D-printed, and you’re not going to know
it. Let’s say there’s a factory that makes
cars, and they find out that one of their
tail-lights – the bracket that they ordered
5000 of – doesn’t fit onto the frame, and
they need to print a shim. That is where
3D printing will come in and save the
day, because you can solve this problem
quickly, cheaply, reliably, without having
to make tooling to mould this thing. I see
a real future for 3D printing in solving
problems that are below the surface, not
necessarily in people buying things for
the novelty of owning things that are
3D-printed.

HS: A lot of the time I see 3D printing


projects online, someone’s made the
1,000,000th Dungeons and Dragons or
Right Warhammer miniature. I look at it and
Compare the dragon
shown here with the think I’ve seen this so many times before,
scanned image on and it’s just the same as an injection-
p54; it’s unbelievably
accurate moulded thing, but less efficient. Do you
think 3D printing is still exciting?

58
drew LENS

nk
Left
The same model
in lowpoly3d.xyz,
in high- and low-
poly forms

AS: My Nana, my Italian grandmother,


when she first saw a 3D printer, it was an
old printer made of wood, and it was
printing a fork. And she took one look at it
and just immediately she was like, ‘Oh, so
you just draw something and it pops out’.
Zero explanation required. It just
immediately clicked in her head. And I
thought that was just such a powerful
thing. And so I try to make sure that,
when I’m working on things like
photogrammetry, or 3D scanning or the
low poly generator, I’m thinking about
what people are going to think when they
see it.
Let me take you back to that first
camera analogy I used earlier. Just like
there are millions of little Baby Yodas and
Dungeons and Dragons figures floating
around, there’s also millions of photos
online of flowers, right? But people aren’t
going to stop taking pictures of flowers
because it’s already been done. There’s
something really uniquely personal about
making something yourself. When you
download something and print it out
– it’s an accomplishment – you made
this. This is something you’ve brought
into the world. I think that’s a really
special thing. It also leads to all sorts of
things – maybe they get curious; maybe
they learn CAD and go and create more
things. Or, maybe they
decided to become
Right
a photographer, This disguise
and take pictures fooled Google,
but not Andrew’s
of flowers. iPhone

59
www.dbooks.org
Improviser’s Toolbox: Barbed wire

FEATURE

BARBED
WIRE Sharp, but pliable, barbed wire is ideal for
practical indoor and outdoor reuse.
Rosie Hattersley suggests getting creative

I
f you want to seem ‘alternative’, erect miles of fencing that wouldn’t blow down in
introducing barbed wire into the prairie winds or need costly maintenance helped
your decor is a handy short cut. landowners demarcate their territory and prevent
The practical, low-cost means of cowboys and cattle from ranging over and trashing
demarcating your territory is visual their crops. Native Americans, chased off their own
shorthand for both unashamed lands by fortune-chasers, were less enamoured.
Rosie Hattersley attitude and keeping those you dislike at bay. No Barbed wire was first introduced in the 1840s
@RosieHattersley wonder it’s beloved of warmongers and absolutists, and 1850s, while Joseph Glidden, a farmer from
as well as punks and edgy fashionistas. These Illinois, patented his version of barbed wire in 1873,
Rosie Hattersley writes days, specially produced barbed wire is often found improving on the version he’d seen at the DeKalb
tech, craft, and life artfully holding up displays of dried flowers rather County Fair by twisting two strands of wire together
hacks and tweets
than the original ‘razor wire’ type being deployed for for added strength and tension.
@RosieHattersley.
more straightforward practical purposes. This more robust version of barbed wire also
came in useful when the telecoms industry wanted

“it began as a game-changing


to bring phone lines to rural communities, since
they now had a cheap method of connecting to the
agricultural material that could be telephone network using the wire fencing.

used to fence off homesteaders’ land” Electric and smart fencing has, to some extent,
replaced the need for barbed wire in agricultural
settings, but there are millions of miles of the
Although we associate barbed wire with keeping near-indestructible stuff on farms and in former
people or animals at bay or interned, it began as a war zones. Depending on the regulations where
game-changing agricultural material that could be you live, recycling such unforgiving material can
used to fence off homesteaders’ land from their be a challenge, and you’ll find plenty of online
neighbours. In the US Midwest, where trees were advice about how best to store it and to unravel its
either scarce or non-existent, being able to quickly deliberately tangled reels.

60
LENS

BARBED
WIRE
TRELLIS
T
urning a former fencing material Project Maker
into a gate or decorative trellis Dan Towell
might not seem a huge stretch, aka The
but there must be several hours’ Dusty Raven
work involved in unravelling and
Project Link
then artistically bending and hsmag.cc/
rearranging the spiky lengths of wire into a BarbedWireTrellis

useful form. It’s also arguably a more practical


reuse than some of the crafty options we’ve
seen. Dan Towell combines the attractive with the
pragmatic with his 34-inch-tall trellises, designed
Left
to support and show off shrubs and climbing There’s probably
plants. The rusty, rustic look provides a good foil to some deep
commentary in
effulgent foliage and is also the sort of idea a more turning a utilitarian
whimsical gardener, keen to create a unique focal fence into an ornate
trellis, but we just like
point, could consider emulating. the way it looks

61
www.dbooks.org
Improviser’s Toolbox: Barbed wire

FEATURE

RUSTIC PINE TABLE


WITH INLAID
BARBED WIRE
w
oodworking site Lumberjocks
Project Maker
Juniper showcases interesting timber-
Canyon based projects, as well as hosting
Design a useful forum. The site’s mixed
media builds include this beautifully
Project Link finished table, made from a pine
hsmag.cc/
InlaidBarbedWire
slab that maker John, from Juniper Canyon Design,
rescued and fashioned after discovering the
miraculously rot-free stump of a tree that had fallen.
He also just happened to have a roll of rusty barbed
wire hanging up in his workshop. Just the right size
for his uncle’s horse trailer-cum-camper-van, the
table was full of sap, making it tricky to work with.
He used a belt sander with 100-grit sandpaper to
bring out the wood’s grain, before his wife set about
routing a groove following the shape of the tree’s
outline for the barbed wire. “I pushed the barbed
wire down into the rout groove and took advantage
of the barbs by nailing them into the wood where
possible, and adding a few finishing nails to any
spots that wanted to pop up above the groove,”
Right John explains. He embedded horseshoes in the
Sometimes, all tabletop, in line with the table’s intended use in a
you need is a
finishing touch horse trailer.

62
LENS

BARBED WIRE BALL

Y
ouTube often comes up trumps are scarce. Melinda’s, aka Scrapmetalsheila, Project Maker
for ideas about what to recycle (scrapmetalsheila.com.au) excellent videos are an Scrap Metal
and what you might reasonably honourable exception. Armed with 100–200 m of Sheila
produce from said scrap item. barbed wire, engineering gloves rather than leather
Project Link
There are plenty of helpful video tips ones (since they catch on sharp objects), and a hsmag.cc/BarbedWireBall
on how best to unfurl, stretch, and bolt-cutter, Melinda demonstrates how to create
use (or roll up your unused) barbed wire rolls, but a beach-ball-size barbed wire ball. Having cut the
tutorials on how to achieve a barbed wire makeover wire into five 5-metre-long pieces, corralling the raw
materials and tying it in place with flexible wire help
you form the basic shape. After this, it’s a matter of
wrapping, securing, and tightening sections of wire.
Once complete, you could mount the ball on
a rock or plinth in the garden, wrap it with solar
lights, or dangle it from a light fitting and illuminate
it. Should chandeliers and other lighting catch your
imagination, there are lots of barbed wire versions Left
Note – while this is
to be spied in upcycling videos and blogs, but most beach-ball sized, we
omit how-to details. Scrapmetalsheila’s advice will don’t recommend
that it’s used as a
provide an invaluable guide. beach-ball

BARBED WIRE EMUS


A
boriginal artist Laurie Nilsen’s life- barbed wire is commonly used, such as prisons and Project Maker
size barbed wire emu sculptures law courts. Other artists who use barbed wire for Laurie Nilsen
were inspired by him encountering sculpture and art also frequently have a personal
Project Link
a fence line that had ensnared more connection with it, such as Ernie Poe, a former hsmag.cc/BarbedWireEmu
than 40 emus fleeing drought- rancher who, at the age of 73, began the first of
ravaged plains, highlighting the 200 sculptures each made from rusty barbed wire:
material’s dual role of both fencing off and fencing hsmag.cc/WireSculptures.
in. Laurie described having to put the dying emus
out of their misery as one of the most gut-wrenching
tasks he ever faced, but also acknowledged that
he’d used barbed wire himself for fencing in former
times. He often drew close-ups of barbed wire, Left
The emus are
calling attention to its dainty knots. Using satire to planning for a third
draw attention to social issues, several of Nilsen’s victory, should there
be another war with
emu sculptures are sited adjacent to places where the Australian army

63
www.dbooks.org
In the workshop: Beer BBQ

FEATURE

IN THE
WORKSHOP:
Beer BBQ
By Andrew Gregory Combining two of our favourite things:
beer and barbecues

A
fter a butchery course a couple
of months ago, I had a freezer
full of meat; that meant I needed
to upgrade my cooking facilities.
I wanted the option to barbecue,
and I also wanted something with
a top that I could close too, so that I could use it as an
outdoor oven.
With this in mind, I trawled the internet for a nearby
second hand beer keg that I could simply cut in half
and stick legs on. Two candidates presented
themselves: a stainless steel beer keg an hour and a
half’s drive away, or a barrel made of non-specific
material, 50 minutes’ drive away. I chose the nearer
barrel. This was my first mistake. But we’ll come to
that later.
The barrels had been sitting outside a disused
brewery, and were not rusty, but covered in old paint
and something rust-adjacent. I set to work with a wire
brush attachment on an electric drill to get the worst of
it off, before marking out where I was going to cut.
This is where the shape of the barrel gave me another
problem: working out where the hinges would go for
the lid. As there was only one flat bit in the middle of
the barrel, I decided to cut it not in half, which would
have been easier, but in two unequally-sized pieces, so
that the sole hinge wouldn’t have to take too much
weight. I marked out the cutting lines, and set about it
with an angle grinder.

64
LENS

Above
We angled the leg attachments by a couple
of degrees for more stability

Two days of struggle later, my neighbour, who is a


Left
welder by trade, asked me what on earth I was doing The reciprocating
trying to cut aluminium with an angle grinder (here’s saw: looks like a
Transformer (of the
where the initial error of going for the alloy barrel, robots in disguise
variety); actually,
rather than the stainless steel one, came back to haunt a terrifying
cutting machine

I set to
work with a
wire brush
attachment
me). Aluminium (and aluminium alloy, which is what it
turned out my barrel was made of) has a very low
melting point. Rather than cutting through the barrel,
the angle grinder was cutting a very short way; then
the heat from the cutting disc was melting the
aluminium dust, which was cooling on the cutting edge Right
Cutting off-centre
of the disc, clogging it, damaging it, and eventually made it easier
breaking it. A new approach was needed. to hinge

65
www.dbooks.org
Improviser’s
In the workshop:
Toolbox:
BeerPaper
BBQ plates

FEATURE

I threw money at the problem, in the form of a


reciprocating saw. This terrifying machine tore through

I had to go the barrel in no time, apart from the rims, which are
much thicker than the rest of the barrel, and which I

over the edges


cut by hand using a hacksaw. And, for the only time
ever in my life, I managed to cut in a straighter line by
hand than when using the power tool. A reciprocating

with a 40-grit saw cuts quickly, and so leaves a pretty rough edge on
the cut metal, so I had to go over the edges with a
40-grit sanding disc – at last, a useful application for the

sanding disc angle grinder!


I’d seen a maker online who’d painted a beer keg to
look like a can of Coca-Cola, leaving the ends unpainted
to look like the polished aluminium of a Coke can. I
liked the contrast between the painted surface and the
raw metal, so I masked off the rims and applied many
coats of Rust-Oleum barbecue and stove paint in
British Racing Green.
Those rims, which look so good contrasted with the
green, at this stage, became a blessing and a curse. A
curse, because if I were to attach the legs to the
relatively flat ends of the barrel, I’d have to cut gaps in
the rims to allow the legs to sit flush. After the amount
of work it took to cut through them the first time, I
didn’t fancy taking any more chunks out of them, so
elected to attach the legs to the rims themselves, even
though attaching a straight length of steel to a curved
bit of aluminium isn’t the neatest-looking solution.
Now, back to that initial choice of the alloy barrel
over the stainless steel. Pure aluminium melts at
660°C. Aluminium alloy melts at… an unknowable

Above
I marked out the
positions of the holes Above
to mount the hinge British Racing
while the barrel was Green means we
still in one piece can grill faster

66
LENS

Above
The highlights on the edge of this cutting disc are
re-formed aluminium dust. Those bits don’t cut
anymore; they just get hot Danger!
Angle grinders work by spinning an abrasive disc at very high
temperature, since we have no idea what the speeds. They throw up dust, sparks, and, if you’ve very unlucky,
aluminium is alloyed with. Charcoal burns at well over broken bits of grinding disc, which is why you should always
that temperature, at 1100°C, so there’s a medium use the right PPE when you’re using one. For us, that comprised
probability that, with the coals heaped at the bottom of of the medical-grade face masks that we’ve had spare since
Covid went away; a pair of padded work gloves; and a pair of
the keg, the fire will melt through and drop onto
safety goggles big enough to fit over the writer’s extra-large
whatever’s below. I say medium, because the spectacles. It’s uncomfortable, it’s hot, but that’s nothing
temperature of the air outside the barbecue will always compared to the discomfort of getting a chunk of broken angle
be well below 660°C, even on a very hot day, so grinder disc in your eye.
there’s always going to be some air to cool the exterior
– the worst that will probably happen is that it’ll get a
bit soft. To reduce the risk of even this happening, I Left
bought a sheet of 2 mm perforated steel and cut it to fit From left to right:
a cutting disc
so that it sits roughly two centimetres from the bottom straight out of the
of the barbecue at its deepest point; steel melts at packaging; a heavily
damaged, unusable
around 1300–1500°C, so as long as the hottest part of cutting disc; and a
the fire sits on the steel mesh, all should be well. Cross disc that got stuck
in the barrel and
your fingers for me. fragmented

67
www.dbooks.org
3 ISSUES FOR £10
+
FREE BOOK

hsmag.cc/hsbook
Subscribe to The MagPi, HackSpace magazine, or Custom PC. Your first three issues for £10, then our great value rolling subscription
afterwards. Includes a free voucher for one of five fantastic books at store.rpipress.cc/collections/latest-bookazines
UK only. Free delivery on everything.
FORGE
HACK MAKE BUILD CREATE
Improve your skills, learn something new, or just have fun
tinkering – we hope you enjoy these hand-picked projects

PG

74
TIME-LAPSE
PHOTOGRAPHY
PG
70
Videos for speed freaks
SCHOOL OF
78
PG
MAKING
Start your journey to craftsmanship

KNITTING with these essential skills

WITH MATHS 70 Welding helmet


Combining coding with yarn work

PG

84 PG

96
K40
PG

90
CAMERA
OPTICS
Make sure your mirrors
INFRARED
PHOTOGRAPHY
PRINTER
Because photos should
are aligned Photographs in the dark exist in the real world

www.dbooks.org
Upgrade your helmet

TUTORIAL

Upgrade your helmet


How to be a cool welder on a budget

A
properly trained welder can earn Welding can be an uncomfortable hobby. There
a good living from their trade, are times when you’ll find yourself hot, sweaty, and
and putting that money into cramped into an uncomfortable corner, while you’re
good-quality equipment like a struggling to see the joint you need to weld through
welding helmet is a sensible your visor. Then, when you finally manage to get
move. For the weekend welder the weld, you need to raise your helmet and put on
Dr Andrew Lewis who spends more time holding a grinder than an safety glasses to finish up with an angle grinder.
electrode holder, it’s harder to justify spending It sounds miserable, but each of the problems
Dr Andrew Lewis is a a large chunk of cash on an item like a welding mentioned here can be solved, and some welding
specialist fabricator helmet. In this article, you’ll learn how a few simple helmets include solutions to these problems as a
and maker, and is the
owner of the Andrew helmet upgrades can make a big difference to your standard feature. Just because you’re working with
Lewis Workshop. comfort without costing a fortune. a basic model welding helmet, doesn’t mean that

70
FORGE

you should expect to be uncomfortable while you


practise your welding skills.
Almost every welding helmet these days is
auto-darkening. The lens appears to be tinted like
sunglasses, but it blacks out even more when you
start to weld. It’s a very convenient feature, but it
doesn’t always work as you want it to. The initial
tinting of the lens can be so dark that it’s difficult to
see the parts you’re trying to weld clearly, and you
either need to remove the helmet to double-check
everything, or try to balance a flashlight somewhere
to give yourself some extra illumination. Adding a
work light to your welding helmet eliminates this
problem completely, so it’s an ideal place to start
modifying your helmet.

HACK YOUR HELMET


You can buy LED headlamps from almost every
supermarket, but they’re not a perfect solution for
welding. The lamp needs to fit onto the helmet and
not to your head, so the strap provided is pretty
much useless. A bigger problem is that the lamps
aren’t designed to be used by someone wearing can access it, then you can use it to power other
heavy welding gloves, and the tiny power button helmet upgrades. Above
You can clearly see
on most lamps is pretty much useless. On the plus Crack open the LED headlight and take a look that this lamp has a
side, the lamp has a built-in power source and, if you at the circuit board. You’re looking for the battery tiny PCB-mounted
switch at the top that
power wires and the connections that lead to the would be crushed into
button that turns the light on and off. Solder jumpers oblivion by chunky
welding glove fingers.
onto these wires and drill a small hole in the side of Next to it, on the right,
are the main battery
the light to pass these wires through. You should be connections. These
able to remove the elastic strap and mount the light are the areas that
you need to solder


extension wires onto

Adding a work light to your


welding helmet eliminates
this problem completely, so
it’s an ideal place to start

on the helmet by screwing or gluing the adjustable
bracket into a convenient place. Drill a small hole in
the helmet and pass the wires inside, and then make
a hole in the side of the helmet to mount a large
arcade button. This arcade button will be your light’s
new on/off switch, so position it on whichever side
feels most convenient. For a right-handed person,
QUICK TIP
it’s probably the most comfortable to position the You might need to
lower the brightness
switch on the left-hand side of the helmet because
of the LED headlight
that’s the hand that won’t be holding a tool. Solder to prevent it from
Above
The elastic has been removed from the headlamp the switch jumper wires onto the arcade button, and triggering the auto-
bracket, and the bracket has been bolted to the body
of the helmet. A rivet, glue, or hook-and-eye fasteners
use hot glue to hold the wires in place on the inside darkening feature
could also be used to fix the headlamp in position of the helmet. You should now be able to switch of the helmet.

71
www.dbooks.org
Upgrade your helmet

TUTORIAL

want to use a standard PC or laptop fan. For one


thing, the thought of spinning plastic blades near
to your face isn’t particularly comforting. More
importantly, the welding helmet is designed to
protect your entire face and not just your eyes – if
you start drilling large holes through the plastic then
UV light will be able to get in and give you a welding
tan. A blower pulls in air from the front and uses an
impeller to push air out of its side rather than straight
through to the back like an ordinary fan. Blowers are
generally more powerful than regular fans, and the
enclosed blades and right-angled exhaust means
that they’re a great choice for a welding helmet. Your
face is protected from blades and UV light. You can
position the fans in your helmet so that the airflow

Above
Blowers are available
in a wide range of
voltages and sizes,
the light on or off by tapping the switch on the side
of your helmet.
The next modification for the helmet will help
” The thought of spinning
plastic blades near
but something around keep you cool, and will keep your visor (and glasses, to your face isn’t


a 50 mm 5 V blower
if you wear them) free from condensation. Adding
fan should fit into
most helmets fans to the helmet is easy to do, but you don’t just particularly comforting

QUICK TIP SPARE PARTS feels most comfortable to you. Faces and helmets
Check the position are all different shapes, but try to get at least one
You can buy replacement auto-darkening lenses quite
of your light on the fan blowing over the welding lens.
cheaply, and even units with built-in grinder buttons
helmet and give it a You can use the power cables that you soldered
and adjustable trigger settings aren’t that expensive.
quick test before you
However, if you’ve already got access to the parts you into the headlamp battery to power the fans, and
fix it in place. Check
need and the modification only takes a few minutes to all you need to do is add a suitable (chunky) toggle
you’re not blocking
complete, why spend more money? switch to turn the fan on or off. Positioning the
the recharge socket
for the lamp. toggle switch can be tricky on some helmets, but if

Right
If the case doesn’t
pull open with plastic
spudgers, you might
need to carefully cut
the plastic seam using
a sharp Stanley blade.
Don’t try to apply force
with the blade, just
make shallow cuts
along the seam. Once
you have a gap in the
seam, switch back
to using the plastic
spudger and picks

72
FORGE

BATTERY PROTECTION
If your headlamp uses a LiPo battery, you need to
figure out whether the battery is protected from excess
discharge or not. If a LiPo battery is drained too much,
it isn’t possible to recharge it again and will need to be
replaced. Some batteries have a discharge protection
circuit built into the battery itself, while others rely
on the attached electronics to deal with discharge
protection. If you’re not sure, err on the side of caution
and add a battery discharge protection circuit to
the fans.

you can place it underneath the visor, you’ll be able


to reach the switch easily and toggle it while using
the helmet itself for leverage.
The last modification for the welding helmet is the
trickiest to get right, because it involves breaking
open the auto-darkening lens and modifying it to
add a switch. This means that you can stop the
auto-darkening when it’s not needed (such as when
grinding), but ensure that you re-enable it before
starting to weld. The circuit isn’t complicated, but
the housing for the auto-darkening lens is often
glued shut and it needs special care to open it
without damaging the plastic. Remove the lens unit DISABLE DIMMING
from the welding helmet, and begin working along Once you have the case open and the circuit board Above
You can see the
the edges of the case where the two halves meet exposed, you should see two wires running from circuit used to control
with a plastic spudger and picks. the LCD screen to the circuit board. Disconnect the auto-darkening
lens, including the
the wire at the circuit board end, and solder on battery in the top left,
and the connection
extension wires that lead to a toggle switch. Take a that needs to have
close look at where the helmet clips hold onto the a switch installed at
the point marked P1
lens, and make a hole in the lens unit’s plastic case on the bottom left of
so that you can feed the switch wires out without the PCB. It’s easier to
just cut this wire and
interfering with the clips in the helmet. Toggling extend it than it is to
the switch to the open position will prevent the disconnect it from the
board and replace it
circuit board from altering the state of the LCD. Test
the lens by shining a bright light onto the sensor.
If everything is working correctly, reassemble the
plastic case and hold the two halves together with
a few dabs of superglue. Don’t go mad and glue the
whole seam, or you’ll never be able to get the unit
apart again if you need to. Just add a drop of glue at
each corner, and an extra few drops along the edges
to ’stitch’ the two halves back together. The clips in QUICK TIP
the helmet will hold the two halves in compression, Beware that the
so the glue doesn’t need to do any heavy lifting. welding helmet
Keep all of the wires tidy inside your helmet might not be safety
rated for something
with hot glue, and consider adding a layer of resin
Above like impact from a
over the top of them to keep them firmly in place. shattered cutting
The wires in this helmet are kept in place with hot glue. A thin
layer of foam or epoxy resin will hide all of the electronics Protect any exposed connections with hot glue or disc – always wear
away permanently, although it isn’t strictly necessary as long
as there are no exposed wires or connections that could short
PCB lacquer, and you should be all ready to weld and the proper PPE for
out and cause a problem grind without the uncomfortable side effects. the job you’re doing.

73
www.dbooks.org
Turn your photos into time-lapse videos

TUTORIAL

TURN YOUR
PHOTOS INTO
TIME-LAPSE VIDEOS
Can we get to the good bit? Shooting time-lapse
videos makes drawn-out processes more engaging

Python code controls


the PIR sensor and snaps Our Camera Module will
images with the camera take a new picture every
time we detect movement

G
Enable legacy camera support
ood things are usually worth the wait –
unless they come at the end of a long and
01 The functions we need to use in our
Nik
MAKER

largely repetitive video. In this workshop, Python code will run natively on older versions
Rawlinson we’ll show you how pairing Raspberry Pi with a of Raspberry Pi OS, but require legacy support if
Camera Module 2 and a PIR motion detector lets you’re running Raspberry Pi OS Bullseye or later.
Coffee-drinking,
typewriter lover you shoot stills only when there’s something To enable support in these versions, open a new
with a penchant for worth watching. Discover how to convert images Terminal window by pressing CTRL+ALT+T (or
pencils and paint.
into a time-lapse video packed with action. We’ve connect to your Raspberry Pi remotely using SSH)
Frequently found
staring at the sea been using this technique to show how time- and type:
from the back of consuming artistic processes result in a finished
a camper-van. image, but you could also use it to see what your sudo raspi-config
nikrawlinson.com pet does when you’ve left it home alone.

74
FORGE

Select option 3 – Interface Options and 1 – Legacy


camera, then confirm that you want to enable
legacy camera support. Quit raspi-config and
allow your Raspberry Pi to reboot and implement
the changes.

Correct your screen


02 We’re setting up our time-lapse camera
using a Raspberry Pi 3 B+ connected to a Raspberry
Pi Touch Display (magpi.cc/touch). Enabling legacy
camera support caused our display to rotate through
180 degrees (only locally; the orientation was still
correct when connecting via VNC), and removed the
Connect your PIR sensor
Displays option from Raspberry Pi OS’s graphical
interface. If you experience the same, open a
04 The passive infra-red (PIR) sensor lets
The screw on the
right controls the
sensitivity of the PIR
Terminal window and type: you take pictures only when there’s some kind motion detector

of movement. Place your Raspberry Pi on a flat


sudo nano /boot/config.txt surface so the USB ports are to the right and the
GPIO pins are running along the top edge, and hold
Key down to the bottom of the file, add a new your PIR sensor so that its pins are also running
line, and type: along the top edge and pointing towards you. Use
jumper wires to connect the PIR’s left pin and right
lcd_rotate=2 pins to GPIO pins 6 and 2 respectively, and the
PIR’s middle pin to GPIO pin 7 (magpi.cc/pinout).
Press CTRL+X to quit and press Y when asked if
you want to save, then reboot by typing:

Position and test your camera


Top Tip
sudo reboot
05 At this point, you want to get your Zeroes ain’t
Raspberry Pi and camera in position. We’ve heroes
E nabling legacy camera mounted ours on a goose-neck stand, which plugs
into an unused USB port, so we can point it directly If any of your

support caused our at the scene we want to capture. Take a test photo
by returning to the Terminal prompt and typing:
saved images are
0kB in size, delete

display to rotate them: FFmpeg


may quit early if it
raspistill -o test.jpg
through 180 degrees encounters them.

Open the resulting test.jpg, which will be saved


in your home folder (/home/pi/test.jpg) to check
Connect your camera
03 We’re using the regular Camera Module 2
the orientation, so you can apply correction later,
if necessary. You’ll Need
here because we only want to shoot time-lapses
in regular lighting. However, this tutorial works > Camera Module 2
magpi.cc/
equally well with the Camera Module 2 NoIR, which
cameramodule2
Set up your FTP server
can shoot low-light and night-time stills and
video (you will need to provide an infra-red light
06 To avoid filling up your Raspberry Pi’s > PIR motion sensor
source for night-time use). Connect the camera to microSD card, our code uploads each captured image magpi.cc/pir
Raspberry Pi’s CSI (Camera Serial Interface) using to a server and then deletes the local copy. It doesn’t
> Three female-female
the bundled ribbon cable. Don’t confuse it with matter whether you’re running your own server
jumper wires
the display connector: on Raspberry Pi Model B on-site or using a remote commercial offering: what magpi.cc/
computers, the camera connector is the one does matter is that you have FTP access. Log on to jumperjerky
between the HDMI and headphone ports. your host’s control panel and create a folder for

75
www.dbooks.org
Turn your photos into time-lapse videos

TUTORIAL

Top Tip
Running
too slow?
FFmpeg defaults
to a framerate of
25 fps. To swap
it for 60 fps, add
‘-framerate 60’
before ‘-pattern_
type’ in Step 12.

uploaded images, as well as a user account that logs removing the # at the start, and adjust the number
straight into that folder. The process for doing this at the end of the line to correct the framing. Our
will vary between providers. Make a note of your camera is positioned with Raspberry Pi’s logo
username, password, and server address. printed on the baseboard in the top left corner,
so we need to rotate the image by 270 degrees to
correct its orientation. However, you may instead
need to make an adjustment of 90 or 180 degrees,
Supply your login details
07 Download the code from GitHub
depending on your setup.

(magpi.cc/timelapsepy) and save it in your home


folder (/home/pi/) as timelapse.py. Open it in
Automate your capture
Thonny Python IDE (in the Programming menu of
a standard install of Raspberry Pi OS) or an editor
09 Save your edited code, then return to the
of your choice. Edit lines 21 and 22, inserting your Terminal and type:
server address where indicated on line 21, and your
You’ll need three
jumper leads to username and password where indicated on line 22. crontab -e
connect the PIR
motion detector to
the GPIO pins on If you’ve never edited crontab before, you’ll be
your Raspberry Pi
asked which tool you want to use. Select 1 for Nano.
Correct the camera…
08
If you’re running When Nano opens, key down to the bottom of the
Raspberry Pi OS
Bullseye or later, if necessary file, create a new line and type:
use raspi-config If the test shot you took in Step 5 showed that
to enable legacy
camera support the camera was rotated, uncomment line 17 by @reboot python3 /home/pi/timelapse.py &

This tells Raspberry Pi OS to run your code as soon


as it starts, with the & at the end telling it to run the
process in the background. Press CTRL+X to quit
Nano, confirm that you want to save your edit, and
reboot your Raspberry Pi.

Testing, testing, 123


10 Your Raspberry Pi should begin capturing
images and uploading them to your server when
the sensor detects motion. If it doesn’t, either
reposition the sensor (not the camera) or adjust its
sensitivity. To set the sensitivity to maximum, hold

76
FORGE

the sensor so the dome is pointing up and the pins


are away from you, then rotate the orange screw on
the right (which controls sensitivity) as far as you
can to the right, to maximise the range across which
it detects motion. If you get false positives, dial back
a little. Finding the optimal position can require
some trial and error.

Download your stills


11 Download the stills from the server to a
folder called timelapse inside your home folder.
Open Terminal and type:
If you’ve never edited crontab before, Raspberry Pi OS
will ask you to choose an editor. We’d recommend Nano
cd timelapse

Press RETURN, then type: timelapse.py DOWNLOAD


THE FULL CODE:
Credit: magpi.cc/repaddzeros and magpi.cc/renamingfilesseq.

lv -v | cat -n | while read n f; do mv -n


> Language: Python magpi.cc/timelapsepy
"$f" "$n.jpg"; done

Press RETURN. This renames your files 001. import time


sequentially. You now need to add padding so the 002. import os
file names are all the same length. 003. import ftplib
004. from datetime import datetime
Type the following: 005. from gpiozero import MotionSensor
006. from picamera import PiCamera
sudo apt install -y rename 007. from ftplib import FTP
008.
Press RETURN, then type the following and 009. pir = MotionSensor(4)
press RETURN: 010.
011. def thegrab():
rename 's/\d+/sprintf("%05d",$&)/e' *.jpg 012. thetime = datetime.now()
013. detectiontime = thetime.strftime("%y-%m-%d-%H-%M-%S")
014. extension = ".jpg"
015. filename = detectiontime + extension
Create your time-lapse 016. camera = PiCamera()
12 Install FFmpeg by typing: 017. #camera.rotation = 270
018. time.sleep(2)
sudo apt install -y ffmpeg 019. camera.capture(filename)
020. camera.close()
Press RETURN. When installation completes, 021. ftp = FTP('[server address]')
compile your images into a video by typing: 022. ftp.login('[username]','[password]')
023. ftp.cwd('')
ffmpeg -pattern_type glob -i "*.jpg" 024. ftp.storbinary("STOR " + filename, open(filename, 'rb'))
-s:v 640:480 -c:v libx264 -pix_fmt yuv420p 025. ftp.quit()
timelapse.mp4 026. os.remove(filename)
027.
If you want to change the output resolution, 028. while True:
adjust 640:480 to your preferred dimensions. The 029. pir.wait_for_motion()
time taken to complete the process depends on 030. thegrab()
both the resolution and the number of images 031. time.sleep(30)
you’ve saved.

77
www.dbooks.org
A stitch in code

TUTORIAL

A stitch in code
The intriguing relationship between the fibre arts and coding

H
ave you ever considered how chain of interchangeable punched cards. In weaving,
a knitting or a crochet pattern a single weft thread is passed over and under a set
resembles coding, and the many of warp threads. Before this invention, workers had
parallels that exist between the to manually raise and lower wrap threads in order
fibre arts (an umbrella term which to create any kind of fabric pattern, and this was an
includes knitting, crochet, spinning, extremely slow process.
weaving, and yarn dying, to name but a few) and The cleverly designed cards of the Jacquard loom
Nicola King
coding? These two seemingly unrelated fields have were fed into the Jacquard mechanism at the top
@holtonhandmade an interesting history together and, in this article, of the loom and had small holes punched in them,
we will take a look at the fascinating similarities that which held the instructions for the weaving pattern.
Nicola King is a freelance really illustrate how much they have in common – They basically controlled which warp threads should
writer and sub-editor. spreading, we hope, an appreciation of the fact that be raised to allow the weft to pass underneath.
She firmly believes that
purchasing arts and coding and the fibre arts have many more similarities So, this was a very early example of instructing a
crafts goodies, and than you may ever have previously considered. machine to carry out an automated process, using
actually sitting down
and making something,
a binary system (with either a punched hole, or no
are two completely A CLOSE-KNIT RELATIONSHIP punched hole), where the information could be read
different pastimes. Let’s begin with a little history, which illustrates how by the loom and reproduced as required. The use of
coding/programming and the fibre arts are entwined. the replaceable punched cards to control a sequence
To see one of the most famous examples of this, of operations is widely held as an important step
we can simply look at the Jacquard loom, patented in the history of computing, as Charles Babbage
in 1804 by French weaver Joseph-Marie Jacquard. (1791–1871) was inspired by the Jacquard loom’s
Above The Jacquard system was way ahead of its time, use of punch cards to program his Analytical Engine
Fibre arts have a lot in
common with coding,
and enabled unskilled workers to weave intricate of 1837, considered by many as the first modern
as we shall explain patterns easily: the central principle being the use of a computer design. So, we can begin to see a link

78
FORGE

GRAPHGHANS
There is a stitch in crochet called C2C or ‘corner to
corner’, and each C2C stitch basically creates a small
square or block. This means that C2C is a handy stitch
to know if you want to design a pixel crochet blanket for
example (also known as graphghans – afghans made
from graphs), made up of a series of squares where
each square represents one pixel of the image. You
Figure 1
could write your own simple pattern for this on a piece The knitted swatch
of graph paper and then stitch it up. Or, you could use a illustrates a simple
lace design achieved
website such as Stitch Fiddle (hsmag.cc/PixelCrochet)
by following the
and create your chart there, where you can upload a dictated code and
picture to the site, or create a new design yourself. C2C various commands
therein. In knitting,
is similar to how computers store images in grids of stitches stay on the
coloured squares. needle and are active
What we are also illustrating here is that crocheters for a whole row, and
you use either single
and knitters are very happy to use tech help, including point, double point, or
websites and apps, in their designs if it makes the • R2 – 3 Ch, skip first 3 Tr *[2 Tr, 1 Ch, 2 Tr] in 1 Ch fixed circular needles
process easier – is your image of the average knitter sp, skip next 4 Tr, repeat from *, end by skipping
or crocheter evolving at all? It’s not just about the yarn Figure 2
last 2 Tr, 1 Tr in next Ch, turn The crocheted swatch
these days… • Repeat R2 until desired length – a different effect
is achieved from
(Abbreviations: Ch – Chain, Tr – Treble, Ch sp – Chain following the crochet
space, R – Row) code. In crochet, you
complete each stitch
here between the two, on first sight, seemingly very one at a time, so only
one stitch is live, and
different worlds. These are forms of code, knitting and crochet code: work with just a
sets of instructions used to complete several single hook
ILLUSTRATIONS OF CRAFTING CODE
Let’s now look more closely at the parallels between
coding and the fibre arts, and perhaps the easiest
thing to do to illustrate these is to take a look at
some very simple patterns which, when knitted
and crocheted, will produce the swatches shown in
Figures 1 and 2, respectively.

SIMPLE KNIT PATTERN


• CO 16 stitches
• R1 – P2, [K5, P2] to end of row
• R2 – K2, [P5, K2] to end of row
• R3 – P2, *K2tog, YO, K1,YO, Sl1, K1, PSSO, P2;
rep from * to end of row
• R4 – Repeat R2
• Repeat R1 – R4 until work measures 10 cm
in length
• Bind off
(Abbreviations: CO – Cast On, R – Row, K – Knit, P
– Purl, K2tog – Knit two stitches together, YO – Yarn
Over, Sl – Slip, PSSO – Pass slipped stitch over)

SIMPLE CROCHET PATTERN


(UK CROCHET TERMINOLOGY)
• Ch 15
• R1 – [2 Tr, 1 Ch, 2 Tr] in 5th Ch from hook, *skip
3 Ch, [2 Tr,1 Ch, 2 Tr] in next Ch, repeat from * to
last 2 Ch, skip 1 Ch, 1 Tr in last Ch, turn

79
www.dbooks.org
A stitch in code

TUTORIAL

rows of knitting or crochet. Note particularly, in


both patterns, the use of brackets and asterisks,
which are also of course used in coding – here,
these are indicating a group of stitches that will be CRAFTY CORRELATIONS
Above
We downloaded repeated, or a specific instruction to be carried out So, looking specifically at the handcrafts of knitting
the free (open- in a certain stitch such as, in the crochet example, and crochet, it can be suggested that the numerous
source) pattern
(code) from the completing two trebles, one chain, and two trebles comparisons between coding and these two fibre-
designer (developer),
channelled the Force
in a single stitch. Designing a pattern is basically based techniques include the following:
through our hook and just like writing a program. You can think of the
yarn, and hey presto…
The Child! knitter or crocheter as the computer, translating the 1. Standard notation
(hsmag.cc/BabyYoda) code, executing functions in the code line by line, Knitting and crochet patterns are written using a
in the correct order. Knitters and crocheters won’t standard notation describing precisely the actions
generally refer to these instructions as code; in fact, required to achieve the desired outcome – a series
it may not occur to many of them that it is code, of detailed steps to create an object or a piece
but any knitted or crocheted item, such as a scarf, of fabric made from stitches. Similarly, computer
is created one stitch at a time from such a piece of programs are also written using a standard notation
code. OK, if you’re not a knitter or crocheter, these describing the steps a computer needs to take to
patterns won’t make a huge amount of sense, and solve a problem.
the purpose of this article is not to teach you how to
knit or crochet. Also, knitting and crochet use very 2. Loop-the-loop
different techniques and tools to reach their end- As already mentioned, if you take a look at the
products, but you can see from the patterns on the patterns on the previous page, you will see the use
previous page that code plays a very important part of asterisks and brackets. In knitting or crochet, these
in these two crafts – makers need the correct, error- basically indicate the beginning of a stitch sequence
free code in order to perform the function. which often needs to be repeated until you reach a

80
FORGE

certain point, such as the end of the row, for example.


Sounds familiar… a little like a loop in coding perhaps?
RAVELRY: A CODING AND
KNITTING COLLABORATION
3. Terminology There are many stereotypes associated with knitting and crochet but, these days, the
Both the spheres of coding and fibre arts use their average age of a fan of these two crafts, in particular, is much lower than in years gone by.
own languages or vernacular – a unique syntax that Banish (please!) any thoughts of little old ladies in rocking chairs – fibre artists are cool,
seems to make little sense unless you understand/ on-trend, tech-savvy, and want to regularly communicate with fellow creators online.
research the terms involved. A few baffling knitting Consequently, tools have developed to meet the inherent demand for a form of ‘social
expressions include rib, cables, brioche, intarsia, networking’ specifically for the yarn arts. Ravelry (ravelry.com) was created in 2007
by Jessica and Cassidy Forbes from Boston, Massachusetts, and now has over nine
frogging, and entrelac, while crochet lingo includes
million (yes, you read that figure correctly!) users worldwide. Interestingly, one half of
seemingly unfathomable terms such as amigurumi, the founding partnership was originally a knitter, and the other was… a coder! Their
back post double crochet, filet, mosaic… and so complementary skills are still used today to keep this gargantuan network functioning at its
on. But, as with anything, once you understand that optimum. Nearly half a million knit and crochet patterns, for example, can be downloaded
jargon, it all falls into place. from the site, some free, some paid for, thus generating an income for thousands of pattern
designers and sustaining Ravelry so that it can continue to unite fibre artists.
Users can utilise the organisational tools, share patterns, stashes, thoughts, ideas,
4. Open source
discussions, and projects. It’s a fibre-loving community using a massive database of
In the world of the fibre arts, patterns are sometimes patterns and yarns – you can filter your searches on hundreds of criteria and get instant
paid for, but can often be found for free. Fibre artists, access to exactly what you’re looking for. It’s free to join, and a great place to visit if
like coders, are a generous bunch, and many people you’ve lost your crochet or knitting mojo, as you’re guaranteed to want to start at least 150
make their patterns available to all on sites such as different projects once you start looking for inspiration.
Ravelry (see separate box). Hundreds of knitting and
crocheting podcasters are also willing to share their
knowledge for free on YouTube in videos showing

” Note particularly, in both


patterns, the use of brackets
and asterisks, which are also


of course used in coding

how to crochet a Baby Yoda, how to weave a wall-


hanging, or how to knit a pair of socks. There is a
real sense of community in the fibre arts world, as
the many forums and online communities will attest with. Believe it or not, repetitive counting is also very
– much like the world of programming and coding. calming as it’s so meditative. Above
A vast database of
This author recently downloaded a free crochet thousands of patterns
at your fingertips,
5. Maths, maths, and more maths pattern in which the maths didn’t add up, based on or should that be
When this author is knitting and crocheting, at the what the code was telling her to do and the required needle tips?
same time, she is also counting. It’s about order, stitch counts at the end of each row. The pattern
accuracy, and precision. Following the code, she appeared to not have been tech-edited, so she
is processing that algorithm that a designer has emailed the company concerned and rewrote the
created in order to instruct her on how to achieve bothersome incorrect elements of the pattern. She’s
the end goal. When executing the code, she needs determined to write more of her own crochet code
to count (a lot!). Stitch counts are critical, so she now, as it’s really not that hard!
needs to follow the designer’s code precisely, or
that crocheted version of Bernie Sanders at the 6. Refactoring and checking for ‘bugs’
inauguration will have the wrong-sized head, (yes, a Just as coders will refactor code to try and improve
talented individual had the ingenuity to design such a the design of a piece of software, fibre artists do
pattern – hsmag.cc/Bernie). ‘Ssshh, I’m counting’ is the same thing, as it’s all in the finish. Most paid-
a line that this author’s family are more than familiar for patterns, and many free patterns too, will be

81
www.dbooks.org
A stitch in code

TUTORIAL

bug- and error-free, just as fibre artists want to see a


LEARN A NEW SKILL beautiful end-product too.
AND FURTHER READING
If you would like to experience the many therapeutic benefits that knitting, crochet, 8. Tech skills are also essential
weaving, or any other fibrous form of creativity can offer (mindfulness, reduction of anxiety It’s a given that coders require technical expertise,
and stress, improved cognitive function, sense of control, sense of achievement… to name but fibre artists have those skills too. Being able
just a few), then there are many options: to read a pattern and translate it is a technical skill,
as is knowing how to knit or crochet in the first
• YouTube videos – there are hundreds to choose from, and it’s how this
place, knowing what yarns to use for each pattern,
author taught herself to crochet. Try: youtube.com/c/BlossomCrochet/videos,
youtube.com/c/RJKnits/videos, or youtube.com/c/SpruceandLinen/videos
measuring gauge correctly so that the new jumper
• Ask a friend/family member to teach you – nothing beats a hands-on lesson with you are constructing fits you properly, or modifying
an expert patterns to include your own personal slant, for
• Join an online lesson. Try: creativebug.com, skillshare.com, or udemy.com example. (See ‘Graphghans’ box.)
• Buy a beginner kit – these come with instructions and everything you need. Try:


weareknitters.co.uk, or bytomdaley.com/collections
• Get yourself a book from the library – we suggest you grab a ‘How to’-type publication
along with a stitch dictionary, if you are learning crochet or knitting You can do both – you can
When you get that ‘light bulb’ moment, and everything finally clicks into place, you’ll feel
such a sense of achievement and you’ll be away (oh, and start making space for some yarn, code and program and you
fibre, tools… it’s a rabbit hole). You might even start designing your own patterns…also
can knit or crochet or


known as coding!
spin or weave

rigorously tested by test knitters or crocheters, and


by tech editors, to make sure that there are no errors 9. Continuous learning curve
in the pattern. Much like coders and developers, As in all areas of life, both coders and fibre artists
designers will search for bugs in the system – are constantly facing challenges to develop, to learn
the end goal in a knit/crochet piece of coding is more, and to hone their skills, as there are always
documentation that delivers what it promises, and new elements to master. Fibre artists will be learning
only once it has been debugged can it be released, new stitches, techniques, about new yarns, how to
or deployed in software terminology. As in coding, read charts, how to fix errors, while coders need to
pattern designers will use trial and error to achieve keep up with new languages, frameworks, libraries,
their desired outcome. Designers will rewrite their and so on.
code so that they explain the pattern, in as few Perhaps a key point to make here is that you can
lines as possible, very similar to the DRY (Don’t do both – you can code and program and you can knit
Repeat Yourself) principle of software development. or crochet or spin or weave. You can be both creative
Fibre arts patterns and coding are both trying to and technical at the same time. Coding and the fibre
communicate complex instructions as simply arts are not mutually exclusive pastimes – would
as possible. you be surprised to find a coder or developer who
likes to knit, or a professional crochet designer who
7. Creativity is inherent also coded for fun? Based on the many similarities
Fibre artists are, by definition, creative. They often discussed here, we wouldn’t be surprised at all… and
tweak patterns, add their own touches, choose there are indeed many people who happily do both.
appropriate yarn colours, and basically express
Figure 3 themselves through their yarny creations. Take, for AN EXPERIMENT
The Python program
prints out a chart
example, yarn bombing (hsmag.cc/YarnBombing) So, just to see what would happen, this author
of stitches for front – a creative, edgy, expressive form of street art, decided to take a very basic knitting pattern and
and rear
spreading colourful fibre joy. This author has recently turn it into Python code (with the help of her code-
found a pattern for crocheting toppers for UK loving husband!)
postboxes, and hopes to create one soon for her local The original pattern she drafted was as follows:
postbox. And, yes, coders are also creative – they • CO 20 stitches
need to possess a technical creativity in order to • R1 & R2 – K
write any piece of software. It can be suggested that • R3 – K
coders are aiming for a form of beauty in their code, • R4 – K3, P14, K3

82
FORGE

Left
Africa Teen
Geeks’ Knit2Code
programme brings
together girls of
different generations
to learn, relearn, or
enjoy knitting and,
as a by-product, the
basics of computing

• Repeat R3 & R4 until work measures 10 cm in


length
COVERT CODE
• Final 2 rows – K Did you know that you can encode secret messages into that hat or cardigan that you’re
• Bind off knitting? Well, this is something that was used to great effect during wartime – yes,
unassuming knitters became useful spies, using steganography (a way of hiding a message
You can find the link to the resulting Python code physically in plain sight) and passing on valuable information in their pattern of stitches
to the people who could use the information effectively in the war effort. It was relatively
here (hsmag.cc/issue57). As you can see, there’s
straightforward to encipher information into a fabric using, for example, Morse code. When
quite a lot of repetition/looping here, along with a you think about it, it makes complete sense – knitting consists of two kinds of stitches,
conditional (‘until work measures 10 cm in length’). knit (flat stitches resembling a ‘v’) and purl (horizontal bumps) – and it is the chosen
In our Python code, we created functions for knit combination of these that makes a pattern, and is relatable to binary code.
and purl, which simply add a letter ‘k’ or ‘p’ to a ‘row’ To illustrate, during World War I, Belgian Intelligence agents sought the help of knitting
string the number of times specified in a ‘stitches’ women who could see train stations and tracks from their windows. They asked them to
parameter. We also created a special ‘row4’ function monitor the passing of German Imperial trains – in their knitting, these inconspicuous-
looking women would drop stitches or add extra purl stitches and so on, as a form of
which calls the knit and purl functions to execute its
predetermined code, to signify how many artillery trains had passed, if a train full of troops
mixture of knitted and purled stitches. had gone through, etc. They then passed their completed fabric to the Belgian Resistance,
An ‘addrow’ function adds each completed row to who could decode the fabric, based on their pre-agreed stitch meanings. Had they been
a ‘front’ or ‘rear’ string – since in knitting, the side of discovered by the enemy, these knitters’ lives would, of course, have been in peril. It must
the work is reversed with each row, we alternate this. have been a successful form of information gathering, as coded knitting played a part in
The first ‘for’ loop knits two rows (akin to ‘R1 & R2 WWII as well. This is a truly fascinating subject area if you are interested in history and
knitting espionage, and you can read more here: hsmag.cc/KnittingSpies.
– K’ in the pattern). A ‘while’ loop then repeats rows
3 (knit 20) and 4 until the ‘length’ variable (increased
with each row) is 10 or greater. We finish with
another ‘for’ loop to knit two more rows. At the end,
we print the ‘front’ and ‘rear’ strings, which results
in a chart of stitches for the front and rear of the
work (Figure 3).
To conclude, if you’d like to read more, we really
suggest that you take a look at this article from The
New York Times (hsmag.cc/YarnProgrammable)
where the ideas of physicist Dr Elisabetta
Matsumoto, that ‘yarn is a programmable material’
and that ‘knitting is coding’, are explored. It’s mind- Above
blowing stuff, looking specifically at the mathematics Who’d have thought
that a humble ball
of knitting. Here, we have really only just skimmed of yarn and two
wooden sticks could
the surface of the coding and fibre arts entanglement, communicate vital
but hope we have piqued your interest in this intelligence?
fascinating area.

83
www.dbooks.org
Moving beyond the K40

TUTORIAL

Configuring your cutter


Dial in your laser cutter’s settings

E
ven the most highly engineered position as the gantry moves. The typical advice is to
products need to be configured use layers of masking tape or custom labels to see
correctly when they are installed, so where the beam is striking the mirror, but this isn’t
it’s no surprise that a homemade very useful if you’ve only just put the machine
piece of kit based on a K40 laser will together and the lasers aren’t even close to aligned. A
need some finesse and a few well- very slight change to a single mirror can shift the
Dr Andrew Lewis placed hammer taps before it will perform beam’s path by several feet over a relatively short
properly. In this article, you’ll learn some tips and distance, missing any masking tape or focussing
Dr Andrew Lewis is a tricks that will get your machine levelled, trammed, targets completely. Some expensive lasers use a
specialist fabricator
and maker, and is the and generally calibrated in the safest way possible. beam combiner to inject a low-powered visible laser
owner of the Andrew beam into the same path as the CO2 laser beam so
Lewis Workshop. DON’T LOOK AT THE INVISIBLE LIGHT that it’s easier to see exactly where the beam will hit
The most obvious set of calibrations that you need to an object, but these are typically an expensive extra
do with a laser cutter is aligning the mirrors. Ideally, that needs to be calibrated anyway.
this should be done after you’ve calibrated the gantry, A cheaper option for the home builder is to either
or you’ll risk having to start the whole mirror remove the lens and fire a visible laser through the
adjustment process again. Mirrors in the laser cutter system in reverse, or remove the laser tube
Above
The bigger the are angled to bounce the beam into the lens completely, and replace it temporarily with an
laser cutter, the regardless of the position of the laser head. Each appropriately mounted visible laser emitter. The latter
more difficult it
will be to calibrate, mirror is around 20 mm in diameter, so you need to be option requires more effort to calibrate the laser, but
because errors are accurate. The difficulty with calibration is that the the parts can be printed on a standard 3D printer and
amplified over the
long distances laser beam is invisible, and the mirrors change don’t need to be particularly accurate. The former

84
FORGE

option is neater and doesn’t involve removing the QUICK TIP


tube, but it does require a lathe to create the parts
SAFETY Don’t disable the
with sufficient accuracy. The initial setup and calibration process for a laser interlocks and fire
Print or make a suitable caddy to hold your visible cutter is probably the most dangerous operation you the laser with the
laser emitter. Assuming that you are using a 3D can carry out on the machine. You will be operating a chamber open,
machine that might fire a laser at an unexpected time even if you’re
printer, create the part so that the outer dimension of
in an unexpected direction, or move motors in ways wearing appropriate
the caddy is the same as the measured diameter of safety goggles.
that you might not expect. The process of calibration
the laser tube and the inner dimension holds the laser takes time and requires you to perform the same
emitter firmly and squarely in position. Place the series of tasks several times. It is easy to fall into a
rhythm and forget the risks, and with repetition comes


a strong temptation to disable some of the interlocks
The burn mark will tell to make the process of calibration quicker. Do not
disable interlocks unless it is absolutely necessary,
you whether the beam because they are there to protect you from serious
harm. Invisible laser radiation can disfigure or blind
is striking the mirror in


you. The power supplies inside a laser cutter can
the centre or not generate high enough voltages to cook meat. You
are made of meat. Always wear laser safety goggles
when working with the laser, and be aware of the risks
caddy into one of the clamps for the laser tube, and from mechanical parts, high voltages, unexpected
fires, and reflective surfaces. Never leave the laser
position it so that the beam is parallel to both the
in a state where it could be activated accidentally by
clamps and the base of the machine. You can do this someone who does not understand the risks. Always
by measuring the distance of the beam from multiple have appropriate safety equipment nearby.
locations along the surface that the laser tube clamps
are mounted to, and the base of the machine. Your
emitter is aligned when the two measurements are the beam is bouncing to inside the laser chamber.
consistent along the length of the machine. With this Place your first mirror so that the beam striking it will
visible laser in place, it should be easier to see where be reflected to the next mirror at its furthest position
from the laser tube. Move on to position the next
mirror in the same way, and repeat this process for
each mirror. Move the gantry so that each mirror is
positioned in its opposite extreme, and repeat the
process until your beam is consistently visible on the
bed of the machine, regardless of the position of the
gantry. For the Z axis, remove the lens from the head
if it is already installed, and use a piece of tape to
mark the position of the laser beam projected onto
the bed, then lower the machine bed. Adjust the head
as necessary to get the laser point in the same place
at different bed heights.
Once you have the mirrors aligned with the visible
laser, you can remove it and place the CO2 laser tube
back into its clamps. In an ideal world the laser will
still line up and work perfectly, but in reality you might
need to do a more traditional calibration by placing
some masking tape or card over the first mirror and Left
A visible laser can
briefly firing the laser at its lowest power setting. The still be dangerous,
and you still need
burn mark will tell you whether the beam is striking to wear appropriate
the mirror in the centre or not, and then you can make laser protection when
working with them.
any minor adjustments to the lens angle and position The safety goggles
before tightening the bolts to lock it into place. Move for visible laser light
are different to those
the gantry to each extreme, and test the laser on a for the IR CO2 laser,
piece of scrap material. Hopefully everything should so make sure you’re
wearing the right one
line up correctly, but if you’re still having problems, while you work

85
www.dbooks.org
Moving beyond the K40

TUTORIAL

Above
Different types of bracket have different amounts of
adjustment. These large laser tube clamps can be
adjusted from side to side using the long bolt
channels, and can also be adjusted up and down using
the thumb screw in the centre. This adds an additional
layer of flexibility when aligning the beam, but it also
adds extra complexity. Some brackets have no
adjustment at all, and all alignment errors must be
corrected by the movable mirrors, which have a wide
range of adjustability

86
FORGE

Left & Above


This 2020 aluminium extrusion makes it easy to attach
motors, and the slots can even hide toothed belts, offering
better protection than an exposed belt. Sprung idler pulleys
maintain pressure on the belt to prevent it from slipping

you can repeat the same process for each mirror,


using tape to see where the laser fires and then
adjusting as necessary.

KEEP FIDDLING WITH IT


The ultimate goal is to get the laser beam running
parallel to the rails of each axis so that when you’re
running the lens along the rail, the beam should strike
the same place on the mirror all the way along the
length of the rail. If it doesn’t, you need to keep
adjusting the alignment of the mirror until you get
consistent results along the entire length. If the laser
beam is hitting in a consistent position along the
length of the axis, but is not close to the centre of the
mirror, then you can move the whole bracket to
centre it on the dot.

UNDER TENSION
One source of errors in machines like 3D scanners
and laser cutters is slippage caused by insufficient
belt tension. Belt tensioners are critically important
to avoid errors while cutting or printing. You have
multiple options when it comes to belt tensioners,
ranging from springs that clip around the belt to pull it
tight, large sprung or weighted tensioner assemblies,
or integrated tensioners that include the idler pulley. It
doesn’t really matter which style you choose, as long
as you have one. Second to low belt tension, motors
skipping steps can also cause problems. If the belts
are too tight or bind on part of the chassis, the friction
may be enough to cause the motor to skip steps. Above
If you hear the familiar ‘clack-clack’ sound, check Actually measure the
your motors are wired correctly, and your belts are diameter of the laser
tube. The number on
running freely. the side of it is just a
rough guide

87
www.dbooks.org
Moving beyond the K40

TUTORIAL

Above & Right


On most machines,
adjustments can be
made to the angle of
the head by turning
screws on the rear
of the mirror mount,
but some cheaper
machines (like the
K40) have a fixed
head. If you have
a skew on a fixed
head machine,
you need to figure
out if the source
of the skew is the
mounting bracket or
the rails, and correct
for it accordingly.
If the rail is twisted
but can’t be moved
to a better position,
you’ll have to adjust
the bracket with
shims or washers to
correct for the error

88
FORGE

The next calibration check involves a process called


tramming, which might be familiar to those of you
TROUBLESHOOTING
who own a lathe or a milling machine. The term is
There are a few symptoms to watch out for when
often confused with levelling, particularly when talking assessing your laser cutter. Let’s take a quick look
about 3D printers, but levelling and tramming are two at some of the more common ones. Poor or variable
different processes. Levelling the bed of a machine cutting power can be caused by a worn tube or dirty
involves making sure that it is level relative to gravity, optics, but it can also be caused by misaligned mirrors
while tramming makes sure that all of the important or a lens that’s been fitted into the head backwards.
parts (like milling cutters or nozzles) are parallel or When using a planoconvex lens, the flat side of the
lens should be closest to the object that you’re cutting.
perpendicular to each other. When tramming, the
The kerf of a laser beam should be tiny – less than a
alignment of parts in relation to each other is far more millimetre. If you’re seeing very wide cut lines, your
important than being parallel with the floor of the laser is probably out of focus.
workshop. Laser cutters can be quite forgiving of Cut lines starting and finishing in the wrong place
small errors in their Z axis alignment, but you’ll have to can be caused by the stepper motors losing steps
check for and correct any other misalignments that because they are underpowered or restricted in some
way, or by a slipping belt. Belt slips can also cause
could cause you a problem. Too large a misalignment
systems to lose the alignment between rails, resulting
will push the laser out of focus and result in an in skewed cuts.
uneven, shallow cut with sloped edges. Smoke staining on printed parts can be caused by
Most importantly, the laser lens assembly needs to excess power, or poor ventilation. Sometimes it’s just
be perpendicular to the bed of the machine. If you a product of the material that you’re working with and
have any warp or twist on the lens, your laser will be it can be almost impossible to eradicate completely.
If smoke stains are a problem, consider masking the
cutting at an angle, and cutting through thicker
surface with masking tape before you start cutting, or
materials will result in chamfered edges rather than polishing wood so that stains will wipe off easily.
right-angle cuts. Think of it as trying to cut through a
piece of wood with the saw crooked. There are some
times when you’d want to do this on purpose to form
a mitred edge, but generally you want the laser to be with only a single endstop to work from. A similar rule
perpendicular to the bed. applies to the Z axis of the machine, when the motors
affect the tilt of the table relative to the rails. These
THE TRAM PROBLEM can be set so that the optimum distance from the lens
Errors in perpendicularity between the X and Y axis is the point where the motors find their home position.
will cause right angles to be cut incorrectly, turning As with the lens alignment, any skew in the table can
squares into be measured relative to


parallelograms. Testing the rails of the machine
for this is simple enough, and adjusted with shims
and involves using a large
If you’re getting ovals or if necessary.
engineering square with other strange shapes, With all of the
a known good right angle adjustments to the
you need to check your


to check the rails of the chassis and the mirrors
two axes are alignments again complete, you can insert
perpendicular. How you the laser lens and make
correct the problem will some low-power test
vary depending on how your system is wired. If each dots at the corners of the gantry. Each dot should be
side of your X axes has an independent motor with an crisp and round; if you’re getting ovals or other strange
endstop, then you need to adjust the endstop position shapes, you need to check your alignments again.
and rehome the axes to get them square. If you share Even a temperature change in the workshop can
a single motor for both of the X axes rails or only use be enough to push a laser reflector out of alignment,
one endstop, you’ll need to slip the pulley or the so you’ll need to recalibrate your laser every few
toothed belt around the shaft to better align the Y weeks, just to make sure that nothing has crept out
axes. Axes with a shared motor like this will need to of tolerance. Once you get the hang of it, you’ll be
be checked more frequently for slippage, as the able to get through the whole procedure in just a
controller’s homing process can’t correct any errors few minutes.

89
www.dbooks.org
Photographing the invisible

TUTORIAL

Photographing
the invisible
We can’t see it, but we can photograph it, as Mike Bedford
reveals in this hand-on guide to infrared photography

B
ecause our eyes are sensitive to Pi and one of its associated camera modules. Not
that part of the electromagnetic only are the results unusual but, we feel sure you’ll
spectrum that we call light, and agree, they’re impressive in the extreme.
since the cone cells of our retinas
respond differently to the various UNDERSTANDING INFRARED
wavelengths of light, we’re able to Infrared, often abbreviated to IR, is often thought
Mike Bedford see the world in full colour. But beyond the long- of as heat, but that’s not true of the whole infrared
wavelength end of the visible spectrum, that’s just spectrum. Heat is called thermal infrared, or
Despite loving all things after red, we find an area of radiation that’s known sometimes far infrared (FIR), but that’s not our
digital, Mike admits to
being a bit of a Luddite,
as infrared. Our eyes aren’t sensitive to infrared, of subject here. Sure, you can photograph thermal
vinyl records and all. course, so we might wonder how different the world infrared, but it requires specialised and expensive
would look if we could see this invisible radiation. equipment, and it’s mostly used for scientific or
In other words, what it would it be like to mimic technical applications, not for artistic pursuit.
the visual capabilities of some insects, fish, frogs, Instead, we’re going to see how to photograph
and snakes? The good news is that, by employing in the near infrared (NIR), which is the portion of
a special form of photography, we really can see IR just beyond the limit of human vision. The good
infrared and it’s not nearly as difficult as you might news is that the image sensors in digital cameras
imagine. Here, we’re going to see how to do that are sensitive to NIR. But to create images using only
using an ordinary camera and then, better still, by IR, we need to prevent visible light getting into the
making your own infrared camera using a Raspberry camera. This is done using a filter over the camera’s

Right
Using an ordinary
camera normally.
Middle: Using an
ordinary camera for
infrared photography.
Right: Using a camera
with no IR block filter
for infrared
photography –
this is the only
solution which
doesn’t filter out
most of
the infrared

90
FORGE

Left
The classic infrared
look is monochrome
but with high-contrast
dark skies, while grass
and foliage almost
seem to glow

lens, that will allow IR to pass while blocking visible


light – we’ll call this an IR pass filter. There’s a snag,
though. Camera manufacturers use a different
type of filter internally to block IR – we’re calling it
an IR block filter – to prevent the unnatural colour
cast that would otherwise occur. So, if you fit an IR
pass filter over your camera or phone’s lens, you’ll
be able to take IR shots, but your camera won’t be
very sensitive. Even so, it’s a good place to start
because it’s so easy. See the first two parts of the
diagram below left to get a better understanding of
these filters. In the first part, we see how in normal
photography, the IR block filter very much reduces
the amount of infrared (shown as grey) reaching the
image sensor but visible red, green, and blue light
are unaffected. In the second part, we see how an
IR pass filter can be used to block out the visible
light to take a purely IR shot, but the amount of
infrared reaching the sensor is still reduced. We’ll
come to the third part later.

GETTING PRACTICAL and I’ve had some good results. However, before
Using an ordinary camera with an IR pass filter gives buying an IR pass filter, do check that your camera
you an infrared camera which isn’t very sensitive or phone is sensitive to IR. I haven’t found one that
– so you need long exposures – but don’t dismiss wasn’t, although they do vary in their sensitivity, and
it. Until recently, I’d taken all my IR shots this way, older cameras might be better because they have
less effective IR block filters. A good way to check
is to observe the end of a TV remote control on your
camera’s LCD viewfinder – the end you point at the
TV – in a dim room while you press a button. Or, if
you have a DSLR that doesn’t use the LCD panel
as a viewfinder, you’ll have to actually take a photo.
If your camera can see infrared, you’ll see a small
bright circle at the end of the remote control unit.
If you’ve made sure your camera is IR-sensitive,
it’s safe to buy an IR pass filter – just search for
’IR filter’. A good choice is an R72 filter, which
has a 720 nm cut-off, because it’ll give you shorter
exposures than an 850 nm filter. If your camera has
a filter thread, the filter needs to be of the same
size or, if it doesn’t, like most compact cameras and
phones, just buy any filter that’s big enough to cover
the lens. Prices vary from about £8 to £100, but we
suggest a fairly cheap filter to start.

91
www.dbooks.org
Photographing the invisible

TUTORIAL

namely dark blue skies which are sometimes


virtually black, and vegetation that’s almost glowing.
To use the much-used adjectives, infrared photos
have been described as bizarre, weird, surreal, eerie,
dreamlike, otherworldly, and spooky. And scenes
like graveyards and derelict buildings have become
something of a cliché among IR photographers.
Depending on your camera, IR photos might appear
like black and white photos on steroids, which is
what we want, but if they have a colour cast as they
probably will, just convert them to true black and
white using photo editing software. Perhaps also
increase the contrast.

THE RASPBERRY PI ALTERNATIVE


Using an ordinary camera and an IR pass filter is
a great way to get a feel for infrared photography,
Practically, there’s not a lot to say except that but most serious IR photographers are put off by
you should screw on, or otherwise fix, the filter the lack of sensitivity. So, they either get a camera
over your camera’s lens and you’re then ready to modified by a specialist who removes the internal
go. However, because of the long exposure times IR block filter, or they convert it themselves. But
Above
You could design your – perhaps a second or more, even in bright sunlight the former is expensive and with the latter, unless
own Pi NoIR-based
IR camera, as you
– you should use a tripod. Tripods don’t have to cost you’re careful or lucky, you could end up with a load
can see from this one a lot. Alternatively, you could use some support like of parts you can’t put back together. We have a
that was produced by
experimenter Rob Gill, the top of a wall to steady your camera during the different solution. Raspberry Pi produces a version of
and which we used to exposure. About the only other thing you need to its V2 camera module that doesn’t have an IR block
take all the IR photos
presented here. know is what to photograph. You’ll soon learn what filter – it’s called the NoIR. It’s commonly used with
Alternatively, you’ll find makes a good IR photo, and the photos reproduced an IR light source for night-time security applications,
no shortage of ready-
to-go projects here will show you some of the classic effects, but it’s also suitable for artistic IR photography.

92
FORGE

Compared to some cameras, the resolution is so you have a portable unit. We’re not going to
modest, at 3280×2464, but you could easily find suggest exactly how to do that, because some of Above
Just as red, green,
that adequate, indeed we concentrated on it here the decisions are matters of personal choice, and and blue pixels have
because it’s such a cost-effective way into blocking- there are lots of published designs to choose from. different peaks in the
visible spectrum, they
filter-free IR photography. However, for unexplained Most of those designs will use an ordinary Camera do in the infrared too.
reasons, we experienced blurring towards the edges Module v2, not the NoIR version, or an unmodified This means that, if
your camera has its IR
of the photos. A better alternative would be based HQ Camera, but swapping a Camera Module v2 block filter removed,
on a Raspberry Pi High for a NoIR camera or you can capture false


colour information in
Quality (HQ) Camera. It removing the filter from the infrared. These
graphs are typical,
has a higher resolution, an HQ Camera barely
Using a NoIR or HQ but will differ
larger sensor, and larger impacts the design. between cameras
interchangeable lenses Camera Module requires a About the only addition
which have adjustable you’ll need – and this
bit more work than with an


aperture and focus, only applies to the
and is still affordable. ordinary camera NoIR because the HQ
There isn’t a version Camera lenses have
without the IR block filter threads – is some
filter, but it’s a fairly simple job to remove it, and means of attaching the IR pass filter over the lens. If
there are instructions on the Raspberry Pi website, you don’t need to use the filter elsewhere, you could
although it does invalidate the warranty. The working glue it in place; otherwise, glue on a filter stepper
of a camera with no internal IR block filter, but an ring so that you can screw the filter over the lens.
external IR pass filter, is shown in the third part of
the diagram on page 91. INFRARED COLOUR
Using a NoIR or HQ Camera Module requires a bit Conventionally, infrared photos are monochrome,
more work than with an ordinary camera because but there are several ways of creating colour IR
it needs to be housed together with a Raspberry shots. The methods involve post-processing and
Pi board, an LCD panel, and a power supply, you’ll need a fully featured editor but, if you don’t

93
www.dbooks.org
Photographing the invisible

TUTORIAL


have one, we suggest GIMP, which is free. We don’t
have space to provide step-by-step instructions, but
Remember, though, that we’re processing the invisible
we’ll give enough guidance for you to figure it


so there’s no correct way for these photos to look out yourself.
With an ordinary camera, i.e. one with an internal
IR block filter, the methods involve taking two
photos, an ordinary one and one taken with an IR
pass filter over the lens, and combining them. One
of the best ways is to split the normal photo into
hue, lightness, and saturation channels, discard
the lightness channel and replace it with the
monochrome infrared photo before recombining
them to make a colour photo. The colours will be
normal (-ish) but with the classic features of an
infrared photo, like dark skies and bright foliage.
The second method – which we call false colour
– requires only an infrared photo, but it should have
been taken on a camera with no IR block filter. The
graph on page 93 helps you to understand how
this works. It shows how a typical camera, not any
particular one, responds to different wavelengths.
We can see that the camera has peaks for red,
green, and blue in the visible part of the spectrum,
as we’d expect, but the camera’s red, green, and
blue pixels also react differently to different parts
of the IR spectrum. In other words, there is 'colour'
– although we don’t use that word in its strictest
sense – in the infrared. If the camera has an IR block

94
FORGE

filter, though, the camera will only be sensitive to a have to experiment. So, in post-processing, define a
small part of the IR spectrum, between where the white point from an area of the photo that ought to
IR pass filter (e.g. R72) starts and where the IR block be white – for example, clouds or grass. This should
filter ends. In our graph, that’s from about 675 nm remove the red cast by boosting the green and blue
to 780 nm and, since the red, green, and blue pixel pixels. Because the sky will be red or brown rather
sensitivities don’t change a lot in that range, you can than blue, though, it’s common to swap the red and
see why it only works well if the camera has no IR blue channels. The sky will now be blue and, while
Above
block filter. foliage will be very light like IR monochrome photos, We prefer the false
Straight out of the camera, images will probably it might have a pale orange, yellow, or pink hue colour effect that
renders grass and
have a strong red or magenta colour cast, after which many people think is a good look. Remember, foliage in a pale peach
all, as we can see from the graph, the red pixels though, that we’re processing the invisible so there’s or apricot colour, but
the effect with almost
are the most sensitive to IR. However, the actual no correct way for these photos to look, so feel white vegetation is
colour depends on the setting for white balance free to experiment to your heart’s content, perhaps quite pleasing too,
and no, that’s not
and whether you shoot in JPEG or RAW, so you’ll increasing the saturation and adjusting the hue. snow on the ground

95
www.dbooks.org
Make a printing party camera

TUTORIAL

Make a printing
party camera
Create a camera that sends pictures to a portable Bluetooth printer.
Use it at parties (or anywhere else) to capture the fun

T
hese days, no big social occasion The printer is a battery-powered device that
is complete without a photo booth provides a Bluetooth endpoint that can accept
where guests can take instant image printing commands. There are lots of low-
pictures of themselves. Now, you can cost ‘receipt‘ and personal printers available. The
make your own device to do the same ‘MobilePrinter’ that the author used was purchased
thing. It will detect when subjects for around £15 ($18), and works well enough.
Rob Miles arrive and offer them the chance to immortalise The camera can be powered via the micro USB
themselves on 57 mm-wide thermal paper with connector on the TTGO ESP32 module. You can add
@robmiles
the touch of a button. The camera and the printer an internal battery which should be large enough
are connected wirelessly over Bluetooth, and both to keep it going for a few hours. There is no power
Rob Miles has been
playing with hardware
devices are battery-powered. So, you can turn any switch. The camera switches on when the passive
and software since event into a picture party. The picture quality is not infrared (PIR) sensor detects a person. When the
almost before there was the best, but it does provide a recognisable and camera awakens, it displays a start sequence and
hardware and software.
You can find out more unique memory. invites the user to press the button on the front to
about his so-called life take a picture. Pressing the button starts a five-
at robmiles.com and
second countdown, after which a picture is taken
follow him on Twitter at
@robmiles and printed. The camera automatically powers down
after 30 seconds of inactivity. The OLED screen
displays large friendly messages to keep the user
informed of what is going on. You can find all the box
design, parts list, and all the software on the GitHub
site for this project here: hsmag.cc/PartyCamera.

INSIDE THE BOX


All the electronics for the project are on a single
device – a TTGO ESP32 Camera Module. You can see
the back of this in the bottom right of Figure 1. At
the top right of the box, you can see the back of the
⅜-to-¼-inch tripod socket adapter which is screwed
into a hole in the box and exposes a ¼-inch standard
tripod socket on the outside of the box. The shutter
button on the bottom left is connected across the
GND and IO22 connections on the TTGO expansion
Right
The camera can be connector which you can see on the right of the board
attached to a tripod in Figure 1. The first version of the device used wire-
using the built-in
tripod bush wrapped connections to the pins in this connector.

96
FORGE

YOU’LL NEED
Bluetooth
thermal printer
Search for ‘Mini
Portable Bluetooth
Thermal Printer’.
They are usually
supplied with a
small roll of 57 mm-
wide thermal paper.
You can get more
from any office
supply shop

ESP32 camera
board. The ‘TTGO
ESP32 camera’ unit
is perfect for this
project. It has a
display and a PIR
sensor to wake up
the camera. Search
Figure 1 for it by name
The battery is glued to
the inside of the case Battery. The TTGO
using double-sided device can connect
sticky tape to a rechargeable
battery. Search for
You could instead solder wires to the back of the the display is quite simple, but setting up the PIR ‘1000mAh 802540
3.7 volt’ if you want
connector, or you can buy a cable (search for ‘LilyGO sensor is more interesting: one that works with
TTGO camera cable’) which plugs into the connector. the case design
Figure 2, overleaf, shows the front of the TTGO #define PIR_PIN 33 A button to
module. On the left of the board is the micro USB activate the
connector, next along is a PIR sensor, followed by void setup_pir() camera. Search
for ‘24mm arcade
the camera and 128×64 OLED display. There are {
button’. The author
also two push-buttons: one is connected to the pinMode(PIR_PIN, INPUT); used wire-wrap
processor reset and the other to General Purpose esp_sleep_enable_ext0_wakeup((gpio_num_t)PIR_ wire to connect the
button to the TTGO.
Input/Output (GPIO) pin 34. The GPIO button could PIN, HIGH); You can also get
be used as a shutter button for the camera, but it } a connector that
you can use rather
was decided that a large arcade button would be
than wire wrap.
more fun and easier to press. The code above shows the function setup_pir that Search for ‘TTGO
sets up the PIR sensor. The symbol PIR_PIN specifies camera cable’

STARTING UP THE CAMERA SOFTWARE the GPIO to which the sensor is connected. On A box. There is a
The camera is controlled by a program written in the TTGO board, the PIR sensor is connected to 3D-printable design
available. If you want
C++ using the Arduino software environment inside GPIO 33. The first statement in setup_pir sets this
to put the camera
a PlatformIO project. The code contains a setup pin to be an input pin. The second statement uses on a tripod, you will
function to start the device and a loop function the esp_sleep_enable_ext0_wakeup function to tell the need a 3/8" to 1/4"
camera adapter
which is called repeatedly when the device is active. ESP32 to wake up and start running when the PIR which you can
sensor lifts PIR_PIN high. The next thing the setup search for by name
void setup() function does is make sure there is someone there
Screws. You’ll need
{ to photograph. some screws size M2
Serial.begin(115200); 4 mm in length to fix
the TTGO device to
setup_shutter(); if (!digitalRead(PIR_PIN)) { the case (search for
setup_display(); go_to_sleep(); ‘laptop screws’)
setup_pir(); }
Micro USB cable.
You program and
The above code shows the beginning of the setup The code above tests the PIR input. If the input is power the camera
via the micro
function which sets up the shutter input, OLED low, this means that there is nobody in front of the USB port on the
display, and PIR sensor. Setting up the shutter and camera so it should shut down. TTGO module

97
www.dbooks.org
Make a printing party camera

TUTORIAL

Figure 2
The TTGO board
can be bought with
one of two different
camera lenses. This
board is fitted with
the ‘fish-eye’ which
gives a very wide field
of view. For pictures
of individuals, the
‘normal’ version
works better

void go_to_sleep() DEALING WITH FAILURE


{ Hardware designers must deal with situations where
// turn off the screen parts of a system might not work every time. During
u8x8.setPowerSave(true); testing, it was noticed that sometimes the camera
// disconnect the printer module on the TTGO board was not detected.
tpDisconnect(); Furthermore, attempting to connect to a Bluetooth
// turn off bluetooth printer is not always successful. The printer may
btStop(); be switched off or connected to another device.
// enter deep sleep Normally, a user could attempt to fix these problems
esp_deep_sleep_start(); by turning the device off and on again to force a
} retry. Unfortunately, the camera doesn’t have an
on/off switch, so we must make our code able to
The code above shows the go_to_sleep function. deal with failures.
This turns off all the devices on the camera and
then puts the ESP32 to sleep. If the PIR sensor bool try_setup(bool (*try_setup_function)(),
is triggered, the ESP32 will reset and the camera int retry_gap_millis,
software will start running again and call setup. int no_of_retries)
{
while ((no_of_retries--) > 0) {
WHEN IN DOUBT, SLOW THINGS DOWN if (try_setup_function())
First attempts to use the camera on the TTGO board were not encouraging. The camera return true;
was not always detected. There are a variety of possible reasons for failures like this. delay(retry_gap_millis);
Perhaps the power supply glitches when the camera powers up. Perhaps the reset pulse }
the ESP32 sends to the camera is too short. Perhaps the connections between the devices return false;
are noisy. Perhaps the camera is not responding quickly enough to requests from the }
ESP32. In the case of the TTGO camera, it was the last issue. The fix that worked was to
slow down the ESP32 processor so that the camera could keep up. This is very easy to do.
If you are using the Arduino IDE to develop your program, you can find the setting in the The code above shows how the camera software
Tools menu there. sets up devices which might not work first time.
If you are using PlatformIO to write your code, you can add this line to the platformio.ini The try_setup function repeatedly calls a setup
file for your project: function. It accepts three arguments. The first is a
pointer to the setup function to use. The second is
board_build.f_cpu = 160000000L the interval between retries in milliseconds, and the
third argument is the number of retries. The body
Slowing down the processor in a device will reduce the power consumption, which can
be a good thing if you are worried about battery life. However, if you slow the CPU speed
of try_setup uses a while loop to repeatedly call
down below 80MHz, Bluetooth and WiFi will stop working. the supplied try_setup_function until the function
succeeds, or it fails after the specified number of

98
FORGE

PICTURE QUALITY
A thermal printer works by heating up elements
in the print head which cause chemicals on the
printer paper to turn black. When printing text, the
amount of ‘black’ that needs to be printed at any
time is quite small. However, when printing images,
there may be quite a lot of black to print, and not all
printers handle this equally well. The image to the
right shows the result of trying to print a completely
black image on the thermal printer used for this
project. You can see how the print head has ‘given Left
up‘ towards the end of some of the rows. The The image should be
completely black. The
author is quite happy with this level of quality for bands are caused
the price, but you might be able to find printers that by the print head
can produce better results. overheating, or by
the limitations in the
power supply

attempts. If the setup works, the function returns from another Bluetooth device, find the printing
true, otherwise, it returns false. service, and then send text to it.
The screenshot in Figure 3, overleaf, shows
if (!try_setup(try_setup_camera, 200, 5)){ the text ‘hello world’ being sent from a mobile
esp_restart(); phone into the MPT-II printer using a program
} called ‘BLE Scanner’ from Blue Pixel Technologies
(bluepixeltech.com). This is an excellent way
The code sample above shows how try_setup to discover the services and characteristics of a
is used to call the try_setup_camera function five Bluetooth device. You can see parts of the very
times, with a 200-millisecond delay between large numbers that are used to identify services
each attempt. If a call of try_setup returns true and characteristics. We could write our own code
(indicating that the camera has been set up), the to drive the printer, but it is much easier to use a
program continues running. If a call of try_setup library written by Larry Bank, which you can find
returns false, the function esp_restart is called to here: hsmag.cc/ThermalPrinter. This finds and
reset the device completely. The program also uses connects to Bluetooth printers and works a treat.
try_setup to connect to the printer. We have already The only change the author needed to make to the
seen that each time the device resets, it will check library, to make it work with his printer, was to add
to see if there is anyone in front of the camera the printer’s name (MPT-II) to the list of printers the
before continuing. This means that if the printer library supports. There are instructions on how to do
is not powered on, the camera will keep trying to this on the GitHub site for this project.
connect until it detects that nobody is trying to take a
photograph, at which point it will shut down. bool try_setup_bluetooth_printer()
{
PRINTING OVER BLUETOOTH if (tpScan()){
A Bluetooth device exposes services, each of which if (tpConnect()){
contains several characteristics. A client connects tpSetWriteMode(MODE_WITHOUT_RESPONSE);
to a service and can send messages to the service return true; QUICK TIP
by writing values into a characteristic which are } The camera unit on
then picked up by code in the service. Services and else{ the TTGO module
characteristics are identified by large numbers. A return false; just ‘dangles’ on the
particular value means “this is a printer service” } ribbon cable, which
and another value means “this is a characteristic } can make for wobbly
pictures. Use a small
that accepts text to be printed”. In addition, each else{
piece of double-
Bluetooth device has a specific ID which is a string return false; sided sticky tape to
of text. The thermal printer used for this project has } hold it in place on the
the Bluetooth ID ‘MPT-II’. You can connect to this } TTGO board.

99
www.dbooks.org
Make a printing party camera

TUTORIAL

unsigned long timer_millis = millis();


if (digitalRead(PIR_PIN)) {
// reset the timer if people are still in
front of the camera
start_time = timer_millis;
}

if ((timer_millis - start_time) > TIMEOUT_


MILLISECS) {
// turn off the camera
go_to_sleep();
}
}

This function turns off the device if nobody has


been detected for a while. It also resets the timer
if there is someone in front of it so that the camera
stays awake when it is being used. The go_to_sleep
function is called to put the camera to sleep. We
have already seen how this function is used when
the camera starts up and there is nobody using it.

TAKE A PICTURE
The second statement in the loop function calls the
update_shutter_button function to check if a picture
Figure 3 should be taken.
You need to send a
message containing
the hex value ‘0a’ (line void update_shutter_button()
feed) to get the printer {
to print text you
have sent it bool new_shutter = digitalRead(SHUTTER_PIN);
if (last_shutter_input != new_shutter) {
The preceding code shows the try_setup_bluetooth_ if (new_shutter == 0) {
printer function which connects to the printer. The take_picture_and_print();
tpScan, tpConnect, and tpSetWriteMode functions are }
part of the thermal printer library. last_shutter_input = new_shutter;
Once the camera has been set up, the update }
function is repeatedly called to operate the camera. }
Let’s look at that next.
The code above is for the update_shutter_button
PHOTO LOOPY function. This detects when the button has been
void loop() pressed down by comparing the new shutter input
{ (new_shutter) with the last one (last_shutter_input).
update_timeout(); If the two are different, the button has changed
update_shutter_button(); state. If the new state of the button is 0, this means
delay(10); that the button has been pressed down, and the
} camera must take a picture and print it. This action
is performed by the take_picture_and_print function.
The code above shows the loop function for the This function displays a smile countdown and then
camera. First, the loop function calls update_timeout calls the functions take_picture and print_picture to
to check if the camera should shut down. produce the picture output.

void update_timeout() uint8_t *frame_buffer = NULL;


{ int frame_buffer_size;

100
FORGE

The preceding code shows the variables in the


program that hold information about an image. The
frame_buffer variable refers to a buffer of pixel data
and frame_buffer_size specifies the number of
pixels in the buffer. These variables are global. The
take_picture function puts values into them and the
print_picture function reads them.

Left
void take_picture() The AI Thinker
ESP32-CAM board
{
is a good match for
frame_buffer = (uint8_t *)cam.getfb(); the TTGO device
frame_buffer_size = cam.getSize();
} return 1; // Continue decode
}
The code above shows the take_picture function
which sets the frame buffer and frame buffer size by The code above shows the printRows function, which
activating the camera. sends image bytes generated by decodeDither to the
printer. Each byte in the image data gives the state
void print_picture() of eight dots across the printed row. These need
{ to be inverted because the camera image uses a
if (jpg.openRAM(frame_buffer, frame_buffer_ set bit to indicate white, whereas the printer uses
size, printRows)) a set bit to indicate that a black dot is to be printed.
{ The buffer is assembled and then printed by the
jpg.setPixelType(ONE_BIT_DITHERED); tpPrintBuffer function.
jpg.decodeDither(ucDither, JPEG_SCALE_HALF);
} GOING FURTHER
} There is a lot of scope for extending this project. You
can use the printer to add bar-codes, QR codes, and
The print_picture function shown above prints the text to an image. You could create a ticket creator
image stored in the frame buffer. It uses another application which has a picture of the ticket holder
library written by Larry Bank. The JPEGDEC and a QR code holding the URL for the event. Or a
(hsmag.cc/JPEGDEC) is used to decode the image simple photo ID. The author hopes that you have
from the camera and send it to the printer. The learned some tips about creating devices that power-
print_picture function sets up the JPEG decoder up automatically, capturing images and using a
and then uses the decodeDither method from Bluetooth printer from an ESP32. And just maybe, if
JPEGDEC to decode the image from the camera. you make the party camera, you might get invited to
As the image is decoded, decodeDither calls the even more parties. Below
printRows function to send rows of image data to You can screw a
3/8 tripod adapter
the printer.
PRINTING TINY TEST PIECES into the bottom of
the case so that
the camera can be
int printRows(JPEGDRAW *pDraw) It is often a good idea to print parts of a design to make attached to a tripod
{ sure that they fit before you print the entire thing. Below,
int i, iCount; you can see a test piece that was created to make sure
uint8_t *s = (uint8_t *)pDraw->pPixels; that the opening in the camera base was the right size
for the USB plug. It is very easy to use a CAD tool to cut
large chunks away from your design so that you can
tpSetBackBuffer((uint8_t *)pDraw->pPixels,
print just small test parts to make sure that they fit.
pDraw->iWidth, pDraw->iHeight);
iCount = (pDraw->iWidth * pDraw->iHeight) / 8;
for (i = 0; i < iCount; i++){
s[i] = ~s[i]; // find inverted patterns in s
}

tpPrintBuffer(); // Print this block of pixels

101
www.dbooks.org
FIELD TEST
HACK MAKE BUILD CREATE
Hacker gear poked, prodded, taken apart, and investigated

PG

112
WAVESHARE
LORA 104
PG

BEST OF
Adding distance to your
wireless communications

BREED Our pick of


Raspberry Pi robots
DON’T MISS THE BRAND NEW ISSUE!

SUBSCRIBE
FOR JUST

£10!
> T
 HREE!issues
of The MagPi

> F
 REE!
Raspberry Pi
Pico W

> F
 REE!
delivery
to your door

NEW
+ FREE
MO
DEL!

RASPBERRY PI
*W

PICO W*
hil
es
toc
ks
las
t

Three issues and free Pico W for £10 is a UK-only offer. Free Pico W is included with a
12-month subscription in USA, Europe and Rest of World. Not included with renewals.
Offer subject to change or withdrawal at any time.

magpi.cc/subscribe www.dbooks.org
Raspberry Pi Bots & Rovers

BEST OF BREED

ONLYTHE
BEST
Raspberry Pi
Bots & Rovers
Get your Raspberry Pi moving

By Marc de Vinck @devinck

T
he Raspberry Pi made waves when it In this Best of Breed, I wanted to look at some
entered the market, and for good interesting robotics kits and accessories that can help
reasons – it was affordable, powerful, you put that extra Raspberry Pi to use. Some of these
and relatively easy to use. We have kits have Raspberry Pis integrated, but most just need
come a long way since the introduction you to add one of your own to make it complete. And
of the original Raspberry Pi back in 2012. for those of you that are Raspberry Pi-less right now,
Now you have a choice of small form factor Raspberry keep your eye out for inventory online. I do see them
Pis such as Raspberry Pi Zero W and the incredible pop up from time to time, and at reasonable prices.
power you can unleash from Raspberry Pi 4.
But there is one issue plaguing the Raspberry Pi
community, and that’s availability. Although I can’t say
exactly how many Raspberry Pi boards have been
sold, I can say it’s a lot! But as of lately, they have
become difficult, but not impossible, to find in stock.
And it’s not just Raspberry Pis that have become hard
to find, it’s basically everything, especially electronics.
And it stinks!
But there are a lot of DIY-ers out there that have an
extra Raspberry Pi in their stash of electrical FRIENDLY
components. You might have torn apart an old project, TIP
or you had the foresight to order a few extra when Try rpilocator.com
they were easier to find. Remember those days? to help you find a
Yeah, me neither. Raspberry Pi online!

104
FIELD TEST

MonsterBorg vs
Trilobot Base Kit
PIBORG $257 piborg.org PIMORONI $54.12 pimoroni.com

T
he MonsterBorg from PiBorg is a and you are ready to tackle
robust robotics platform for your the outdoors. PiBorg
Raspberry Pi. It features a custom motor claims you will get up
driver: the ThunderBorg. This allows you to three hours of run
to easily control a variety of DC motors time on ten AA
directly from your Raspberry Pi. The kit batteries. Adding a
includes four high-torque 300 RPM metal geared camera, GPS, and some
motors, a well-designed aluminium chassis, 105 mm additional sensors could
off-road tires, and a mount for a Camera Module. make for a great autonomous outdoor
No soldering is required. All you need to do is add robotics platform capable of withstanding
your Raspberry Pi, almost any standard variant will do, a fair amount of abuse.
Above
For when the
going gets tough

T
he Trilobot from Pimoroni is a sturdy
Raspberry Pi-based robotics kit. It was
designed with educational use in mind,
so it also has great documentation and
example files. The Trilobot features VERDICT
2WD, breakout headers for additional
sensors and accessories, six-zone under-bot lighting, MonsterBorg
status LEDs, and a front-facing ultrasonic sensor for A very robust
measuring distance. robotics platform.

9 / 10
The PCB is labelled for ease of use, even for a
beginner. Pimoroni has a full-featured Python library to
help you get up and running quickly. You can pick up
the Trilobot with or without a Raspberry Pi, so if you
are lucky enough to have an extra one and want to Trilobot Base Kit
build a bot, this is a great choice. Just remember, if you Add a Raspberry
go for the version without a Pi and get going!

9 / 10
Raspberry Pi, you’ll also need a
Left battery and a USB card for your
We love the
clear wheels Raspberry Pi to get going.

105
www.dbooks.org
Raspberry Pi Bots & Rovers

BEST OF BREED

Robotics Superset with pi-top [4]


PI-TOP $399.85 pi-top.com

T
he pi-top [4] robotics kit includes 50+
metal build plates, two servo
motors, two encoder motors,
wheels, camera, ultrasonic sensor,
and the pi-top controller. It’s designed
for autonomous and AI-based robotic
projects. You can pan and tilt the front-facing camera
ultrasonic sensor, allowing for a full 180º view of the
surrounding environment.
At the heart of the robotics kit is the pi-top [4]. This
module can be purchased with or without a Raspberry
Pi, and the robotics kit can be purchased with or
without the pi-top [4] module. The module allows your
Raspberry Pi to run without wires and integrates a
five-hour internal battery. It also has a heatsink, fan,
UPS power circuitry, touchscreen, speaker, and easy
access to Raspberry Pi’s GPIO pins. It’s a very
professional-looking and well-made enclosure. Head
over to the website to download additional resources
and learn more about the different pi-top robotics kits
that are available.

VERDICT
Robotics
Superset with
pi-top [4]
Well-developed
hardware.

8
Left
Add some

/ 10 intelligence
to your robot

106
FIELD TEST

Maker Pi RP2040 –
Motor and Robot Controller
ADAFRUIT $12.50 adafruit.com

T
his one is a little different from the
other reviews in this Best of Breed.
No, not because it isn’t a full robot, but
because it’s not the typical Raspberry
Pi. This motor controller features the
relatively recently released RP2040 Left
You can also use
microcontroller, not a Raspberry Pi-based single-board a Raspberry Pi
computer. Either way, it still makes for a great central Pico W
brain for your next robot build.
The Maker Pi RP2040 features a dual-channel
DC motor driver, four servo motor ports, and seven VERDICT
Grove I/O connectors. It can control two brushed Maker Pi
DC motors or one stepper motor, providing up to 1 A RP2040 – Motor
current per channel. It also has an array of LEDs, so and Robot
you can quickly check the status of various digital Controller
I/O states. It also has an on-board piezo buzzer and computer and it will immediately start playing a Makes building
several push-buttons. friendly tune. Add a few motors, click some buttons, bots easy!

9 / 10
To get you up and running quickly, the board already and you’re able to test your setup before you build a
has CircuitPython preloaded and preprogrammed with bot. This looks like a great way to get started with the
a simple demo program. Just plug it into your RP2040, and best of all, they are typically in stock!

RASPBERRY PI BUILD HAT

ADAFRUIT $25 adafruit.com

Who doesn’t love LEGO? It’s hard to find someone


who wasn’t obsessed with LEGO at some point in
their life. Young or old, it’s a universally fun
product. And it’s great to see the Raspberry Pi
Build HAT allows you to integrate your Raspberry
Pi and LEGO Technic motors and devices. And
since all the components are on the bottom of the
board, you can easily add a small breadboard or
LEGO board on top of it.

107
www.dbooks.org
Raspberry Pi Bots & Rovers

BEST OF BREED

RockyBorg
PIBORG $121 piborg.org

T
he RockyBorg by PiBorg features two
20 mm 180 RPM metal geared motors,
and a metal gear servo for leaning the
chassis into turns. It also comes with a
newly designed motor controller that is
compatible with your Raspberry Pi. The
body is made from laser-cut acrylic and features a
unique leaning motion that
would be interesting to see VERDICT
from the viewpoint of a
RockyBorg
forward-facing on-board
camera. The website has An interesting
bot platform.
more information, including

7 / 10
builds for controlling the bot
with a PS3/PS4 controller Left
Three wheels means
via Bluetooth. one less thing to
worry about

108
SUBSCRIPTION

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 109


www.dbooks.org
PLAY
& CODE
GAMES!
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


www.dbooks.org
Waveshare SX1262 LoRa

REVIEW

Waveshare SX1262 LoRa


Add to a Raspberry Pi Pico to create a networked sensor

Waveshare £14.50 inc VAT waveshare.com

By Rob Miles @robmiles

M
aking a connected device just make a device part of a LoRaWAN application. In an
got a bit easier and cheaper application, messages are sent to a local gateway
with the launch of a module that which provides a connection to a LoRaWAN service
allows a Raspberry Pi Pico to use running in the cloud. You can set up your own
the LoRa network. LoRaWAN infrastructure, but most people use ‘The
LoRa – short for ‘long Things Network’ (thethingsnetwork.org), which is
range’ – is a great way to send data over free to access and underpins a huge number of
Below considerable distances whilst operating from community-operated gateways. You can check the
You get a lot of kit
for your money, tiny batteries due its low power requirements. gateway coverage in your area by using the TTN
including a LoRa You can use LoRa to pass small messages mapper site (ttnmapper.org). Your programs can
antenna and a
rechargeable battery between devices, but it is much more useful to interact with a LoRaWAN application in a variety of
ways, including MQTT (Message Queuing Telemetry
Transport) endpoints. The Waveshare board is
supplied with an example that transmits values from
the temperature sensor on the Pico. You can connect

” You don’t just get the


device – you also get an
external antenna and a


rechargeable battery

more sensors to the Pico, and send their readings in


LoRa packets.
For your money, you don’t just get the device –
you also get an external antenna and a rechargeable
battery. You just need to add a Pico and any sensor
inputs or control outputs that you want to connect to
it. The hardware is especially well thought out. You
plug your Pico into it, but it also provides pass-
through pins to connect to other devices, or for
plugging into a breadboard.
You program the device in C++ using Visual Studio
Code. And this is where things start to get a bit
tricky. Installing Visual Studio Code on a computer is
easy enough, but configuring it to create Pico

112
FIELD TEST

Left
You have to solder
three extra pins onto
the top of your Pico
to connect the
debug signals

Below
This shows Visual
Studio running one of
the sample programs
that connects to
The Things
Network and sends
temperature values
to a LoRaWAN
application

Above
The device includes a power switch you can use to disconnect
the battery power. This is a great feature; it means that you can
manually power everything off without having to add power-
switching code in the program that controls the device

programs turns out to be a bit trickier. The


best solution is to use a Raspberry Pi as the
development device. The getting started guide (at
hsmag.cc/PicoGetStarted) describes how to use a You do this on The Things Network console web
batch file that sets up everything automatically. It page. Each device in an application has a unique
even shows you how to set up in-circuit debugging, address, and all messages sent by the device contain
which turned out to be very useful when testing this this address. Any messages the device sends are VERDICT
device. The in-circuit debugging works by linking the received by any gateway, and the device address is This board
Pico directly to the development device. C++ used to direct the message to the corresponding would be a
programs are compiled on the Raspberry Pi and then applications. And here we hit a snag. Whenever our
great way to
get started
sent into the Pico. The additional connections on the device tries to connect to LoRaWAN, it uses an
with LoRaWAN
top of the Pico are used to control the debugging incorrect device address. using the
process. Note that if you want to use the serial Fortunately, we traced the problem to a small part Raspberry Pi
output from the Pico to interact with your programs, of the driver that converts the addresses from text Pico. You get
you can connect the USB port on the Pico to a into the numeric values used in the transmission. an awful lot for
device and then run a terminal program on that Thanks to Brian N for his help with this. At the time your money.

9/ 10
device to talk to it. of writing, Waveshare is aware of the problem
Before a device can interact with a LoRaWAN and an updated version of its software will be
application, it must first be added to the application. available soon.

113
www.dbooks.org
ON SALE
18 AUGUST

HACK YOUR

FOOD
Also
PICO W
3D PRINTING
LASER CUTTING
ELECTRONICS
AND MUCH MORE

hsmag.cc/subscribe
www.dbooks.org

You might also like