Home Creators Posts Import Register Favorites Logout

Content

Learn how to create an escape room puzzle in which you place four objects in the correct position to deactivate a magnetic lock, using RFID sensors and an Arduino.

For patreons to download the code used, wiring diagrams, and additional documentation, please see https://www.patreon.com/posts/object-placement-15681373

Files

Escape Room Object Placement Puzzle using Arduino/RFID

Learn how to create an escape room puzzle in which you place four objects in the correct position to deactivate a magnetic lock, using RFID sensors and an Arudino. If you'd like to download the code, wiring diagram, and additional documentation that accompanies this video, or support me to make more tutorials in the future, please visit my Patreon page at https://www.patreon.com/playfultech - thanks! HARDWARE --- Arduino UNO - £4.99 https://www.ebay.co.uk/itm/Arduino-UNO-R3-Development-Breadboard-Microcontroller-MEGA328P-ATMEGA16U2-Compat/272823197906 4x RFID RC-522 Module + Key Ring - £1.97 each https://www.ebay.co.uk/itm/RFID-RC-522-RF-IC-Card-Module-S50-Blank-Card-Key-Ring-13-56MHz-Sensor-Kits-High/152691643069 280Kg 12V MagLock - £14.98 http://www.ebay.co.uk/itm/280KG-600LB-12V-Electro-Magnetic-Door-Lock-Holding-Force-Access-Control-UK-/142243965274 SOFTWARE --- Arduino RFID library https://github.com/miguelbalboa/rfid

Comments

Dallas Nichols

Hey Alastair! Thanks for making such great videos and being an amazing resource for the puzzle design community! I built out a project inspired by the work here and had a great breakthrough for the code that I would like to share. I built a puzzle that utilizes 8 of these, but it was important that I set each of the SS (sometimes called CS) pins to be pullups in the setup function. When these pins float they cause mixed readings. By doing this I have consistent and strong reads without issue. e.g. pinMode(2, INPUT_PULLUP); I'm also using the most recent version of the library MFRC522v2.h which negates the need for the reset pin. Hopefully this information can guide others to success.

Sean McQuarrie

Great video this helped alot! I do have one question, is it possible to extend the range of the RFID signal? Currently its only picking up the sensors with approx 5mm distance, is there any way to do this in code?

Forrest Lynch

I am trying to build this project with an ESP32. I have set the reset to 22, ss pins to 21, 16, 2 &33, MOSI to 23, MISO to 19, clock to 18, and relay to 26. It powers up with the usb, but the serial monitor shows absolutely nothing. I have timestamp checked, and it shows a timestamp when i place a tag. But nothing else. What else should I do to get this code to work with the ESP32? Thanks in advance!

Sean McQuarrie

Hi Mate, I was also just wondering if you were to power this puzzle without a USB to a computer what power source would you recommend? I know powering could be a whole topic but any info in relation to this project would help alot, thanks in advance

Sébastien Laban

Hello, i m trying to use this code on a esp32 and i have do exactly the same wiring than Forrest but i can't read tag ( my serial monitor work...

Steven Fletcher

Hey Alastair, i am trying to incorporate sound with mp3. I have successfully finished "weight for it" that with the use of extra cases will play audio that states too heavy or too light.... with this rfid puzzle i am trying to identify when all 4 cards are placed and how many are correct... I then intend to play audio of the x number in the correct position. basically, instead of receiving constant information of when a card state changes.... i need when card state changes and 4 cards are present. I am not a coder but with a little tip i would then be able to Frankenstein some code to play audio representing the results. What should i be looking at?

Steven Fletcher

WOW, thanks for the fast answer... My hardware solution that works with "weight for it" is the addition of a YX5300 UART Control Serial MP3 Music Player Module and TDA7297 Version B 2*15W Digital For Audio Amplifier. <a href="https://youtu.be/bc_OXFeaVN4" rel="nofollow noopener" target="_blank">https://youtu.be/bc_OXFeaVN4</a> I added new cases “Zero" “Measure” Heavy" Light" "mp3 play ( give time for audio to finish)" With the rfid cards instead of looping and reading everytime there is a state change… I am trying to find the coding for state change and all 4 cards are on the reader… this way I can then create switch case that will indicate how many are correct. I want the audio to play each time cards have change position but all 4 are touching reader. Each time a new order is completed audio will play indicating the state of how many are correct.

