RFID - multiple RC522's. Error: "Reader 0: Firmware Version: 0x8C = (unknown)"

Hi there.

Im running several rc522’s at once and get this error about the firmware on certain rc522 units:
Reader 0: Firmware Version: 0x8C = (unknown)

It seems it shows up for a random reader each time I rerun the script.

No issue when using just one. Only when using 2, 3 or 4 readers. With 2 it only occurs occasionally and with 4 it occurs every time to 2 random readers.

I’m using the Arduino pro micro. All connections are checked an double checked. The random nature of the error tells me that it’s not a connection issue however.

My code was modified from here:

Any tips would be much appreciated.

Here is my code:

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

// PIN Numbers : RESET + SDAs
#define RST_PIN         9

#define SS_1_PIN        10
#define SS_2_PIN        8
#define SS_3_PIN        7
#define SS_4_PIN        6
#define NR_OF_READERS   4

byte ssPins[] = {SS_1_PIN, SS_2_PIN, SS_3_PIN, SS_4_PIN};

// Create an MFRC522 instance :
MFRC522 mfrc522[NR_OF_READERS];

// Init array that will store new NUID 
byte nuidPICC[4];


void setup() {

  Serial.begin(9600);           // Initialize serial communications with the PC
  while (!Serial);              // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

  SPI.begin();                  // Init SPI bus

  /* looking for MFRC522 readers */
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);
    Serial.print(F("Reader "));
    Serial.print(reader);
    Serial.print(F(": "));
    mfrc522[reader].PCD_DumpVersionToSerial();
    //mfrc522[reader].PCD_SetAntennaGain(mfrc522[reader].RxGain_max);
  }
}


void loop() {
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {

    // Looking for new cards
    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
      nuidPICC[reader] = mfrc522[reader].uid.uidByte[0];
      Serial.print(F("Reader "));
      Serial.print(nuidPICC[reader]);
      Serial.print(reader);

      // Show some details of the PICC (that is: the tag/card)
      Serial.print(F(": Card UID:"));
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();


      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC..
  } //for(uint8_t reader..
}



void dump_byte_array(byte * buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

I'm using the Arduino pro micro. All connections are checked an double checked. The random nature of the error tells me that it's not a connection issue however.

Wrong. Multiple MFRC522 usually don't make sense as you should have an SPI bus longer than about 50cm and 4 readers withing that area would disturb each other massively. So I guess you have a considerably longer SPI bus and get these errors because electrical noise get caught by the bus wires.

Tell us more about your project, what you want to achieve and how it will be located (distances). Maybe we'll find a better solution than connecting multiple readers to one Arduino.

Thanks for the response, pylon. I am basically using many (up to 12 possible) readers to make a sort of weird midi controller for some music software. They can’t be too far apart however as i guess I won’t have enough desk space. If this mean that I have to run each reader on a separate arduino then so be it I guess. I’m just trying to figure out if I can economise and not be left with like 10 arduinos I have no use for at the end of this project :wink:

Currently I have 4 readers connected to one arduino and everything is contained on two large breadboards. Yes, the readers are quite close together, so around 7 cm from the epicentre of one reader to the epicentre of the next.

I have included a picture of the current configuration in an attachment

They might disturb each other on the RFID side but also the SPI bus is quite long and might get more noise than you expect. I would try decreasing the SPI frequency to see if the helps with the errors.

BTW: I hope you're using the Pro Micro 3.3V/8MHz and you've chosen the correct board in the IDE.

Thanks. What do you mean by adjust the "spi frequency"?

Yes I'm using the pro micro but it's the 5v version, but to power the circuit I am not running the 5v but I'm running 3.3v (and ground) from a spare arduino mega ATK.

I should have mentioned this. Perhaps this is adding to the issue?

It is still strange that, although there was firmware errors, all readers were still able to read the cards and key rings fine but only had trouble with the rfid stickers.

Thanks. What do you mean by adjust the "spi frequency"?

The SPI bus can be run with lower frequencies than the default 4MHz. You can change that by adapting the following line in the MFRC522.h file:

#define MFRC522_SPICLOCK SPI_CLOCK_DIV4			// MFRC522 accept upto 10MHz

If you set that to SPI_CLOCK_DIV16 you lower the speed to 1MHz which might work better with your setup.

Yes I'm using the pro micro but it's the 5v version, but to power the circuit I am not running the 5v but I'm running 3.3v (and ground) from a spare arduino mega ATK.

I cannot see that additional board on the posted picture.
Even if you provide 3.3V to the Vcc pin of the readers the 5V Pro Micro will have 5V level on it's SPI bus signals. According to the datasheet that level may fry the MFRC522. You might run at the level for some time, the chip may fail later but it's still because of the too high voltage.

It is still strange that, although there was firmware errors, all readers were still able to read the cards and key rings fine but only had trouble with the rfid stickers.

That's a new information. Does that mean you can clearly and reproducible read all cards and key rings but get random failures on the stickers? Or do all stickers fail?

Sorry for the delay, pylon. I was away and did not see that you had replied.

I just changed the SPI settings. I tried both 16 and 32. No difference. Had no idea what the SPI was before now so thanks for letting me know about that as something to try in future.

I have simplified and gone back to test with 2x RC522's. Only very occasionally (1/10) both firmware versions of each RC522 is recognised.

When I wrote 2 weeks back, yes, the stickers were the only ones that had the issue of being read by an RC522 with unknown firmware. The cards and fobs seemed to work fine. However, tonight all of the above are not read. Same setup too.

I have just tried with a 3.3v Arduino (all connections connected to this 3.3v unit this time;) and the same issue persists.

I have read in these forums that breadboards and wiring, in general, can be a bit troublesome with these guys.... perhaps it's down to that.

Post a sharp picture of your setup.

I just tried with a Mega ADK with 2x RC522’s. Although I still got a firmware error on one RC522 (always the error occurs with the first RC522 in the chain), both readers read every kind of tag I had. All this was running fine at the 5v supplied by the MegaATK.

I swapped in a Pro Micro and the same issue as before. Only cards and fobs are read on both, so again stickers are unread on reader 1.

A photo of the pro micro setup is in the following link. (phone camera is best I currently have)

photo of pro micro and 2x rc522’s

Many thanks!

Something came to mind. Perhaps there is an issue with the reset (RST) pin not being set correctly in my code.

As you see at the top of the code, on the Arduino Pro Micro, the reset pin must be “RST”. However I have checked the documentation and this pin does not have a number.

When I try to define the RST pin to be “RST”, I get an error as I guess it expects a number:
e.g. “#define RST_PIN RST”

My code is here:

/* Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS 1    SDA(SS)      ** custom, take a unused pin, only HIGH/LOW required **
 * SPI SS 2    SDA(SS)      ** custom, take a unused pin, only HIGH/LOW required **
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 */
 
#include <SPI.h>
#include <MFRC522.h>

#define MFRC522_SPICLOCK SPI_CLOCK_DIV16     // MFRC522 accept upto 10MHz

#define RST_PIN         5         // Configurable, see typical pin layout above
#define SS_1_PIN        2 //8         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN        3 //10          // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1

#define NR_OF_READERS   2

byte ssPins[] = {SS_1_PIN, SS_2_PIN};

MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.

// Init array that will store new NUID 
byte nuidPICC[4];


//Initialize.
void setup() {
  Serial.begin(9600); // Initialize serial communications with the PC
  //while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  SPI.begin();        // Init SPI bus
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
    Serial.print(F("Reader "));
    Serial.print(reader);
    Serial.print(F(": "));
    mfrc522[reader].PCD_DumpVersionToSerial();
  }
}


