Hello all here is my demo.

Since I got my RFID reader, I just wanted create a RFID door unlock system for my apartment's door. At first, I designed the work flow above, as a Newbie, its not quite an easy task to accomplish for me, then I found similar project on Instructables and modified it for use with specific RFID Reader (MFRC522 SPI Protocol).

With this project, you can let people to unlock apartment's door without a key, or modify the code for something else to do. Simply, this project gives you an opportunity to build what you want with this particular RFID reader.

I would like to thank dronmarket for sponsoring me about RFID usage on drones.

-------- Features ----------

Unlocks a Door (controls a relay actually) using a RC522 RFID reader with SPI interface on your Arduino. You define a Master Card which acts as a Programmer then you can able to choose card holders who can able to unlock the door or not.

* Easy User Interface *

Just one RFID tag needed whether Delete or Add Tags to memory. You can choose to use Leds for output or Serial LCD module to inform users. Or you can use both, of course.

* Stores Information on EEPROM *

Information stored on non volatile Arduino's EEPROM memory to preserve Users' tag and Master Card. No Information lost if power lost. EEPROM has unlimited Read cycle but 100,000 limited Write cycle.

* Easy to Modify *

You can modify the code and use a Servo motor instead of a relay. My apartment's door lock runs on 12vAC, when 12vAC applied it unlocks the Door Lock. I am new to coding, and know how it is hard to understand whole code as a newbie, I tried to create fully commented code for newbies like me. Maybe its not complete but there are many comments.

* Security *

To keep it simple we are going to use Tag's Unique IDs. It's simple, a bit secure, but not hacker proof.

What you will need: (Minimum Setup)

1x Arduino of your choice (UNO, Nano, Pro Mini)

1x RC522 13.56MHz RFID Reader Writer (Every module with MFRC522 compatible)

1x Relay Module or Relay Circuit that you build (You can DIY or buy as module)

nx RFID Tags (Mifare 13.56 Mhz as many as users)


1x 3.3v Voltage Regulator if you don't have any 3.3v power source. (For powering RC522 Module)


1x Common cathode or anode RGB led or just use regular single color leds (to inform users)

1x Serial LCD Module (to inform users)

17/08/2014 UPDATE

Now you don't need to know Master RFID card's UID. Master Card can be defined when first use, just scan a card and it will become the Master Card. Also now there is a Wipe Mode to wipe every record (including master card) on EEPROM. While holding wipe button, power up your Arduino and wait 10 second without releasing the button, everything will be erased (Careful: this process can not be undone).

For more information follow this link: http://forum.arduino.cc/index.php?topic=256260


Step 1: Software Setup

You will need MFRC522 Library from here

Add this library to your Arduino IDE
If you don't know how to add a Library to Arduino IDE you can follow this guide:

And grab Main Sketch here

https://github.com/omersiar/RFID522-Door-Unlock/ (latest code always be here)
Try to Verify. There should be no errors if you installed Library correctly (IDE 1.0.5-r2).

Step 2: Hardware Setup

I suggest build everything on breadboard then tweak for your exact needs, since we don't know how every door unlocks you need to modify the setup.

Connect RC522 RFID Module
Pin layout should be as follows

For not-Mega Arduinos

MOSI: Pin 11 / ICSP-4
MISO: Pin 12 / ICSP-1
SCK : Pin 13 / ISCP-3
SS : Pin 10 (Configurable)
RST : Pin 9 (Configurable)

For Arduino Mega:

MOSI: Pin 51 / ICSP-4
MISO: Pin 50 / ICSP-1
SCK : Pin 52 / ISCP-3
SS : Pin 53 (Configurable)
RST : Pin 5 (Configurable)

Connect RGB Leds and Relay (All Configurable)

Red: Pin 7
Green: Pin 6
Blue : Pin 5

Relay : Pin 4
Wipe Button : Pin 3

Step 3: You Are Almost Ready.

Upload code to the Arduino, open serial monitor experiment, tweak, and build your final setup.

When your Arduino first run it will flash Blue Led and wait you to scan a card in order to set this card as Master Card. Which will be act as programmer for users' tag.