Nathanael Auran

Hey Alastair! I setup this same puzzle with 4 sensors and your code on an UNO and am able to get it to work with a slight modification that I don't know why. Straight off the breadboard to the readers with dupont wires, everything is the same...but the reader won't power on if I have the 3.3v connection. I have to disconnect it from the breadboard or the reader and it powers on and functions like it should. It is odd to me why... Also, I purchased as well the cat5e RJ45 jacks with 8 pins out to easier span distances to the readers. I have verified the jacks to the board they came manufactured and already soldered as working. When the sensors are connected to the other end, they are receiving power and the code recognizes them as well. BUT...it won't pick up /read any of the tags.?!?!? I have tried as short as a 1 foot network cable as well as pre-manufactured 6 foots and still nothing. Have you ever encountered this issue? Is it something with the twist of a network cable that is causing this issue? Or maybe they should be cat6 cables? Thanks in advance for any feedback!

CadilLACi

Hello! I saw it in your video that You call the PCD_Init() in the loop() part of the sketch. I only every saw this being called in the setup() part. Why did you do it like this and what does this change?

Keith DiBuono

I am having a heck of a time trying to get this sketch to work. I have the hardware portion fully built...the RFID readers power up when i power the system, but i cant get the readers to recognize the cards. i have tried to install the library, but when using the serial monitor, it always seems to say there is a problem with the MFRC522 file or just says nothing, and doesnt read any tag signal.

Sammy Rey

I would like to add one green LED that comes on when the puzzle is solved . Where do you suggest I hook this up , as well , what would you add to the already existing code ? Thanks.

R Vance

I just got done making only using 2 RFIDs at this time all works great

R Vance

..new here sent before i finshed. the question is there a way to have it restart after 5 min or any time limit. where i plan on puting it it will be hard to reach the reset buttion. I can turn off and on power but that takes time. the dore being released is spring loaded so I do not have to worry about mag lock locking before some one opens the door

Michael H. Sparks

Alistair, thanks you so much for all the informative videos. I subscribed to Playful Tech and believe this is a great investment for a novice puzzle designer like me. I followed the library download instructions you provided but when I went to compile the code I got the following error message: Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno" C:\Users\Owner\Downloads\Multi_RFID\Multi_RFID.ino:22:21: fatal error: MFRC522.h: No such file or directory #include <mfrc522.h> ^ M Sparks </mfrc522.h>

Michael H. Sparks

Alastair, I deleted the other items in the C:\Users\Owner\Documents\Arduino\libraries folder and pasted in the unzipped files from the download. The verify/compile executed without an error...that's great news ( and a welcome relief). I will follow up with additional details but really want to let you know how much your support is valued. You have a customer (and positive referral) for life. Mike

R Vance

you are using windows 10 so what happened to me may not make a difference. when I down loaded arduino web editor using explore it would not work right. when I used Firefox it solved a lot of problems for me. If I remember right win 10 uses edge but try loading on Firefox from <a href="https://create.arduino.cc/" rel="nofollow noopener" target="_blank">https://create.arduino.cc/</a> it had the library all ready I did not need to download it and I have more then one working with different number of readers.

James Sheahan

