Getting the RFID-RC522 to work! [SOLVED]


@peekay123 I’ll try that now see if it works!

edit: That didn’t seem to fix it for me. What are the chances that the reader is bad? I feel like I probably messed something up…

I don’t have an available arduino to test it on either to verify if the device is working. I guess I can just order another one and see…

edit 2: before I order a new RC522, does anyone have a recommendation for another RFID reader?

I did find this arduino library for it, though which apparently has the read/write aspect figured out: , which doesn’t help me if I can’t get it to work in the first place :stuck_out_tongue_closed_eyes:


@austinpe, before you give up on the module, let me port the other library so you can test it.

Other members like @BDub have used the adafruit PN532 and we have a working library for that module.


@peekay123 that’d be awesome! Thanks :smiley:


@austinpe, I have posted a new RC522 library for you to test. Hopefully, this one will work. :wink:


@peekay123 , it didn’t work, HOWEVER, I’m really excited for this port when I get it working. I’ve got a really cool project that will really utilize this!

I’m pretty sure my card is bad :cry: – I just played a Saturday delivery for another one on Amazon, so I’ll be able to try it out in a day.


@austinpe, it may be worth picking up an Arduino to do some hardware validation. :wink:


Just tested it, workes great!

I thought it would take a while to be ported but I was wrong. Now I can integrate this in my project.

Thank you all for the hard work and time!



@mstelt, that’s great news! which library did you use???


The one straight from Github. Just changed the digital pin for reset and set it to hardware mode.


@mstelt, that is great news cause @austinpe was having a heck of time trying to make his work. He suspects, as I do, that he had a bad board so he ordered another one. Thanks for the infor! :smile:


So, interesting turn of events @peekay123 . I got my new board in, plugged it in and tried to register one of the cards from the original RFID package and it didn’t work.

I was pretty bummed and though the issue was somewhere with my wiring, but I tried to register one of the newer cards that came with the new RFID package… and that worked! I plugged in the old one and registered one of the new cards on it, so that one was working, but the cards weren’t!

tl;dr: The new board came and worked with the new cards. The old one works with the new cards. The old cards are trash.

Also, I tried the new library (the RC522 library) and it works! But, when I have the DumpInfo.ino loaded, and I scan a card it registers the card correctly, but then when I pull the card away I get an endless stream of:

59 MIFARE_Read() failed: A MIFARE PICC responded with NAK.
58 MIFARE_Read() failed: Timeout in communication.
57 MIFARE_Read() failed: Timeout in communication.
56 MIFARE_Read() failed: Timeout in communication.
55 MIFARE_Read() failed: Timeout in communication.
54 MIFARE_Read() failed: Timeout in communication.
53 MIFARE_Read() failed: Timeout in communication.
52 MIFARE_Read() failed: Timeout in communication.
51 MIFARE_Read() failed: Timeout in communication.
50 MIFARE_Read() failed: Timeout in communication.
49 MIFARE_Read() failed: Timeout in communication.
48 MIFARE_Read() failed: Timeout in communication.


@austinpe, that is really frustrating. A good board but useless cards!! So, if I understand correctly the original and new libraries work well except for that message loop. I will take a look to see what I can find. I am glad that it is working though :smile:


@peekay123 Yep! Both libraries work! Thank you! :smiley:

On the first library, if I put the card next to the reader and hold it there it’ll go back and forth saying “Card Detected” and “Card not Detected” but, I’m sure that’s just a polling issue that I can look into.


Sir, i have try this program, and its working.
but i have 2 RFID MRC522 for 1 arduino.
how can i initiate my RFID with RFID1 and RFID2 in my arduino, so my arduino can detect a card tag from each RFID,
example, RFID1 detect tag1 and RFID2 detect tag2.


@arideba, is this regarding using two MRC522 units on the Spark or on an Arduino? Either way, the way the library works is that you create a reader “instance” by using its constructor like this in the examples:

MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance

Notice that you pass two values - the SS or chipselect pin and the RST or reset for the MRC522 board

So, to use a second board, you would create another instance and specify a different name (mfrc522 in the example above) and different SS and RST pins (so you need two extra pins) like this for example:

MFRC522 RFID1(SS1_PIN, RST1_PIN);	// Create MFRC522 instance
MFRC522 RFID2(SS2_PIN, RST2_PIN);	// Create MFRC522 instance

Of course, you need to define SS1_PIN, SS2_PIN, RST1_PIN and RST2_PIN in your code. The SPI connections (MOSI, MISO, SCLK) stay the same and goes to both boards. Then in your code you refer to each reader separately. :smile:

Please note that I removed the other topic you created with the same question.


@peekay123 Thanks for your reply…
i will try the code,
i will take the data from tag and RFID to the database, in my case i use mysqlserver,
that i want to ask, which one better i use, i put the data in my tag card or only pass the unique code from card and then in database i make database based on the unique code ( i make the unique code as the primary key).


@arideba, if you use the tags for uniquely identifying someone/thing and don’t actually need to store data in the tags then I would just use the unique ID and save having to write of extra code. Using that ID as your primary key is logical then. :smile:


oh, so the best think is only how to pass the unique code from RFID and the tag to the database through the arduino right?
and, if i want to ask you some picture or video that show me how it works with 2 rfid and 1 arduino, please let me see it.
thanks for all your help


@arideba, I don’t have those RFID units! I gave you the necessary wiring instructions for hooking them up. I am still not clear if you are using an Arduino or a Spark Core for this!?


ok sir…
i will try your advise…
maybe i will ask you another question again later…
thank you very much @peekay123