Introduction: RFID Treasure Hunt Box With MP3 Player

I'm back. As those of you know that have seen some of my other instructables, I'm into making treasure hunts. For some of the background lookup some of my other instructables. AAAAnyway, this is another in the series of fun little toys that I have made for a treasure hunt. I must say though that as far as degree of dificulty, this one is pretty far up there. I have an Arduino Mega that has an RFID reader as well as a MP3 player module connected. Separately these things are a snap to get to work...together, they fight for the attention of the arduino loop cycle. This involved some research and some help with the Kung Fu to make them work.

What does it do?

Excellent question. This box is based on a waterproof box that was purchased at Harbor Freight for another purpose that didn't work out so it has been sitting on the shelf for quite some time. I was at a HF the other day and they are still available so getting the exact one is still possible. You don't have to use this box. The principles can be applied to pretty much any box. But if your like me and want something that can be planted in the snow and rain and still be as you left it then why not put it in a waterproof box. But I digress.

In my treasure hunts I like to make each of the clues be some manner of riddle or puzzle that must be solved to allow the team move on to the next step. This was designed to be the final puzzle that opened and reviled the final prize which, in this case, is several gift cards to a local restaurant for lunch which is my normal go-to final prize.

When you open the box you are greeted with a white sticker over plexiglas that has a square image of a fence in the center. There is a small picture of a magic wand in the lower right corner. No other markings are visible on outside or inside of the box. To the right of the fence image is a small handle that is to be used to lift the lid off the box when the code is solved, but first...how do you turn it on.

In another section of the treasure hunt a random little princess wand with a very small rare earth magnet installed in the tip is given to the team. It has more than a passing resemblance to the image in the lower right of the sticker on the box. If the princess wand is touched to the image of the wand the magnet inside triggers a magnetic reed switch which turns the power control module on. Looks like magic but is very simple to do.

Once the module is on, the Arduino powers up and sends a signal to play the first track which sounds like, "Greetings Adventureres and welcome to your final task. One by one place the animals in the fence, in this order, then remove."

What animals you say. Im glad you asked. I travel a bit for work and have been collecting the RFID cards that the hotels give out to open the room door lock. WIth a small amount of fiddling these cards can be read by the RFID reader which then manipulates the sketch. I gathered 16 of the cards and printed vinyl stickers for both sides to cover up the hotel logos. Each of the stickers has a different cartoonish picture of an animal. These are the cards that are used to enter the code by waving them one after the other across the RFID reader.

The sketch has 3 combinations of 8 animals that it needs to have read by the RFID reader to unlock the box. The evil part of it is that the box tells you through a voice MP3 track what the order is of the animals is. However it says it only once so if you're not paying attention.... In the case if you get it wrong the box saves your place in EEPROM memory then shuts it self off. You must wave the princess wand again to restart the box. This time when it restarts the code changes to a different series of animals. Again the voice prompt tells you what the order is only once. if you get it wrong again the box shuts off after saving its place. Upon restart, new series of animals told to you only once. If you do get it wrong a third time it loops back to the first set of animals upon restart. Unless someone has a perfect memory they will probably have to write it down, and most people will get it wrong at least once before they think to write it down. Muuhhhahahhhhhhahah.

Now once you do get it right, an MP3 track tells you so, the servo unlocks, and the box lid can be lifted off. Sounds pretty simple right? Yes...then again no, but nevermind that lets get into it and Ill show you how its done.

Supplies

This list is the things that I used to make this version of the box. Feel free to make whatever modifications that you wish to what you have available. Most of these things I found from amazon but they are in multi packs. Use them as examples to get what you need.

Supplies that you will need.:

1 waterproof box - i used this one from Harbor Freight

Section of plexiglas sheet around 3/16 thick (4.5mm +/-) and 12 inches (304 mm) x 12 inches (304 mm). This will give you enough to create the same thing I did with some left over to make a mistake or two. - available everewhere and also known as acrylic sheet - from tap plastics

super glue - available everywhere - i used Gorillia gel because it fills in gaps and dries slower

acrylic cement - available from Tap plastics - you can also use thin (watery) super glue for this step but it will leave a milky white and rough glue joint. This cement will give you clear joints that you can see through and are much stronger

Arduino Mega - I tried to do this with an Uno but it just didn't have the memory - i used this one

MP3 player board - DY-SV5W - 2 pack from Amazon - note this board can not use a sd card larger than 32 GB

32GB micro sd card - 3 pack from Amazon

4 ohm speaker - yes it must be a 4 ohm or it will be too quiet for you to hear - 2 pack from Amazon

11.1 volt LIPO battery - 2 pack from Amazon with chargers - if you want, you can also use (2) 9 volts wired in parallel the slight voltage difference between the two wont matter here.

