PN532 SPI Connection

Has anyone successfully swapped out the Nano v3 for the Nano Every when paired with a PN532 NFC module? I had a successful prototype with the Nano v3, but decided to move to the Nano Every to reduce footprint and cost. The same program and wiring that works with the v3 won't communicate with the PN532 module with SPI communication.

I am using the Adafruit_PN532.h library. Can't figure out if its a library issue? or something simpler (fingers crossed its something simpler).

and you use software SPI as I see in many posts about Adafruit libraries for SPI devices?
then use hardware SPI.

I'm not sure I'm seasoned enough in programming arduinos to be able to answer your question.

In order to troubleshoot, I reverted all the way back to an example sketch included in the Adafruit_PN532.h library that includes both the wire.h and spi.h libraries, and I'm back to a breadboard to see if I can get it to work.

pdock:
I'm not sure I'm seasoned enough in programming arduinos to be able to answer your question.

In order to troubleshoot, I reverted all the way back to an example sketch included in the Adafruit_PN532.h library that includes both the wire.h and spi.h libraries, and I'm back to a breadboard to see if I can get it to work.

see in the example the part about hardware SPI

I used the SPI software connection for the nano v3. Do I need to change to the hardware SPI connection for the Nano Every?

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>

// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SCK (13)
#define PN532_MISO (12)
#define PN532_MOSI (11)
#define PN532_SS (8)

// Uncomment just one line below depending on how your breakout or shield
// is connected to the Arduino:

// Use this line for a breakout with a software SPI connection (recommended):
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

and why do you use software spi?

Juraj:
and why do you use software spi?

I'm a novice at arduino programming, and the example noted it was "(recommended)" so I went that direction.

That said, after your recommendation I changed the sketch to be a hardware SPI with SS on pin 8 and it has the same issue that it can't communicate with the PN532.

I'm wondering if it is a compatibility issue with the Adafruit_PN532 library. The Atmega4809 is not listed in the compatibility table on the github page. I was (possibly wrongly) hoping that the emulator in the megaAVR Board package would resolve any incompatibility. Any other tips?

pdock:
I’m a novice at arduino programming, and the example noted it was “(recommended)” so I went that direction.

That said, after your recommendation I changed the sketch to be a hardware SPI with SS on pin 8 and it has the same issue that it can’t communicate with the PN532.

I’m wondering if it is a compatibility issue with the Adafruit_PN532 library. The Atmega4809 is not listed in the compatibility table on the github page. I was (possibly wrongly) hoping that the emulator in the megaAVR Board package would resolve any incompatibility. Any other tips?

did you wire the device to SPI pins?

Yes, i wired the MOSI to pin 11, MISO to pin 12 and SCK to pin 13. Which, based on the documentation for the EVERY are the SPI pins.

pdock:
Yes, i wired the MOSI to pin 11, MISO to pin 12 and SCK to pin 13. Which, based on the documentation for the EVERY are the SPI pins.

and you use

Adafruit_PN532 nfc(8);

?

Juraj:
and you use
Adafruit_PN532 nfc(8);
?

!!! That worked !!! I'd been using a

#define PN532_SS (8)

to set the pin, but when i directly assigned in the line it worked. Thank you!

Follow up question. on the nano v3 I could use the software SPI connection, and was able use different pins. Is that possible in the Nano Every? My PCBs are set up so that the SPI connection:

#define PN532_SCK (2)
#define PN532_MISO (3)
#define PN532_MOSI (4)
#define PN532_SS (5)

Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

Any chance I can similarly re-assign for the Nano Every?

I guess the software SPI in the library is optimized for classic AVR and doesn't work good in emulation mode of megaavr core