Hi Alistair. Thanks for another great post. I have adapted this so there are multiple RFID sensors and the players must place a single RFID tag on those sensors in a specific order, i.e. A the B then C then D then E. It all works, lights up lights on each successful placement (and when complete), and resets if there's a wrong move. All good so far. However, when I added the 4th and 5th sensor (and I am planning 6 in total), I noticed there's quite a delay in detecting each placement. With 3 sensors, it was pretty instant, but with 5 it can be almost a second before it notices the tag (which means players may tap and move on before it registers the placement which would be frsutrating). I assume this is because the code is looping through to check every sensor each time, so more sesnors means more time for each loop through them. Would that be correct? If so, is there a way I can reduce this time, i.e. speed up the checks made per second? (I tried running two of the sensors from a different 3.3V pin on the Arduino nano but no difference.) (One way to reduce the time to loop through the sensors is to stop checking sensors which have already been correctly used, as each is only used once in the solution, but that doesn't help the first placements.) As always, thanks for all these posts which are great and very inspiring.

steve maas

Is a logic level converter required for converting the signals from the Arduino to what the RFID readers want to work with (3.3v)? I found that elsewhere on the web, and wondered why it wasn't mentioned in this project.

steve maas

In your video, you seem to imply that more that 4 readers could be problematic. I got this setup to run with 5 readers, but now and then the 5th one flakes out, for no apparent reason. Is there some inherent limit that would make an Arduino UNO only reliably handle 4 readers? Is there a different setup that would allow more readers?

ziiicos

Hi Alastair ! I'm thinking becoming a patreon and building this for one of my escape room but one short question the sensor should be in my case behind a large magnet, do you think it could still work properly ? Or magnet is forbidden while using RFID ? (My puzzle stands vertically, the pieces are supposed to be placed vertically thanks to magnets, but to have a full mecanism RFID would be great :)

Irin Stošić

Hi Alistar, thank you for the great video! I have a problem I cannot understand, maybe you could help. I used this code on an arduino nano with 4 readers and 4 coin tags and it works perfectly. I really need to add WiFi functionality to this puzzle so I can control it from the GM room and see what was placed where, but when I use the code on ESP32 (of course I adjusted the pins) readers do not read the coin tags (one time i did get 2 out of 4 readers to read them, but only once), but they read the blue keychain tags completely normally and reliably! I use external power for the readers, I've lowered the SPI speed to 4 MHz, I've reconnected the wires multiple times (they are short cca 10cm). It really buffles me because I supposed RV522 should work even better on ESP32 since they are sharing 3.3 V logic. Do you maybe have some ideas?

Russell Hardman

Just complete this and all working fine. I only had one RFID but I can see a lot of potential uses for this. Many thanks.

Brain Squeeze

Hi Alastair! We have followed the tutorial and we are having problems to get the game works properly. The code and assembly is identical to what is shown in the tutorial. 1- RFID readers fail randomly. There are times that it detects all and others it does not detect them. Showing the following error: Reader # "X" initialized on pin "X". Antenna strength: 64. Version: Firmware Version: 0x82 = (unknown) 2- We had to remove everything related to Serial in the code for the game workS without having open the console of the arduino. Arduino is connected to pc in this case. 3- With the arduino without being connected to the pc, we have not gotten it to work and we do not understand the reason. We test with diferentes AC/DC adapters, it seems that everything is well connected but the puzzle is not resolved.

Sagareth

Hi Alastair, I am having a similar issue as Brain Squeeze. I got 4 RFID to read tags when they were connected on the ~20cm premade dupont connector wires into a breadboard. When I extended the lengths is where I run into an issue. I have one RFID at about 40cm, a second at 75cm and the last 2 at about 1m. the shorter ones read ok at 3.3v, but to get all 4 to read, the power needs to be connected to the 5v. I only found this by mistake. i switched the mag-lock from your video with a LCD 1602 I2C. Somewhere along the line I switched around the power between the RFID and the LCD. I only noticed b/c the letters on the LCD were extremely faint. I am totally new to electronics, the RFID stat sheets say they are 3.3v, will running them off 5v fry them over time?

Rocky Williams

Hey Alastair, I am new as a Patreon. I love your projects. I've been working on making this one work but keep having problems when I go to upload. Here is the error message I am getting: "Arduino: 1.8.2 (Mac OS X), Board: "Arduino/Genuino Uno" Sketch uses 8076 bytes (25%) of program storage space. Maximum is 32256 bytes. Global variables use 361 bytes (17%) of dynamic memory, leaving 1687 bytes for local variables. Maximum is 2048 bytes. avrdude: ser_open(): can't open device "/dev/cu.usbmodem1411": No such file or directory Problem uploading to board. See <a href="http://www.arduino.cc/en/Guide/Troubleshooting" rel="nofollow noopener" target="_blank">http://www.arduino.cc/en/Guide/Troubleshooting</a>#upload for suggestions. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Justin Simmons

Aistair, quick question for you, I am trying to make an escape room puzzle and I would like to include multiple solutions in the puzzle instead of a single solution like the one you have, any ideas on how to include multiple solutions in the const byte statement? I am really new to coding and I am at a loss on how to include them. Also, I am trying to include a total of 3 relays and make a solution to actuate each of them, any help would be much appreciated!

Marcy Judd

I have checked on another UNO if each of my sensors are working and they are but when I plug them into this project I get the following code error. I am very new to arduino and don't know how to fix it. Please help! Reader #0 initialised on pin 2. Antenna strength: 0. Version : Firmware Version: 0x0 = (unknown) WARNING: Communication failure, is the MFRC522 properly connected? Reader #1 initialised on pin 3. Antenna strength: 0. Version : Firmware Version: 0x0 = (unknown) WARNING: Communication failure, is the MFRC522 properly connected? Reader #2 initialised on pin 4. Antenna strength: 0. Version : Firmware Version: 0x0 = (unknown) WARNING: Communication failure, is the MFRC522 properly connected? Reader #3 initialised on pin 5. Antenna strength: 0. Version : Firmware Version: 0x0 = (unknown) WARNING: Communication failure, is the MFRC522 properly connected? --- END SETUP ---

Daniel Shilling

Hi! Currently having a problem, everything is set up exactly the same as yours but its extremely temperamental. The readers sometimes register the tags and sometimes don't, they sometimes immediately register and sometimes take over 5 seconds! Any idea?

Aleksandar Pancic

Hi.. Is there a difference with connections if I use ESP32 instead of Arduino UNO? Also, is the code the same? Thank you..

federico guillen

Hi! I am a new patreon, and I want to make this RFID project, I loved the idea and it solves some problems with a similar game. But I'm having a strange problem... in the serial monitor appears the next message "Serial communication started Reader # 0 initialized on pin 2. Antenna strength: 64. Version: Firmware Version: 0x88 = (clone) Reader # 1 initialized on pin 3. Antenna strength: 64. Version: Firmware Version: 0x12 = counterfeit chip Reader # 2 initialized on pin 4. Antenna strength: 64. Version: Firmware Version: 0x2 = (unknown) Reader # 3 initialized on pin 5. Antenna strength: 0. Version: Firmware Version: 0x0 = (unknown) WARNING: Communication failure, is the MFRC522 properly connected? "

federico guillen (edited)

Comment edits

2026-09-07 18:00 But it does not end there ... if you remove one of the sensors the other three read them, if I put the 4 does not read any, I have one more sensor because I plan to put 5 and the problem is very random, the first tests I did with three sensors and had the same problem read 2 at the same time, but not the 3 ... any ideas .. ??
2019-03-14 19:06

federico guillen

I was using a separate 3.3v source ... but GND was apart ... I'm going to try the arduino gnd

federico guillen (edited)

Comment edits

2026-09-07 18:00 same problem ... but there is hope .... once among the many permutations that I did .... once the 4 worked ... but they were for a few seconds ... and then he read again 3 ... I'm going to rest tomorrow I'll keep trying
2019-03-14 21:06

federico guillen

I can't find the video referred to the TTL converter 3.3 to 5v, could you give me the link?

Crux Scenica LLC

Just commenting to add great project and very helpful video. BEWARE of cheap Chinese knock-off MFRC522s though. The ones I purchases show up as "Counterfeit" in the setup code with a firmware version of "0x12" and for whatever reason while working by themselves they do not work when multiples are connected to the same SPI bus. It took me a while to confirm this (after all I wasn't sure if the serial data the library was spitting out was accurate initially) but after a number of tests it appears that a batch from a different supplier works consistently.

Crux Scenica LLC

One question: with logic level converters, shielded cable and a separate 3,3v power source, do you think more devices than 5 could be run reliably? Or is it simply a matter of signal degradation between so many shared pins?

Emily Bosschaart

Any advice on how to set up this puzzle with multiple relays.....each with a different combination or tags?

Teia Powell

Just finished this project. We decided on two sensors for our setup. Everything worked beautifully! Your instructions make these projects so simple, even for a beginner like me.

Pierre-Alexandre Caron

Hiya Alastair, just want to start by thanking you for your great work here: you are very passionate and it shows in every video and project you put out so - keep it up! I put this little multi-RFID project together rather quickly and it works great - until I try to embed the RFID sensors within a prop. I printed the case out of PLA, the cover face is less than 5mm and somehow, tit looks like this is too much of a blocker for the sensors... they aren't reading the tags. I notice you put a line in there regarding the gain and how to adjust it - I removed both slashes and burned that code in without issues but it's done nothing for issue. Any ideas on what I could do?

Cedric Galland

Hi I have a problem : the arduino programm say 'dump_byte_array' was not declared in this scope.

Cedric Galland

I used your video and project to create an escapegame for french student in BACCALAUREAT and I don't know where is the solution of theproblem. Please help me

Chun Huat

Hi Alastair. Can I get the new codes and circuit diagram with the level shifter included? Thank you :)

RJ Hemy

What code can I add to activate a separate relay if the item was correctly put on its spot? but not trigger the final relay? Or just turn on 1 relay per correct position?

R

Hi Alistair, Is there anyway you could help me. I have a successful rfid puzzle with lock working correctly. I was wondering, if i replaced the lock with an led display eg:TM1637, do you know what I would need to alter in the code for the display to show a message once the rfid puzzle is solved? I know you did something similar with your chess puzzle but the code isn't available here. Thanks

russell maguire

Hi Alastair, One question on the RFID set up - can i install magnets between the RFID sensor and the tags without disturbing the signal? Reason is i have 4 objects to be located that fit into location holes but in the vertical plane. The magnet will help the objects remain in position and hence once all 4 are in place the puzzle is solved. Thanks Russell

Gonzalo Cuevas

Hi everybody! This puzzle works like charm. That being said, I'm having a little problem that maybe someone can assist me with. When I use Mifare Classic tags, I have no issue at all. The problem appears when I try to switch to Mifare Ultralight tags. If I run the same code, it doesn't work at all. Basically the RFID-RC522 does not read the tags. It took me a couple of days to figure out what was going on. The problems emerges when I initialize the sensors on the main loop (mfrc522[i].PCD_Init();), it seems like it won't permit the Ultrilight tags to be read for some reason. If I just remove that line, the tags are read as supposed. At this point, I thought the problem was solved, but I was just fooling myself. The RFIDs works fine this way, but when I place the Ultralight tag, it gets read and immediately it gets cleared, so, for the puzzle purposes, it's not working. I searched around the internet for a while now, but could not find any suitable solution. Any idea would be appreciated! Thanks in advance.

Christian Lopez

How would someone add many more RFID sensors with Arduino’s limited slave select pins? Would like to use your example and attach it to my poker table using RFID poker cards.

David Bodsworth

Seem to have lost the original comment! So, while the puzzle was working fine on it's own, I seem to be struggling with the MQTT side. I've copied across all parts relating to MQTT from another puzzle I have that is working, but this one refuses to connect to the broker with an rc=-2 error. Can you take a look and see if there's something I'm missing? #include #include #include #include const byte mac[] = {0x74, 0x69, 0x69, 0x2D, 0x30, 0x33}; const IPAddress IP(192, 168, 0, 108); const IPAddress serverIP(192, 168, 0, 101); const byte numReaders = 3; const byte ssPins[] = {2, 3, 4}; const byte resetPin = 8; int LEDpins[] = {A1, A2, A3}; int numLEDs = 3; MFRC522 mfrc522[numReaders]; const String correctIDs[] = {"9a8760aa", "5a665caa", "ea8860aa"}; String currentIDs[numReaders]; const byte lockPin = A0; // Callback function header void callback(char* topic, byte* payload, unsigned int length); EthernetClient ethClient; PubSubClient MQTTclient(ethClient); void callback(char* topic, byte* payload, unsigned int length) { /* Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); */ byte* p = (byte*)malloc(length + 1); memcpy(p, payload, length); p[length] = 0; // MQTTclient.publish("toHost/switches", p, length); // Serial.println("checking"); if (strcmp(p, "SOLVE") == 0) { onSolve(); } else if (strcmp(p, "RESET") == 0) { onReset(); } // Serial.println("check done"); free(p); // Serial.println("memory cleared"); } void reconnect() { // Loop until we're reconnected while (!MQTTclient.connected()) { Serial.print("Attempting MQTT connection..."); // Attempt to connect if (MQTTclient.connect("monkeys")) { Serial.println("connected"); // Once connected, publish an announcement... MQTTclient.publish("toHost/monkeys", "connected"); // ... and resubscribe MQTTclient.subscribe("lab/monkeys"); MQTTclient.subscribe("lab/all"); } else { Serial.print("failed, rc="); Serial.print(MQTTclient.state()); Serial.println(" try again in 5 seconds"); MQTTclient.publish("lab/monkeys", "connection failed"); // Wait 5 seconds before retrying delay(5000); } } } void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(lockPin, OUTPUT); digitalWrite(lockPin, LOW); SPI.begin(); MQTTclient.setServer(serverIP, 1883); MQTTclient.setCallback(callback); // Serial.println("Connecting to network"); if (Ethernet.begin(mac) == 0) { Ethernet.begin(mac, IP); } Serial.print("Connected! IP address: "); Serial.println(Ethernet.localIP()); for (uint8_t i=0; i

WinterStormBorn

Hi Alastair I'm having a bit of trouble getting 2 of my readers to work. 3 of the readers work fine but the other 2 initialized but won't read tags. I'm using a mega2560 board.

Cherie Mickley

Firstly, i want to say this video is awesome. I’m in the process of opening my first escape room and this is so incredibly helpful. I’m really new to arduino. But I was able to assemble this and worked!!! So yay! But I want to stabilize the wiring because it’s coming loose. I’ve ordered a protoboard. But in the the video the wiring from each rfid reader seems to be connected to a little black connector which is connected to a gray-ish cord. Can anyone tell me what they are?

Cherie Mickley

Thanks so much! And thanks for doing these videos!!! They are so helpful

Nicholas Bicica

Hey there! I’ve used this puzzle before with great success, but now I’m trying to tweak it a bit and I’m having a hard time. Not sure if this was asked and answered already, but I didn’t see it. I’m trying to activate a linear actuator when the puzzle is solved. I was able to get the linear actuator to extend, but can’t seem to get it to retract. Is there a way to code this so while all the pieces are in place it extends, but once 1 is removed it will retract similar to your plasma ball tutorial?

gorilla

hi alastair Thanks to the good videos, I'm making the device well. I have one question. When I put 4 cards on 4 rfid sensors to fit, the relay works. What should I do if I remove all the cards after solving the problem and reset them automatically? Now, it cannot be reset unless the Arduino is turned off and on or the reset button is pressed directly. I want to know the codes .

Borko Miljkovic

Hi Alastair. Where can i get the code for 4 RFID?

Russell Albright II

Hello Alastair I am trying to run this up using the RJ45 breakout boards, but on the Arduino side I am using a 4 port version (for simplifying). The cabling is going to each corner of a room, so some of the ethernet cables are 35 ft, others are about 15-20ft. I can see the initial initialization but I cannot get the reader to show any card data. Any suggestions? Russell