Pololu power control board - 1 pack from Pololu - there are other ways of doing this but this is super slick, small footprint and best of all cheap. This module gives your Arduino the ability to turn off its own power.

Reed switch - 10 pack from Amazon - these magnetic triggered switches allow you to trigger them through a layer of plexiglas and turn on the Pololu power control board. Super slick. This is what the magnet in the princess wand triggers to turn the box on.

Pololu step down power regulator - from Pololu this is only needed because the MP3 board combined with the servo sucks up more power than the Mega's on-board power supply can provide. Or you can hand build a 5 volt regulator to provide power to just the MP3 board.

Princess wand - 12 pack from amazon or something similar, or be artistic and make it from scratch.

tiny neodium magnets - 100 pack from amazon

RFID board - 3 pack from Amazon - I used this type because I had it laying about. There are others. If you use the others you will have to adjust the code and libraries to make them work.

18 RFID cards - 30 pack from amazon or get them from hotels like I did. You can also use the key fob type as well 100 pack from Amazon

micro servo - 2 pack from Amazon

1/16 inch (2mm) shrink tube to make jumper wires - from Amazon

Header Pins - male and female selection from Amazon

very thin wire - 28 gauge from amazon

sticky velcro strips - for attaching the battery to the plexiglas - from Amazon

1/4 inch x 3 1 1/2 inch bolt -or- 1/4 inch x 3 1/2 inch round rod - to make the locking pin - from Amazon - or 6mm for our metric friends

thin pushrod material to attach servo to pin lock (see following pictures)

Tools that you will need:

soldering iron and solder

wire cutters

tablesaw or means to accurately cut the plexiglas

hot glue gun

other tools as needed to shape plexiglas

tools as needed to cut and shape the steel rod

drill with bit the same size as the steel rod

anything else that I forgot to mention

Step 1: Prepare the Box

If you used the same box that I did from Harbor Freight then it came with a block of foam in the top lid and bottom of the box. Leave the upper foam but remove the lower foam. Your box should look like this.

All the way around the inside of the rim of the lower section of the box, use a piece of 120 grit sand paper or a nail file card and rough up the plastic. We will be super gluing to this surface and it needs a little bit of roughness to make the glue stick really well.

Step 2: Cut the Acrylic

First thing is to cut a piece of plexiglas that just fits inside the lip of the box. This box has a slight taper toward the bottom so don't cut it so that it sits flat on the bottom for that will make it to small. It should just fit just below the rim of the box and be able to hold itself there and yet still be removed easily without having to use a prybar to get it out. You will need to round over the corners to match the radius inside the corners of the box.

Step 3: Install the Box Lip

Next step is to create the lip inside the box for the lid to sit on and also to lock to. Cut a strip of plexiglas EXACTLY 3/4 of an inch. The rest of the measurements provided are based on this one measurement. You can make this measurement what ever you want but you will have to adjust the rest of the measurements to match. Using a scrap piece of the same plexiglas that you cut the lid out of as a spaer, attach the pieces as shown to create a lip around the inside of the box. Use the spacer to get the lip to the same depth below the top edge of the box as the lid is thick. (see drawing) Using superglue bond the plexiglas pieces to the inside of the box all the way around. Make very sure that all of the pieces create an even surface all the way around for the lid to sit on and that the top of the rim below the top edge of the box is the same distance down as the thickness of the lid plexiglas. This will allow the lid to sit flush with the top edge of the box when the lid is installed.

Step 4: Create Lip Edge on Lid

Next step is to create this lip on the lid that will engage the left side of the box lip. The pictures should explain. This is the part where if you make the 3/4 measurement on the lip of the box different then adjust accordingly.

Step 5: Cut and Shape Locking Pin

The pin is just that, a pin. This pin is about 3 inches long and is polished very smooth. The end that is closest to the edge of the plexiglas has a very slight chamfer sanded into it. I found out the hard way that if you clamp the pin in a vice it will slightly deform the pin making is bind in the tabs that you will install next. make sure the pin is as smooth and burr free as possible. This pin is a bit longer than you need and you may end up trimming it down a bit later. Better a bit to long.

Step 6: Install Locking Pin Tabs

This part was by far the most fiddly bit of the whole project. You will need to cut two tabs that are exactly identical. I suggest that you make the tabs about an inch wide and about 3 inches long. This is much larger than they need to be, but it is very important that the holes that are drilled in the tabs for the pin to pass through are aligned perfectly. A slightly oversized tab allows you to drill the holes while the two tabs are clamped together. Then trim the tabs together to make them the exact same. See the pictures for what I mean.

