I struggling with my setup over two weeks now, I can't make my WeMos D1 mini and PN532 RFID on I2C to work constantly and stable.
I have bought PN532 RFID v3 Module and I hooked and setup to work over I2C.
In 85% it will give me "Didn't find PN53x board" message and exception error:
Soft WDT reset
ctx: cont
sp: 3ffef460 end: 3ffef640 offset: 01b0
>>>stack>>>
3ffef610: 3fffdad0 3ffee394 3ffee5f4 40202178
3ffef620: 3fffdad0 00000000 3ffee610 40203058
3ffef630: feefeffe feefeffe 3ffee620 40100114
<<<stack<<<
or it will freeze the entire I2C bus on restart or after uploading the Sketch with infinite loop.
I'm using Arduino IDE 1.8.2 and ESP8266 Arduino Core 2.3.0.
Libraries what I'm using/tried:
https://github.com/adafruit/Adafruit-PN532
https://github.com/elechouse/PN532
Sketch what I'm using:
#include "Wire.h"
#include "PN532_I2C.h"
#include "PN532.h"
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);
String userRFID = "";
void setup(void)
{
Serial.begin(9600);
Serial.println("NFC/RFID Reader");
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);
// Non-blocking procedure
nfc.setPassiveActivationRetries(0x01);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}
void loop()
{
readRFID();
}
void readRFID(void)
{
boolean success;
uint8_t uid[] = {0, 0, 0, 0, 0, 0, 0};
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
if (success)
{
for (uint8_t i = 0; i < uidLength; i++)
{
if (uid[i] <= 0xF) {
userRFID += "0";
}
userRFID += String(uid[i] & 0xFF, HEX);
}
userRFID.toUpperCase();
Serial.println(userRFID);
delay(400);
userRFID = "";
}
}
Just to mention, I'm only using 4 wires, 2 for Power and 2 for I2C bus, 20cm Dupont cable.
The DIP switch/selector is set correctly 1:On and 2:Off.
Also mentionable that I have way more better results on Uno and Mega Dev boards.
Any suggestion or help would be greatly appreciated!
Thank you!