<p>I am happy to announce new project:</p><p><a href="https://github.com/omersiar/esp-rfid" rel="nofollow">https://github.com/omersiar/esp-rfid</a></p>ESP-RFID Access Control with ESP8266<p>Access Control demonstration using a cheap RC522 RFID Hardware and Espressif's ESP8266 Microcontroller.</p>Features<ul><li>Using WebSocket protocol to exchange data between Hardware and Web Browser<li>Data is encoded as JSON object<li>Records are Timestamped (Time synced from a NTP Server)<li>Bootstrap for beautiful Web Pages<li>Built-in HTML Editor<li>Thanks to ESPAsyncWebServer Library communication is Asyncronous</ul>
Hi there. i made it and it works great. Thanks
<p>Hello, did you just copy and pasted the code to the arduino? it is my first time using github and i have no idea if it's a part by part from a package of code. </p>
<p>I get a SD intialtion failed in my com 4</p>
<p>:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:276: error: use of enum 'PICC_Type' without previous declaration</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:276: error: expected primary-expression before '{' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:276: error: expected ';' before '{' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:291: error: use of enum 'StatusCode' without previous declaration</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:291: error: expected primary-expression before '{' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:291: error: expected ';' before '{' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:338: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:356: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:357: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:358: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:359: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:360: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:361: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:362: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:367: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:369: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:370: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:371: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:372: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:373: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:374: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:375: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:376: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:377: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:378: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:383: error: 'StatusCode' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:386: error: expected ';' before '(' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:387: error: 'PICC_Type' does not name a type</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:390: error: expected ';' before '(' token</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:396: error: 'PICC_Type' has not been declared</p><p>C:\Users\rc\Documents\Arduino\libraries\mfrc522/MFRC522.h:415: error: 'StatusCode' does not name a type</p><p>sketch_nov27a.ino: In function 'void loop()':</p><p>sketch_nov27a:19: error: 'Rfid' was not declared in this scope</p><p>sketch_nov27a:20: error: 'Return' was not declared in this scope</p><p>sketch_nov27a:23: error: 'PICC_Type' is not a member of 'MFRC522'</p><p>sketch_nov27a:23: error: expected `;' before 'piccType'</p><p>sketch_nov27a:27: error: 'PiccType' was not declared in this scope</p><p>sketch_nov27a:27: error: expected `)' before '!' token</p><p>sketch_nov27a:29: error: expected primary-expression before '.' token</p><p>sketch_nov27a:31: error: 'Return' was not declared in this scope</p><p>sketch_nov27a:34: error: 'STRING' was not declared in this scope</p><p>sketch_nov27a:34: error: expected `;' before 'Strid'</p><p>sketch_nov27a:35: error: expected primary-expression before '.' token</p><p>sketch_nov27a:36: error: expected primary-expression before '=' token</p><p>sketch_nov27a:37: error: 'Rfid' was not declared in this scope</p><p>sketch_nov27a:37: error: expected primary-expression before '.' token</p><p>sketch_nov27a:38: error: 'i' was not declared in this scope</p><p>sketch_nov27a:38: error: expected primary-expression before '.' token</p><p>sketch_nov27a:39: error: expected unqualified-id before '(' token</p><p>sketch_nov27a:39: error: expected `)' before '!' token</p><p>sketch_nov27a:41: error: 'strID' was not declared in this scope</p><p>sketch_nov27a:49: error: 'class MFRC522' has no member named 'PICC_HaltA'</p>
<p>I got this error too, I was frustrated as all get out, the fix is simple but not stated update your Arduino IDE to version 1.6, this fixed my problem, you can find it by googling &quot;arduino ide&quot; then if you need to add the RFID-Master to the library, under Arduino interface click &quot;File-&gt;Example-&gt;MRFC522-&gt;AccessControl&quot; Then be sure to select your Arduino Board, COM Port, and Processor if needed and upload &quot;AccessControl&quot; Sketch. I WAS DOING THIS AS I WAS WRITING THIS AND IT WORKS!!!! YES,YES,YES,YES SO HAPPY, Open serial monitor and you will scan master card, then scan it again and it will allow you to add a new rfid, then scan master again to close setup, then scan added rfid and it should read out &quot;welcome, you may pass&quot;</p>
<p>can you give me the code,tks</p><p>nhok010398@gmail.com</p>
<p>You can design additional system components to LCD display</p>
<p>can you give me the code and circuit diagram?</p><p>diofbrn@gmail.com<br>thanks</p>
<p>How if i want lock by lock button without included time delay. Pls help me ....</p>
<p>can you share the code to me,thx</p><p>email: forgttip1@gmail.com</p>
<p>hiiii, i need your code, please send me :)</p><p>eng.mustafa.hamza.mh@gmail.com</p>
deanhutchmary@gmail.com send me the code . Thanks. I need it for final year project..
<p>Link to the code is in step 1:</p><p><a href="https://github.com/omersiar/RFID522-Door-Unlock/" rel="nofollow">https://github.com/omersiar/RFID522-Door-Unlock/</a></p>
<p>Do you have a schematic I could see?</p>
<p>I made it and used a servo instead of a relay, if anyone wants the code.</p><p>I also hooked up the RC522 3.3v pin to the 3.3v pin on my arduino, so i didn't need any transformer :D</p>
<p>hiiii, i need your code, please send me :)</p><p>Aroyoapelu@gmail.com</p>
<p>if u got the code, please share with me hyattatan@gmail.com</p><p>thank you</p>
<p>Please don't post any more emails on here, it's a serious security concern I have not thought of before. Get the code from the Github, I made a pull request.</p>
<p>I've made a pull request on Github everyone, it's there now!</p>
<p>Oh and I might add a 8x8 matrix later depends if i can implement the code. :D</p>
<p>Wow, so many replies! Sorry I haven't gotten back to you all yet, but I will tonight, haven't gotten the code from my old hard drive yet. :)</p>
<p>You may want to contribute to code on GitHub, Pull Requests are always welcomed. Thank you.</p>
<p>Yeah, I definetely will, making a pull request ASAP</p>
<p>can you give me the code and circuit diagram?<br>kazijubyer@gmail.com<br>thanks</p>
<p>Would you be able to email me your code?</p><p>smthj938@gmail.com</p><p>Thanks</p>
<p>Hey could i see your code?</p><p>email: firefarter10@gmail.com</p>
<p>I just sent you the code, should be waiting in your inbox.</p>
<p>DNG, I really, really, really would like to have the code too please.</p><p>muzino55@gmail.com</p><p>Thanks.</p>
please someone send me the code<br>muzino55@gmail.com
<p>Hi could You Please send me the code </p><p>email : mitchell123411123@gmail.com</p>
<p>could you please send me the code</p><p>email: rodrigongw@hotmail.com?</p>
<p>Hey could i see your code?</p><p>email: xgodofminecraftx@gmail.com</p>
<p>Hi Could You Please Send Me The Code As well </p><p>Email: mitchell123411123@gmail.com</p>
<p>could you please send me the code</p><p>email: rodrigongw@hotmail.com?</p>
<p>Sorry I Dont Have The Code Yet But When I Get It Ill Send It To You</p>
<p>Hi, can you send me the code, too ? And i have a question. In the code from omersiar from this website is a bit of ethernet and i want to know, if it is important or for what is that ? And for what is the sd pin and do i need that ? Sorry, if my english is bad but iam german and really at the beginning by programming arduinos. Email:kevin.eilers1999@googlemail.com </p><p>Thanks!</p>
<p>could you please send me the code</p><p>email: rodrigongw@hotmail.com?</p>
<p>could you please send me the code</p><p>email: niels-1997@hotmail.com</p><p>thnx</p>
<p>could you please send me the code</p><p>email: andrews_sheldon02@hotmail.com</p><p>thnx</p>
<p>could you please send me the code</p><p>email: rodrigongw@hotmail.com?</p>
<p>could you please send me the code</p><p>email: rodrigongw@hotmail.com?</p>
<p>can u give me the codes that u have done?</p>
Can i use same cone and library for 125MHz RFID Module? <br>Or in RC522 RFID Module can i use 125MHz card?
<p>how to add code epprom RFID to LCD and kaypad??</p>
<p>can you send me a code?</p><p>eko.pratama.setiyawan@gmail.com</p>
<p>Hi.. I will fill my UID number in my program. but it doesnt work (unsigned char master[4] = {113, 25, 162, 230 };) in example 5 number</p><p>can you send me a code?</p><p>patiunus9@gmail.com</p><p>sorry i have bad English</p>
<p>Hi.. I will fill my UID number in my program. but it doesnt work (unsigned char master[4] = {113, 25, 162, 230 };) in example 5 number</p><p>can you send me a code?</p><p>patiunus9@gmail.com</p><p>sorry i have bad English</p>
<p>hi, i need some help i'm trying to add an sd entrace log with IR counter and i need some help is for my grade project, i'm using an arduino mega i don't really know how to do an sd loggin D: someone could help me with the code?</p>
<p>my RFID HAS </p><p>-VCC<br>-RST</p><p>GND</p><p>-MISO</p><p>-MOSI</p><p>-SCK</p><p>-NSS</p><p>-IRQ</p><p> wich is SS</p>

About This Instructable



More by omersiar:3D modelling with a drone and AutoDesk® ReCap 360™ Arduino RC522 RFID Door Unlock 
Add instructable to: