ESP32 TTGO-T-display + pn532

hello. i try to connect pn532 nfc module to esp32 TTGO-T-display over spi, like this:

I try to use code:

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

#define PN532_SCK  (2)
#define PN532_MISO (15)
#define PN532_MOSI (13)
#define PN532_SS   (37)

Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);


void setup(void) {

  Serial.begin(115200);
 delay(3000);

  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);
  
  // configure board to read RFID tags
  nfc.SAMConfig();

}

Then i fix bitrade to 100000 in file Adafruit_PN532.cpp:

Adafruit_PN532::Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
                               uint8_t ss) {
  spi_dev = new Adafruit_SPIDevice(ss, clk, miso, mosi, 100000,
      SPI_BITORDER_LSBFIRST, SPI_MODE0);
}


Adafruit_PN532::Adafruit_PN532(uint8_t ss) {
  spi_dev =
      new Adafruit_SPIDevice(ss, 100000, SPI_BITORDER_LSBFIRST, SPI_MODE0);
}

and I get in serial out put: Didn't find PN53x board and it halt. The connection pins is correct I recheck it one more time.
Any one can help me, what is problem and how to fix it? Thanks!

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