Mega 2560.

I can't get the RFID board detected. The code is as below, and outputs Didn't find MFRC522 board.. I also tested some other library and test code with success.

I triple checked the wires (3,3V pin, GND, and PWM pin 8 and 9).

I have some questions:

  1. All tutorials shows that MOSI, MISO, SCK needs to be hooked up to digital pin 50, 51, 52. But I don't understand why these matter, because they are not referenced in any code I've found? Are they really necessary? And if so, does it have to be 50,51,52? Can't it be any other digital pin?

  2. I accidentally connected it to 5V at first, for maybe 1 minute. Could it be burnt? The LED still lights RED when connected with power.

  3. If the problem was the (correct) library was not loaded, wouldn't I get a compile error?

I'm running this code:

    #include <MFRC522.h>
    #include <SPI.h>
    #define SAD 9
    #define RST 8
    MFRC522 nfc(SAD, RST);
    void setup() {
      Serial.println("Looking for MFRC522.");
      uint8_t version = nfc.getFirmwareVersion();
      if (! version) {
        Serial.print("Didn't find MFRC522 board.");
        while(1); //halt
      Serial.print("Found chip MFRC522 ");
      Serial.print("Firmware ver. 0x");
      Serial.print(version, HEX);
      if (nfc.digitalSelfTestPass()) {
          Serial.print("Digital self test by MFRC522 passed.");
      } else {
          Serial.print("Digital self test by MFRC522 failed.");
    void loop() {
  • 1
    I almost tried to answer to this with one giant answer despite that you're really asking about three thing that you know of and in away more things than that. But then I saw "I also tested some other library and test code with success" What kind of success are we walking about here and did you have that success before or after hooking 5V to the board? Because if "success" was that you got it reading you should say whether or not you managed to do that after feeding it 5V. That said, it would be better to pick one question and go with that.
    – timemage
    Commented Oct 6, 2022 at 20:52

1 Answer 1


Welcome, hopefully we can help you. You do not have to connect MOSI, MISO, SCK, CS if you do not want to however without them connected properly it will not work. Note you did not mention the CS pin, that is also needed as that is what tells the MFRC522 it has been selected. Those pins are what is used to communicate with the device. The pins may be different for different boards but you need to check the data sheet for that. The numbers appear correct for the Mega.

The LED tells you that there is power there, it in no way tells you if the board is good. Did you fry it, probably probably as the MFRC522 is a 3V3 device but that is not a given as I do not know what pin you connected the 5V to. More than a few nanoseconds on a voltage higher than rated tends to fry things, but you could be lucky I have no way of knowing. The Mega is 5V so that would probably be OK.

You ask: "If the problem was the (correct) library was not loaded, wouldn't I get a compile error?", again no not necessarily. The compiler does not know your design or what you are connecting to. If the library happens to have functions etc appropriately named it will compile with errors but the odds are very slim your code will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.