Connecting to a PN532 Board

Hi,

I try to use an elechouse PN532 Board with the Nano ESP32 with the current Arduino IDE under Linux. The communication should be done with i2c.
I found a Script with the basic functions, but it is for a "regular" esp32 bord. The (really old) library for the PN532 uses Pins D22 and D21 for SCL and DCA, but the nano doesn't have this pins. So logically the script says "PN53x card not found!"

The library is from here:

The script I am using is from here:

Is there any way to change he pins for the communication?
Is there any better way to communicate with that NFC board?

Hello @tosho57. I have no experience with NFC or the libraries you mentioned, but I think the sample code you referenced in the second link doesn't explicitly set I2C pins - it uses the board's generic Wire object here:

PN532_I2C pn532i2c(Wire);

So unless it explicitly sets them inside the library (odd), I would expect this to use the Nano ESP32's default I2C pins (which are A4 for SDA and A5 for SCL). Have you already tried that?

Yes, exactly! That solves my problem. I now use the default pins (which I didn't know at all) and it works right away.
thanks a lot.

I am completely new to Arduino, so the docs are somewhat overwelming to me.

1 Like

No worries, one step at a time! Happy hacking! :slight_smile:

Uuhh! i'm just getting mad.
I just uploaded the script agein, with a removed testprint statement, and now it dosn't find the card again.

Even stranger: I added a new testprint like so:

bool connect() {
  
  Serial.println("Trying to connect to PN53x card");
  nfc.begin();

  // Connected, show version
  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata)
  {
    Serial.println("PN53x card not found!");
    return false;
  } 
 . . .

The output of the serial console is:

PN53x card not found!
Trying to connect to PN53x card

Why is the second message printed before the first one?