I used this arduino library for the PN532 https://github.com/elechouse/PN532
It basically worked first time on the SPI but I only had 3 pins left so tried to switch to UART 2.
Changed this in the PN532 "iso14443 example"
Code: Select all
#elif 1
#include <PN532_HSU.h>
#include <PN532.h>
HardwareSerial Serial1(1); <------------------ add this
PN532_HSU pn532hsu(Serial1);
PN532 nfc(pn532hsu);
<install directory>\Arduino\hardware\espressif\esp32\cores\esp32\HardwareSerial.cpp
Code: Select all
if(_uart_nr == 1 && rxPin < 0 && txPin < 0) {
rxPin = 16; <---------------------your pin number
txPin = 15; <--------------------- your pin number
}
Code: Select all
void PN532_HSU::begin()
{
_serial->begin(115200,SERIAL_8N1,16,13); <------- your pin assignments
}
I initially called
Code: Select all
Serial1.begin(115200, SERIAL_8N1, 16, 15);
Currently I am not sure if the problem is because serial1.begin() was called twice or because set HardwareSerial::changeBaud() is called twice (indirectly through begin). I suspect the latter because of the error reported in https://github.com/espressif/arduino-esp32/issues/441
Hope this helps somebody.