ubilab-ws21 / puzzle-5

0 stars 1 forks source link

NFC reader stop working after idle for a few minutes #51

Closed archerindigo closed 2 years ago

archerindigo commented 2 years ago

Issue description:

If the NFC reader detect nothing for a while (~5 minutes), the reader will not read any card anymore. The problem won't fix by hard/soft reset the ESP32. Usually need to re-load the program with little bit of modification

Affected hardware:

Both the NFC readers in the charger/ battery dock of the electric box

Measurements attempted:

Direction of debugging:

archerindigo commented 2 years ago

Previous commit pushed but the issue persist afterwards:

1109a4e5e69e3c25c18ef1af8b6fca9a6e6c93e3

archerindigo commented 2 years ago

Following comments on this issue, use hardware SPI and lower frequency. Then the reader is much more stable.

Hack to the library:

Adafruit_PN532::Adafruit_PN532(uint8_t ss) {
    // Terry: Lower frequency from 1MHz to 100kHz with regard to issue #80 for ESP32
  spi_dev =
      new Adafruit_SPIDevice(ss, 100000, SPI_BITORDER_LSBFIRST, SPI_MODE0);
}

Issue regarding "unable to get firmware version" and "read fail after scanning 7-byte-UID tag" mentioned in #14 are also resolved by this way.

Commit: d29eed914cead9958d805bdc13ae6ac91b2ee012