Treasure Chest

A treasure chest that opens up when you reach a specified location.

Similar projects worth following
I wanted to make a box that opened up a given location. My motivation was to add a twist to classic scavenger hunts. Instead of going around and just finding objects or clues in different places, you would have to bring the object to the place for it to work. Follow a map and you will find the treasure.


What I did?

I made one really quickly using an Arduino and shield and a wooden box I found at Michael's. The box was flimsy and my assembly of everything into to it was with a glue gun. It was not a great presentation but it did work.
  • Box
  • Arduino Uno
  • GPS Shield
  • LiPo Battery
  • Solenoid
  • Extra-circuit to drive the solenoid
  • Vibration motor
  • Plastic bits to align the solenoid and make it latch
I tested it by setting the location to my work address and hoped it would vibrate when I got to work, indicating it found the location. This took a lot more trips than I would have hoped and there were better ways of debugging it but that seemed like the least effort.

What I want better?

While the Proof of Concept worked it wasn't all that great. I wanted to improve a lot.

The Box

First and foremost it was really flimsy and wanted to make a more robust version that I wouldn't be worried about someone dropping 1 inch.


The box would take a really long time to acquire the GPS signal.

Battery Life and Charging

The battery life on it was pretty poor and charging it was a pain. The shield I had, you couldn't charge the battery and use it at the same time which was kind of annoying and easily fixable.

Locking mechanism

I wanted to improve it so it would be more reliable in both locking and unlocking. No hoping and wishing it would actually unlock. Also, wanted to add some delight to how the box opened.


Wanted to create a user friendly way to set the secret location of the box. The system had it compiled in and now way to change the location without a using Arduino IDE.


I am working on the second version of it. It's using custom electronics instead of an Arduino board.

The mechanical aspect is still the hardest part for me.

Currently working on the firmware and integrating everything.


* Using an off the shelf box, with some modifications

* Solenoid is used to latch the box closed.


* Electronics are functioning

* Based on PIC16F15345 and L80-R GPS

* Charges a LiPo from USB

* Drivers for vibration motor and solenoid



  • 1 × Microchip PIC16F15345
  • 1 × Quactel L80-R GPS module with incorporate antenna

  • Close Enough

    Door Pop09/17/2020 at 22:04 0 comments

    I decided to stick to 16F15345 and see where I can reduce code.

    I wanted to use the haversine formula to calculate distance between the current location and the secret location but did not have enough program memory to do floating point operations. So I started scaling things down, start using equarectangular approximation and then a cosine approximation.

    To approximate cosine I used the CORDIC algorithm in fixed point.

    After all that, I realized I don't need to any of that math and can just see if the difference between my two coordinates is small enough. It's not an exact distance but it's close enough.

  • Mistakes and dilemmas

    Door Pop08/19/2020 at 00:05 0 comments

    I started running out of space on the PIC16F15345, so I ordered what I thought was a drop in replacement with more memory. I made a mistake, the PIC16F18346 is not.

    First issue is that it only has one UART port and I need two. I haven't looked through all the differences yet but trying to think through my options. There are no other 20 pin PICs that seem to fit. 

    1. Use the 16F18346 and write or find a software defined UART library.

    2. Go back to 16F15344 and see if I can squeeze everything I need into the memory. This is toughy because there is some geometry calcs that are needed. Also want to eventually use a bootloader for flashing.

    3. Respin the board for a bigger MCU. I plan on respining the board eventually but not for this version. Seems wasteful to do it now. 

  • Locking clip

    Door Pop08/17/2020 at 18:13 0 comments

    Took a long time to get this locking clip in. I tried just chiseling away the wood and have the solenoid latch to the wood but that didn't work so well. I made the clip but it was very hard to screw it in. The space is very tight and I didn't have a way to pre-drill. It came out a bit crooked but works.

    Only downside is that the solenoid needs to be retracted before you can lock the box. That can be done with a finger or through a command.

  • Solenoid mounting

    Door Pop08/11/2020 at 00:55 0 comments

    Took me a long time to figure out how to mount the solenoid. Milled out a little mounting plate.

  • GPS Configuration

    Door Pop07/22/2020 at 00:48 0 comments

    Spent some time debugging GPS communication. I couldn't get the GPS to respond to my configuration commands. Turned out it was all on the terminating characters. For some reason, which I haven't spent time understanding, sending "\r\n" is not the same as sending 0xD 0xA.

  • Mechanical troubles

    Door Pop07/21/2020 at 12:32 0 comments

    The mechanical portion of this has been a struggle every step of the way. Worked on trying to install the latch plate, but can't get a screw driver in, so using tacs for now.

    Also noticed the assembly that's holding the solenoid to the board is loose. I will need to add some lock washers to get a bit more bite.

  • Firmware work continues

    Door Pop07/17/2020 at 01:05 0 comments

    Today been fixing some issues with integrating the different pieces of firmware. Had to trouble getting GPS to read out but can now read it but not getting a fix. Not sure what changed as it used to work.

    Also got the solenoid to fire on command, because it's fun.

View all 7 project logs

Enjoy this project?



Dan Maloney wrote 07/13/2020 at 17:07 point

I like the reverse scavenger hunt idea. I used to geocache with my family a lot, so I can see the appeal of finding a location to open the prize.

  Are you sure? yes | no

Door Pop wrote 07/15/2020 at 00:00 point


  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates