I bought myself a Serial 13.56MHZ RFID Reader/Writer Module Kit on ebay that came with a RFID tag and card.
I was playing with it and the following code worked like a charm:
#include <SoftwareSerial.h> SoftwareSerial mySerial(2,3); unsigned char command, devnull; unsigned int returnLength; void setup() { Serial.begin(9600); Serial.println("Waiting for Card\n"); mySerial.begin(9600); mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual } void loop() { if (mySerial.available()) { Serial.print("\n\rCARD SERIAL: "); for (unsigned int i=0; i<4 ;i=i){ if (mySerial.available()) { Serial.print(mySerial.read(),HEX); //Display the Serial Number in HEX i++; } } mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual } } void Get_Reply() { while (!mySerial.available()); devnull = mySerial.read(); while (!mySerial.available()); returnLength = mySerial.read() - 1; for (unsigned int i=0;i< returnLength;i=i){ //Serial.print("2"); if (mySerial.available()) { //Serial.print("\n\ri is: ");Serial.print(i);Serial.print(" "); Serial.print(mySerial.read(),HEX); //Display the Serial Number in HEX Serial.print(" "); i++; } } }
When I passed a tag over the reader the output was:
Waiting for Card CARD SERIAL: E298ABB9
I played around more with some more commands I found here:
– Manual
– Test document
I was especially interested in the “wallet functions”. IE how to initialize the wallet, how to deduct from it etc.
And then somehow I messed up… Whatever message I sent to the reader it immediately sent back 0xFF which means a general error. The state led was on but the mode led was always off… weird. Fortunately I got help in the Arduino forum.
The idea was to send the “factory defaults” command to the reader in different baud rates using the Uno’s serial interface. After I did that the mode led was still off and I was disappointed. I thought the module was dead.
But I just uploaded the RFID tag reader sketch up to the UNO and it worked again!
Here’s the code that sends the factory defaults command to the RFID module:
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.begin(2400);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(4800);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(9600);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(14400);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(19200);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(28800);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(38400);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(57600);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
Serial.begin(115200);
delay(1000);
Serial.write(0xAB);
Serial.write(0x02);
Serial.write(0x0F);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
}

Hi,
I found your this post because I was having the same issue. Now I am able to read the cards Serial, but I am having some issues while trying to write them or read data… did you manage to get that working?
Misael, unfortunately not. Tried using the wallet function but didn’t get it working. So I am thinking to set up a web service that deals with the access control.
No
Hello. I have MF522-AN, like this http://s3.amazonaws.com/thmb.inkfrog.com/pix/christanery/9_023.jpg/450/0
I have trying now for some time to make it read card but i was unsuccessful, i think i have same problem. Can you please help me and tweak the code to work with MF522-AN. Thanks.
did you try using the code above?
I just received my RFID module and was able to test it using the sample code and it reading the card and sending its info through serial.