Using the acrylic cement attach the first tab about 1/4 back from the right edge of the lid. make sure it is straight and square with the edge. When the cement has dried install the pin in the attached first tab and slide the second tab over the pin and bring it up behind the first with a gap of about 3/8 inch. Test slide the pin back and fourth and feel for a smooth almost effortless movement of the pin. Once you have the correct position of the second tab apply the acrylic cement and hold all three pieces in place for at least a minute to make sure nothing shifts. Once the cement dries gently test the pin and see if it still slides smooth. If it doesn't, allow the glue to set fully for a good 5 minutes before disturbing the pin. When the time is up gently remove the pin and re-insert the drill bit that you used to drill the holes and with finger power only slowly rotate the bit to take any burrs off and trim the edge of the hole. Test the pin now occasionally to test the sliding. When you are satisfied that the pin moves freely, then cut and bond the two side pieces of the of the tabs to add stability. (see pictures)

Take your time here. Be very patient. Go slow. It will save you much swearing and airborne tools.

Step 7: Attach the Servo

As you can see there is a brass wire wrapped around the pin. This is how I made the attachment to the pin. After tightly wrapping the brass wire around the pin it was bent to attach to the servo. The coil wrapped around the pin was still a bit loose so adjustment was still possible. Align the servo up and with a couple of drops of super glue, attach the servo to the plexiglas. Once the servo is attached, make adjustments so that when the servo horn is straight to the side the pin sticks out of the edge tab about 1/8 inch. Once you have it adjusted put a drop or two of super glue on the coil to attach the coil to the pin. Allow a good long set for this glue before you test the servo.

Do not rush this one either. I glued the pin to the tab because I rushed it. Walk away, have a coffee then come back

Step 8: Test the Servo

The attached sketch will help you find the settings for the servo that you will program into the final sketch. This will also give you the ability to test your pin alignment and linkage to the servo. Download the sketch and follow the directions at the top. When you are done, write down the numbers that you get to be enter in a later sketch. See the attached drawing for the wiring of the servo to the MEGA.

Step 9: MP3 Player Board

The MP3 player board that I'm using is a DY-SV5W. This is a pretty simple setup. There are several modes that this board can be set into. We wont go into that as it is a whole other instructable about how to use each setting. For this application, set the dip switches as shown in the picture and it will allow the board to be triggered with parallel binary inputs. The bottom view picture shows the pins that control the board. We will be using I00 - I05. The chart shows how each of the tracks are triggered up to track 50. The board can play tracks all the way up to 00255 however you may run out of room on the SD card depending on how large each track is. What we will be doing is turning on the inputs to trigger a track then after a slight pause turning them off again. If the inputs are left on the track will play over and over.

Connect the MP3 board as shown. The wiring may seem a bit backward but when you create the risers to support the MP3 board over the top of the MEGA board then they line up better. The final hookup will be different as the separate power supply for the MP3 board will be covered in an another step but for now it will work with the MEGA

Disconnect the servo while you are doing this step as the MP3 board and the servo together pull more power than the MEGA can provide.

Step 10: Record Your Tracks

There are a hundred different programs to be able to record MP3 files from a microphone. I used Audacity because it was free and I already had it. It allows you to record and playback the file before exporting it as an MP3. I recorded 46 files, edited them to have as little silence on the beginning and ending of each track, exported them as MP3, then saved them to the SD card. NOTE: each file must have a 5 numeral file name or they won't play. Name your first track 00001, then 00002, 00003 etc. SECOND NOTE: the MP3 board can only used a 32GB micro sd card or smaller.

Download Audacity here: https://www.audacityteam.org/download/

For the exact text of the tracks that I recorded see the attached text file

Step 11: Testing the MP3/MEGA Together

Once you have the files copied on to the SD card, insert the card into the MP3 board with the power off. When you have the wiring and the card inserted load the code below to test the MP3 player working with the MEGA. Download the sketch and follow the instructions at the top. This will give you the ability to play each of the tracks that you recorded one after the other with the serial monitor control. If all goes well you should be able to play all the files on the card.

Step 12: RFID Reader

First you will need to download the MFRC522-1.4.8.zip library and install it. There are newer versions of this same library but this project was tested with this version and I know it works.

Installing the RFID reader was a snap and mine worked perfect right out of the box. It uses the SPI bus to communicate with the Arduino. This board is a 3.3 volt board so be very sure not to power it with 5 volts or you may let the smoke out. Connect the board as shown with the power to the 3.3v port of the Mega. Then download the sketch to the Arduino. Follow the instructions on the top and you should be able to wave the card next to the RFID reader and a hexadecimal number will be displayed in the serial monitor. For each of the cards or keyfobs you are using, each has its own number. I found that most of the numbers are 8 digit numbers. Some of the higher security cards may have more. It doesn't matter as for each piece you will write down the numbers to be added to another sketch later. When you are buying your RFID cards you will find the option for read only or rewriteable cards. For this project either will do as all we are doing is just using the cards individual card numbers not changing the data that can be stored on the card. There is also a possibility that some cards wont read. This may be because they are on a different channel. This reader is specifically used for 13.56mhz items. Some cards are not of this type and wont work. I have found that every RFID hotel key that I have ever tried will work. If the hotel key has a stripe on the back of it like a credit card then it is not RFID and won't work. All of the ones that you can buy on Amazon will work as long as they are 13.56mhz type.

