Stephen Cass is the special projects editor at IEEE Spectrum. Only a programmable secret gesture with a magnet can open this lockbox. Or a hammer.

Stephen Cass is the special projects editor at IEEE Spectrum. Only a programmable secret gesture with a magnet can open this lockbox. (Or a hammer. It’s a proof of concept.) Like many a nerd, I have a certain fascination with locks. This originates in reading the memoirSurely You’re Joking, Mr. Feynmanas a teenager, in which Richard Feynman recounts picking locks and cracking combinations while at his day job working onthe Manhattan Projectat Los Alamos. I currently have a couple oflocksportpick sets and training locks that I purchased athackerconferences over the years (although I’m still terrible at it), and I delight in theYouTubeexploits of folks like theLockPickingLawyer. All of which left me wondering if I could try building an interesting lock. One dodge that lockmakers have long used to challenge would-be plunderers isto conceal the existenceof the lock itself. A modern variant of this is the magnetic lock, where a magnet is held or slid against an innocuous portion of a door or box, releasing a catch. The problem with this is that, once you guess the location of the lock,anystrong magnet will open it. So I started thinking about embedding anRFID reader under the surfaceand resigning myself to keeping track of yet another access card. But then I stumbled across something much more interesting: SparkFun’s US 100magneticimagingtile.IrealizedIcouldusethistobuildamagneticlockthatopenswithaprogrammablesecretgesture.Iusedafewdiscretecomponentstodrivetheservomotorandputthelockintoprogrammode[top],controlledbyaTeensy4.1microcontroller[middle].AnarrayofHall−effectsensorsdetectmagneticfields[bottom].JamesProvostThemagneticimagingtileisasmall−runSparkFunboardbasedontheworkofPeterJansen.Itfeaturesan8−by−8gridofHall−effectsensors,andusesanSPIinterfacetotalktothemicrocontrollerofyourchoice.Thesesensorscandetectboththemagnitudeandpolarityofamagneticfield,andtheboardcanreportitsmeasurementshundredstothousandsoftimespersecond,dependingonhowmuchprocessingpoweryourmicrocontrollerhasavailable.Thisiseasilyfastenoughtocapturethemotionofamagnetbeingmovedbyhandacrosstheboard’ssensorarea—mysecretgesture.AninterestingthingaboutusingmagneticfieldsisthatifIwasinextremeparanoiamode,Icouldshieldtheentirelockbehindcoppersheeting,somethingIcouldn’tdowithanRFIDreader.ThecoppersheetwouldactasaFaradaycage,blockinganyRFIDsignal,alongwithanyotherelectromagneticfieldsanattackerwithanEMFmetermightusetolocatethelock.IchoseaTeensy4.1asmymicrocontroller.IliketheTeensybecauseitoffersloadsofinput/output,a600−megahertzprocessor,amegabyteofRAM,andabuilt−inSDcard,allinaslimpackagewithanequallyslim100magnetic imaging tile. I realized I could use this to build a magnetic lock that opens with a programmable secret gesture. I used a few discrete components to drive the servo motor and put the lock into program mode [top], controlled by a Teensy 4.1 microcontroller [middle]. An array of Hall-effect sensors detectmagnetic fields[bottom].James Provost The magnetic imaging tile is a small-runSparkFunboardbased on the work of Peter Jansen. It features an 8-by-8 grid ofHall-effectsensors, and uses anSPI interfaceto talk to the microcontroller of your choice. These sensors can detect both the magnitude and polarity of a magnetic field, and the board can report its measurements hundreds to thousands of times per second, depending on how much processing power your microcontroller has available. This is easily fast enough to capture the motion of a magnet being moved by hand across the board’s sensor area—my secret gesture. An interesting thing about using magnetic fields is that if I was in extreme paranoia mode, I could shield the entire lock behind copper sheeting, something I couldn’t do with anRFIDreader. The copper sheet would act as aFaraday cage, blocking any RFID signal, along with any other electromagnetic fields an attacker with an EMF meter might use to locate the lock. I chose aTeensy 4.1as my microcontroller. I like the Teensy because it offers loads of input/output, a 600-megahertz processor, a megabyte of RAM, and a built-in SD card, all in a slim package with an equally slim 32 price tag. Wiring the Teensy to the magnetic-imaging tile was trivial, only complicated by the fact that one side of the board has a silk-screen error that misidentifies the SPI connections (SparkFun says this will be fixed in future runs of the board). In extreme paranoia mode, I could shield the entire lock behind copper sheeting. To create the gesture-recognition software, I once again turned to vibe coding. If you read my Hands On piece in the April 2026 issue ofIEEE Spectrumoncreating a teletext suite for ham radio, you’ll know I’ve been grappling with how vibe coding should be used inDIYprojects, if at all. So this time, instead of letting Claude write all the software, I confined it to writing just two support libraries, which you can find in our online repository athttps://github.com/IEEESpectrumHandsOn. One library is in charge of recording a lock gesture and saving it to the Teensy’s nonvolatile storage. The other library monitors the tile and reports whether or not a newly detected gesture passes a selectable threshold to be considered a match. I wrote the top-level code myself to keep it as DIY as possible. This code handles things like a button that puts the system in gesture-recording mode after a brief delay, the indicator LED for recording mode, and the code that operates the physical locking mechanism. Hall-effect sensors rely on a current passing through a p-type slab of silicon. A magnetic field passing through the silicon deflects charge carriers toward the edges of the slab, creating a voltage proportional to the field [left]. By looking at the intensities of the voltages across an 8-by-8 grid of sensors, the microcontroller can reconstruct a gesture [right].James Provost Of course, I needed something to lock to demonstrate my proof of concept. I bought awooden craft boxand removed the existing lid latch. I glued a notched beam inside the lid and built a mechanism that uses a servo motor to rotate another beam in and out of this notch. I will be the first to admit this mechanism goes beyond “simple” and into “simplistic,” but it’s sufficiently robust for my demo. The box has ample room for the magnetic imaging tile to be mounted against one wall, along with the Teensy and other supporting electronics. These include a battery pack, the recording button, and a small additional board with two NPNtransistors. These convert the Teensy’s 3.3-volt control signals to a 5-V signal needed to drive the servo. Once it was all put together, I soon discovered that the small size of the magnetic tile’s sensing area—just 3 centimeters square—made it easy to fit the tile inside the box but hard to do the unlock gesture on the outside so that it is read correctly. Marking the outline of the sensor area on the outside defeated the point of having a hidden lock, so instead Ionce again turned to mining my Irish heritage. I created aCeltic knotwork patternthat runs in a band across the front of the lockbox (I used anonline knotwork generatorand then projected and traced the pattern onto the box). Using the pattern as a camouflaged reference grid I can make a repeatable gesture within the confines of the sensor area. (To make the gestures I’m using a magnetic stylus borrowed froma ferrite core-memory kitwe featured in 2022.) There’s obvious room for improvement in any more serious installation. The biggest drawback currently is that if the box is locked when the battery runs out, you can’t open it again without breaking something. This could be solved by adding a hiddeninductive chargingcoil. Nonetheless, the demo lockbox works well—now I just have to think what I should store in it! Stephen Cassis the special projects editor atIEEE Spectrum. He currently helmsSpectrum'sHands On column, and is also responsible for interactive projects such as theTop Programming Languagesapp. He has a bachelor's degree in experimental physics from Trinity College Dublin.