Getting the RFID-RC522 to work! [SOLVED]


@Ambition1906, I found the bug!!! There are three key variables used for counters that are cast as “char”, assuming this is a SIGNED 8 bit type. However, the firmware code casts “char” as an UNSIGNED 8 bit type. So, tests like:

for (char i = no_of_sectors - 1; i >= 0; i--) {

will NEVER be less than zero since it is an unsigned value. I changed three vars to int8_t to fix the problem. The one causing the Ultralight to no read was “currentLevelKnownBits”. With these fixes, the ultralight cards reads just fine. I will fix the code in both the repo and the IDE. :smile:

UPDATE: IDE and repo libraries are updated :stuck_out_tongue:


@peekay123 Awesome!!! I’ll download and reflash tonight! (Cant wait!) :smiley:


@Ambition1906, I have reading all the card types. One thing to remember when running the DumpInfo example is to hold the card over the reader until ALL the data is read and printed. I was taking the card away to fast and getting errors! :smile:


@peekay123, ok, thanks for the tip. I’ll make sure to do that.


@peekay123, I just tested it from your github and it works as you said!!! Both the 1k and the Ultralight read perfectly after I compiled and flashed using the CLI! Thanks so much for your help! :smiley:


Good morning,
I’ve got a new RFID-RC522 and a couple of tags. First of all thank you for this library. I got my RFID-RC522 to work - wonderful.

But …
All tags I have tried with the example DumpInfo show me the card UID and the PICC type (MIFARE 1KB), but then I get PCD()_Authenticate() failed: Error in communication.
followed by 15 times PCD()_Authenticate() failed: Timeout in communication.
Can someone please enlighten me what the reason could be ? My hardware is an Arduino Pro Mini.

Thank you so much in advance for any hint.



@joshmosh, this forum is for Spark Core users and not Arduino users :flushed: Nonetheless, I have found that waiving the card too quickly over the RFID sensor will not allow the code to completely read the card, thus giving the authentication errors. :smiley:


i bought this
i cant find example to get sart with arduino ,can you please help me


@mohammed_l, this is the Spark Community supporting the Spark family of products :stuck_out_tongue_winking_eye: I you are looking for an arduino library, I suggest you look here :grinning:


okey, but the module is uart tll not spi ,how i can to make it work


@mohammed_l, DOH! Unfortunately, the serial version of this module is poorly supported. Most, if not all people use the SPI version. The only UART library I could find is very “lite” and can be found here.


thanka,but how i can change the spi code to operate in uart


@mohammed_l, I could not find the manual for the board you have. I hate to say it but my recommendation is to buy the SPI version of the board :neutral_face:


thank you, but can you help me to write a code to send command via uart to the board using arduino


@mohammed, the Arduino library I pointed you to allows you to do that. You will have to do the rest yourself. Again, this forum is for the Spark family of products, not Arduino!


Hi, I have the same problem, i cant write or read a data, almost everytime the problem is the timer timeout.
How do you solve the problem?


@denis222, can you clarify please - are you using Arduino or Spark?


HI, i’m not using anyone of both.
But i’ve the same library and the functions are very similary.

When i ask for the Tag or the Serial Number, it’s ok.
But when i want to write or read any block the authentification is OK but the register ComIrqReg says that the Timer Irq is in “1”. That’s means that the MFRC522 couldn’t comunicate with the tag in 25 [ms].

Do you what i mean?
(Sorry for my english i’m from Argentina)


@denis222, I need to know which platform you are using. When I ported the MFRC522 from Arduino to the Spark Core, I discovered some issues with variable types causing problems in reading certain cards. This is a forum for Spark Core users!


I’m Using a PIC 18F24k50, the problem is that in the net te most complete forum that i’ve found is this.
Therefore, i try to ask here, Do you read registers in your platform? for solve the problem of “variable types”?