user80298: I have a Elechouse PN532 module (bought here - https://robu.in/product/pn532-nfc-rfid-read-write-module-v3-kit/). When I try to use to it with I2C and connect it to my ESP32 (DOIT ESP32 DEV KIT V1, 30 pin version), the PN532 gets detected but it doesn't detect when a card or token shown to it. When I try the exact same code with Arduino Uno with I2C, it works flawlessly. Below are the connections for both boards, the code, the output and actual connection picture (since some said wire position matters for PN532).
Connections

ESP32





ESP32
PN532




GPIO 22
SCL


GPIO 21
SDA


3.3V
VCC


GND
GND





Arduino Uno





Uno
PN532




A5
SCL


A4
SDA


3.3V
VCC


GND
GND




The code
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

void setup(void) {
  Serial.begin(115200);        
  //Wire.begin(21, 22);        //used this line only when connected with ESP32
  Serial.println("Hello!");

  pn532i2c.wakeup();    //delays 500ms
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);

  // configure board to read RFID tags
  nfc.SAMConfig();

  Serial.println("Waiting for an ISO14443A card");
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);

  if (success) {
    Serial.println("Found a card!");
    Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    Serial.print("UID Value: ");
    for (uint8_t i=0; i < uidLength; i++) 
    {
      Serial.print(" 0x");Serial.print(uid[i], HEX); 
    }
    Serial.println("");
    // Wait 1 second before continuing
    delay(1000);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    Serial.println("Timed out waiting for a card");
  }
}

Output

For Arduino Uno

For ESP32


Connection Placements

For Arduino Uno


For ESP32



Also, the configuration of ESP32 in Arduino IDE


user83247: To use PN532, UART or SPI seems to be a good choice. Also, the little red board needs a strong power supply, and the power supply capacity from the ESP32 DEV KIT will be insufficient; I recommend adding a capacitor of about 47uF on the PN532.


80298: <p>I have a Elechouse PN532 module (bought here - <a href="https://robu.in/product/pn532-nfc-rfid-read-write-module-v3-kit/" rel="nofollow noreferrer">https://robu.in/product/pn532-nfc-rfid-read-write-module-v3-kit/</a>). When I try to use to it with I2C and connect it to my ESP32 (DOIT ESP32 DEV KIT V1, 30 pin version), the PN532 gets detected but it doesn't detect when a card or token shown to it. When I try the exact same code with Arduino Uno with I2C, it works flawlessly. Below are the connections for both boards, the code, the output and actual connection picture (since some said wire position matters for PN532).</p>
<p><strong>Connections</strong></p>
<ul>
<li>ESP32</li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ESP32</th>
<th>PN532</th>
</tr>
</thead>
<tbody>
<tr>
<td>GPIO 22</td>
<td>SCL</td>
</tr>
<tr>
<td>GPIO 21</td>
<td>SDA</td>
</tr>
<tr>
<td>3.3V</td>
<td>VCC</td>
</tr>
<tr>
<td>GND</td>
<td>GND</td>
</tr>
</tbody>
</table>
</div>
<ul>
<li>Arduino Uno</li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Uno</th>
<th>PN532</th>
</tr>
</thead>
<tbody>
<tr>
<td>A5</td>
<td>SCL</td>
</tr>
<tr>
<td>A4</td>
<td>SDA</td>
</tr>
<tr>
<td>3.3V</td>
<td>VCC</td>
</tr>
<tr>
<td>GND</td>
<td>GND</td>
</tr>
</tbody>
</table>
</div>
<p><strong>The code</strong></p>
<pre><code>#include &lt;Wire.h&gt;
#include &lt;PN532_I2C.h&gt;
#include &lt;PN532.h&gt;
#include &lt;NfcAdapter.h&gt;

PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);

void setup(void) {
  Serial.begin(115200);        
  //Wire.begin(21, 22);        //used this line only when connected with ESP32
  Serial.println(&quot;Hello!&quot;);

  pn532i2c.wakeup();    //delays 500ms
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print(&quot;Didn't find PN53x board&quot;);
    while (1); // halt
  }

  // Got ok data, print it out!
  Serial.print(&quot;Found chip PN5&quot;); Serial.println((versiondata&gt;&gt;24) &amp; 0xFF, HEX); 
  Serial.print(&quot;Firmware ver. &quot;); Serial.print((versiondata&gt;&gt;16) &amp; 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata&gt;&gt;8) &amp; 0xFF, DEC);

  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);

  // configure board to read RFID tags
  nfc.SAMConfig();

  Serial.println(&quot;Waiting for an ISO14443A card&quot;);
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &amp;uid[0], &amp;uidLength);

  if (success) {
    Serial.println(&quot;Found a card!&quot;);
    Serial.print(&quot;UID Length: &quot;);Serial.print(uidLength, DEC);Serial.println(&quot; bytes&quot;);
    Serial.print(&quot;UID Value: &quot;);
    for (uint8_t i=0; i &lt; uidLength; i++) 
    {
      Serial.print(&quot; 0x&quot;);Serial.print(uid[i], HEX); 
    }
    Serial.println(&quot;&quot;);
    // Wait 1 second before continuing
    delay(1000);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    Serial.println(&quot;Timed out waiting for a card&quot;);
  }
}
</code></pre>
<p><strong>Output</strong></p>
<ul>
<li>For Arduino Uno
<a href="https://i.stack.imgur.com/ZKuZo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKuZo.png" alt="enter image description here" /></a></li>
<li>For ESP32
<a href="https://i.stack.imgur.com/n5sB5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n5sB5.png" alt="enter image description here" /></a></li>
</ul>
<p><strong>Connection Placements</strong></p>
<ul>
<li><p>For Arduino Uno
<a href="https://i.stack.imgur.com/Nys3L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nys3L.jpg" alt="enter image description here" /></a></p>
</li>
<li><p>For ESP32
<a href="https://i.stack.imgur.com/F6mzm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F6mzm.jpg" alt="enter image description here" /></a></p>
</li>
</ul>
<p>Also, the configuration of ESP32 in Arduino IDE</p>
<p><a href="https://i.stack.imgur.com/C263H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C263H.png" alt="enter image description here" /></a></p>
 83247: <p>To use PN532, UART or SPI seems to be a good choice. Also, the little red board needs a strong power supply, and the power supply capacity from the ESP32 DEV KIT will be insufficient; I recommend adding a capacitor of about 47uF on the PN532.
<a href="https://i.stack.imgur.com/cEhcr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cEhcr.jpg" alt="enter image description here" /></a></p>
