The Reverse Geocache™ Puzzle

[Author's note: This post is the first in a real-life story that ultimately took a full year and four chapters (1, 2, 3, 4) to tell. Read them all, then browse through the other surprising puzzle box stories that have popped up along the way.]

Early this summer, the friend who first introduced me to Arduino amazed us with the news that he was moving to France to get married. Once I recovered from the surprise, it occurred to me that putting together some sort of Arduino-based wedding present might be a uniquely fitting thanks for his years of friendship and for helping get me started in this delightful enterprise. And so after weighing several ideas — I didn’t fancy adding some ugly techno-junk to the pretty collection of tea cozies and china sets — I finally settled on building the device I describe here: a puzzle box that won’t open until it is taken to a certain location.

To better understand my conception, let’s fast forward and imagine the gift opening. The new couple, freshly back from their honeymoon, remove the wrapping to reveal a book-sized wooden box elaborately carved with elephant images. (I didn’t carve it; I bought it that way at World Market.) Mounted into the lid, perhaps incongruously, are an illuminated button, a small display, and a mysterious module that sharp-eyed readers might recognize as a GPS. There’s also some kind of connector tucked away on the box’s left side. More about that later.

What do they make of all this? It’s hard to guess, but naturally I imagine they might try to open it up and take a look inside. When they do, however, they find the lid stuck tight — it seems to be latched from the inside. Will they push the button? Pretty buttons are awfully hard to resist, so let’s assume so. The blue display fires up and displays a friendly, personal greeting:

Bonsoir, famille Immel! This is attempt 1 of 50.

Huh?

Now they don’t know this yet, but the box’s embedded electronics require a good GPS fix – something that’s probably hard to come by inside a Parisian apartment. And so the display flashes “SEEKING SIGNAL” for a couple of minutes and gives up.

No signal acquired... Powering off...

Now my hope is that they’ll realize they need to take the box outdoors or near a window. Is that a stretch? I don’t think so. My friend is a patient fellow with an engineering background, so I expect he will at least try moving it before throwing it against the wall or chiseling off the hinges. Let’s assume, then, that they go outside and push the button again. This time the series of messages is different:

This is attempt 2 of 50. Distance 391km *Access Denied* Powering off...

Hmm. What does “Distance 391km” mean? “Access Denied” suggests that getting inside the box is indeed the objective of all this button pushing. Just for fun, let’s try again.

This is attempt 3 of 50. Distance 391km *Access Denied* Powering off...

Uh oh. We seem to be consuming our limited supply of “attempts”. The “No signal” problem seems to be solved, but the message “Distance 391km” remains puzzling. Does the box know its own location? Is there something 391 kilometers away? London? The Hague? A circle of that radius drawn around Paris intersects quite a few interesting places in France, England, Holland, Switzerland, and Germany.

Knowing my friend, he will eventually think to move the box to a new location to see how the message changes. Let’s imagine, then, that he hops in his car and motors down the A11 to the famous city of Le Mans, about two hours to the southwest. After a brief tour of the cathedral and a snack at a sidewalk café, he pulls the elephant box from his backpack and pushes the button again.

This time the display is once again slightly different:

This is attempt 4 of 50. Distance 226km *Access Denied* Powering off...

Aha. We seem to be getting somewhere. If we are in fact looking for a specific place, it would appear that it is 391 kilometers from Paris but only 226 from Le Mans. As you can see by the map in Figure 3, there are only two places on earth that meet these criteria – a spot just off the northern Brittany coast, and a rural area in the southwest near Bordeaux. And, as my friend is aware, one of these can be quickly eliminated simply by taking a third “reading” in a new spot.

I suspect that from here things will proceed relatively quickly. My friend will triangulate that the “magic spot” is Île-de-Bréhat, a tiny island just a short ferry ride off the northern coast of Bretagne. If and when the couple do bring the box here, they’ll be greeted with a congratulatory “Access Granted!” and the whir of a motor announcing that the treasure inside is about to be finally revealed!

Hardware

The electronics for this project are fairly simple. At the core, of course, is the Arduino, surrounded by a handful of devices that talk harmoniously through various native and third-party libraries. The peripherals are wired to a custom “shield” that I soldered together. The shield design makes the system modular and easy to disassemble for moving. Power is provided by 4 AA lithium batteries mounted in the box’s interior.

Major components

1 Arduino Duemilanove

1 USGlobalSat EM-406A GPS module

1 8×2 blue backlight HD44780 LCD

1 Hitec HS-311 servo motor

1 illuminated pushbutton

1 low voltage Pololu power switch

1 2.5mm female DC power connector

1 Adafruit Arduino prototype shield

1 ornamental box

Minor components

1 severed chopstick used as latching dowel

3 #14 eyelet screws

1 Battery pack with 4xAA lithium batteries

Various mounting screws and glue

Wire, headers, solder, and other circuit connecting items

I designed this project to last a long time. The batteries are locked inside the box and can’t be replaced if they run down — not while the puzzle remains unsolved, anyway — so it’s important to conserve power. That’s why a given “session” lasts at most 2-3 minutes before the system powers off. Furthermore, the owner is allowed only 50 attempts to discover the box’s secret, so the active lifespan of the batteries need be no more than about 150 minutes. Between sessions, the electronics draw virtually no power and should last idle for years.

The secret to this power conservation is the clever little Pololu switch, which gives a circuit the ability to completely turn itself off through software. When you push the button, it latches and distributes power to the system. When the sketch decides it’s time to shut down — either because it can’t find a GPS signal or it’s not close enough to the target — it simply brings the Pololu’s power control pin high, cutting power. In this “off” state the switch draws just 0.01 microamps.

Like most GPS units, the EM-406A generates a stream of NMEA position data. This stream enters the Arduino via a “soft” serial port managed by my NewSoftSerial library. The NMEA data is parsed into latitude/longitude using TinyGPS, a popular library I built especially for this project. If the GPS is getting a good fix, the box can determine its location within 10 meters and, through a simple calculation, how close it is to the target.

The display is an HD44780-compatible device controlled by the Arduino LiquidCrystal library. I wanted to incorporate some visual effects like flashing and scrolling, so my sketch contains several custom display routines. These were carefully written so as not to block the all-important serial input stream coming from the GPS.