Hello all,
My first post, and I really hope that I'm getting all the instructions right... please tell me otherwise!
I've been headdesking for three days over a thorny problem. As part of a larger project, I've been using a PN5180 RFID reader. It worked fine with an UNO, but I've had to switch to MEGA for the extra memory. All other components work fine (including other SPI ones)... except this one, with some very strange results.
For starters, here are the pinouts, old and new. (I've checked them over a dozen times, so hopefully no mistake there.) All pins are shifted 5V <> 3.3V. I chose only pins that have interrupt, just in case.
RST: 7 on UNO, 10 on MEGA
NSS: A0 on UNO, A8 on MEGA
MOSI: 11 on UNO, 51 on MEGA
MISO: 12 on UNO, 50 on
SCK: 13 on UNO, 52 on MEGA
BUSY: 8 on UNO, 11 on MEGA
Next, a simplified bit of code that I wrote to showcase the issue:
#include <PN5180.h>
#include <PN5180ISO15693.h>
PN5180ISO15693 nfc(A8, 11, 10);
void setup() {
Serial.begin(9600);
Serial.println(F("Initialising..."));
nfc.begin();
Serial.println(F("Resetting..."));
nfc.reset();
Serial.println(F("Enabling RF field..."));
nfc.setupRF();
Serial.println(F("Setup Complete"));
}
void loop() {
nfc.reset();
nfc.setupRF();
// Variable to store the ID of any tag read by this reader
uint8_t thisUid[8];
// Try to read a tag ID (or "get inventory" in ISO15693-speak)
ISO15693ErrorCode rc = nfc.getInventory(thisUid);
// If the result code was that a card had been read
if (rc == ISO15693_EC_OK) {
Serial.print(F("New Card Detected on Reader: "));
for (int j = 0; j < sizeof(thisUid); j++) {
Serial.print(thisUid[j], HEX);
}
Serial.println();
}
delay(1000);
}
I use ATrappmann's library, which as far as I can find is the only one available for the PN5180:
And finally, the results on MEGA:
Looks fine... except that these were obtained with only three RFID tags, which stayed in contact with the reader the whole time! (One for the first four lines, one for the next three, one for the last three.) So the readings vary, and come in at random intervals of several seconds.
By contrast, on UNO, the results are correct and come in every second as they should.
Right now, the only idea that I have left is that something in the library might be malfunctioning with MEGA... but I searched for "mega" and "uno" in every h and cpp file with no results, and after that I'm out of my depths. I checked several other programs from the library's examples folder, all have comparable issues: difficulty finding the card, semi-random results when they do, and work fine on UNO.
Does anyone have any leads, any ideas of where such an issue could come from? I'm open to anything right now.
Thank you all,
Alex
