Hi,
I have been trying to configure the MFRC522 with an ESP32S3 in I2C mode. I managed to get it working within SPI following 'randomnerdtutorials' with some slight adjustments to the pins as the tutorial was for ESP32 not the S3.
I really need to get it working for the i2c protocol. I have found a library which i have tried but not compatible
"GitHub - semaf/MFRC522_I2C_Library: MFRC522 i2c for Arduino and ESP8266 "
Here is what i have done so far.
#include <Wire.h>
#include <MFRC522_I2C.h>
// Define the RST pin
#define RST_PIN 10 // GPIO10 on ESP32-S3
// Default I2C address for MFRC522
#define MFRC522_I2C_ADDRESS 0x28
MFRC522 mfrc522(MFRC522_I2C_ADDRESS, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200);
Wire.begin(8, 9); // SDA = GPIO8, SCL = GPIO9
mfrc522.PCD_Init(); // Initialize the MFRC522
Serial.println("Scan an RFID card");
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
// Print UID
Serial.print("Card UID:");
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
}
The code runs, but i am unable to scan a card.
I have used SDA, and MISO on the new board
horace
February 17, 2025, 12:08pm
2
which specific I2C module are you using?
have you tried running the ESP32 I2C scanner
the default SPI and I2C pins for my ESP32-S3-DevKitC-1 are
default pins
MOSI: 11
MISO: 13
SCK: 12
SS: 10
SDA: 8
SCL: 9
Hi, I am using the MFRC522 and plugging that directly into the ESP32 S3.
MFRC522 -> ESP
SDA -> GPIO8
MOSI - > GPIO9
3.3V -> 3V3
GND -> GND
I have run that I2C Scanner, and nothing is being shown.
Supposedly for the MFRC522 the clock line is on the MOSI pin.
Sorry, i did put it on this MISO, and it did not work. Dunno why i said MOSI
horace
February 17, 2025, 5:19pm
6
tried an experiment with an ESP32
MFRC522 SDA to ESP32 GPIO21 (SDA)
MFRC522 MISO to ESP32 GPIO22 (SCL)
ran I2C scanner - - no I2C devices found
then tried MFRC522 MOSI and then SCK to GPIO22 - no I2C devices found
checked GPIO 22 and 21 with oscilloscope and can see SCL and SDA signals
You think esp is not compatible with this device then?
horace
February 17, 2025, 5:39pm
8
the ESP32 communicates with the same MFRC522 using SPI OK
e.g. sample serial output
Reader 1: Firmware Version: 0x92 = v2.0
reading RFID
reading RFID
Reader 1: Card UID: C0 FF 62 1A
PICC type: MIFARE 1KB
reading RFID
reading RFID
reading RFID
reading RFID
Reader 2: Card UID: 15 64 FD C2
PICC type: MIFARE 1KB
possibly I2C is not enabled on the MFRC522 I am using?
or is there some configuration that is missing?
I believe looking at the datasheet, it might need to be soldered?
kmin
February 17, 2025, 5:59pm
10
horace:
MFRC522
The module is probably hardwired for SPI (the pin1 of the chip connected to gnd). To enable I2C you probably need to modify the circuit.
Why you need I2C?
From the datasheet:
to use the I2C interface the I2C pin on the MFRC522 must be pulled high.
From a schematic of the module found online:
the I2C pin is tied to ground. Short of doing surgery on the board, you're stuck with SPI.
And from looking at the board, the trace to I2C does not extend out from underneath the IC. So it would not be easy to modify.
Hi I am trying to connecr Seed Studio Esp32s3 chip with MFRC522 RFID Reader, please can someone give me connection and code as well