ESP32C6 + PN532 NFC Reader (HW-147C) SPI/I2C Communication Not Working - "Didn't find PN53x board"

I'm trying to get an NFC reader (PN532 module, HW-147C model) working with my ESP32C6 using SPI. I tried using multiple libraries (seeed-studio, Adafruit, and some on github, but nothing worked).

This is the wiring (not my picture but this is how it is) (the switch are 1 up and 2 down)

And this is the ESP32 I'm using

I've been running the Example in NDEF library (readtag). When I upload the Seeed-Studio example iso14443a_uid.ino (with CS pin set to GPIO5), the Serial Monitor shows:

    ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0x6f (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875730,len:0x12e0
load:0x4086b910,len:0xdc8
load:0x4086e610,len:0x3180
entry 0x4086b910
Hello!
Didn't find PN53x board

The module is not being detected. The power LED on the PN532 is lit (red light), indicating the module has power
Does anyone know how to solve this issue?

Did you set the dip switches for spi-mode?
What board you have selected on ide?

Yes the dip switches are on spi-mode. I can't really show you because it's not clear on picture

I used the ESP32C6 dev module as board in the Arduino IDE

Try with the default pins
SS = 18
MOSI = 19
MISO = 20
SCK = 21

Nothing changed

Hopefully at least your wiring and pin definitions on your code...

yes the wiring definetly changed.
For the code I'm using the example code that doesnt ask to define pins

/**************************************************************************/
/*! 
    This example will attempt to connect to an ISO14443A
    card or tag and retrieve some basic information about it
    that can be used to determine what type of card it is.   
   
    Note that you need the baud rate to be 115200 because we need to print
    out the data and read from the card at the same time!

    To enable debug message, define DEBUG in PN532/PN532_debug.h
    
*/
/**************************************************************************/


/* When the number after #if set as 1, it will be switch to SPI Mode*/
#if 0
  #define NFC_INTERFACE_SPI
  #include <SPI.h>
  #include <PN532_SPI.h>
  #include <PN532_SPI.cpp>
  #include "PN532.h"

  PN532_SPI pn532spi(SPI);
  PN532 nfc(pn532spi);

/* When the number after #elif set as 1, it will be switch to HSU Mode*/
#elif 0
  #define NFC_INTERFACE_HSU
  #include <PN532_HSU.h>
  #include <PN532_HSU.cpp>
  #include <PN532.h>
      
  PN532_HSU pn532hsu(Serial1);
  PN532 nfc(pn532hsu);

/* When the number after #if & #elif set as 0, it will be switch to I2C Mode*/
#else 
  #define NFC_INTERFACE_I2C
  #include <Wire.h>
  #include <PN532_I2C.h>
  #include <PN532_I2C.cpp>
  #include <PN532.h>
  
  PN532_I2C pn532i2c(Wire);
  PN532 nfc(pn532i2c);
#endif
  
void setup(void) {
  Serial.begin(115200);
  Serial.println("Hello!");

  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");
  }
}

Try this and define your pins accordingly.

Also, how is your wiring?
All carefully soldered?
Or jumper wires on factory soldered headers?
Something else? Post a photo.



I have did some changes but nothing again

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>

// nanoESP32-C6 SPI Pins (alternative set)
#define PN532_SS    18   // GPIO18
#define PN532_MOSI  19   // GPIO19
#define PN532_MISO  20   // GPIO20
#define PN532_SCK   21   // GPIO21

// Initialize PN532 with SPI
Adafruit_PN532 nfc(PN532_SS);

void setup(void) {
  Serial.begin(115200);
  delay(3000);
  
  Serial.println("\n╔════════════════════════════════════════╗");
  Serial.println("║  nanoESP32-C6 + PN532 Test            ║");
  Serial.println("║  GPIO18=SS, GPIO19=MOSI               ║");
  Serial.println("║  GPIO20=MISO, GPIO21=SCK              ║");
  Serial.println("╚════════════════════════════════════════╝\n");
  
  Serial.println("Initializing PN532...");
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (!versiondata) {
    Serial.println("\n❌ PN532 not found!\n");
    Serial.println("Troubleshooting:");
    Serial.println("  • Check mode switches: S1=OFF, S2=ON");
    Serial.println("  • Verify all 5 wires connected");
    Serial.println("  • Check power LED is ON");
    while (1);
  }
  
  Serial.println("✓ PN532 Found!");
  Serial.print("Firmware: ");
  Serial.print((versiondata >> 16) & 0xFF, DEC);
  Serial.print(".");
  Serial.println((versiondata >> 8) & 0xFF, DEC);

  nfc.SAMConfig();
  
  Serial.println("\n✓ Ready! Hold a card near the module...\n");
}

void loop(void) {
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
  uint8_t uidLength;

  if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength)) {
    Serial.println("✓ CARD FOUND!");
    Serial.print("UID: ");
    for (uint8_t i = 0; i < uidLength; i++) {
      Serial.print("0x");
      Serial.print(uid[i], HEX);
      if (i < uidLength - 1) Serial.print(" ");
    }
    Serial.println("\n");
    delay(1000);
  } else {
    Serial.print(".");
    delay(200);
  }
}

Your dip switches are not 01 on photo.
Are your pin headers properly soldered?

I put the dip switches in 01 and it didnt work.
There should be no problem with the soldering. I'm trying everything I find but the cheap just seem to not be detected

Then try 10 in case the labels are wrong.

That would be my first bet here.

I got the same problem. Them I switched the SDA and the SCK jumpers an it worked just fine. I my case they make the device with the SDA and SCK with swapped places

sorry but I didn't really understand. Do I have to switch SCK and SDA on the pn532? In I2C or SPI?

I connected the esp32 with a i2c scanner to the pn532, and I get:

ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0x7f (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875730,len:0x11e4
load:0x4086b910,len:0xc7c
load:0x4086e610,len:0x3088
entry 0x4086b910


I2C Scanner
====================
Scanning I2C bus...

Found device at address: 0x28 (40)

The problem is that on the code:

// Add this at the very top to fix boolean compatibility
#ifndef boolean
#define boolean bool
#endif

#if 0
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else

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

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif

void setup(void) {
    Serial.begin(115200);
    delay(1000);
    
    // Initialize I2C with pins 6 (SDA) and 7 (SCL) BEFORE nfc.begin()
    Wire.begin(6, 7);
    delay(500);
    
    Serial.println("NDEF Reader");
    Serial.println("Initializing PN532...");
    nfc.begin();
    
    delay(500);
    Serial.println("Ready to scan NFC tags!");
}

void loop(void) {
    Serial.println("\nScanning for NFC tag...");
    if (nfc.tagPresent())
    {
        Serial.println("Tag detected!");
        NfcTag tag = nfc.read();
        tag.print();
    }
    else
    {
        Serial.println("No tag detected.");
    }
    delay(5000);
}

it still gives me pn532 not found

The problem is that you still have wiring or dip-switch error.
Scan should give 0x24 when everything is correct.
Try flipping the dip switches 1/0 or 0/1, if it doesn't solve the issue, post high quality photo presenting your pin soldering.





The wiring is: VCC -->5V
GND --->GND
SDA--->6
SCL--->7

I can't tell from the images if your soldering is sufficient. At least control VCC and SDA , doesn't look so good.
Also, vcc and scl have both white wires, easy to make mistake and fry something.

I checked voltages and it's all good. at this point i can only think of a library issue