I have an MF522 RFID reader hooked up using softwareserial to my Arduino uno.
I was playing around, was able to read the serial number, the card's make, read and write data to/off the card and initialize the wallet.
All of a sudden it stops working and just replies 0xFF and it looks like it's stuck.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup() {
Serial.begin(9600);
Serial.println("Waiting for card");
mySerial.begin(9600);
mySerial.write(0x02);
}
void loop() {
if (mySerial.available()){
Serial.print(mySerial.read(),HEX);
Serial.print(" ");
}
if (Serial.available()){
Serial.println("");
mySerial.write(Serial.read());
}
}
this used to work like a charm and return the card's serial but now the output is
Waiting for card
FF
the MF522 answers the 0xFF to the mySerial.write(0x02) command and then it looks like the arduino freezes as it does not update anything. The RFID Card LED flashes when it detects an RFID but the state LED won't flash.
How did you connect the reader to the Arduino (including wiring, external components, etc)? Do you have a link to the device you're using (to get the exact model)?
Try using AltSoftSerial, it might solve your problems. SoftwareSerial can't xmit and recv at the same time. You'll have to switch to pins 8 and 9 to use AltSoftSerial.
When I first connected the RFID reader, the State and the Mode LED were on:
(There's 3 smd leds in the bottom left corner).
When the mode led is on it means that it's in "compact command" mode, which means it expects 1 byte. So I sent 0x02 and the module responded by sending back the serial number of the tag when passed over the the reader.
I then also sent some "basic commands" like to initialize the cards wallet, deduct from the wallet and so on.
But now the mode led is always off. Which would mean it's still in basic command mode. But no matter what command I send now it returns back "FF" immediately.
From the manual:
"For any wrong command sending to this module, 0xFF will be returned."
Is it possible that you changed the baud rate? Have you tried sending the "reset factory defaults" command?
I would try to send that command with every baud rate specified on page 10 of the user manual. And don't use the SoftwareSerial for that, use a hardware serial (on the UNO you only have one, so you're not able to use the serial interface for debugging during that procedure).