Pages: [1]   Go Down
Author Topic: Problem with MF522  (Read 977 times)
0 Members and 1 Guest are viewing this topic.
Switzerland
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
#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
Code:
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.


Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4755
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)?
Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

Logged

Experience, it's what you get when you were expecting something else.

Switzerland
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry for the late response...

anyway... this is what I bought on ebay: Serial 13.56MHZ RFID Reader/Writer Module Kits

Here the documents I worked with
Manual
Test code

 
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."

It looks like it's stuck in basic command mode...
« Last Edit: March 26, 2013, 05:32:55 pm by kwyjib0 » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4755
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Switzerland
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I did try to send the reset factory defaults command with no success.

Thanks for the hint with the baud rates and the hw serial though. Will try it out tonight and let you know!
Logged

Switzerland
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@pylon, thank you so much!!!

I did exactly what you told me to do and my rfid reader works as before! I must have overridden the config settings.
Logged

Switzerland
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

btw, put the description and the code onto my blog.
Logged

Pages: [1]   Go Up
Jump to: