0
votes

Alright so I'm pretty new to Arduino, picked up a Mega2560 starter kit as well as some other accessories off of eBay a little while ago I've got a "knockoff" board but it's seemed to work fine for everything else so far. Anyhow I purchased a MF522-AN RFID reader and have not been able to get it to work. I've tried the code found on this page:

http://www.grantgibson.co.uk/blog/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/

and when I hook everything up it just gives me a blank serial page and the TX and RX lights stay unlit. I've tried hooking it up based on both of the pinouts that this page suggests:

http://www.b2cqshop.com/products/203-arduino-rfid-module-kit-1356-mhz-with-tags-spi-w-and-r-by-cooqrobot.aspx

and nothing. I've tried both the RFID tags that came with it as well as my Keyfob to get into my dorm and nothing has worked, the serial window on the Arduino software just remains blank. Here's the code I'm attempting to run:

http:// pastie.org/4235666

3
Watch this video youtube.com/watch?v=fzM5731MuO0 I think you will find you solution after seeing this video. They have suggested to use original arduino rather then china arduino. It works for me. :)user6123079

3 Answers

1
votes

Try uncommenting lines 186-196:

// Serial.println("The card's number is  : ");
// etc

That should provide some verbose output whenever a tag is brought into range.

1
votes

First make sure all connections are correct. If your MF522-AN have pin markings, do in that order. If not, start from the bottom left hand pin.

The code you are using is checking if the first pair of the card number is the same as the ones used by Grant (lines 200-204):

if(serNum[0] == 88) { // Is the first pair equal to 88?
   Serial.println("Hello Grant");
   } 
else if(serNum[0] == 173) { // Is the first pair equal to 173?
   Serial.println("Hello David");
   }

Probably your cards doesn't match any of those two examples. Comment those lines (200-204) and uncomment lines (186-196) if you want to print the card number pair by pair:

  Serial.println("The card's number is  : ");
  Serial.print(serNum[0]);
  Serial.print(" , ");
  Serial.print(serNum[1],BIN);
  Serial.print(" , ");
  Serial.print(serNum[2],BIN);
  Serial.print(" , ");
  Serial.print(serNum[3],BIN);
  Serial.print(" , ");
  Serial.print(serNum[4],BIN);
  Serial.println(" ");

Also uncomment lines (173-177) if you want to print a confirmation that the card is detected:

  Serial.println("Card detected");
  Serial.print(str[0],BIN);
  Serial.print(" , ");
  Serial.print(str[1],BIN);
  Serial.println(" ");

If you find that original code by Dr.Leong confusing to work, try this one. I also included the pin and SPI information there. All card number pairs are also converted to decimal numbers in the example code.

0
votes

I don't know if you have already tried this yet, but you may have to slightly change the connections from the Arduino to the RFID reader because the mega 2560 you have has different SPI pins than the UNO, which the demo is originally destined for. I believe 51. 52, and 53 are responsible.. you should check the Mega 2560 page on the Arduino website.

-Ben