Multiple RFID readers.

Ok, I saw that a lot of people has my problem but haven't find a solution yet.

I try to build Black Jack by mega2560 Arduino.

I need to connect 4 RFID readers. and read the cards from them.

This is my scheme: http://i.stack.imgur.com/huuiu.png

Im using the example code at the arduino: rfid/ReadUidMultiReader.ino at master · miguelbalboa/rfid · GitHub

ofcourse that I change the arrays to 4 cards.

when I put all of the cards on the Arduino it reads them all.
but, If I put less than 4 is not working!

Can someone help please with this code. thx!

Can someone help please with this code

You haven't posted any code.

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

#define RST_PIN 5
#define SS_1_PIN 22
#define SS_2_PIN 24
#define SS_2_PIN 26
#define SS_2_PIN 28

#define NR_OF_READERS 4

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

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

/**

  • 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();
}
}

/**

  • Main loop.
    */
    void loop() {

for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
// Look for new cards

if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
Serial.print(F(“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();
Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));

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

/**

  • 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 < 0x10 ? " 0" : " ");
    _ Serial.print(buffer
    , HEX);
    _
    * }*
    }
    it works only if I put all of the cards on the readers, If I lay less than 4 its not working well.

Code tags would be nice - the forum software has mangled your code at the end.

What happens if you have fewer than four tags?

There is something not right about this

#define RST_PIN         5          
#define SS_1_PIN        22         
#define SS_2_PIN        24   
#define SS_2_PIN        26       
#define SS_2_PIN        28

Maybe that SS_2_PIN is just “staying” on pins 24 and 26 while it gets its mail on pin 28.

byte ssPins[] = {SS_1_PIN, SS_2_PIN, SS_3_PIN, SS_4_PIN};How does that even compile?