I am working on a project for my local Makerspace, we have limited budget so I was hoping to use the RFID-RC522 el'cheap'o RFID/NFC readers on eBay, I received a couple of SPI based boards, they work, however the code examples for them are limited.
I have found several different libraries and settled on this one: https://github.com/ljos/MFRC522
The trouble is that all the code available online seem to spawn from some Chinese guys Python code that people have translated, and hacked into an Arduino library.
The code works, but Mifare cards are meant to have 4, 7 or 10 byte UIDs and the example/library is returning a 5 byte serial number.
There is no documentation and the NXP datasheet is incomprehensible... Additionally it seems to work with most cards, but it doesn't work with Mastercard PayWave cards which conform to the ISO 14443 standard. The more expensive RDM880 reader which is based on the MFRC500 works fine and has a nice library but the cost makes the implementation impossible.
So, can someone help me to get this NXP MFRC522 based unit reading the UID from all ISO 14443 cards.
#include <SPI.h>
#include <MFRC522.h>
#define RFID_SS 10
#define RFID_RST 5
MFRC522 rfid( RFID_SS, RFID_RST );
void setup() {
SPI.begin();
Serial.begin(115200);
rfid.begin();
}
void loop() {
byte data[MAX_LEN];
byte uid[5];
if ( rfid.requestTag( MF1_REQIDL, data ) == MI_OK ) {
if ( rfid.antiCollision( data ) == MI_OK ) {
memcpy( uid, data, 5 );
for ( int i = 0; i < 5; i++ ) {
Serial.print( uid[i], HEX );
Serial.print( ' ' );
}
Serial.println();
}
}
}
uid
array is of length 5. Did you try using a larger array since you want a 10 byte result?