Hey, I have an ESP32 connected to a mini mfrc522. Admittedly, I purchased it from Aliexpress so its very likely a counterfeit. However, when I use it with the first mfrc522 library, it works just fine. When used with the mfrc522v2 library, it just doesn't read any cards. The firmware version shows as 0xB2 = FM17522_1, is there any way around this? Thank you!
Hi @baysell.
Are you referring to the library that is titled "MFRC522 by GithubCommunity" in the Arduino IDE Library Manager?
I'm referring to this one:
Please provide the full code of the working sketch you are using with "the first mfrc522 library" in a reply on this forum topic.
Make sure to follow the forum user guide to correctly post the code:
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code
Are you referring to the library that is titled "RFID_MFRC522v2 by GithubCommunity" in the Arduino IDE Library Manager?
I'm referring to this one:
Please provide the full code of the non-working sketch you are using with "the mfrc522v2 library".
I'm not sure I understood correctly what you mean by "doesn't read". Please provide a more detailed description of what you mean to help us to understand it.
Make sure to include the following information:
- What did you do?
- What were the results you expected from doing that thing?
- What were the results you observed that did not match your expectations?
If you encountered any errors or warnings, please provide the full and exact text of those messages.
Please also provide information about the cards you are using. I see that there is a known lack of support for certain specific types of cards. I do note that this is specified for both libraries, but it still might be relevant information.
My apologies. Yes, I am referring to
GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522 and
GitHub - OSSLibraries/Arduino_MFRC522v2
the code i used with the mfrc522 by miguelbalboa is:
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 21 // Configurable, see typical pin layout above
#define SS_PIN 5 // 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));
}
The code used with the mfrc522v2 lib is:
#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
//#include <MFRC522DriverI2C.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>
MFRC522DriverPinSimple ss_pin(5); // Configurable, see typical pin layout above.
MFRC522DriverSPI driver{ss_pin}; // Create SPI driver.
//MFRC522DriverI2C driver{}; // Create I2C driver.
MFRC522 mfrc522{driver}; // Create MFRC522 instance.
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.
MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial); // 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.
MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial, &(mfrc522.uid));
}
The mfrc522 one reads cards just fine
The latter one, the mfrc522v2, reads the board as 0xB2 as stated before & doesn't read any cards
I'm waiting for a response. Thank you!
Why are you looking for a way round the problem when you have a working library ?
the mfrc522v2 library is a lot easier to code with & i built a good amount of code using it a while ago, so id rather get this board working with that.
As I said, I had an unoriginal board which didn't work quite up to spec as the original one, so after adding a few delays between all critical events like the initialization and whatnot, it started working fine.