Issue with RC522 "Firmware Version: 0xB2 = (unknown)"

I only started coding on Arduino and RC522 like 2 weeks ago and I've been having this problem recently, I use the MFRC522 and Easy MFRC522, also Adafruit BusIO Libraries

Here's my code

#include <Servo.h>
#include <SPI.h>
#include <MFRC522.h>

// Define RFID RC522 pins
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

// Define servo motor and LED pins
Servo myservo;

const int redLedPin = 6;
const int greenLedPin = 7;

// Define variables
boolean doorLocked = true; // Initially, the door is locked

void setup() {
  Serial.begin(9600);  // Start the communication with your computer
  SPI.begin();         // Initialize the SPI communication.
  mfrc522.PCD_Init();  // Initialize the RFID reader.
  delay(5);
  Serial.println("Hold your card close to the reader...");
  Serial.println();

  myservo.attach(3); // Attach servo to pin 3
  myservo.write(0);  // Close the door (servo at 0 degrees)

  pinMode(redLedPin, OUTPUT);
  pinMode(greenLedPin, OUTPUT);
}

void loop() {
  // Check for RFID card
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    // Read the RFID card's UID
    Serial.print("Card ID: ");
    String cardUID = ""; // Store the card's ID
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : ""); // Format the ID with leading zeros
      Serial.print(mfrc522.uid.uidByte[i], HEX);              // Print the ID in hexadecimal
      cardUID += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "") + String(mfrc522.uid.uidByte[i], HEX); // Concatenate the ID in hexadecimal
    }
    cardUID.toUpperCase(); // Convert to uppercase

    // Check if the card UID matches the authorized card
    if (cardUID == "90 95 4C 58") {
      // Unlock the door and indicate with green LED
      digitalWrite(greenLedPin, HIGH);
      myservo.write(90); // Open the door (servo at 90 degrees)
      delay(2000);       // Keep the door open for 2 seconds
      myservo.write(0);  // Close the door (servo at 0 degrees)
      digitalWrite(greenLedPin, LOW);
      Serial.println("Access granted. Welcome!");
      Serial.println();
      delay(3000); // Wait for a few seconds
    } else {
      // Unauthorized card, indicate with red LED
      digitalWrite(redLedPin, HIGH);
      delay(1000); // Show red LED for 1 second
      digitalWrite(redLedPin, LOW);
      Serial.println("Access denied. Unauthorized card.");
      delay(3000); // Wait for a few seconds
    }

    mfrc522.PICC_HaltA(); // Halt the card
  }
}

here's the wiring diagram (I got it from youtube)

Thanks!

The "Firmware Version" might not match the expected values in the library.
Add this block after mfrc522.PCD_Init(); in setup() to verify the firmware version:

byte firmwareVersion = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print("Firmware Version: 0x");
Serial.println(firmwareVersion, HEX);
if (firmwareVersion == 0x92) {
  Serial.println("RC522 v2.0 detected.");
} else if (firmwareVersion == 0x91 || firmwareVersion == 0x90) {
  Serial.println("RC522 v1.0 detected.");
} else {
  Serial.println("Unknown firmware version. Check connections.");
}

If the firmware version still shows 0xB2, it's an indication of hardware communication failure.

1 Like

I added the code in and the firmware version still showed 0xB2

How do you think I could fix it?

I ended up fixing it by replacing the whole board thanks for the help though

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.