Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

PN532 Breakout with ESP32 Feather
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PN532 Breakout with ESP32 Feather

by coralisk on Thu May 13, 2021 11:33 pm

Hello,

I purchased a second PN532 breakout to build another RFID reader for a project. The first one works great so it seemed like a good choice. However I've struggled the last few days trying to get the second breakout to actually work. I've tried a wide variety of things here just to not waste anyones time so let me describe the current test case.

I have an Adafruit ESP32 Feather connected to a PN532 Breakout over SPI. I'm using the hardware pins for SPI with GPIO 4 for SS.
IMG_3038.JPG
IMG_3038.JPG (584.87 KiB) Viewed 133 times


This is the code that is running:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>

#define PN532_SCK  (5)
#define PN532_MOSI (18)
#define PN532_SS   (4)
#define PN532_MISO (19)

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

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10); // for Leonardo/Micro/Zero

  Serial.println("Hello!");

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
}


Only gives me the failure case:
Code: Select all | TOGGLE FULL SIZE
Hello!
Didn't find PN53x board


I've tried the following:
- Resoldering all the cables
- Using a different SS pin
- Using different SPI pins
- Used a multimeter to measure the pins on the ESP32 module against the small pins on the PN532 module, all connected, non shortage (this to make sure that it was correctly soldered).
- Used a multimeter to test for any shorted pins
- Verified that the protocol selectors are properly soldered

Ok, so we know that the connection is solid, can it be that the ESP32 for some reason doesn't output SPI?
IMG_3039.JPG
IMG_3039.JPG (495.2 KiB) Viewed 133 times


Turns out it does, this is showing CLK and MOSI from the ESP32 (my scope is only 2 channels sadly).

What happens if we check CLK and MISO?

IMG_3041.JPG
IMG_3041.JPG (517.54 KiB) Viewed 133 times


No signal back from the PN532 it seems.


This leads me to believe that the breakout I got was faulty, the other one works but this one just doesn't respond to SPI.
What does one do in this situation?

coralisk
 
Posts: 3
Joined: Mon Aug 20, 2018 11:41 pm

Re: PN532 Breakout with ESP32 Feather

by blnkjns on Fri May 14, 2021 12:40 am

You use GPIO pin numbers in the SPI setup. Was your previous success story with the exact same 2 parts?
These are the regular ESP32 SPI pins:
Code: Select all | TOGGLE FULL SIZE
MOSI      MISO      CLK       CS
GPIO 23   GPIO 19   GPIO 18   GPIO 5

Maybe you can use standard placeholders instead of GPIO pin numbers. What happens if you try this:
Code: Select all | TOGGLE FULL SIZE
Adafruit_PN532 nfc(SCK, MISO, MOSI, PN532_SS);

blnkjns
 
Posts: 624
Joined: Fri Oct 02, 2020 3:33 am

Re: PN532 Breakout with ESP32 Feather

by coralisk on Fri May 14, 2021 12:50 am

@blnkjns

Thanks for the reply!

I have tried this, also tried just not specifying pins and relying on the hardware SPI overloaded initializer:
Code: Select all | TOGGLE FULL SIZE
Adafruit_PN532 nfc(PN532_SS);

Sadly the result is still the same.

To answer your question, my other board runs on the NRF52832 feather which uses Soft SPI. For this specific example I used the example code in the Adafruit PN532 library to make sure that none of my other code was conflicting.

coralisk
 
Posts: 3
Joined: Mon Aug 20, 2018 11:41 pm

Re: PN532 Breakout with ESP32 Feather

by adafruit_support_mike on Fri May 14, 2021 2:43 am

coralisk wrote:the other one works but this one just doesn't respond to SPI.

Does the other PN532 breakout work with the same ESP32 and wiring connections? That kind of comparison test seeds up the debugging process a lot.

adafruit_support_mike
 
Posts: 62799
Joined: Thu Feb 11, 2010 2:51 pm

Re: PN532 Breakout with ESP32 Feather

by coralisk on Fri May 14, 2021 12:22 pm

adafruit_support_mike,

Let me clarify that point. The other works but is currently on the other side of the world so it's hard to test side by side. I agree that having it nearby would make this a lot easier to debug. What I meant is that the same "wiring" to a feather with the same code has worked previously, I basically copied my schematics from the previous build to new hardware I purchased from Adafruit and ran into these problems.

In reality the big difference is that I switched from NRF52832 to ESP32 but of all things that I expected to be problematic with going from the Nordic bluetooth stack to ESP32, SPI communication was not one of them :D

coralisk
 
Posts: 3
Joined: Mon Aug 20, 2018 11:41 pm

Re: PN532 Breakout with ESP32 Feather

by adafruit_support_mike on Fri May 14, 2021 9:42 pm

Okay, we can rule out a direct comparison test.

The 'scope traces show MOSI at a consistently low voltage. What do you see on that line with a voltmeter?

Also, how did you bridge the jumper pads to put the breakout in SPI mode? I can't make out details in the photo above.

adafruit_support_mike
 
Posts: 62799
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.