Board
Arduino Nano ESP32
Device Description
Here is the link to the exact device: link
Board:
- Name: Arduino Nano ESP32
- SKU: ABX00092
Microcontroller: u-blox NORA-W106 (ESP32-S3)
Hardware Configuration
Currently, I have an RFID Module plugged into the Arduino Nano ESP32.
Power:
The Arduino Nano ESP32 is powered via the USB-C Connector to my computer.
Wiring:
Nano ESP32 | PN5180-NFC |
---|---|
VIN | +5V |
3.3V | +3.3V |
D7 | RST |
D10 | NSS |
D12 (COPI) | MOSI |
D11 (CIPO) | MISO |
D13 (SCK) | SCK |
D9 | BUSY |
GND | GND |
RFID Module:
- PN5180-NFC
- Link
IDE Name
Arduino IDE 2.2.1
Operating System
Windows 11
Upload speed
115200
Description
I am attempting to use an Arduino Nano ESP32 board instead of an Arduino UNO REV3. The code included has successfully run on an Arduino UNO REV3, with the only alterations being to the PN5180_NSS, PN5180_BUSY, and PN5180_RST definitions.
From my attempts at resolving the issue, I gathered the issue may lie somewhere in the const __FlashStringHelper *strerror(ISO15693ErrorCode errno);
portion of the error and how Arduino Nano ESP32 reads flash memory.
The code is the example pulled from the following GitHub repository: Link
The only alterations are to the pin declarations mentioned above.
Sketch
#include <PN5180.h>
#include <PN5180ISO15693.h>
#define PN5180_NSS 10
#define PN5180_BUSY 9
#define PN5180_RST 7
PN5180ISO15693 nfc(PN5180_NSS, PN5180_BUSY, PN5180_RST);
void setup() {
Serial.begin(115200);
Serial.println(F("=================================="));
Serial.println(F("Uploaded: " __DATE__ " " __TIME__));
Serial.println(F("PN5180 ISO15693 Demo Sketch"));
nfc.begin();
Serial.println(F("----------------------------------"));
Serial.println(F("PN5180 Hard-Reset..."));
nfc.reset();
Serial.println(F("----------------------------------"));
Serial.println(F("Reading product version..."));
uint8_t productVersion[2];
nfc.readEEprom(PRODUCT_VERSION, productVersion, sizeof(productVersion));
Serial.print(F("Product version="));
Serial.print(productVersion[1]);
Serial.print(".");
Serial.println(productVersion[0]);
if (0xff == productVersion[1]) { // if product version 255, the initialization failed
Serial.println(F("Initialization failed!?"));
Serial.println(F("Press reset to restart..."));
Serial.flush();
exit(-1); // halt
}
Serial.println(F("----------------------------------"));
Serial.println(F("Reading firmware version..."));
uint8_t firmwareVersion[2];
nfc.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion));
Serial.print(F("Firmware version="));
Serial.print(firmwareVersion[1]);
Serial.print(".");
Serial.println(firmwareVersion[0]);
Serial.println(F("----------------------------------"));
Serial.println(F("Reading EEPROM version..."));
uint8_t eepromVersion[2];
nfc.readEEprom(EEPROM_VERSION, eepromVersion, sizeof(eepromVersion));
Serial.print(F("EEPROM version="));
Serial.print(eepromVersion[1]);
Serial.print(".");
Serial.println(eepromVersion[0]);
/*
Serial.println(F("----------------------------------"));
Serial.println(F("Reading IRQ pin config..."));
uint8_t irqConfig;
nfc.readEEprom(IRQ_PIN_CONFIG, &irqConfig, 1));
Serial.print(F("IRQ_PIN_CONFIG=0x"));
Serial.println(irqConfig, HEX);
Serial.println(F("----------------------------------"));
Serial.println(F("Reading IRQ_ENABLE register..."));
uint32_t irqEnable;
nfc.readRegister(IRQ_ENABLE, &irqEnable));
Serial.print(F("IRQ_ENABLE=0x"));
Serial.println(irqConfig, HEX);
*/
Serial.println(F("----------------------------------"));
Serial.println(F("Enable RF field..."));
nfc.setupRF();
}
uint32_t loopCnt = 0;
bool errorFlag = false;
//SLIX2 Passwords, first is manufacture standard
uint8_t standardpassword[] = {0x0F, 0x0F, 0x0F, 0x0F};
//New Password
uint8_t password[] = {0x12, 0x34, 0x56, 0x78};
void loop() {
if (errorFlag) {
uint32_t irqStatus = nfc.getIRQStatus();
showIRQStatus(irqStatus);
if (0 == (RX_SOF_DET_IRQ_STAT & irqStatus)) { // no card detected
Serial.println(F("*** No card detected!"));
}
nfc.reset();
nfc.setupRF();
errorFlag = false;
}
Serial.println(F("----------------------------------"));
Serial.print(F("Loop #"));
Serial.println(loopCnt++);
/*
// code for unlocking an ICODE SLIX2 protected tag
ISO15693ErrorCode myrc = nfc.unlockICODESLIX2(password);
if (ISO15693_EC_OK == myrc) {
Serial.println("unlockICODESLIX2 successful");
}
*/
/*
// code for set a new SLIX2 privacy password
nfc.getInventory(uid);
Serial.println("set new password");
ISO15693ErrorCode myrc2 = nfc.newpasswordICODESLIX2(password, standardpassword, uid);
if (ISO15693_EC_OK == myrc2) {
Serial.println("sucess! new password set");
}else{
Serial.println("fail! no new password set: ");
Serial.println(nfc.strerror(myrc2));
Serial.println(" ");
}
*/
uint8_t uid[8];
ISO15693ErrorCode rc = nfc.getInventory(uid);
if (ISO15693_EC_OK != rc) {
Serial.print(F("Error in getInventory: "));
Serial.println(nfc.strerror(rc));
errorFlag = true;
return;
}
Serial.print(F("Inventory successful, UID="));
for (int i=0; i<8; i++) {
Serial.print(uid[7-i], HEX); // LSB is first
if (i < 2) Serial.print(":");
}
Serial.println();
Serial.println(F("----------------------------------"));
uint8_t blockSize, numBlocks;
rc = nfc.getSystemInfo(uid, &blockSize, &numBlocks);
if (ISO15693_EC_OK != rc) {
Serial.print(F("Error in getSystemInfo: "));
Serial.println(nfc.strerror(rc));
errorFlag = true;
return;
}
Serial.print(F("System Info retrieved: blockSize="));
Serial.print(blockSize);
Serial.print(F(", numBlocks="));
Serial.println(numBlocks);
Serial.println(F("----------------------------------"));
uint8_t readBuffer[blockSize];
for (int no=0; no<numBlocks; no++) {
rc = nfc.readSingleBlock(uid, no, readBuffer, blockSize);
if (ISO15693_EC_OK != rc) {
Serial.print(F("Error in readSingleBlock #"));
Serial.print(no);
Serial.print(": ");
Serial.println(nfc.strerror(rc));
errorFlag = true;
return;
}
Serial.print(F("Read block #"));
Serial.print(no);
Serial.print(": ");
for (int i=0; i<blockSize; i++) {
if (readBuffer[i] < 16) Serial.print("0");
Serial.print(readBuffer[i], HEX);
Serial.print(" ");
}
Serial.print(" ");
for (int i=0; i<blockSize; i++) {
if (isprint(readBuffer[i])) {
Serial.print((char)readBuffer[i]);
}
else Serial.print(".");
}
Serial.println();
}
#ifdef WRITE_ENABLED
Serial.println(F("----------------------------------"));
uint8_t *writeBuffer = malloc(blockSize);
for (int i=0; i<blockSize; i++) {
writeBuffer[i] = 0x80 + i;
}
for (int no=0; no<numBlocks; no++) {
rc = nfc.writeSingleBlock(uid, no, writeBuffer, blockSize);
if (ISO15693_EC_OK == rc) {
Serial.print(F("Wrote block #"));
Serial.println(no);
}
else {
Serial.print(F("Error in writeSingleBlock #"));
Serial.print(no);
Serial.print(": ");
Serial.println(nfc.strerror(rc));
errorFlag = true;
return;
}
}
#endif /* WRITE_ENABLED */
/*
// code for locking an ICODE SLIX2 protected tag
ISO15693ErrorCode myrc = nfc.lockICODESLIX2(password);
if (ISO15693_EC_OK == myrc) {
Serial.println("lockICODESLIX2 successful");
delay(5000);
*/
delay(1000);
}
void showIRQStatus(uint32_t irqStatus) {
Serial.print(F("IRQ-Status 0x"));
Serial.print(irqStatus, HEX);
Serial.print(": [ ");
if (irqStatus & (1<< 0)) Serial.print(F("RQ "));
if (irqStatus & (1<< 1)) Serial.print(F("TX "));
if (irqStatus & (1<< 2)) Serial.print(F("IDLE "));
if (irqStatus & (1<< 3)) Serial.print(F("MODE_DETECTED "));
if (irqStatus & (1<< 4)) Serial.print(F("CARD_ACTIVATED "));
if (irqStatus & (1<< 5)) Serial.print(F("STATE_CHANGE "));
if (irqStatus & (1<< 6)) Serial.print(F("RFOFF_DET "));
if (irqStatus & (1<< 7)) Serial.print(F("RFON_DET "));
if (irqStatus & (1<< 8)) Serial.print(F("TX_RFOFF "));
if (irqStatus & (1<< 9)) Serial.print(F("TX_RFON "));
if (irqStatus & (1<<10)) Serial.print(F("RF_ACTIVE_ERROR "));
if (irqStatus & (1<<11)) Serial.print(F("TIMER0 "));
if (irqStatus & (1<<12)) Serial.print(F("TIMER1 "));
if (irqStatus & (1<<13)) Serial.print(F("TIMER2 "));
if (irqStatus & (1<<14)) Serial.print(F("RX_SOF_DET "));
if (irqStatus & (1<<15)) Serial.print(F("RX_SC_DET "));
if (irqStatus & (1<<16)) Serial.print(F("TEMPSENS_ERROR "));
if (irqStatus & (1<<17)) Serial.print(F("GENERAL_ERROR "));
if (irqStatus & (1<<18)) Serial.print(F("HV_ERROR "));
if (irqStatus & (1<<19)) Serial.print(F("LPCD "));
Serial.println("]");
}
Debug Message
C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino: In function 'void loop()':
C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:205:35: error: no matching function for call to 'PN5180ISO15693::strerror(ISO15693ErrorCode&)'
Serial.println(nfc.strerror(rc));
^
In file included from C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:76:
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: candidate: 'const __FlashStringHelper* PN5180ISO15693::strerror(ISO15693ErrorCode* (*)())'
const __FlashStringHelper *strerror(ISO15693ErrorCode errno);
^~~~~~~~
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: no known conversion for argument 1 from 'ISO15693ErrorCode' to 'ISO15693ErrorCode* (*)()'
C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:221:35: error: no matching function for call to 'PN5180ISO15693::strerror(ISO15693ErrorCode&)'
Serial.println(nfc.strerror(rc));
^
In file included from C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:76:
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: candidate: 'const __FlashStringHelper* PN5180ISO15693::strerror(ISO15693ErrorCode* (*)())'
const __FlashStringHelper *strerror(ISO15693ErrorCode errno);
^~~~~~~~
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: no known conversion for argument 1 from 'ISO15693ErrorCode' to 'ISO15693ErrorCode* (*)()'
C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:238:37: error: no matching function for call to 'PN5180ISO15693::strerror(ISO15693ErrorCode&)'
Serial.println(nfc.strerror(rc));
^
In file included from C:\Users\<username>\AppData\Local\Temp\.arduinoIDE-unsaved2023914-29884-6tr55t.8t2qo\PN5180-Library\PN5180-Library.ino:76:
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: candidate: 'const __FlashStringHelper* PN5180ISO15693::strerror(ISO15693ErrorCode* (*)())'
const __FlashStringHelper *strerror(ISO15693ErrorCode errno);
^~~~~~~~
C:\Users\<username>\OneDrive\Documents\Arduino\libraries\PN5180_Library/PN5180ISO15693.h:67:30: note: no known conversion for argument 1 from 'ISO15693ErrorCode' to 'ISO15693ErrorCode* (*)()'
exit status 1
Compilation error: no matching function for call to 'PN5180ISO15693::strerror(ISO15693ErrorCode&)'
Other Steps to Reproduce
I have gotten this code to work on an Arduino UNO REV3 and Arduino UNO Wi-Fi REV2.
moderator edit: anonymize URL