void loop() {
  LeftReader();
  RightReader(); 
}


//Helper routine to dump a byte array as hex values to Serial.
void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}


void LeftReader(){
  for (uint8_t reader = 0; reader < 1; reader++) {

    // Look for new cards
    if (mfrc522[0].PICC_IsNewCardPresent() && mfrc522[0].PICC_ReadCardSerial()) {
        nuidPICC[0] = mfrc522[0].uid.uidByte[0];
        Serial.print("Reader 1: ");        
        Serial.println(nuidPICC[0]);

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}


void RightReader(){
  for (uint8_t reader = 1; reader < 2; reader++) {

    // Look for new cards
    if (mfrc522[1].PICC_IsNewCardPresent() && mfrc522[1].PICC_ReadCardSerial()) {
        nuidPICC[0] = mfrc522[1].uid.uidByte[0];
        Serial.print("                   Reader 2: ");           
        Serial.println(nuidPICC[0]);

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}

Something came to mind. Perhaps there is an issue with the reset (RST) pin not being set correctly in my code.

As you see at the top of the code, on the Arduino Pro Micro, the reset pin must be "RST". However I have checked the documentation and this pin does not have a number.

The pin you connect the RST pin of the MFRC522 to is configurable. You can use any pin that you have still available. It's possible to use the same pin for both readers but then you have to reset them yourself (not the library). I'd recommend to use separate pins for each reader.

pylon:
The pin you connect the RST pin of the MFRC522 to is configurable. You can use any pin that you have still available. It’s possible to use the same pin for both readers but then you have to reset them yourself (not the library). I’d recommend to use separate pins for each reader.

Thanks for that tip. I simplified code greatly to test that with RST on 2 separate pins. Still no joy however… Cards/Fobs read on both readers but stickers only on reader 2, as before.

My code is here:

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

#define MFRC522_SPICLOCK SPI_CLOCK_DIV16    // MFRC522 accept upto 10MHz
#define NR_OF_READERS   2

byte RST_PINs[] = {5, 6};
byte ssPins[] = {2, 3};

MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.

// Init array that will store new NUID 
byte nuidPICC[4];


//Initialize.
void setup() {
  Serial.begin(9600); // Initialize serial communications with the PC
  //while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  SPI.begin();        // Init SPI bus
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PINs[reader]); // Init each MFRC522 card
//    Serial.print(F("Reader "));
//    Serial.print(reader);
//    Serial.print(F(": "));
    mfrc522[reader].PCD_DumpVersionToSerial();
  }
}



void loop() {
  Reader();  
}



void Reader(){
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    //mfrc522[reader].PCD_SetAntennaGain(mfrc522[reader].RxGain_max); // I tried setting antenna read gain to max: No effect
    
    // Look for new cards
    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {

        // Simplifying: Only getting first byte for testing purposes
        nuidPICC[0] = mfrc522[reader].uid.uidByte[0];
        Serial.print("Reader No.");
        Serial.print(reader+1);  
        Serial.print(": ");  
        Serial.println(nuidPICC[0]);

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}


//Helper routine to dump a byte array as hex values to Serial.
void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

I just got delivery of a soldering iron so I might try and make solid connections and see if that works. Failing that then one RFID reader per Arduino Pro Micro will have to do… but I’ll need so many that I’ll see how far I can push it with a powered multi USB hub :wink:

I have exactly the same problem (on Uno). Using the library by miguelbalboa with the sample code ReadUidMultiReader.ino, I get that error when 2 readers are connected:

Reader 0: Firmware Version: 0x82 = (unknown)
Reader 1: Firmware Version: 0x92 = v2.0

Both readers work when they are connected separately but not together. Did you find a workaround?

Explanation: new version of readers work only on 3.3v boards, so impossible with Uno without the use of level shifters for all readers.