Build a Hidden Lock With a Magnetic Imager
<img src="https://spectrum.ieee.org/media-library/a-medium-sized-box-with-an-open-lid-inside-is-a-lock-mechanism-a-battery-pack-and-some-circuit-boards.png?id=68493268&width=1245&height=700&coordinates=0%2C385%2C0%2C386"/><br/><br/><p>Like many a nerd, I have a certain fascination with locks. This originates in reading the memoir<a href="https://archive.org/details/surely-you-re-joking-mister-feynman-richard-feynman/page/136/mode/2up" rel="noopener noreferrer" target="_blank"> <em><em>Surely You’re Joking, Mr. Feynman</em></em></a> as a teenager, in which Richard Feynman recounts picking locks and cracking combinations while at his day job working on <a href="https://spectrum.ieee.org/trinity-nuclear-test" target="_self">the Manhattan Project</a> at Los Alamos. I currently have a couple of <a href="https://en.wikipedia.org/wiki/Locksport" rel="noopener noreferrer" target="_blank">locksport</a> pick sets and training locks that I purchased at hacker conferences over the years (although I’m still terrible at it), and I delight in the YouTube exploits of folks like the <a href="https://www.youtube.com/channel/UCm9K6rby98W8JigLoZOh6FQ" rel="noopener noreferrer" target="_blank">LockPickingLawyer</a>.</p><p>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 is <a href="https://www.facebook.com/watch/?v=421986253303149" rel="noopener noreferrer" target="_blank">to conceal the existence</a> of 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, <em><em>any</em></em> strong magnet will open it.</p><p>So I started thinking about embedding an <a href="https://ibspot.com/us/products/rixiang-rfid-electronic-cabinet-lock-hidden-diy-for-wooden-cabinet-locker-drawer-cupboard-latch-lock" rel="noopener noreferrer" target="_blank">RFID reader under the surface</a> and resigning myself to keeping track of yet another access card. But then I stumbled across something much more interesting: SparkFun’s US $100 <a href="https://www.sparkfun.com/sparkfun-magnetic-imaging-tile-8x8.htm" rel="noopener noreferrer" target="_blank">magnetic imaging tile</a>. I realized I could use this to build a magnetic lock that opens with a programmable secret gesture.</p><p class="shortcode-media shortcode-media-rebelmouse-image rm-float-left rm-resized-container rm-resized-container-25" data-rm-resized-container="25%" style="float: left;"> <img alt="Major electronic components of the lockbox." class="rm-shortcode" data-rm-shortcode-id="00e27d194d3aa13bc81b5f11f16b4373" data-rm-shortcode-name="rebelmouse-image" id="6921a" loading="lazy" src="https://spectrum.ieee.org/media-library/major-electronic-components-of-the-lockbox.png?id=68493271&width=980"/> <small class="image-media media-caption" placeholder="Add Photo Caption...">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 detect magnetic fields [bottom].</small><small class="image-media media-photo-credit" placeholder="Add Photo Credit...">James Provost</small></p><p>The magnetic imaging tile is a small-run SparkFun board <a href="https://github.com/sparkfun/SparkFun_Magnetic_Imaging_Tile" target="_blank">based on the work of Peter Jansen</a>. It features an 8-by-8 grid of <a href="https://en.wikipedia.org/wiki/Hall_effect" rel="noopener noreferrer" target="_blank">Hall-effect</a> sensors, and uses an <a href="https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all" rel="noopener noreferrer" target="_blank">SPI interface</a> to 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.</p><p>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 an RFID reader. The copper sheet would act as a <a href="https://en.wikipedia.org/wiki/Faraday_cage" rel="noopener noreferrer" target="_blank">Faraday cage</a>, blocking any RFID signal, along with any other electromagnetic fields an attacker with an EMF meter might use to locate the lock.</p><h2>Choosing the Brains of the Box</h2><p>I chose a <a href="https://www.sparkfun.com/teensy" rel="noopener noreferrer" target="_blank">Teensy 4.1</a> as 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.</p><p>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).</p><p class="pull-quote"><span>In extreme paranoia mode, I could shield the entire lock behind copper sheeting.</span></p><p>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 of <em><em>IEEE Spectrum</em></em> on <a href="https://spectrum.ieee.org/reviving-teletext-for-ham-radio" target="_self">creating a teletext suite for ham radio</a>, you’ll know I’ve been grappling with how vibe coding should be used in DIY projects, 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 at <a href="https://github.com/IEEESpectrumHandsOn" target="_blank">https://github.com/IEEESpectrumHandsOn</a>.</p><p>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.</p><p>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.</p><p class="shortcode-media shortcode-media-rebelmouse-image"> <img alt="A diagram showing negative and positive charge carriers being separated towards different edges in the presence of a magnetic field, and a grid of sensors readings beneath the stroke line of a gesture." class="rm-shortcode" data-rm-shortcode-id="800afd64839d8686c49854d2645e5584" data-rm-shortcode-name="rebelmouse-image" id="c3a69" loading="lazy" src="https://spectrum.ieee.org/media-library/a-diagram-showing-negative-and-positive-charge-carriers-being-separated-towards-different-edges-in-the-presence-of-a-magnetic-fi.png?id=68493270&width=980"/> <small class="image-media media-caption" placeholder="Add Photo Caption...">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]. </small><small class="image-media media-photo-credit" placeholder="Add Photo Credit...">James Provost</small></p><p>Of course, I needed something to lock to demonstrate my proof of concept. I bought a <a href="https://www.michaels.com/product/85-wood-trinket-box-by-make-market-10357776" target="_blank">wooden craft box</a> and 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 NPN transistors. These convert the Teensy’s 3.3-volt control signals to a 5-V signal needed to drive the servo.</p><p>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 I <a href="https://spectrum.ieee.org/watchy-the-hackable-50-smartwatch" target="_self">once again turned to mining my Irish heritage</a>. I created a <a href="https://en.wikipedia.org/wiki/Celtic_knot" target="_blank">Celtic knotwork pattern</a> that runs in a band across the front of the lockbox (I used an <a href="https://dmackinnon1.github.io/celtic/" rel="noopener noreferrer" target="_blank">online knotwork generator</a> and 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 from <a href="https://spectrum.ieee.org/weave-your-own-apollo-era-memory" target="_self">a ferrite core-memory kit</a> we featured in 2022.)</p><p>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 hidden inductive charging coil. Nonetheless, the demo lockbox works well—now I just have to think what I should store in it!</p>
Read original article ↗
Related Articles
Micron plans to use wafer bonding and High-NA EUV for next-gen DRAM
Micron rejects 4F2, intends to use wafer bonding and High-NA EUV before going 3D NAND over the next few years.
Kevin Roose is AGI-pilled. Why aren’t you?
Today, I’m talking to Kevin Roose, journalist and author of the new book The AGI Chronicles, which details the recent an
Custom Arm-Based SoC Design Services
Custom Arm Processor Integration, ASIC Design and Turnkey SoC Development Developing a custom Arm-based System-on-Chip (
As device architectures shrink and move into 3D, the process windows for atomic layer processes have narrowed to the poi