Projects‎ > ‎

Arduino Lego GeoCache Box


I started this project in early 2011 with the intention of presenting it to my Dad as a locked box holding his birthday present in March. Due to life getting in the way, and the inevitable learning curve associated with Arduino, the GPS module, and some frustrating bugs the project fell way behind schedule. It wasn't until I volunteered to organise a GPS treasure hunt for my department's Christmas fun week, that I started thinking about finishing off this too. I had some help from someone at work who is a much better programmer than me. Thanks Ricky! Many late nights and lunchtime coding/testing sessions and we finally had something that worked well.

The inspiration came from a similar project by Mikal Hart which I think I read about on or some other similar geek news site. Details of his project can be found here
Thanks for the inspiration Mikal and several of your arduino libraries which I've made use of.

The early prototype used my first arduino board and was a rectangular box with a very deep lid. A total redesign took place with a single goal to make the lid no more than 2 lego bricks high (plus and extra 2/3rds for the top and bottom plates).  

What does it do?

After getting into geo-caching I was familiar with the concept of using a hand held GPS receiver and some magical signals from the sky to locate a box hidden somewhere in the countryside.
Imagine turning that idea on it's head. You already have the box in your hands, it's locked, and it will only open when you take it to a precise location on planet Earth.  Cool Idea, and I just had to build one.

Here is the finished box. (with two of the lid pieces in the wrong place - oops!)

It has a 16x2 display which tells you how many satellites are in view (0 on the dining room table), number of buttons presses you have left, and on the second line your current co-ordinates.
Each time you press the button on the bottom left corner the second line changes to tell you how many meters you are away from the target and the quota drops by one. Simples!

If you get within a dozen or so meters of the target before your quota hits zero then the locking mechanism will release on the next button press. The lid can then be lifted away from the bottom of the box and you then get to keep what's inside. Currently loaded with fun sized chocolate bars.

Let's take a peek inside...


There are two power circuits, one to drive the mini servo which unlocks the box. A pair of triple As do the job well. The other drives the arduino board with a 9V PP3 battery. The initial design had the servo hanging off the arduino which would crash as the current nose dived when the servo fired.

The locking mechanism consists of two pins which come out of the side of the lid and locate into holes in the base. The lid sits on 4 tabs in the corners. The pins had the be modified by beveling the ends to ensure a low friction transition into the holes otherwise the servo couldn't cope. I also cut it down to 2 pins from 4. The depth of the box has changed over time. It's current slim format was so that it would easily fit into my rucksack. 

As our plan was to send out around a dozen small teams to try to unlock the box, the eeprom was pre-loaded with an array of 10 co-ordinates. Holding down the button when the power jumpers are replaced (left then right) triggers a full reset where the locking mechanism closes and a random co-ordinate pair is chosen. The randomness comes from the value read from an initialised analogue pin.


From left to right, top to bottom:-
Servo battery, 2 line 16 character display, GPS module
2nd servo battery, servo, unlocking mechanism, arduino mini pro
3 button board, PP3 battery, power circuit jumpers, and reprogramming header
blobs of hot glue
lots of lego from the Mindstorms kit and my children's toy boxes

Detailed Components list

(coming soon)

Lego Plans

(coming soon)

Arduino Source Code

Source code can be found below. Please feel free to re-use or report bugs. If you build a similar box based on my design or code, then please send me a message/link and I'll add your project to the page. Of course please link to this page and give credit to Paul Mandell.

Credits and links

Arduino (start here if you're new to Arduino) 
Proto Pic (where I bought most of my kit from) 
Mikal Hart for the NewSoftSerial library and the idea for this project
Maarten Lamers for the NMEA GPS library
Ricky for the help with coding and testing at lunchtimes at work.
The teams at Hursley and Southbank who took the box out and tested it for me. :-)

anyone else I've missed - if you feel you deserve a link then please shout...

Paul Mandell,
15 Apr 2012, 13:18
Paul Mandell,
15 Apr 2012, 13:21