I initially said that there are 16 card. That's not totally true. I added two more later to allow me to open and close the box without having to go through the whole code process. These are labeled "Master Unlock" and "Master Lock" You don't have to use them it just makes it easier to load the box with a prize when the time comes.

Step 13: Pololu Power Control Board With Power Regulator

This is one of my favorite finds from a electronics company out of Las Vegas, Nevada. While not a paid sponsor, I'll happily endorse this little gem. And yes there are other ways to do the same thing but for sheer size and elegance this is the smoothest I've ever used. Without going into the weeds about how it does what it does, this is what it does for us. Your battery power goes in the Vin and Gnd, and out the Vout and Gnd ports to the Mega's gnd and Vin ports. Simple enough. The reed switch, triggered by a magnet inside the tip of a princess wand, momentarily shorts between Vin and on. The board turns on.

In your programming you wish to turn off the board; simply digitalWrite (pin3, HIGH). Boom the board turns off. Easy squeezy. The drawing should sort out the wiring. If you are interested go to the Pololu website and read up on this thing as it can do a whole host of other things as well.

https://www.pololu.com/product/2809

I had to add a separate power control board just for the MP3 board. Both it and the Servo can operate at the same time and it quite a bit more juice than the mega can provide. This causes the board to constantly reset it self.

Step 14: Create Your Princess Wand

I came across the princess wand that I used as a pen in a dollar store. Using a flush cut saw I parted off the top of the ball that was on the end. Made a slight hollow in the bottom half with a dremel tool and inserted a pencil eraser sized rare earth magnet. Glued the top back on and viola! a magic wand. Feel free to make up whatever you want as your "magic" object, be it a ring, necklace, princess wand or even a random stick. Just make sure to mount the magnet close enough to the tip of whatever it is to be able to trigger the reed switch. This is what my wand looks like after its finished. As you can see its still a pen. Side note: when I set a team of on a treasure hunt they usually get a "box of tools". Some of it is actually used for the treasure hunt and some of it is just distractionary crap that I scoop up out of my junk drawer at home. Stuff like a compass (used), allen wrench (used) three paper clips (not used) bread bag twist tie (not used) hair rubber band (may be used but not for the treasure hunt) handful of nuts and bolts, roll of tape and the most important part in this case...a pad of paper...and a pen. They will have been given the wand up front but it will just look like a odd pen. They may even use it to take notes on the treasure hunt.

Step 15: Create the Graphics for the Top of the Lid

This is the sticker that I made to put on the top side of the plexiglas lid to show where to place the cards and where to tap the magic wand. Use it or change it as you feel. I used a laser printer and vinyl sticker stock. It only used half of the sheet when printed portrait style. You'll notice the little target and wand on the lower right side of the sticker. Underneath that target is where I attached the reed switch. Very subtle instruction but when there are no other instructions then they will have to figure it out. ;D

Step 16: Create the Graphics for the Cards

Using the same vinyl sticker stock that I used for the lid I also created the images for all of the RFID cards. The images are on both side so you will have to print each one twice, apply the stickers and then very precisely trim the edges of the sticker with a razor knife to match the edges of the cards.

Step 17: Smushing It All Together

I have given you separate wiring diagrams for each piece to make it a little easier to read. Once you have verified the wiring then upload the code, remove the power wires from the MP3 board or you will have to listen to the tracks over and over as you make modifications to the code with the information that you have written down from the other test sketches. Download and open the sketch in Arduino IDE (integrated development environment). First take all the RFID card numbers that you wrote down and alter the ones in the top section of the sketch labeled "String tag_UID1" thrugh "String tag_UID18" If you choose not to use the master lock and unlock cards then just leave them un-altered. Don't remove them as the IDE will be looking for their definition but if there is no card to associate with them then they wont work. Then scroll down to line 60 and 61 to where the "servoOpen" and "servoClosed" are located. Alter the numbers there with the numbers that you wrote down in the servo test sketch. Once both of those things are done then upload to the Mega.

You will need to download the MFRC522-1.4.8.zip library and install it.

This entire series of sketches was written with Arduino IDE 1.8.19

NOTE: when you load the sketch for the first time the servo will move to the closed position so don't have it on the box until you have tested it a fair bit.

Good luck and have fun. Feel free to modify this as much as you want but if you build it, show me as I would love to see what the world does with this.

Cheers

MachineTech