Getting the RFID-RC522 to work! [SOLVED]


hello guys ,,i began to learn about rfid and arduino ,, i tried your code to read RFID tag but there was a problem with it ,, when i compiled it there was an error which is "RFID"doesn't name a type , what should i do
help me please !


@nooraqqad, which RFID library did you use?


@peekay123 i don't know , how can i know ehich one i used ! frowning


@nooraqqad, where are you getting the library from?


i think there was a problem in adding RFID library
how can i get RFID library ?


@nooraqqad, I am confused. First you say that you had compile problems then you ask how can you get the library! WHICH library did you try in the first place (where did you get it from)?


from here !


@nooraqqad, ok now I understand. There is a bug in the examples that come with the libraries. For some reason, I cannot seem to be able to republish my own library! @jgoggins, perhaps you can help? The library is call MFRC522.

In the meantime, you can fix the problem by replacing #included MFRC522.h in the example (.ino file) with #include MFRC522/MFRC522.h. That should get you compiling. smile


This lib looks cool and work fine, I got a nicely packaged one here

Still there is one problem, all it can do is read the serial number, how can I make it read rfid data and even write data ?


Hi @notsgnik,

Most RFID readers only pull in the serial number from the fob. Emulating an RFID card is harder, I remember someone posted a project on that recently here:



@notsgnik, the original library I posted was for a specific member. There are a couple of other examples that show how to read and write to the fob, as well as, how to setup a block on a MIFARE Classic PICC to be in "Value Block" mode. I can port these examples and add them to my repo later today. smile

ACTUALLY, have you looked at the MFRC522 library on the web IDE? It has those examples already!


@Dave I found some good one that have doc and lib to fully understand it all. it's not emulating a card that i want, it's to be able to read it's content or even copy it. i'm starting to understand it more thanks to the doc on a repo i founded.

@peekay123 i'll look it up. i'll will also be glad to take a look at your repo.
( also i'm new to all this, how can i found the web ide you are talking about? if it's not too noob to ask)

thanks for answering that quickly smile


@notsgnik, I am assuming you have a Spark Core and have logged in to the web IDE at:


Sorry, I ended up on this forum and signed-up cause it looked like,
I would have the best answer here.
I actually have a BuonoR3 from this maker kit :

btw: I took a look a your repository for the rc522, this one have a nice documentation

I took a look at the library from, It looks exactly the same minus some examples.

Thanks for the answer, the web IDE look cool and the fact that the spark core is tiny and wifi enabled is cool too! ( [troll] making the Intel Galileo looking even more useless [/troll] ).
I hope that the fact that I don't own a Spark core will not exclude me from this community.


@Dave Thinking about it, it will actually be more easy with the device from hack a day ^^.
:D thanks for the link.


@notsgnik, we are a cool bunch in this forum. We often help folks who don't have a Spark smile


I just had a look at plugging this board into the Spark.IO using UART rather than SPI, and what I found was that this is possible using an MFRC522 based circuit, it most likely is not possible on the RFID-RC522.

Basically Pin 1(I2C) is connected directly to GND, and Pin 32 (EA) is connected directly to 3.3V. These are the two pins that select between UART/SPI/I2C mode. As set, they force the device into API mode, and I have not yet found a way to override them. In fact, I am not quite sure why there is an SDA pin on the PCB, since I have not found a way to select I2C mode.

If there was a way change mode, the MISO pin could be used as SCL in I2C mode. MOSI and SCK would be address pins. In UART mode, RX and TX would be SDA and MISO with MOSI and SCK used for handshaking

To summarise, unfortunately, with this PCB, it looks like you are stuck with SPI. Of course there might be an SPI way to change the device into UART or I2C but I could not find it looking at the data sheed.


@vk2tds, from what I could see of the spec sheets, the SPI/I2C/UART configuration is done via hardware pin configuration and unless someone wants to desolder the pins on the smd chip, the board will remain SPI.


hi @peekay123,

for the project ,
it is throwing a error from my C++ compiler, but not Spark Web IDE.

C:\Users**\spark\core-firmware\build/../src/application.cpp:53: undefined reference to `MFRC522::MFRC522(unsigned char, unsigned char)'


@yuanetking, can I assume you are setup to compile locally with the Core toolchain and repos? The way the IDE compiles libraries, examples require a path like this to include the .h files:


However, this may not be correct for your compile environment. You will need to review the include statements in each file to make sure it the .h files re found by your compiler. smile