New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major rewrite #9

merged 5 commits into from Oct 21, 2013


None yet
3 participants

Sthing commented Oct 20, 2013

Hi Miguel.
Thank you very much for having your code in the public domain and on GitHub. It is much appreciated! ;-)

Lately I have spent a lot of time recently refactoring your rfid ibrary. Here is a summary of my changes:

  • Renamed library from RFID to MFRC522 (RFID seemed to generic).
  • Register names changed to comply with datasheet.
  • Global defines moved into class.
  • All constants, functions and parameters are now commented in English.
  • Code refactored, most function names have changed.
  • Now supports ISO-14443-3 anti collission and 4/7/10 byte UIDs (cascade levels).
  • Added functions for MIFARE Classic Decrement/Increment/Restore/Transfer and MIFARE Ultralight Write.
  • New examples written.

From a functional point of view, the most important changes are that the library now knows about 7 and 10 byte UIDs (those were ignored before) and that it can perform the anti collision procedure specified in ISO-14443-3.

I learned a lot about ISO-14443-3 and MIFARE chips while working with the library.
A lot of that information is now collected at the top of MFRC522.h,

I would like to offer you all my changes back into your repository in the hope that it is welcomed, and believing that a common codebase will be beneficial to the community.
However if you find the changes too invasive (and I would understand that) I will proceed and offer my library as an alternative to yours.

Again, thank you for a great starting point. It sure helped my to get going.
I look forward to receive your response.

Best regards


This comment has been minimized.


miguelbalboa commented Oct 21, 2013

Hello Søren.

The truth is:
I only rewrote and encapsulate more "Nice" the code supplied by the manufacturer.
Your contribution is very well appreciated and I am totally happy to place it in my repository.
I can see here that you are the expert.

Thank you very much.
Best regards.

@miguelbalboa miguelbalboa merged commit b6892aa into miguelbalboa:master Oct 21, 2013


This comment has been minimized.


Sthing commented Oct 21, 2013

Hi Miguel!
Great :-)
I'll add some information at the arduino forum and/or playground one of the next days.
(Unless you would rather do that yourself?)


This comment has been minimized.

s1102658 commented Mar 8, 2017

Hi Miguel.

Thanks a lot for providing the community with such a useful library.
I recently encountered a blocked Chinese-made changeable RIFD tag. I used the UnbrickUidSector Function to unbrick it successfully so that I can write a new UID on it again. It would be great to unbrick and assign a new UID in one pass. So, I would like to suggest a minor amendment to the Function as follows.

**bool MFRC522::MIFARE_UnbrickUidSector(bool logErrors, byte block0_buffer[] ) {

//byte block0_buffer[] = {0x01, 0x02, 0x03, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

// Write modified block 0 back to card
MFRC522::StatusCode status = MIFARE_Write((byte)0, block0_buffer, (byte)16);
if (status != STATUS_OK) {
	if (logErrors) {
		Serial.print(F("MIFARE_Write() failed: "));
	return false;
return true;


Then, end-users can conveniently pass a byte array (16bytes long) to unbrick and assign a new UID at the same time.
Please kindly see if this change may be included in your repository.

Thanks for your consideration.

Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment