#include <Wire.h>
#include "MFRC522_I2C.h"
#define SDA_PIN 21
#define SCL_PIN 22
#define RST_PIN 2
MFRC522 mfrc522(0x2B, RST_PIN);
MFRC522 mfrc522_2(0x28, RST_PIN);
void setup() {
Serial.begin(115200);
Wire.begin(SDA_PIN, SCL_PIN);
mfrc522.PCD_Init();
mfrc522_2.PCD_Init();
ShowReaderDetails();
ShowReaderDetails_2();
Serial.println(F("Scan UID"));
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
return;
}
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
if ( ! mfrc522_2.PICC_IsNewCardPresent() || ! mfrc522_2.PICC_ReadCardSerial() ) {
return;
}
for (byte i = 0; i < mfrc522_2.uid.size; i++) {
Serial.print(mfrc522_2.uid.uidByte[i], HEX);
}
Serial.println();
}
void ShowReaderDetails() {
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("MFRC522 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown)"));
Serial.println("");
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
}
}
void ShowReaderDetails_2() {
byte v = mfrc522_2.PCD_ReadRegister(mfrc522_2.VersionReg);
Serial.print(F("MFRC522 - 2 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown)"));
Serial.println("");
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 - 2 properly connected?"));
}
}
The UIDs of the first device (0x2B) came up quickly, but the second device (0x28) made no output. Only if I put an nfc card on the first device, then came out an output.