Arduino RFID Door Lock
Once again me and one of my class mates have finished a project in school using the Arduino.
This time it’s an RFID Door Lock made with a real door and a real lock. The lock is turned using a standard 6V servo.
The project was about luxury, and we thought it might be luxurious if the door could be unlock automatically, fx when you come home from shopping, carrying a bag in each hand. This was the beginning of this project.
In the video below you can see a short demonstration of the system.
We thought you might be interested in the code, and to see how we implemented the “Master-system”, so the code can be found beneath. Remember that you should download the Servo library, and the Parallax RFID reader should be connected to the Serial RX pin (Pin 0).
#include <eeprom.h>
#include <servo.h>
//Initialiser
Servo servoLock; // create servo object to control a servo
// a maximum of eight servo objects can be created
#define RFID_Enabled_Pin 2 // sets RFID enable pin to pin 2
#define servoPin 3 // sets the servo's pin to pin 3
#define LockedPos 10
#define UnlockedPos 110
byte buffer[100]; //used to store the incoming bytes from the RFID
byte RFID_Master[10] = {'1', '7', '0', '0', '7', 'D', 'B', '2', '4', 'F'}; //the secound RFID fob (key) to look for
byte RFID_Slave1[10], RFID_Slave2[10], RFID_Slave3[10]; //the first RFID fob (key) to look for
byte i; //used to keep track of which bit to write to
byte i2; //used to erase the RFID fob (key) number from the buffer
boolean DoorLocked; //true if door is locked
byte checkPosition; //used to check if the incomming number is true or false
boolean RFID_Master_Correct; //true if it's the right RFID fob (key), false if not
boolean RFID_Slave1_Correct, RFID_Slave2_Correct, RFID_Slave3_Correct; //true if it's the right RFID fob (key), false if not
boolean RFID_SaveNextRead;
void setup() {
pinMode(13, OUTPUT); //enables the diode on the arduino
pinMode(RFID_Enabled_Pin, OUTPUT); //sets the RFID pin to output
RFID_Enable(false); //used to set the status of the RFID reader
EEPROM_Read_Slaves();
//Lock
PreLock(); //locks the arduino on startup
RFID_Enable(true); //used to set the status of the RFID reader
Serial.begin(2400); //sets baudrate
i = 1; //sets the varible to 1, and thereby skip the start byte (0x0A)
}
//Go To
//Loop
void loop() { //the main loop
// Serial data
if (Serial.available()) { //check if the RFID reader sends anything
if (buffer[0] != 0x0A) { //check if it the start bit is 0x0A
buffer[0] = Serial.read(); //write bit to buffer
} else {
//Recieve
buffer[i] = Serial.read(); //write next bit to buffer
if (buffer[i] == 0x0D) { //if end bit is send, disable the RFID reader temporary
Serial.print("RFID Tag scanned: ");
RFID_Enable(false);
RFID_Master_Correct = true;
RFID_Slave1_Correct = true;
RFID_Slave2_Correct = true;
RFID_Slave3_Correct = true;
//RFID ID
// We have read all bytes - we are now going to check them
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
Serial.print(buffer[checkPosition+1], BYTE);
if (buffer[checkPosition+1] == RFID_Slave1[checkPosition] && RFID_Slave1_Correct == true) { // compares the written bits to "RFID1"
RFID_Slave1_Correct = true; //Slave1 RFID tag is detected
} else {
RFID_Slave1_Correct = false; //Slave1 RFID tag is not detected
}
if (buffer[checkPosition+1] == RFID_Slave2[checkPosition] && RFID_Slave2_Correct == true) { // compares the written bits to "RFID1"
RFID_Slave2_Correct = true; //Slave2 RFID tag is detected
} else {
RFID_Slave2_Correct = false; //Slave2 RFID tag is not detected
}
if (buffer[checkPosition+1] == RFID_Slave3[checkPosition] && RFID_Slave3_Correct == true) { // compares the written bits to "RFID1"
RFID_Slave3_Correct = true; //Slave3 RFID tag is detected
} else {
RFID_Slave3_Correct = false; //Slave3 RFID tag is detected
}
if (buffer[checkPosition+1] == RFID_Master[checkPosition] && RFID_Master_Correct == true) { // compares the written bits to "RFID1"
RFID_Master_Correct = true; //Master RFID tag is detected
} else {
RFID_Master_Correct = false; //Master RFID tag is detected
}
}
Serial.println("");
if (RFID_SaveNextRead == false && (RFID_Slave1_Correct == true || RFID_Slave2_Correct == true || RFID_Slave3_Correct == true) && RFID_Master_Correct == false) { //see if the right RFID fob (key) is detected
if (RFID_Slave1_Correct == true) { Serial.println("Slave1 Card Scanned"); }
if (RFID_Slave2_Correct == true) { Serial.println("Slave2 Card Scanned"); }
if (RFID_Slave3_Correct == true) { Serial.println("Slave3 Card Scanned"); }
//Door
if (DoorLocked == true) { //see if door is locked or not
//Unlock
Serial.print("Unlocking..."); //if the door is locked then unlocked it
Unlock(5); //unlock with 5ms delay
Serial.println(" Unlocked!");
} else {
//Lock
Serial.print("Locking..."); //if the door is unlocked then lock it
Lock(5); //lock with 5ms delay
Serial.println(" Locked!");
}
//Vent
delay(1000); // Wait for you to remove the RFID fob (key)
} else if (RFID_Master_Correct == true && RFID_SaveNextRead == false) { // If the Master Card is scanned when not in programming mode
Serial.println("Master Card Scanned - Programming mode Enabled");
delay(1000);
RFID_SaveNextRead = true; // Enable programming mode
} else if (RFID_Master_Correct == false && RFID_SaveNextRead == true) { // If another card is scanned when in programming mode
// Save the Card
if (RFID_Slave1[0] == 0) { // Is the Slave1 Card slot empty?
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave1[checkPosition] = buffer[checkPosition+1]; // Save the scanned card as Slave1
}
Serial.println("RFID Card saved in: Slave1");
delay(1000);
} else if (RFID_Slave2[0] == 0) { // Is the Slave2 Card slot empty?
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave2[checkPosition] = buffer[checkPosition+1]; // Save the scanned card as Slave2
}
Serial.println("RFID Card saved in: Slave2");
delay(1000);
} else if (RFID_Slave3[0] == 0) { // Is the Slave3 Card slot empty?
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave3[checkPosition] = buffer[checkPosition+1]; // Save the scanned card as Slave3
}
Serial.println("RFID Card saved in: Slave3");
delay(1000);
} else {
Serial.println("No free Card slots");
RFID_Enable(true); //turns on the RFID reader
delay(1000);
RFID_Enable(false); //turns off the RFID reader
delay(1000);
}
EEPROM_Save_Slaves();
RFID_SaveNextRead = false;
} else if (RFID_Master_Correct == true && RFID_SaveNextRead == true) { // If the Master Card is scanned when in programming mode
Serial.println("Master Card Scanned again - Removing all saved Cards");
delay(1000);
// Remove all Slave Cards
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave1[checkPosition] = 0;
}
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave2[checkPosition] = 0;
}
for (checkPosition = 0; checkPosition < 10; checkPosition++) { //Read bit fra 0-9
RFID_Slave3[checkPosition] = 0;
}
EEPROM_Save_Slaves();
RFID_SaveNextRead = false;
}
RFID_Enable(true); //turns on the RFID reader
EmptySerialBuffer(); //erase the buffer
Serial.println("");
}
i++; //used in the beginning to write to each bit in the buffer
}
}
//Go to
}
void EmptySerialBuffer() { //replaces all bits in the buffer with zeros
while (Serial.available()) { Serial.read(); }
for (i2 = 0; i2 <= i; i2++) {
buffer[i2] = 0;
}
i = 0;
}
void PreLock() {
servoLock.attach(servoPin); // attaches the servo on pin 3 to the servo object
servoLock.write(LockedPos); // tell servo to go to position in variable 'LockedPos'
delay(250); // waits 1s for the servo to reach the position
servoLock.detach(); //detaches the servo, so it's not using power
DoorLocked = true; //the door is locked
}
void Unlock(byte speedDelay) {
int pos;
servoLock.attach(servoPin); // attaches the servo on pin 3 to the servo object
for(pos = LockedPos; pos < UnlockedPos; pos += 1) // goes from 10 degrees to 110 degrees
{ // in steps of 1 degree
servoLock.write(pos); // tell servo to go to position in variable 'pos'
delay(speedDelay); // waits 5ms for the servo to reach the position
}
servoLock.detach(); //detaches the servo, so it's not using power
DoorLocked = false; //the door is unlocked
}
void Lock(byte speedDelay) {
int pos;
servoLock.attach(servoPin); // attaches the servo on pin 3 to the servo object
for(pos = UnlockedPos; pos > LockedPos; pos -= 1) // goes from 110 degrees to 10 degrees
{ // in steps of 1 degree
servoLock.write(pos); // tell servo to go to position in variable 'pos'
delay(speedDelay); // waits 5ms for the servo to reach the position
}
servoLock.detach(); //detaches the servo, so it's not using power
DoorLocked = true; //the door is locked
}
void RFID_Enable(boolean enabled) {
if (enabled == true) {
digitalWrite(RFID_Enabled_Pin, LOW); //enables the RDIF reader and turns on the diode on the arduino
digitalWrite(13, HIGH);
} else { //disables the RDIF reader and turns off the diode on the arduino
digitalWrite(RFID_Enabled_Pin, HIGH);
digitalWrite(13, LOW);
}
}
void EEPROM_Read_Slaves() {
byte EPROMaddr;
for (EPROMaddr = 0; EPROMaddr < 10; EPROMaddr++) { //Read bit fra 0-9
RFID_Slave1[EPROMaddr] = EEPROM.read(EPROMaddr);
}
for (EPROMaddr = 10; EPROMaddr < 20; EPROMaddr++) { //Read bit fra 0-9
RFID_Slave2[EPROMaddr-10] = EEPROM.read(EPROMaddr);
}
for (EPROMaddr = 20; EPROMaddr < 30; EPROMaddr++) { //Read bit fra 0-9
RFID_Slave3[EPROMaddr-20] = EEPROM.read(EPROMaddr);
}
}
void EEPROM_Save_Slaves() {
byte EPROMaddr;
for (EPROMaddr = 0; EPROMaddr < 10; EPROMaddr++) { //Read bit fra 0-9
EEPROM.write(EPROMaddr, RFID_Slave1[EPROMaddr]);
}
for (EPROMaddr = 10; EPROMaddr < 20; EPROMaddr++) { //Read bit fra 0-9
EEPROM.write(EPROMaddr, RFID_Slave2[EPROMaddr-10]);
}
for (EPROMaddr = 20; EPROMaddr < 30; EPROMaddr++) { //Read bit fra 0-9
EEPROM.write(EPROMaddr, RFID_Slave3[EPROMaddr-20]);
}
}
Update:
The newest version of the code is now available at Github: https://github.com/TKJElectronics/ArduinoRFIDDoorLock.
Thanks for directing me to this.
Great job!!!!!! well I try to use your code but my RFID module work to 13.56Mhz. Can u tell how use this tag
tag numbers that can have access
int tag[10] = {175,175,175,178,175,179,100,100,121,61};
can you help me whit the code???
@joshuaUnreal01
Dear Joshua.
You would just have to change the RFID_Master constant to your tag.
Like this: byte RFID_Master[10] = {175,175,175,178,175,179,100,100,121,61};
Best Regards
Thomas Jespersen
Hi!
This project is awesome! I’m starting at electronics, more as a hobby and I would love to do this project, and I was wondering if you can show me the schematic.
Thanks.
And I hope you can help me.
@Gerard
Dear Gerard.
Unfortunately in this project we didn’t make any schematic because the setup was that simple.
It was just a matter of connecting +5V and GND to the Servo and RFID board, connecting Digital Pin 3 to the Servo PWM pin, Digital Pin 2 to RFID Enable and Digital Pin 0 (RX) to RFID Output. As simple as that π
Please do not hesitate writing again with further questions.
Thomas
Thank you so much for all your help I really appreciate it π
Greetings and thanks again, I’m going to do this project as soon as possible π
Hi!What is the servo that you used?
Nice project BTW π
@John
Thank you.
We are using a TowerPro SG-5010 from Sparkfun – Servo – Large
Thomas
Hello, I am really new to arduino and hardware, but I really like this project of yours. So mind my stupidity in asking this, but i really am clueless:
When your RFID reader reads a card, does the code of the card go directly from the reader to the computer, or it passes through the arduino, and the arduino passes it to the pc? And if it goes through the arduino, how do you make it give signal to the pc?
@Toh
The Arduino takes care of reading the card and parsing the data/code. If the code is identified as one of the saved cards, the Arduino either unlocks or locks the door, or goes into Master editing mode.
The computer is only used for debugging purposes. This means that the project works fine without a computer!
Hi! You are using the USB or the Serial RFID reader?
@Steve
Hi. We used this Serial RFID reader from Parallax, as it can then be connected directly to the RX pin on the Arduino.
@Thomas Jespersen
hello, i am very interested in starting this project, but i have been confused about one thing, How do you determine the RFID tag numbers?
@Warren Hanna
It’s actually pretty easy. What we did is we used a USB Serial Converter like this one and then connected the RFID Card Reader Serial directly to the USB Serial Converter, then you just have to open a terminal program and set it to the right baudrate (2400 in this example) and it will print the tag numbers on the screen everytime you put a RFID tag in front of the reader.
Alternatively you could just read the tag numbers with the Arduino. See this page for information.
@Warren Hanna
As Lauszus said, we determined the RFID tag numbers by reading them with the reader, before programming the numbers into our software routine.
This can be done as either explained by Lauszus, by using an USB to Serial converter – or you could also connect the RFID reader to another port on the Arduino and make use of the Software Serial library, and then print the numbers to the Arduino serial console.
hello I am very interested with your project..i would like to ask what was that thing that is placed above the arduino, is it a motor shield for the servo motor?thanks and how qwas the pins connected..thanks a lot!!
*was
@jessica
Hi Jessica.
Are you talking about the “shield” mounted on top of the Arduino?
That is not actually a real shield. It is just a prototyping PCB which connects the proper pins to wires in the cable going into the door.
Best Regards
Thomas Jespersen
Hello ! IΒ΄m from Brazil and I found this great website. I am a newbie with Arduino and I did a copy and paste of you code. when i complided it, the message apeared:
———————————————————–
sketch_feb04a.cpp: In function ‘void loop()’:
sketch_feb04a:57: error: ‘BYTE’ was not declared in this scope
As of Arduino 1.0, the ‘BYTE’ keyword is no longer supported.
Please use Serial.write() instead.
sketch_feb04a.cpp: At global scope:
sketch_feb04a:234: error: function definition does not declare parameters
—————————–
I have no ideia how to fix this issue. Can Anybody help me?
Thanks a lot
Pablo
@Pablo
Dear Pablo.
Thank you for your interest in our project.
The problem you describe occours because the Arduino team made some changes to the coding environment in the recent V1.0 update.
To get the code working you simply have to change the following line to the line below.
Find:
Serial.print(buffer[checkPosition+1], BYTE);
Replace with:
Serial.write(buffer[checkPosition+1]);
Best Regards
Thomas Jespersen
Is it possible to integrate a milti-colored LED into this project to denote weather the door is unlocked or locked?
@Tanner
Yes, definitely. In the video you will notice the Red/Green LED – this is controlled thru the RFID module Enabling pin, so it that easy to control that.
But if you added another multicolor LED you would be able to decide which colors to use in the different modes.
does this require a computer at all times
@Zane
No, we use the computer in the video for demonstrating purpose only. It is fully functional on it’s own, the Arduino only needs power from a a wall wart or battery π
hi thomas, i’m still working on it..I was wondering if how did you connect the servo to the door lock,i really dont have an idea on mechanical side..so, you didn’t use any shield those were just jumpers right? really need it badly thanks a lot..
and one more thing only the start and stop bits were displayed in the hyperterminal when I was about to see the tag of the rfid. I dont know what’s the problem..thanks!!
i mean I could not see the key of the tags. only the start and stop bits were being displayed.
hoping for your reply soon thanks
@jessica
Dear Jessica.
We actually made our own shield as you can see at 0:50 in the video. Though for prototyping it is just as easy simply to connect the wires to the right pins.
The servo motor should be connected to +5V (red wire), GND (black wire) and the PWM data signal (orange or brown). In our case the PWM data wire is connected to pin 3 on the Arduino.
Are you using the same RFID board as we are using – the Parallax one?
Have you connected the TX line coming from the RFID board to the RX input on the Arduino?
Best Regards
Thomas Jespersen
Dear Thomas,
I used your code to programme mine. I use the ID-12 from Sparkfun, so I set the Baudrate to 9600.
If I insert the TAG ID in the master Slave, the programme does not recognize the ID.
But if I open Serial monitor, I see space between the Serial.print(“RFID Tag scanned: “); and the ID it self. If I copy this space and paste it into the Mastercode, it works.
So the RFID Reader, reads a sort of space as the first two bits. In serial monitor, the last two bits of the code are missing.
I hope you understand my problem, if not, you can email me for more information and pictures if needed.
Dear Thomas,
I found the problem. The start bit with the ID-12 is 0x02 instead of 0x0A.
So for the people who want to use the ID-12, adapt the Baudrate to 9600 and the start bit to 0x02.
Make sure that you put the Reset pin on +5V.
Grz
@Remi
Thank you for bringing awareness to the problem.
Regards
Lauszus
Thomas,
I am very interested in utilizing a fingerprint scanner in conjuction with an arduino nano for a home door lock. I have seen a project utilizing a electric door strike and wonder if that would work as well as the servo motor in terms of reliability and cost. Also, I am taking a minimalistic approach for aesthetic purposes and wonder if you have any thoughts on that as well as cost efficiency. Thanks!
Josh
@Josh
All right, that sounds like a great project.
There are definitely different approaches to that project, especially because you have to decide which locking mechanism you would like to use, just as you said.
The most common industrial use locking mechanism would either be the Strike lock or the Bolt lock. Both locks are electric controllable thru the power of a coil. The main difference is the mechanical part where the bolt lock shoots a bolt into the doorframe when locked, while the strike lock disables you to pull the door without lowering the lever.
The difference also means that if you have a door where the lever can’t be locked, you can’t use the strike lock.
If you are really up to this project and are going to utilize it for real, I won’t recommend you to go for any DIY servo solution. The strike or bolt lock is the correct and most secure industrial way – and they aren’t actually that expensive!
Best Regards
Thomas Jespersen
Hello there,
I enjoy the presentation and I wanted to learn this maybe think of another way to do something and I would like to know which kits that I have to buy and where can I get the kits so I can try this.
Thank you for your help and assistance…
@Ghislain
To redo this project you should get the following electronics components together with a door with a rotating door-lock-mechanism:
– Arduino Duemilanove or UNO
– TowerPro SG-5010 from Sparkfun Γ’?? Servo Γ’?? Large
– Serial RFID reader from Parallax
hi. i’m very interested on this project but it’s really hard for us to build, we kind of new on this sort of things. can you show us the circuit for this project please. really helpful thanks.
and can you list the materials that you guys use for this project. it’s really helpful thanks guys.
@clymment
I have listed the materials in my comment response to Ghislain just above yours.
The connections are very simple as there is nothing big in this project.
For the Servo you should connect +5V and GND to it and the Signal wire should be connected to the Arduino pin 3.
The Serial RFID reader board from Parallax that we are using is connected to the Arduino with two pins, the RFID SOUT pin goes to the Arduino serial RX pin (pin 0), and the RFID /enable pin goes to the Arduino pin 2.
Best of luck with the project.
thanks for the tips. and one more thing can i use 125Khz RFID module RDM6300 – UART for the rfid reader.?
@clymment
Yes, you should definitely be able to use that.
But I think you have to change the parts about start bit and end bit to match the output of the module.
Hello.
I’m from Brazil, I’m doing a project like yours, but I use Rfid 13.56 MHz MF522,
How to change the pins it to your code?
thank you very much !
http://www.ebay.com/itm/Mifare-RC522-Card-Read-Module-RFID-Reader-RF-Module-IC-Card-Proximity-Module-/150896531651?_trksid=p2045573.m2042&_trkparms=aid=111000&algo=REC.CURRENT&ao=1&asc=27&meid=2738135009338119720&pid=100033&prg=1011&rk=2&sd=251047079308&
@Bruno
Your module is a bit different as it uses SPI for communication while our used UART.
See the Arduino reference about SPI for more information: http://arduino.cc/en/Reference/SPI
Notice that the sensor is running at 3.3V, so you properly have to use a logic level converter like this one from Sparkfun: https://www.sparkfun.com/products/8745, so you wouldn’t damage the module, as the normal Arduino is running at 5V.
Thanks for the reply.
but the arduino provides voltage of 3.3 V, the example code provides that the seller is very hard to understand.
Do you think your code would work together with my rfid module ?
Thank you.
@Bruno
Just because it provides a 3.3 voltage source doesn’t mean it’s running at 3.3V. What Arduino are you using?
Yes the structure of the program will work, but the communication for your module is very different.
I’m using the arduino mega.
@Bruno
Okay, then it’s running at 5V. You will have to use a logic level converter so you don’t damage your module.
This is a great project! I am writing a tutorial about a similar project. Would you mind if I posted your code on my tutorial? I will also leave a link to this blog if you will let me post it.
@Garrett
Hi Garrett. No, definitely not, it will not be any problem.
As long as you keep a trackback to this post you are more than welcome to use and publish the code.
Ok, thanks! I don’t know when I will get around to posting the tutorial, but I will make sure to leave a link.
Hello!! I think it is very interesting for me, i have an arduino uno with MF522-AN 13.56 MHz.
I read the code you did it before. Do you think it is possible for me to use it?
My arduino can provide 3.3V??
The codes would be change a lots??
@Sam
You have to change the part which reads from the RFID module, as the one we used works via UART, but you can use the rest of the code without modification.
@Sam
Please have a look at the following page with an Arduino project for the MF522 module: How to get started with the Mifare MF522-AN and Arduino
Follow the guide on how to connect the module to the Arduino and then uncomment all the places where it says “Serial. ….so on” in the code to get some debugging information.
my rfid card reader has no “enable pin”.
i use RDM630 Proximity Reader.
how can i connect the rfid to arduino?
@anne
If you don’t have any Enable pin you should just remove anything “RFID_Enabled_Pin” related. As long as your module is then enabled all the time it doesn’t matter.
A quick search on Google lead me to this page which gives you a good explanation on how to get started with the RDM630 RFID module connected to an Arduino: http://blog.iteadstudio.com/play-rdm630-with-arduino/
A bit more advanced tutorial with Interrupts on read can be found here: http://maniacbug.wordpress.com/2011/10/09/125khz-rfid-module-rdm630/
Regards Thomas
thanks:)
the servo @ rfid works but the problem now is the display..
it doesn’t show anything in the serial monitor..
sorry,;):)i’m not good in programming…:D:D
@anne
Which kind of tutorial have you been following?
You should be cautious about the serial monitor when you have connected the RFID reader to the Serial port (RX/TX).
As the pins for the Serial monitor are the same pins as for the RFID board, connecting to the Arduino with your serial monitor in the same time will make the Arduino think that your inputs are actually data from the RFID module.
Please have this in mind π
so what is the wiring diagram
the rfid reader that i have has 7 pins consisting of mso, sck, ss, mosi, gnd, 3.3v and rsst its a “mf522-an”. if you can help me out with this at all that would bea big help
@jake vicary
We used a UART based RFID reader, so the code is not directly compatible with your reader, as it is using SPI for communication.
By doing a simple Google search I found the following blog post: http://www.grantgibson.co.uk/blog/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/, that might be helpful to you.
nice work
but how did you connect the RFID with the arduino and can it work with NFC reader too??
@Mohnnad
The RFID reader is connected to the RX pin of the Arduino as it transmits the read data thru UART.
And no, the module we are using in this project doesn’t work with NFC.
Hello,
Can you please tell me how do you connect the servo with the lock?
@Rui Ferreira
To mount the servo motor to the locking-mechanism on the door we took one of the servo plates and glued it together with the rotating metal-part (in our door a cross) inside the door.
So it will require you to dismantle the lock and modify it.
i have a rc 522 rfid reader module and i am making a rfid security system.it is very similar to your door lock.so can you please write the code of the door lock,which can be processed by the rc522 and how to change a normal rfid tag into a master tag?
Please answer me
@Aamir
Hi Aamir.
We can indeed help you write the code for your lock to work with an Arduino and the rc522 but at a cost.
Instead I would recommend you to have a look at the following already available Arduino library for the MFRC522 device: https://github.com/miguelbalboa/rfid
Otherwise feel free to contact me.
Good luck.
Best Regards
Thomas Jespersen
how did you connected the arduino with the rfid reader . what components did you used for that ? please provide all the connections and components list .
@Sonal
We are using the Parallax RFID module in this video: https://www.parallax.com/product/28140
The module connects to the Arduino thru the Serial/UART port where read data is transmitted directly as bytes.
Other than that we are just using a regular Servo motor connected to a PWM pin on the Arduino Uno.
Please can you list all the components you used are give the tutorial you followed please my final grade depends on it
Pls how did u connect the Led
@Favour
As mentioned in a previous post we are using the Parallax RFID module: https://www.parallax.com/product/28140
Other than that we are just using a regular Servo motor connected to a PWM pin on the Arduino Uno.
The LED itself can’t be individually controlled by corresponds to whether the module is enables or not (thru the enable pin). So we use the enable pin to exploit the changing of color on this LED.
Can you give us schematichs for this project! I would like to use it for my door!
@janko
There is no schematics for this project.
We simply use the Parallax RFID module connected to the UART port of the Arduino together with a servo motor connected to a PWM pin.
Please read the previous comments for similar answers:
http://blog.tkjelectronics.dk/2011/04/arduino-rfid-door-lock/#comment-548231
http://blog.tkjelectronics.dk/2011/04/arduino-rfid-door-lock/#comment-551747
i am planning on using magnetic lock instead of servo. can you help me to debug your codes. any help would be much appreciated. thank you
can i replace servo motor with magnetic lock? if possible, can you tell me how?
To use a magnetic lock you would need some kind of high-current driver connected to the Arduino. The most easy way would be to use either just a transistor, depending on the magnetic lock current or a combination of a relay and transistor.
in terms of the program/codes, what should i remove and what should i replace it with? sorry for the bad grammar, english is not my mother tounge.
got so far in this project but when i use other power source for the arduino, instead of my laptop’s usb port, the RFID_enable pin is always set on high… tell me what cause this to happen
@jereel
Where is this RFID_enable pin connected?
And which power source do you use for powering?
Please have in mind that you are recommended to use between 9V to 12V.
nevermind… i found out that my problem occur because i have a different power source for the parallax. i already fixed the problem by connecting all the ground. thanks for the response. ^_^
I have a question. In this part:
else if (RFID_Master_Correct == true && RFID_SaveNextRead == true) {
Serial.println(“Master Card Scanned again – Removing all saved Cards”);
delay(1000);
for (checkPosition = 0; checkPosition < 10; checkPosition++) {
RFID_Slave1[checkPosition] = 0;
}
for (checkPosition = 0; checkPosition < 10; checkPosition++) {
RFID_Slave2[checkPosition] = 0;
}
for (checkPosition = 0; checkPosition < 10; checkPosition++) {
RFID_Slave3[checkPosition] = 0;
}
for (checkPosition = 0; checkPosition < 10; checkPosition++) {
RFID_Slave4[checkPosition] = 0;
}
how can i delete a specific saved card instead of all saved cards?
@Arjay
You can do so by only including the clearing for-loop for the specific slave that you want to clear.
Eg. only to clear the slave 1 you replace all the above lines with only:
RFID_Slave1[checkPosition] = 0;
}
hi sir.. can u show us your circuit diagram ? please..
@jhed20
Please see this earlier reply: http://blog.tkjelectronics.dk/2011/04/arduino-rfid-door-lock/#comment-560452.
Can this work with a MF522 RFID Reader? If not what has to change. If as I suspect, you might want a token to write the code how much will it cost? – Please reply I am desperate to have this.
@Eme
The MF522 RFID is SPI based, why the connection scheme would be different.
The code could indeed be changed to use the MF522 module, though at first I recommend you to take a look at the following article: http://www.grantgibson.co.uk/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/
Hello! I plan on attempting this project over the summer, but I would like to use the ID-12 from Sparkfun. I saw that someone above also used it and it worked (with slight modifications). I am confused if I would need the USB reader included in the RFID kit they have. The link below is the kit. RFID is fairly new to me, so I am unsure what ports to use as well, although I know it should be a fairly straightforward answer.
https://www.sparkfun.com/products/13198
After further investigation, I believe I do not need the USB reader after all. I believe I only need the ID-12 (or ID-20) for it to work. Is my suspicions correct? However, I am still not sure what pins to use in conjunction with your code. I have attached the datasheet link below; Thank you! The pin assignments are on page 3 with description on page 6.
http://cdn.sparkfun.com/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA2013-4-10.pdf
@Hunter
It is indeed correct that you do not have to use the USB reader when you want to interface and use the ID-12 or ID-20 unit with your microprocessor-based project.
Please read about how I used an ID-12 reader with an Arduino to read EM-Marine RFID cards: http://blog.tkjelectronics.dk/2009/06/rfid-modded-safe/
Hi Greate job, doing well and this information is worth for anyone who unknown for the rfid door lock. I am sure that this door lock is better than other.
Hi, this is very awesome.I have only one question how did you customize the door lock?. I want to make a project like this but I don’t have the idea and the schematics. could you share you idea how did you do this and the hardware.thank you very much.
@Christian Jude
We simply made a bracket to allow a standard 5V servo motor to be attached to a regular mechanical turnable door lock knob.
Although the video shows a working prototype I would probably not recommend this for final and secure applications.
Instead I would recommend to take a look at the electronic bolt locks that can be found on eg. eBay: http://www.ebay.com/bhp/electric-bolt-lock
These locks are solenoid-based bolt locks which offers a higher reliability.
Or as an alternative would be the electronic strike lock: http://www.ebay.com/bhp/electric-door-strike