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


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.
grocha31 year ago
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...
balljoe1 year ago
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.
macdja382 years ago
I would love 3 led's
1.Green excepted
2.red denied
3.yellow ready for an RFID card reprogramming

This would also make it easier for for people like me to connect a motor to the place the led was.

Thank you very much.
hissamu2 years ago
Olá Otavio! Parabéns pelo projeto, porém não estou conseguindo compilar o projeto. Adicionei a NewSoftSerial12 e tentei usando a versão 0021 da IDE do Arduino, só que fica dando erro no NewSoftSerial.cpp. Poderia me ajudar por favor? Obrigado!
Meca2422 years ago
When I try and verify the sketch it says "it says error "RFID" was not declared in the scope."

Please help me fix this!
otaviousp (author)  Meca2422 years ago
Did you add the newsoftserial library?

You can find here: http://arduiniana.org/libraries/newsoftserial/
Yup, I do have the newsoftserial library and it is still giving me the same error as before.
Guibom4 years ago
Hey Man, thanks!! I thought my RFID was broken... I could get the LED to flash when I scanned a card, so I knew the antenna/etc was ok  But I couldn't read the card at all... Turns out using the old SoftwareSerial didn't really work out.
When I saw your example and changed to the NewSoftwareSerial, it instantly fixed the problem.

E vc e' Brasileiro ne'?! =D
otaviousp (author)  Guibom4 years ago
Opa, é nois, xD

Se precisar de algo, pede ae.

Abrass
boas, eu gostava de controlar os 8 leds via webrowser no arduino ( D2 a D9 )
ou seja uma pagina simples em que tenha um ON e OFF via ethernet atravez dele....

email : lx.nuno.rodrigues@gmail.com


OBS : Estou a usar o Arduino Uno + Ethernet Shield ( com MiniSD )
otaviousp (author)  nrodrigues3 years ago
Ola,

Tente usar este tutorial, duvida me pergunta.

http://www.instructables.com/id/Ethernet-Shield-LED-WEB-SERVER/
mwp3 years ago
i have just been trying this code on a Duemilanove with an ATMEGA328, and was not seeing any response to the RFID tags.

When I uncommented the println statements in the reading loop it worked as expected, so it seems that the program was trying to read the bytes too fast. After the first byte is read it loops back to test if another byte is waiting, and if it is not, then the loop exits with the string 'msg' just one byte long.

It works when the println is executed, because then there is always time for the next byte to arrive before RFID.available is called.

The solution is to add an explicit delay:

while(RFID.available()>0){
c=RFID.read();
msg += c;
delay(1); //allow time for another byte to arrive
//Serial.println(msg); //Uncomment to view your tag ID
//Serial.println(msg.length());
}
devondo3 years ago
What is you code? i can't download it here its just a Tmp file
otaviousp (author)  devondo3 years ago
rename it to .pde
paradox1163 years ago
I can't get to the code you included here and I'm still learning the ins and outs of programming.. could you please send me the code in a private message? I have the same RFID reader and I'm stalled on my project until I can figure out how to get my code to work. Thanks!
otaviousp (author)  paradox1163 years ago
Try to download the code and rename the file to rfid.pde.

If it does not work, plz tell me.
It keeps downloading it as a .TMP file. It's probably some simple fix that I just don't know about.
arduinoer4 years ago
where can we get the WString library?
otaviousp (author)  arduinoer4 years ago
arduinoer4 years ago
where can we get the new library, without it it's worthless?
otaviousp (author)  arduinoer4 years ago
SubMicro4 years ago
where did you get the library?
otaviousp (author)  SubMicro4 years ago
(removed by author or community request)
That is not the NewSoftSerial library.  Also I'm trying to use this RFID reader to create an automatic door lock, any help would be appreciated. 
otaviousp (author)  SubMicro4 years ago
sorry, my bad

http://arduiniana.org/libraries/NewSoftSerial/

cya