technology
workshop
living
food
play
outside
How to connect Arduino and RFID
by otaviousp on September 13, 2009
Table of Contents
How to connect Arduino and RFID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Intro: How to connect Arduino and RFID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 1: What you gonna need? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 2: Plugging all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 3: The code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 4: Results! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Intro: How to connect Arduino and RFID
On this instructable I will try to show how to interface a RFID sensor with the Arduino. I am using the RFID sensor from seeedstudio the serial version of it. There are a
few parts you will gonna need. I also bought some RFID keys.
UPDATE: Now it works with IDE 021
Step 1: What you gonna need?
- Arduino Board
- RFID Sensor from seeedstudios
- Wires
- Protoboard
- RFID tags (125kHz) from seeedstudios
Image Notes
1. Arduino Board
2. RFID sensor board
3. RFID antenna
4. Wires
Image Notes
1. Card that I used to add another tag.
2. The card I used to deny others TAGs
3. Sample TAGs
Step 2: Plugging all together
Connect the antenna on the appropriate pins like the first photo.
Plug the RFID sensor to the protoboard like the second photo above.
Only 3 wires are required to interface, 2 wires for supply and another for the serial line(communication)
The wires as connected as the third photo shows.
On RFID sensor: PIN 1 -> Tx
PIN 2 -> Rx (Not Used)
PIN 3 -> NC
PIN 4 -> GND
PIN 5 -> VCC (+5V)
Tx from RFID board goes to Digital PIN 2 on Arduino Board.
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
That is all you gonna need to wire.
Moving on to next step, the software.
Image Notes
1. Some tape to hold the wires.
Image Notes
1. Tx PIN
2. GND
3. Vcc
Image Notes
1. Arduino PIN2 (Rx) SoftSerial
2. NC
3. Tx
4. Vcc
5. GND
6. Antenna
Step 3: The code
I'm not a software guy, so this code is just for demonstration.
I don't make any kind of checksum at the tags code, but it seems to work fine.
The code is really simple. I used a new library for the serial, using software emulation.
With the two white cards you can deny or allow the access of others keys.
Any doubt, please ask me.
Edit (05/11/12):
code update for new Arduino version
File Downloads
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
RFID_2_eng.pde (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'RFID_2_eng.pde']
RFID_arduino_version_1.0.1.txt (2 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'RFID_arduino_version_1.0.1.txt']
Step 4: Results!
There is no LED, sound or LCD for debug or visualization, just through the serial line.
The video demonstrate how to use the software. I didn't post any kind of explanation as text on the video. I hope that the images spokes more then words, xD
Any doubt or suggestion, feel free to ask, or correct me.
Please, if you like it, rate it,
thank you
Related Instructables
Arduino
Tutorials RFID
by tronixstuff
Closable Food
Dish with
Twitter
Notification by
JessieV93
RFID cat door
by landmanr
Reading RFID
Tags with an
Arduino by
MrkTrussell
Music Notes
using Low-Tech
Capacitive
Sensor and
RFID by
krismawil
Switch On and
Shutdown the
PC by RFID & IR
by Rifath
Advertisements
Comments
50 comments Add Comment
view all 131 comments
epidemicz says:
Oct 13, 2009. 4:30 AM REPLY
Thanks for the instructable man, really appreciate it. I've been wanting to do something with rfid and this is going to help me out big time.
otaviousp says:
Oct 13, 2009. 5:16 AM REPLY
Nice, thank you for the positive feedback. xD
FaiquahL says:
Mar 14, 2015. 12:33 PM REPLY
sir kindly again post the vedio in which mention software type and how to add /delete users of tags.
which code is best one between the two of them.please help me sir...........
FaiquahL says:
Mar 14, 2015. 12:35 PM REPLY
tell me either arduino uno will remain best for finger print scanner and rfid or other type??? and also tell me which rfid is available with data base
/software...? and
edugr says:
Mar 1, 2015. 2:06 PM REPLY
Hi, thanks for the tutorial, it worked perfectly on my Arduino Mega 2560 (just changed the RX to digital 50).
Do you know if I can read the Sticker version of RFID with this componente or do I need some other type? can you recommend me one? Thank you very much!
jess.delamerced says:
Feb 10, 2015. 3:00 AM REPLY
Hi, just a noob question:
You're using the RFID Cards and Keys here, right? Is it possible to use the RFID stickers(the ones that can be placed on equipments or someting) as a
substitute? as long as it's 125Khz?
Thanks.
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
otaviousp says:
Feb 10, 2015. 6:33 AM REPLY
I think it is possible, but the distance that you can read the sticker may be smaller than the read bycard.
jess.delamerced says:
Feb 17, 2015. 3:54 AM REPLY
Hi, thanks for the reply. I had used a 125Khz card instead. So I tried the code of brenryan since I just need a simple program that displays the card's
id(also modified 1 line of the code "tag=tag.substring(1,13);" replaced 13 with 19 since my card has 18 digit code. Anyway, now I'm facing a different
problem, do you have any idea why the output looks like this?
vincent.cayanong says:
Feb 6, 2015. 8:13 AM REPLY
Hello! I'm quite confuse on my connection to arduino uno to rfid rc522 don't know where should I connect the pins from rfid rc 522 to arduino uno.. Pls do show
some pics for their connections or guides... Need help also for a sample module to test my rfid rc522 if its working or not using my arduino uno... I really
appreciate your great help..
LeoA5 says:
Jan 28, 2015. 8:05 PM REPLY
can you help im having issues compiling code on the link it one. Not sure if I have the right library.
sketch_jan28a.ino: In function 'void loop()':
sketch_jan28a.ino:30:40: error: 'add' was not declared in this scope
sketch_jan28a.ino:31:45: error: 'del' was not declared in this scope
sketch_jan28a.ino:32:37: error: 'verifica' was not declared in this scope
Error compiling.
RiaanBod says:
Oct 4, 2014. 8:11 PM REPLY
What happens if your arduino restarts or lost power. Do you have to re-program the TAGs again?
otaviousp says:
Nov 14, 2014. 12:51 PM REPLY
On this code you have to reprogram
SimonT2 says:
Thanks!!
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Nov 14, 2014. 6:46 AM REPLY
VishalG1 says:
Sep 14, 2014. 9:13 AM REPLY
Hi, Mandeep for ES-125R Rfid reader you can get complete support by writting mail over this Email, contact@elesof.com, or you can call them directly +917533036999.
me happy to help
abramo.lieo says:
Aug 15, 2014. 2:54 PM REPLY
great. good. amazing.
kamra says:
Jul 5, 2014. 11:42 PM REPLY
Hi,
I have one ES 125 R, please tell me how to connect it to arduino.
RFID pins of ES 125R as such
A0 , A1 , O/P , GND , +5V , R , TX
MandeepS1 says:
Jul 27, 2014. 7:44 PM REPLY
I have the same ES125R, have you been able to figure out as to how to use it, if so would your share it, thanks
otaviousp says:
Jul 28, 2014. 5:54 AM REPLY
A simple search at google returns this schematics
Just connect your TX pin from ES 125R to your RX pin at your Arduino board.
Power UP your ES 125R module, make a program to continues read the serial port at 9600 baud rate, open the serial monitor, approach the rfid tag
to the board and see if something has been send through the serial port.
If it work or doesnt works, please tell me.
otaviousp says:
Forget to upload the image of the schematic
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Jul 28, 2014. 5:56 AM REPLY
AroojZ says:
Jun 25, 2013. 4:08 PM REPLY
Hi I have arduino Mega ADK, Here is a preview of it, http://arduino.cc/en/uploads/Main/ArduinoADK_R3_Front.jpg can you tell me where to connect the TX
of RFID in the arduino board? I,m an extreme beginner so if my question is stupid please bear with me. Just tell me the exact pin number on which to attach
from the arduino board's picture! Thanks in advance.
MandeepS1 says:
Jul 27, 2014. 7:47 PM REPLY
Have your been able to figure it out pl, I have the same question
Ivar Michelena Viti says:
May 29, 2014. 6:58 PM REPLY
Congratulations otaviousp! Do you know how far could we connect the rfid module to the arduino board?
otaviousp says:
Jun 3, 2014. 1:02 PM REPLY
Hi Ivar,
The communication between the arduino and the RFID module is done by a serial cable. So the max distance depends on the velocity of transmission
(baud rate), and the quality of the cable.
Usually the module stay near the Arduino(slave), then the arduino send the information to another arduino(master) for long distance.
Lower the baud rate, bigger the cable you can use.
factory909 says:
Mar 11, 2014. 9:10 AM REPLY
Very nice brotha! Have you did any other interfacing with this since your project? I'm thinking door locks...
otaviousp says:
Apr 22, 2014. 3:40 PM REPLY
Hey,
I did not interface it with other devices, but it is quite simple to do.
With you need any help, please tell me.
brenryan says:
Apr 5, 2014. 5:50 PM REPLY
Nice ible. Well done, I learnt much more about this RFID module here than on it's wiki...
I'm just trying to make a simple reader that just spits out the read tags ID number then moves onto a new line. I've taken bits of your code to get started, I
don't see why it's not working the same way as it does in yours :/
Maybe you can help? I would really appreciate any assistance...
#include <SoftwareSerial.h>
SoftwareSerial RFID(10, 11);
String msg;
void setup()
{
Serial.begin(9600);
Serial.println("Serial Ready");
RFID.begin(9600);
Serial.println("RFID Ready");
}
char c;
void loop(){
while(RFID.available()>0){
c=RFID.read();
msg += c;
Serial.print("Tag ID: ");
Serial.println(msg); //Uncomment to view your tag ID
//Serial.println(msg.length());
}
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
msg=msg.substring(1,13);
msg="";
}
otaviousp says:
Apr 7, 2014. 1:44 PM REPLY
Try this code and send me the result.
#include <SoftwareSerial.h>
SoftwareSerial RFID(10, 11);
String msg;
void setup()
{
Serial.begin(9600);
Serial.println("Serial Ready");
RFID.begin(9600);
Serial.println("RFID Ready");
}
char c;
void loop(){
while(RFID.available()>0){
c=RFID.read();
Serial.println(c);
msg += c;
Serial.print("Tag ID: ");
Serial.println(msg); //Uncomment to view your tag ID
Serial.print("Msg Length: ");
Serial.println(msg.length());
}
msg=msg.substring(1,13);
msg="";
}
brenryan says:
Apr 7, 2014. 4:05 PM REPLY
Hi, thanks for getting back to me!
That code has some of the same unpredictable results I was experiencing sort of a "stacking" phenomenon, If you hold the tag for just the right
amount of time it's ok... But that's not going to happen too often.
Serial Ready
RFID Ready
Tag ID:
Msg Length: 1
0
Tag ID: 0
Msg Length: 2
0
Tag ID: 00
Msg Length: 3
3
Tag ID: 003
Msg Length: 4
C
Tag ID: 003C
Msg Length: 5
3
Tag ID: 003C3
Msg Length: 6
4
Tag ID: 003C34
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Msg Length: 7
E
Tag ID: 003C34E
Msg Length: 8
B
Tag ID: 003C34EB
Msg Length: 9
1
Tag ID: 003C34EB1
Msg Length: 10
5
Tag ID: 003C34EB15
Msg Length: 11
F
Tag ID: 003C34EB15F
Msg Length: 12
6
Tag ID: 003C34EB15F6
Msg Length: 13
Tag ID: 003C34EB15F6
Msg Length: 14
Tag ID: 003C34EB15F6
Msg Length: 15
0
Tag ID: 003C34EB15F60
Msg Length: 16
0
Tag ID: 003C34EB15F600
Msg Length: 17
3
Tag ID: 003C34EB15F6003
Msg Length: 18
C
Tag ID: 003C34EB15F6003C
Msg Length: 19
3
Tag ID: 003C34EB15F6003C3
Msg Length: 20
4
Tag ID: 003C34EB15F6003C34
Msg Length: 21
E
Tag ID: 003C34EB15F6003C34E
It goes on, and on but you get the picture.
With some strategically placed delays I found a (sloppy, I'm a newb, so whatever works right?) code that works for me.
Sometimes it double reads, but that's not so bad. Still mostly taken from your code;
#include <SoftwareSerial.h>
SoftwareSerial RFID(10, 11);
String tag;
void setup()
{
//pinMode(8, OUTPUT);
//pinMode(9, OUTPUT);
//digitalWrite(8, LOW);
//digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Serial Ready");
RFID.begin(9600);
Serial.println("125khz RFID Ready");
Serial.println("Waiting for a Tag...");
}
char c;
void loop(){
while(RFID.available()>0){
c=RFID.read();
tag += c;
}
tag=tag.substring(1,13);
while(tag.length()>0){
Serial.println("Tag Detected"); Serial.print("ID: "); Serial.println(tag);
tag="";
delay(2000);
Serial.println("Waiting for a Tag...");
tag="";
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
}
delay(1000);
tag="";
}
Works fine for my needs. Sorry I didn't update the comment after I found a solution, I posted and then saw it was over 2 years and though "Oh
Crap".
Thanks again for getting back to me and for the help and inspiration!
Take care, Bren
aaafred says:
Mar 31, 2014. 12:00 PM REPLY
Hi Otavio,
I was wondering, you didn't build in an option to deactivate a 'tag' when the tag has been compromised. So when the 'tag'is lost there's no way do deactivate
it.
Maybe it's an option to make a 'deactivate all tags' option with a third 'card'?
otaviousp says:
Mar 31, 2014. 12:11 PM REPLY
Very nice suggestion.
With a little code modification it is possible to implement this option.
aaafred says:
Mar 31, 2014. 3:42 PM REPLY
Wow, that was a fast reply! I just ordered a new RFID reader (one that hopefully works with your solution) and i just like the idea of adding and
deleting tags 'on the fly' rather than hardcoding them. Since I'm an Arduino newbee, I have really no idea how to create such a modification. Could
you help me out please?
otaviousp says:
Apr 3, 2014. 8:34 AM REPLY
A sent you the code by private message but I did not test it.
If it does not work tell me.
aaafred says:
Apr 3, 2014. 1:31 PM REPLY
Thank you! You're faster than the needed hardware. When I get the stuff (next week?) I'll try and certainly let you know!
jacyquint says:
Apr 3, 2014. 7:17 AM REPLY
Where would you go about getting an RFID antenna?
otaviousp says:
Apr 3, 2014. 8:17 AM REPLY
Sorry, I did not understand your question.
zat_90s says:
Jan 21, 2014. 11:28 AM REPLY
thanks bro.. your instruction are clear and easy to follow. I manage to done many things with RFID and arduino with no time.. Thombs up!
cmalivoire says:
Apr 10, 2013. 6:14 AM REPLY
Great guide, however I do need some help. I've followed this guide connecting the module to my Arduino UNO that I have just downloaded the libraries for.
However when I run the code, it downloads, but shows no response when a card is passed over the antenna. I have tried this with another module and 10
different cards to check if its faulty equipment, but all have the same result. Any help would be greatly appreciated.
otaviousp says:
Apr 10, 2013. 1:14 PM REPLY
Hey,
Can you send me pics of your circuit and your code?
I did not try this conde with UNO. With any one here make it works with this arduino please help us.
Cya
KSidiya says:
I have the same problem did you manage to solve it??
I thought it was the connection then the tags but apparently everything is fine. please help ASAP :'(
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Dec 11, 2013. 9:38 AM REPLY
hiteshreddy says:
Nov 16, 2013. 2:32 PM REPLY
how to run this code in arduino 1.0.5 pls help me
dizonjoemer28 says:
Sep 14, 2013. 12:39 AM REPLY
any source code for vb 6.0 that has a same function with the code that you've given before?
otaviousp says:
Sep 19, 2013. 2:35 PM REPLY
Not yet sorry for that.
saiganesh_panchu says:
Aug 26, 2013. 10:17 AM REPLY
i even changed the code and replaced your tag details with mine ..but still showing as access denied
otaviousp says:
Aug 27, 2013. 7:11 AM REPLY
Can you send me a video showing what are you doing and the messages that appear on the screen?
saiganesh_panchu says:
Aug 25, 2013. 10:57 PM REPLY
I have three cards with card id (6B0037E8398D) (6B0037E158E5 ) (0800692B5D17)
when i replace your cards with my card details , i get access denied in my serial monitor with the correct code of my tag displayed
***************************************************************
display in serial monitor
Serial Ready
RFID Ready
6
1
6B
2
6B0
3
6B00
4
6B003
5
6B0037
6
6B0037E
7
6B0037E8
8
6B0037E83
9
6B0037E839
10
6B0037E8398
11
6B0037E8398D
12
Access denied.
otaviousp says:
Aug 26, 2013. 8:54 AM REPLY
On my example you gonna need 2 cards. 1 card to authorize other cards and another card to delete the authorized cards.
For example:
On the code replace ADD_TAG_CODE "210014DFE309" to ADD_TAG_CODE "6B0037E8398D"
and replace DEL_TAG_CODE "210014E2BD6A" to DEL_TAG_CODE "6B0037E158E5"
Recompile and restart your Arduino.
Now, Take the first card number 6B0037E8398D and approach to the sensor and take it away
Then take the third card number 0800692B5D17 and approach to the sensor. A message should appear telling you that for this card authorization has
been granted,
And Now you can use it to have access.
Sorry for my bad english, hope that esxplanation can help you. Any problem please ask.
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
mfinco says:
Jun 4, 2013. 4:50 AM REPLY
do you think is possible programming by adding wifi module? like by WEB? :S
grocha3 says:
May 31, 2013. 8:44 AM REPLY
Not work for me , I'm using RIFD R/W YHY502CTG 13.56 Mhz. I set it to 19200 bauds. but the same that code return characters not recognizable. Sorry for my
English...
otaviousp says:
Apr 10, 2013. 1:12 PM REPLY
Hey,
Can you send me pics of your circuit and your code?
I did not try this conde with UNO. With any one here make it works with this arduino please help us.
Cya
balljoe says:
I just want to say my experience on my testing. The sketch (RFID_arduino_version_1.0.1.txt),
Tx from RFID board goes to Digital PIN 5 on Arduino Board, not PIN 2.
But the old sketch is point at PIN 2, so I think that why some people said that's not work.
view all 129 comments
http://www.instructables.com/id/Arduino-and-RFID-from-seeedstudio/
Mar 4, 2013. 10:53 AM REPLY