# Connecting RC522 to ESP32-S3

**URL:** <https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851>\
**Category:** General Electronics\
**Created:** [February 28, 2023, 7:44am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851 "2023-02-28T07:44:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [February 28, 2023, 7:44am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/1 "2023-02-28T07:44:50Z")

</div>

Hi Forum! I am new here and also new to ESP32.  
I wanted to connect RFID-reader RC522 to the ESP32-S3 board.

Can someone tell me what to connect to what? Thnx!

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [February 28, 2023, 11:05am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/2 "2023-02-28T11:05:20Z")

</div>

Welcome to the forum

What sort of interface does the RC522 have ?

Serial, SPI, I2C, something else ?

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [February 28, 2023, 11:44am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/3 "2023-02-28T11:44:55Z")

</div>

Thank you for the quick response. Please see attached images.

 ![Bildschirmfoto 2023-02-28 um 08.29.50](https://europe1.discourse-cdn.com/arduino/original/4X/9/c/b/9cb55146faa540e293e8e86c49d673ef3621f7b1.jpeg)

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [February 28, 2023, 11:45am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/4 "2023-02-28T11:45:34Z")

</div>

I also found this:

 ![Bildschirmfoto 2023-02-28 um 08.29.38](https://europe1.discourse-cdn.com/arduino/original/4X/2/5/c/25c0f64781a56a5909436098f0ca686f2a767466.jpeg)

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [February 28, 2023, 11:46am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/5 "2023-02-28T11:46:53Z")

</div>

and this is the board:

 ![Bildschirmfoto 2023-02-28 um 08.31.02](https://europe1.discourse-cdn.com/arduino/original/4X/4/9/c/49c7a28f0cc98045657d185735c74de9f052afee.jpeg)

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [February 28, 2023, 2:17pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/6 "2023-02-28T14:17:32Z")

</div>

SPI\_CS --\> SS  
SPI\_D --\> MOSI  
SPI\_CLK -- SSK  
SPI\_Q --\>MISO  
Any available GPIO --\>RST

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [March 1, 2023, 5:14pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/7 "2023-03-01T17:14:46Z")

</div>

Great, thank you, I will try this!

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [March 5, 2023, 10:36pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/8 "2023-03-05T22:36:46Z")

</div>

Not sure if it works. Uploaded an selftest to the device and it shows an error. I will try other GPIO's...

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [March 7, 2023, 11:37am UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/9 "2023-03-07T11:37:58Z")

</div>

Unfortunately it does not work. I uploaded a test script to my ESP32s3 and it is telling me its not working:

```cpp
// RFID Reader
#include <SPI.h>      
#include <MFRC522.h>

#define RST_PIN 21 // any available GPIO          
#define SS_PIN 10 // SPI_CS -> GPIO 10

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
bool selftest_result = false;

#include "TFT_eSPI.h"

unsigned colour = 0xFFFF;
TFT_eSPI tft = TFT_eSPI();

void setup() {

  // RFID
  Serial.begin(9600);
  SPI.begin(); // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 module

  delay(100);
  Serial.begin(115200); // be sure to set USB CDC On Boot: "Enabled"
  
  //(Serial print slows progres bar Demo)
  delay(100);
  tft.init();
  tft.setRotation(3);
  tft.setSwapBytes(true);
  tft.fillScreen(TFT_BLACK); //horiz / vert<> position/dimension
  tft.setTextSize(1);
  tft.setTextDatum(4);

  delay(100);
  Serial.println("In setup!");

  delay(2000);
  
   // RFID selftest
  tft.drawString("MFRC522 Digital self test", 95, 125, 2);
  mfrc522.PCD_DumpVersionToSerial(); // Show version of PCD - MFRC522 Card Reader
  selftest_result = mfrc522.PCD_PerformSelfTest(); // perform the test
  if (selftest_result)
    tft.drawString("Result: OK", 95, 145, 2);
  else
    tft.drawString("Result: Defect or unknown!", 95, 145, 2);
    
}

//RFID
void accessGranted() {
  tft.drawString("Access Granted", 77, 55, 4);
  delay(3000);
}
void accessRefused() {
   tft.drawString("Access Refused", 77, 55, 4);
   delay(3000);
}

void loop() {

  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.drawString("Ready!", 77, 55, 4);
  
  if(selftest_result) {
    tft.drawString("selftest_result: OK", 220, 55, 2);
  }
  else {
    tft.drawString("RFID defect or unknown!", 220, 55, 2);
  }
  

  // RFID
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    tft.drawString("!PICC_IsNewCardPresent", 150, 180, 2);
    return;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    tft.drawString("!PICC_ReadCardSeria", 150, 190, 2);
    return;
  }
  tft.drawString(" UID tag:", 77, 55, 4);
  
  String content= "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  content.toUpperCase();
  tft.drawString(" PICC type:", 77, 75, 4);
  
  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  tft.drawString(mfrc522.PICC_GetTypeName(piccType), 90, 75, 4);
  
  if (content.substring(1) == "39 7B 02 64" || content.substring(1) == "B2 38 DB 0E") {
    accessGranted();
  }
  else {
    accessRefused();
  }
  // END RFID

  delay(100);
}

```

Result is: Display shows 'Result: Defect or unknown!'  
I checked for cold solder joints. all fine.

 ![grafik](https://europe1.discourse-cdn.com/arduino/original/4X/8/4/4/8449498e8294f23834775e092a6345fbf6f5b4ca.jpeg)

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [March 7, 2023, 10:20pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/10 "2023-03-07T22:20:29Z")

</div>

Serial is printing

> MFRC522 Ready!  
> In setup!  
> Firmware Version: 0x0 = (unknown)  
> WARNING: Communication failure, is the MFRC522 properly connected?

---

<div class="post-metadata">

**Author:** ![headkit](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@headkit](https://forum.arduino.cc/u/headkit)\
**Post date:** [March 19, 2023, 7:26pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/11 "2023-03-19T19:26:11Z")

</div>

I bought another RC522 and now it works well.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 15, 2023, 7:27pm UTC](https://forum.arduino.cc/t/connecting-rc522-to-esp32-s3/1095851/12 "2023-09-15T19:27:10Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
