Multiple RFID scanners not working together

Ive tried to get multiple RFID scanners (2) to work like one, but I cant seem to get them to work, only one work, (If I switch there place the other one works. the one to the right). I'm pretty sure its the code, that needs a rewrite, since they work individually in the same setup (code for one, then change the pin output). It just doesn't work when i do it together. I have tried looking at similar forum post, but it hasn't worked for me. I'm really new to C++, so I'm probably missing something obvious. The readers are being fed 3.3 volt through a 1k ohm and 2k ohm resistor.

I saw in an other post, it wight help giving separate reset pin to so that's why i've done it.

Code for two readers (I just copied the code for another reader)

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

//Reader 1
#define RST_PIN         44
#define SS_PIN          45 

//Reader 2
#define RST_PIN1        49
#define SS_PIN1         39

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance
MFRC522 mfrc5221(SS_PIN1, RST_PIN1);

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
	mfrc522.PCD_Init();		// Init MFRC522
	mfrc5221.PCD_Init();
	delay(4);				// Optional delay. Some board do need more time after init to be ready, see Readme
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	mfrc5221.PCD_DumpVersionToSerial();
	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
	// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
	if ( ! mfrc522.PICC_IsNewCardPresent() ) {
		return;
	}

if ( ! mfrc5221.PICC_IsNewCardPresent() ) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial() ) {
		return;
	}

if ( ! mfrc5221.PICC_ReadCardSerial() ) {
		return;

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
	mfrc5221.PICC_DumpToSerial(&(mfrc5221.uid));
}
}

original code

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

#define RST_PIN         49          // Configurable, see typical pin layout above
#define SS_PIN          39         // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

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
	mfrc522.PCD_Init();		// Init MFRC522
	delay(4);				// Optional delay. Some board do need more time after init to be ready, see Readme
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
	// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

Please transform the picture inte schematics.

Many people are getting in trouble trying to connect multiple readers. I got 2 to work out of 3 connected once but never 3.

see also ReadUidMultiReader is not working · Issue #191 · miguelbalboa/rfid · GitHub

It seems the quality of the modules and the wiring plays a role.

Duplicating code is seldom a good idea.

The usual library for the MFRC522 comes with an example for several readers. I tried it long time ago and it worked.

I tried a different code, and it seems to work now. I guess the scanners are very picky with how you interact with them. I think giving them separate reset key helped, cause it didn't work before. Hopes this helps for other people struggling.

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

// Scanner 1
#define SS_PIN_1 45
#define RST_PIN_1 44

// Scanner 2
#define SS_PIN_2 39
#define RST_PIN_2 49

MFRC522 mfrc522_1(SS_PIN_1, RST_PIN_1);
MFRC522 mfrc522_2(SS_PIN_2, RST_PIN_2);

void setup() {
  Serial.begin(9600);
  SPI.begin();

  mfrc522_1.PCD_Init();
  mfrc522_2.PCD_Init();

  Serial.println("To RFID scannere klar...");
}

void loop() {

  // ===== Scanner 1 =====
  if (mfrc522_1.PICC_IsNewCardPresent() && mfrc522_1.PICC_ReadCardSerial()) {
    Serial.print("Scanner 1 UID: ");
    printUID(mfrc522_1);
    mfrc522_1.PICC_HaltA();
  }

  // ===== Scanner 2 =====
  if (mfrc522_2.PICC_IsNewCardPresent() && mfrc522_2.PICC_ReadCardSerial()) {
    Serial.print("Scanner 2 UID: ");
    printUID(mfrc522_2);
    mfrc522_2.PICC_HaltA();
  }
}

void printUID(MFRC522 &reader) {
  for (byte i = 0; i < reader.uid.size; i++) {
    Serial.print(reader.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(reader.uid.uidByte[i], HEX);
  }
  Serial.println();
}

I just used this schematic as a guide, but basically, I just sat up the pins as it was writen, for the arduino mega, wich you can find in the example sketch for the RFID. Of course it all went through resistors, exept for the miso, and 3.3 volt pin.

These are RF (Radio Frequency) devices that can interfere with each other. Try separating them by maybe a meter.

You can’t have multiple RF devices in close proximity without them interfering with each other. However the way to implement it is by only having one device on at any moment and then cycling on/off through the RF devices in a round robin fashion.