Instructables
Picture of 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
 
Remove these adsRemove these ads by Signing Up

Step 1: What you gonna need?

- Arduino Board
- RFID Sensor from seeedstudios
- Wires
- Protoboard
- RFID tags (125kHz) from seeedstudios

Step 2: Plugging all together

DSC05292.JPG
DSC05293.JPG
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.

That is all you gonna need to wire.

Moving on to next step, the software.

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

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


1-40 of 122Next »
epidemicz5 years ago
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 (author)  epidemicz5 years ago
Nice, thank you for the positive feedback. xD
KevenY5 days ago
RiaanBod1 month ago

What happens if your arduino restarts or lost power. Do you have to re-program the TAGs again?

otaviousp (author)  RiaanBod9 days ago

On this code you have to reprogram

SimonT2 made it!9 days ago

Thanks!!

wp_20141114_15_44_51_pro.jpg
VishalG12 months ago

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 +91-7533036999.

me happy to help

abramo.lieo3 months ago

great. good. amazing.

kamra4 months ago

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

temp_-834958804.jpg
MandeepS1 kamra3 months ago

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 (author)  MandeepS13 months ago

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 (author)  otaviousp3 months ago

Forget to upload the image of the schematic

instru.png
AroojZ1 year ago
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 AroojZ3 months ago

Have your been able to figure it out pl, I have the same question

Congratulations otaviousp! Do you know how far could we connect the rfid module to the arduino board?

otaviousp (author)  Ivar Michelena Viti5 months ago
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.
factory9098 months ago

Very nice brotha! Have you did any other interfacing with this since your project? I'm thinking door locks...

otaviousp (author)  factory9097 months ago
Hey,

I did not interface it with other devices, but it is quite simple to do.

With you need any help, please tell me.
brenryan7 months ago

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());

}

msg=msg.substring(1,13);

msg="";

}

otaviousp (author)  brenryan7 months ago
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="";

}
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
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="";
}
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
aaafred7 months ago

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 (author)  aaafred7 months ago

Very nice suggestion.

With a little code modification it is possible to implement this option.

aaafred otaviousp7 months ago

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 (author)  aaafred7 months ago

A sent you the code by private message but I did not test it.

If it does not work tell me.

aaafred otaviousp7 months ago

Thank you! You're faster than the needed hardware. When I get the stuff (next week?) I'll try and certainly let you know!

jacyquint7 months ago

Where would you go about getting an RFID antenna?

otaviousp (author)  jacyquint7 months ago

Sorry, I did not understand your question.

zat_90s10 months ago

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!

cmalivoire1 year ago
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 (author)  cmalivoire1 year ago
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 otaviousp11 months ago
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 :'(
how to run this code in arduino 1.0.5 pls help me
any source code for vb 6.0 that has a same function with the code that you've given before?
otaviousp (author)  dizonjoemer281 year ago
Not yet sorry for that.
i even changed the code and replaced your tag details with mine ..but still showing as access denied
otaviousp (author)  saiganesh_panchu1 year ago
Can you send me a video showing what are you doing and the messages that appear on the screen?
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 (author)  saiganesh_panchu1 year ago
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.
mfinco1 year ago
do you think is possible programming by adding wifi module? like by WEB? :S
1-40 of 122Next »