# Rfid rc522 in esp32

**URL:** <https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226>\
**Category:** 3rd Party Boards\
**Created:** [June 24, 2022, 3:09pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226 "2022-06-24T15:09:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![satpor3](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@satpor3](https://forum.arduino.cc/u/satpor3)\
**Post date:** [June 24, 2022, 3:09pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/1 "2022-06-24T15:09:10Z")

</div>

i'm using in esp32 DOIT KIT V1 and i have RFID Reader also  
pin conection  
3.3v=3.3v  
GND=GND  
RST=D22  
MOSI=D23  
MISO=D19  
SCK=D18  
SDA=D21  
Firmware Version: 0x0 = (unknown)  
WARNING: Communication failure, is the MFRC522 properly connected?  
I'm run in firmware check but not getting proper responce  
please help me

---

<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:** [June 24, 2022, 3:11pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/2 "2022-06-24T15:11:07Z")

</div>

Please post the full sketch that you have a problem with, using code tags when you do

---

<div class="post-metadata">

**Author:** ![satpor3](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@satpor3](https://forum.arduino.cc/u/satpor3)\
**Post date:** [June 24, 2022, 3:13pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/3 "2022-06-24T15:13:29Z")

</div>

```cpp
/*
 * --------------------------------------------------------------------------------------------------------------------
 * 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 22 // Configurable, see typical pin layout above
#define SS_PIN 21 // 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(115200); // 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

```

---

<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:** [June 24, 2022, 3:23pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/4 "2022-06-24T15:23:22Z")

</div>

Some of those pin numbers sound wrong

My notes say that for the ESP32, the default SPI MOSI is pin 23, MISO 19, and SCK pin 18

---

<div class="post-metadata">

**Author:** ![satpor3](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@satpor3](https://forum.arduino.cc/u/satpor3)\
**Post date:** [June 24, 2022, 3:32pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/5 "2022-06-24T15:32:15Z")

</div>

![ESP32-Pinout](https://europe1.discourse-cdn.com/arduino/original/4X/c/1/d/c1da61738262546106abd3f9d2a2aa0775b7e141.jpeg)  
this based i made connection this is my module one

---

<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:** [June 24, 2022, 3:46pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/6 "2022-06-24T15:46:15Z")

</div>

Did you by any chance edit your original post and change the pin numbers that you gave, as I am sure that when I replied your pin numbers were wrong

---

<div class="post-metadata">

**Author:** ![satpor3](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@satpor3](https://forum.arduino.cc/u/satpor3)\
**Post date:** [June 24, 2022, 3:51pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/7 "2022-06-24T15:51:15Z")

</div>

nooooooooo i'm not edit my post

---

<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:** [June 24, 2022, 4:46pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/8 "2022-06-24T16:46:58Z")

</div>

OK, then I am mistaken

Sorry

---

<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:** [December 21, 2022, 4:47pm UTC](https://forum.arduino.cc/t/rfid-rc522-in-esp32/1006226/9 "2022-12-21T16:47:50Z")

</div>

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