Introduction: Puzzling Treasure Chest Opens Using Twitter and Wireless Energy
A puzzling present! My "victim" is given three boxes:
- A very small box locked with chains and a padlock.
- A locked small box with no outside locks, that is closed and has a reflective upper lid.
- A big pirate-y treasure box.
Opening the treasure box reveals a treasure map glued to the bottom. Searching shows a power cord coming from the back of the treasure box. When connected, LED's light up below the treasure map, indicating the treasure location. When the smaller box is placed on the treasure location, wireless charging is used to start the electronics in the smaller box. LED's below the reflective lid of the smaller box light up, revealing a hashtag. When the hashtag is twittered, servo's unlock the smaller box and open it's lid, to reveal a small key. The key fits on the padlock of the smallest box, which when opened, reveals the final gift.
This is a "Sinterklaas Surprise", a dutch tradition that requires some explanation for the un-initiated. At saint Nicks eve (Sinterklaas-avond), december 5th, Saint Nick brings gifts to homes in the Netherlands. Little kids get (mostly) toys and candy. Older kids and grown ups, however, get a "surprise". This is a gift that is elaborately wrapped / hidden in a home-crafted packaging that illustrates some aspect of the gift-receiver. You like football? You might get your gift wrapped in a 3 feet cardboard jersey of your favorite team. See this blog for some more details as a Canadian expat living in the Netherlands describes the weird tradition.
Personally, when making "surprises", I like to make them interactive and somewhat of a puzzle. (No surprise for people that have seen my other instructables, read my columns [dutch] or bought my book [dutch]). The "surprise" that I make in this instructables is for Astrid Poot, initiater of the "klooikoffers" (tinker-boxes). The "surprise" is a treasure chest, referring to Astrids chests full of goodies that the klooikoffers are. The puzzle elements are heavily influenced by a visit to the "Sherlocked" escape room in Amsterdam.
To build this surprise, I used
- Soldering Iron
- Hot Glue Gun
- Jig Saw
So if you are not familiar or uncomfortable working with these tools, look up a nice tutorial instructable before moving on.
Step 1: Materials and Tool
You will need:
- Three boxes: one (small) box to hold the gift, one small box that will hold the electronics and the key to the other small box. One big box that will hold the treasure map. The small box has to easily fit in the big box. If you can get your hands on a big box that already has a pirate-y look: all the better.
For the big treasure chest:
- A plank, can be some scrap wood, about as thick as the IKEA charger (2 cm) and as large as the big box.
- A treasure map that fits in the big box. I used this one.
- 4 flickering candle LEDs. I source them from a local shop near my house, you can find them online here [US] or here [US]. any other LED (that works fine on 5V with a 220 Ohm resistor) is also fine, but those candle LEDs add a lot of atmosphere.
- 4 220 Ohm resistors.
- An old USB plug
- Some wire
- construction glue
- An IKEA NORDMARKE wireless charging station.
For the box containing the electronics:
- A photo frame about as big as the lid of the box. See picture: it must have a considerable edge so you can have the LEDs mounted beneath it.
- An additional piece of glass as big as the photo frame. (I just bought two identical frames).
- reflecting window film (this stuff). You only need as much as the size of the photo frame.
- 6 flickering LEDs (see above)
- 6 220 Ohm resistors.
- some wire
- two servo's that run on 5V and accept 3.3V logic, for example these from Sparkfun [US] or Floris.cc [NL].
- a small L shaped piece of metal with a hole for a screw in it. (This must have a ridiculous easy name in English that I just cannot find).
- An IKEA VITAHULT charging cover for Samsung S3.
- a tea coaster or something similar that you want to cut apart and is as thick as the charging cover (about 2 mm max)
- a rod of wood (popsicle stick will do).
- some tiny screws.
- A Particle Photon
- A breadboard (included if you buy the Photon Starter Kit).
For the smallest box with the gift:
- enough chain to run a few times around the box
- a small padlock that fits through the chain links.
- a gift for the "victim", nicely wrapped. I gave Astrid a Particle Photon.
And you will need the following tools:
- hot glue gun
- soldering iron + solder
- stripping pliers if uncomfortable stripping using regular pliers.
- construction glue gun
- power drill with 5mm wood drill bit and 10 mm wood drill bit.
Finally, the Photon will need to be flashed (ie. uploaded) with a program that I wrote. If this is your first time working with a Photon, I strongly recommend to first follow the tutorials on the Particle website.
And with all these warnings out of the way: let's make some stuff!
Step 2: Box 1: the Actual Gift.
We start with the easiest part: the actual gift box.
Wrap the gift in nice wrapping paper. Put in the box. Wrap the chain around the box as tightly as possible. Connect the ends of the chain using the padlock. Check if you can open the box by moving around the chain. If you can, glue the ends of the chain to the box using some hot glue, but be careful to do it in such a way that the box will still open when the padlock is unlocked.
Step 3: Box 2: the Electronics Box: the Lid.
The electronics box is quite complex and will be made in a few steps. The first step is to make the lid, which has a halfway mirror on top, with light beneath. When the lights turn on, a twitter logo and hashtag become visible.
If the box is not already made of dark wood, paint it in a dark colour. This is especially needed for the lid.
Cut a piece of window film the size of the glass of the photo frame. Apply it to the class per the instructions that come with the film. (Basically, make the glass slightly wet, apply film, use ruler to force the water out).
Using a sharpie or permanent marker, draw a twitter-logo and an appropriate hashtag (ie. #opensurprise) on the second piece of glass: in mirror writing! Put the second piece of glass on top of the film. Hot glue the two pieces of glass with the film in between back into the photo frame. Hold the photo frame up to the light, looking from the top, you should now be able to read the hashtag.
Using a 4 mm drill, make six holes in the lid. Push six LEDs through the holes (light side up). Make sure you can still recognise the cathode (short leg) and anode (long leg) of the LEDs for the wiring step. The holes should be snug, so no glueing required. Put construction glue on the bottom of the photo frame and press it firmly on the lid of the box.
Step 4: Box 2: Servos, LEDs, Photon
screw the little rod (popsicle stick?) on one of the servos. Screw and hot glue the L-shaped metal into the lid as shown in the picture. The servo with the rod will be opening the lid, the other servo will be locking / unlocking the box. Carefully measure where the other two servos have to go and use hot glue to fix them in their places.
Click the Photon in the breadboard as shown in the photo. Run a wire from the "+" line on the breadboard to the Vin on the Photon and another one from the "-" line to the GND on the Photon. Place the breadboard in the box (I did not glue it in place). Connect the servos: black (sometimes brown) lines go to the "-" line on the breadboard. Red lines go to the "+" line of the breadboard. Finally, the yellow data lines go to the Photon. The data line of the "lock"-servo goes to A5 on the Photon and the "lid"-servo goed to the A4 on the Photon.
Solder a 220 Ohm resistor to each LEDs cathode. Than, connect all resistors to each other and all anodes to each other. Solder a wire from all the resistors to the "-" line on the breadboard. (I always solder half a breadboard wire on the end of my lines, to easily put them in the breadboard). Solder a wire from the anodes to the "+" line on the breadboard.
We are now going to test if everything works, before attaching the wireless charging station.
Step 5: Box 2: Photon Firmware and Tests
Connect the Photon to a power source using USB. If not already done so, claim the Photon using the steps on www.particle.io/start. Then, flash the firmware for the surprise. This can be downloaded from my github repo here. If unfamiliar with flashing a Photon, please practice first with a few examples found on the Particle website.
After flashing the code to the Photon, two functions will be available through the Particle cloud service. These are "testSurprise" and "lock". Both functions take a string as input and have two valid inputs: "open" and "close". The lock function only operates the lock servo. The testSurprise function operates both servos. When it receives an "open" it will first unlock using the lock servo and than open the lid using the lid servo. And vice versa for close. Note that the code will freeze intentionally after it has received an "open" on the testServo. This is because by locking the code, the lid gets locked in the open position.
At this point you want to check that calling these functions indeed performs the intended actions. Calling functions on your Photon can be done using a few options:
- using the Particle Dev program (preferred way). Make sure your Photon is selected and open the "Particle Functions" menu.
- Using IFTTT. Particle has an IFTTT channel where "calling a function" is an action that can follow a trigger. I personally like to use the IFTTT "DO" app for testing this when I do not have access to Particle Dev.
- Using the Particle Command Line Interface (CLI). You will need to install the CLI, and than call the Particle Call function.
- by making a direct http call to the particle cloud. Can be done in the browser, but is more easily done using tools such as curl. See explanation on the Particle Cloud API here.
When testing, you may find out that for your particular box design, the angles set in my firmware need to be slightly adjusted. Play around until just fine. Than unplug the USB powering the Photon and proceed to the next step: powering box 2 using the wireless charger.
Step 6: Box 2: Add Wireless Charging
Using a Dremel, very carefully (wear safety goggles!!), trim the outer plastic from the Samsung charging cover. Solder wires to two metal contacts of the cover. I used standard color coding to make it easy for myself to connect it later on. Position the cover in the centre of the (bottom of the) box. Mark where the contacts are and drill a hole in the bottom of the box Route the wires through it. The lower contact will be connected to the "-" line of the breadboard and thus to the GND of the Particle. The upper contact will be connected to the "+" line of the breadboard and thus to the Vin of the Particle.
Test if everything is nicely powered when you put the charging cover on the charing station (do not forget to hook up the charging station). Maybe check the servo's again as well. Only when everything works, hot glue the charging cover in its place on the bottom of the box. Cut the tea coaster in four pieces and glue these on the corners of the bottom of the box. This stabilises the box when put on the ground.
Now put the small box in the larger box, giving it power. Use the online tools from the previous step to open the lid. Place the key to the padlock inside the box and use the online tools to properly close it. Take it of the charger and wrap it in gift paper.
This finishes the work on box 2. We now move on to the final box: the big treasure test.
Step 7: Box 3: the Treasure Chest
Cut the plank to the size of the (inside of the) treasure chest. Put (but don't glue!) the treasure map on the plank and make a pinhole with a nail or needle where you want the treasure chest to be. Take the map from the plank, put the charging station on the centre of the pinhole just made and draw a circle about a centimeter larger than the charging station using a sharpie. Cut that circle from the plank using a jigsaw.
Set the charging station on a table and hook it up. Lay the plank over the charging station, with the station snug in the newly cut hole. But the electronics box on the charging station in such a way that it gets power (the LEDs in the lid light up). Mark the location of the corners of the electronics box on the plank: these will be the location of the LEDs. Drill 4 mm holes in the plank at the marked location. Push in LEDs (from below!). Make sure you know which leg of the LED is the cathode and which is the anode. Just as with the LEDs in the lid of the electronics box, solder 220 Ohm resistors to all the cathodes. Than solder wires that connect all the resistors and another wire that connects all the anodes. Take apart an old USB plug and use the solder the anodes to the 5V and the resistors go to the GND pin of the USB plug. If unsure: measure using a voltmeter.
Drill a hole of 10mm in the back side of the box as close as possible to the bottom. Feed the power cable from the charging station through this hole. Using some scraps from the plank, make "feet" (see photo) to elevate it. Put the charging station on the circle just cut out and slide the plank into place. Stick the USB plug in the USB port of the charging station. At this point: double-check if the LED's light up when the charging station is hooked up. If it does: make a little happy dance. Than glue the treasure map onto plank and wrap the big box up in gift paper!
Step 8: The Online Part: Ifttt Recipes
To finalise, we need to make sure that the "testSurprise" is called when the "victim" sends out a tweet with the correct hashtag. There are a few ways to achieve this and I will only present the easiest one, which is using IFTTT. For those unfamiliar with IFTTT: it lets you tie two webservices together using what they call "recipes", but without you having to write any code. All recipes follow the If This Than That structure. A simple example would be a recipe that says: "If I post a photo on Facebook, Than store that photo in my dropbox."
What I want IFTTT to do is call a function on a Photon when someone else (the victim) sends a tweet with a specific hashtag. The problem is, you can trigger (the if-part) on a tweet with a specific hashtag by yourself, but not by others. So you need two recipes: first, you activate this recipe, which lets you call a function on one of your Photons when you tweet with a specific hashtag. Secondly, you activate this other recipe, which automatically lets you retweet anything that someone else tweets. Be very careful with the second recipe: if you leave it on for too long, twitter might flag your account as a bot (rightly so by the way!). So only turn this recipe on when testing and moments before the big final unwrapping.
Step 9: Give It Away!
and that is it! Give it away to someone you like, your secret Santa, or if your dutch: as a "Sinterklaas surprise!". Add a note (or, if your dutch: a "Sinterklaas gedicht") in which you explain that the boxes should be unwrapped smallest to largest and that no force, only brainpower is needed to get to the final gift.
Enjoy! I certainly enjoyed making it!
Step 10: Some Final Thoughts
A few final thoughts:
- I made this contraption to illustrate how the things I describe in my book can be combined to make new things. Ideas and parts from my steampunk-wireless-charging-lamp-thing, my infinity-mirror-table-thing and my bad-weather-warning-coat-rack all were used in this "surprise". This does mean that some parts could have been made at lower cost, maybe even easier, than the way I did it. For example: the wireless charging can also be achieved using this way cheaper part from Sparkfun. I just really liked the idea to use IKEA stuff for unintended purposes.
- The way the lid opens is not perfect and can certainly be improved upon given more time / money / energy.
- The letters under the halfway mirror are only readable when the room you are standing in is dark enough. I think this can be improved by changing the second piece of glass for some milk-white perspex.