/*
* --------------------------------------------------------------------------------------------------------------------
* Example sketch/program to test your firmware.
* --------------------------------------------------------------------------------------------------------------------
* This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
*
* This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed
* it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken.
*
* @author Rotzbua
* @license Released into the public domain.
*
* 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 SDA(SS) 10 53 D10 10 10
* 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
*
* More pin layouts for other boards can be found here: https://github.com/miguelbalboa/rfid#pin-layout
*/
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 21 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
/**
* Check firmware only once at startup
*/
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 module
Serial.println(F("*****************************"));
Serial.println(F("MFRC522 Digital self test"));
Serial.println(F("*****************************"));
mfrc522.PCD_DumpVersionToSerial(); // Show version of PCD - MFRC522 Card Reader
Serial.println(F("-----------------------------"));
Serial.println(F("Only known versions supported"));
Serial.println(F("-----------------------------"));
Serial.println(F("Performing test..."));
bool result = mfrc522.PCD_PerformSelfTest(); // perform the test
Serial.println(F("-----------------------------"));
Serial.print(F("Result: "));
if (result)
Serial.println(F("OK"));
else
Serial.println(F("DEFECT or UNKNOWN"));
Serial.println();
}
void loop() {} // nothing to do
using a ESP32-S3-DevKitC-1 the MFRC522 CheckFirmware test
// ESP32-S3-DevKitC-1 - ESP32_S3 to MFRC522 CheckFirmware test
/*
* --------------------------------------------------------------------------------------------------------------------
* Example to test your firmware.
* --------------------------------------------------------------------------------------------------------------------
* This is a MFRC522 library example; for further details and other examples see: https://github.com/OSSLibraries/Arduino_MFRC522v2
*
* This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed
* it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken.
*
* @author Rotzbua
* @license Released into the public domain.
*
* 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
* -----------------------------------------------------------------------------------------
* SPI SS SDA(SS) 10 53 D10 10 10
* 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
*
* Not found? For more see: https://github.com/OSSLibraries/Arduino_MFRC522v2#pin-layout
*/
// ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12 to MFRC522 card SCK
// ESP32_S3 MISO pin GPIO13 to MFRC522 card MISO
// ESP32_S3 MOSI pin GPIO11 to MFRC522 card MOSI
// ESP32_S3 SS pin GPIO 10 to MFRC522 card SS (marked SDA on PCB)
// connect ESP32_S3 GND and 3.3V to MFRC522 GND and 3V3
#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
//#include <MFRC522DriverI2C.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>
MFRC522DriverPinSimple ss_pin(10); // Configurable, see typical pin layout above.
MFRC522DriverSPI driver{ss_pin}; // Create SPI driver.
//MFRC522DriverI2C driver{}; // Create I2C driver.
MFRC522 mfrc522{driver}; // Create MFRC522 instance.
/**
* Check firmware only once at startup.
*/
void setup() {
Serial.begin(115200); // Initialize serial communications with the PC for debugging.
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4).
mfrc522.PCD_Init(); // Init MFRC522 board.
Serial.println(F("*****************************"));
Serial.println(F("MFRC522 Digital self test"));
Serial.println(F("*****************************"));
MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial); // Show version of PCD - MFRC522 Card Reader.
Serial.println(F("-----------------------------"));
Serial.println(F("Only known versions supported"));
Serial.println(F("-----------------------------"));
Serial.println(F("Performing test..."));
bool result = mfrc522.PCD_PerformSelfTest(); // Perform the test.
Serial.println(F("-----------------------------"));
Serial.print(F("Result: "));
if (result)
Serial.println(F("OK"));
else
Serial.println(F("DEFECT or UNKNOWN"));
Serial.println();
}
void loop() {} // nothing to do
serial monitor displays
*****************************
MFRC522 Digital self test
*****************************
Firmware Version: 0x92 = v2.0
-----------------------------
Only known versions supported
-----------------------------
Performing test...
-----------------------------
Result: OK
Thanks for the answer! I downloaded your library and tested your code but it still doesnt work. I tried it too with a new RC522, but I have the same issue!
// ESP32-S3-DevKitC-1 - ESP32_S3 to MFRC522 CheckFirmware test
/*
* --------------------------------------------------------------------------------------------------------------------
* Example to test your firmware.
* --------------------------------------------------------------------------------------------------------------------
* This is a MFRC522 library example; for further details and other examples see: https://github.com/OSSLibraries/Arduino_MFRC522v2
*
* This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed
* it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken.
*
* @author Rotzbua
* @license Released into the public domain.
*
* 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
* -----------------------------------------------------------------------------------------
* SPI SS SDA(SS) 10 53 D10 10 10
* 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
*
* Not found? For more see: https://github.com/OSSLibraries/Arduino_MFRC522v2#pin-layout
*/
// ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12 to MFRC522 card SCK
// ESP32_S3 MISO pin GPIO13 to MFRC522 card MISO
// ESP32_S3 MOSI pin GPIO11 to MFRC522 card MOSI
// ESP32_S3 SS pin GPIO 10 to MFRC522 card SS (marked SDA on PCB)
// connect ESP32_S3 GND and 3.3V to MFRC522 GND and 3V3
#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
//#include <MFRC522DriverI2C.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>
MFRC522DriverPinSimple ss_pin(10); // Configurable, see typical pin layout above.
MFRC522DriverSPI driver{ss_pin}; // Create SPI driver.
//MFRC522DriverI2C driver{}; // Create I2C driver.
MFRC522 mfrc522{driver}; // Create MFRC522 instance.
/**
* Check firmware only once at startup.
*/
void setup() {
Serial.begin(115200); // Initialize serial communications with the PC for debugging.
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4).
mfrc522.PCD_Init(); // Init MFRC522 board.
Serial.println(F("*****************************"));
Serial.println(F("MFRC522 Digital self test"));
Serial.println(F("*****************************"));
MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial); // Show version of PCD - MFRC522 Card Reader.
Serial.println(F("-----------------------------"));
Serial.println(F("Only known versions supported"));
Serial.println(F("-----------------------------"));
Serial.println(F("Performing test..."));
bool result = mfrc522.PCD_PerformSelfTest(); // Perform the test.
Serial.println(F("-----------------------------"));
Serial.print(F("Result: "));
if (result)
Serial.println(F("OK"));
else
Serial.println(F("DEFECT or UNKNOWN"));
Serial.println();
}
void loop() {} // nothing to do
serial monitor displays
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x109c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xb50
load:0x403cc700,len:0x2fe4
entry 0x403c98ac
*****************************
MFRC522 Digital self test
*****************************
Firmware Version: 0xB2 = FM17522_1
-----------------------------
Only known versions supported
-----------------------------
Performing test...
-----------------------------
Result: DEFECT or UNKNOWN
copied code from your post 18 compiler, linked and a run gave
*****************************
MFRC522 Digital self test
*****************************
Firmware Version: 0x92 = v2.0
-----------------------------
Only known versions supported
-----------------------------
Performing test...
-----------------------------
Result: OK
using IDE 2.3.2 Tools>Board set to ESP32S3 Dev Module
tried with ESP32 core V3.0.7 and 2.0.17 - both work OK
MFRC522 Digital self test
*****************************
Firmware Version: 0xB2 = FM17522_1
-----------------------------
Only known versions supported
-----------------------------
Performing test...
-----------------------------
Result: DEFECT or UNKNOWN
same results as your post 5
clearly there are different firmware version and the code only works for certain versions
EDIT: try this code
// ESP32-S3-DevKitC-1 - ESP32_S3 to MFRC522 ReadUidMultiReader test
/*
* --------------------------------------------------------------------------------------------------------------------
* Example showing how to read data from more than one PICC to serial.
* --------------------------------------------------------------------------------------------------------------------
* This is a MFRC522 library example; for further details and other examples see: https://github.com/OSSLibraries/Arduino_MFRC522v2
*
* Example sketch/program showing how to read data from more than one PICC (that is: a RFID Tag or Card) using a
* MFRC522 based RFID Reader on the Arduino SPI interface.
*
* Warning: This may not work! Multiple devices at one SPI are difficult and cause many trouble!! Engineering skill
* and knowledge are required!
*
* @license Released into the public domain.
*
* 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
* -----------------------------------------------------------------------------------------
* 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
*
* Not found? For more see: https://github.com/OSSLibraries/Arduino_MFRC522v2#pin-layout
*/
// ESP32_S3_DevKit_1 connections
// ESP32_S3 SCK pin GPIO12 to MFRC522 card SCK
// ESP32_S3 MISO pin GPIO13 to MFRC522 card MISO
// ESP32_S3 MOSI pin GPIO11 to MFRC522 card MOSI
// ESP32_S3 SS pin GPIO 10 to MFRC522 card SS (marked SDA on PCB)
// connect ESP32_S3 GND and 3.3V to MFRC522 GND and 3V3
// Note for i2c:
// With i2c possible if every device has a own unique address.
// Otherwise a i2c multiplexer is required, which requires a own implementation of MFRC522Driver.h.
#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>
MFRC522DriverPinSimple ss_1_pin(10); // Configurable, take an unused pin, only HIGH/LOW required, must be different to SS 2.
MFRC522DriverPinSimple ss_2_pin(8); // Configurable, take an unused pin, only HIGH/LOW required, must be different to SS 1.
MFRC522DriverSPI driver_1{ss_1_pin};
MFRC522DriverSPI driver_2{ss_2_pin};
MFRC522 readers[]{driver_1};//, driver_2}; // Create MFRC522 instance.
/**
* Initialize.
*/
void setup() {
Serial.begin(115200); // Initialize serial communications with the PC for debugging.
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4).
for (MFRC522 reader : readers) {
reader.PCD_Init(); // Init each MFRC522 card.
Serial.print(F("Reader "));
static uint8_t i = 0;
i++;
Serial.print(i);
Serial.print(F(": "));
MFRC522Debug::PCD_DumpVersionToSerial(reader, Serial);
}
}
/**
* Main loop.
*/
void loop() {
//if(!Serial.available()) return;
//while(Serial.available()) Serial.read();
delay(500);
Serial.println("reading RFID");
// Look for new cards.
for (MFRC522 reader : readers) {
if (reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) {
Serial.print(F("Reader "));
static uint8_t i = 0;
i++;
Serial.print(i);
// Show some details of the PICC (that is: the tag/card).
Serial.print(F(": Card UID:"));
MFRC522Debug::PrintUID(Serial, reader.uid);
Serial.println();
Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = reader.PICC_GetType(reader.uid.sak);
Serial.println(MFRC522Debug::PICC_GetTypeName(piccType));
// Halt PICC.
reader.PICC_HaltA();
// Stop encryption on PCD.
reader.PCD_StopCrypto1();
}
}
}
works OK with new MFRC522
Reader 1: Firmware Version: 0xB2 = FM17522_1
reading RFID
reading RFID
Reader 2: Card UID: 15 64 FD C2
PICC type: MIFARE 1KB
reading RFID
reading RFID
reading RFID
reading RFID
reading RFID
reading RFID
Reader 3: Card UID: 83 6E D2 A6
PICC type: MIFARE 1KB
reading RFID
reading RFID
reading RFID
reading RFID
Reader 4: Card UID: C3 65 94 95
PICC type: MIFARE 1KB
reading RFID
reading RFID
I use Tools>Board> ESP32S3 Dev Module
it appears there are many different versions of MRFC522 firmware
both my MFRC522 modules work with the code of post 7