5.1 KiB
5.1 KiB
NFC (PN532) Debugging Guide
Current Status
- Hardware: GPIO26(TX) → PN532 RXD, GPIO25(RX) ← PN532 TXD (UEXT pins 3-4)
- DIP Switches: Both OFF (HSU mode) ✓
- Power: UEXT pin 1 = 3.3V (verified), Pin 2 = GND (verified)
- Wiring: Confirmed correct
- Problem: PN532 module not responding to auto-baud probe
Why NFC Probe Fails
The firmware attempts to communicate with PN532 at various baud rates:
- 115200, 9600, 57600, 38400 baud
- Tries both GPIO26/GPIO25 and GPIO25/GPIO26 (swapped)
- At each combination: sends
getFirmwareVersion()command - Issue: No response from PN532 → returns 0x00
Prerequisites for Debugging
1. Enable Serial Output
Arduino IDE Settings (REQUIRED):
Tools → USB CDC On Boot: ENABLED
Tools → Port: /dev/ttyACM0
Rebuild and flash the firmware:
cd ~/arduino/olimex_ESP32-C5-EVB/esp32_arduino
arduino --verify --board esp32:esp32:esp32c5 esp32_arduino.ino
esptool.py --chip esp32c5 --port /dev/ttyACM0 --baud 921600 erase-flash
esptool.py --chip esp32c5 --port /dev/ttyACM0 --baud 921600 write-flash 0x0 build_output/esp32_arduino.ino.merged.bin
Open Serial Monitor:
- Arduino IDE → Tools → Serial Monitor
- Baud rate: 115200
- Wait for boot messages
Diagnostic Steps
Step 1: Verify Serial Output
Expected output during boot:
=================================
ESP32-C5 Home Assistant Device
Arduino Framework
=================================
...
--- NFC (PN532 HSU) Initialization with Debug ---
Hardware: GPIO26(TX)→PN532-RX, GPIO25(RX)←PN532-TX, DIP:HSU mode
[1/8] Baud=115200, RX=GPIO25, TX=GPIO26 ... ✗
[2/8] Baud=9600, RX=GPIO25, TX=GPIO26 ... ✗
...
If you see:
- ✓ All "✗" symbols → PN532 not responding at any baud rate
- Nothing after "Initialization" → Serial output not working (re-check USB CDC setting)
Step 2: Physical Verification Checklist
□ PN532 powered: Measure 3.3V on VCC pin (should be 3.0-3.3V)
□ PN532 GND: Verify continuity to board GND with multimeter
□ UEXT Pin 1: Should be 3.3V (measure with multimeter)
□ UEXT Pin 2: Should be GND (continuity check)
□ UEXT Pin 3 (GPIO26): No continuity to Pin 4 (should be separate signals)
□ UEXT Pin 4 (GPIO25): No continuity to Pin 3 (should be separate signals)
□ PN532 Module: Try re-seating in connector or using different PN532 board
Step 3: Signal Analysis (Advanced)
If serial output shows all "✗" but hardware checks pass:
Option A: Oscilloscope Check
Connect oscilloscope probe to GPIO26 (TX line)
- Should see UART signal transitions during probe
- If flat line: ESP32 not transmitting
- If signal present: PN532 not responding
Option B: Loopback Test
Connect GPIO26 (TX) directly to GPIO25 (RX) with a jumper wire
Rebuild with loopback test code (at end of this file)
If loopback works: GPIO pins OK, PN532 module is issue
If loopback fails: GPIO configuration issue
Possible Issues & Solutions
Issue 1: PN532 Module Defective
Symptoms: All baud rates fail, hardware verified correct Solution:
- Try different PN532 board if available
- Test with I2C mode (different DIP setting) if supported
- Replace PN532 module
Issue 2: UEXT Connector Loose
Symptoms: Intermittent detection or complete failure Solution:
- Fully remove and re-seat PN532 in UEXT connector
- Ensure connector is fully inserted until it clicks
- Check for bent pins on UEXT connector
Issue 3: Incorrect Pin Mapping
Symptoms: Detection works with swapped pins Solution:
- Edit
esp32_arduino.ino:- Find:
#define NFC_TX_PIN 26and#define NFC_RX_PIN 25 - If swapped RX/TX works: reverse these definitions
- Find:
- Rebuild and test
Issue 4: Baud Rate Mismatch
Symptoms: Serial output shows some attempts as "✓ FOUND!" but then fails to init Solution:
- Firmware will re-init with confirmed baud rate
- If fails at SAMConfig() step: PN532 module may be in wrong mode
Loopback Test Code
(If GPIO pins might be misconfigured):
// Add to setup() after WiFi init, BEFORE NFC init:
void setup() {
// ... existing code ...
// LOOPBACK TEST
Serial.println("--- GPIO Loopback Test ---");
Serial.println("Jumper GPIO26 to GPIO25 to test UART");
HardwareSerial testSerial(1); // UART1
testSerial.begin(115200, SERIAL_8N1, 25, 26); // RX=GPIO25, TX=GPIO26
delay(100);
testSerial.print("TEST_LOOPBACK");
delay(100);
String received = "";
while (testSerial.available()) {
received += (char)testSerial.read();
}
if (received.indexOf("TEST") >= 0) {
Serial.println("✓ GPIO26/GPIO25 loopback OK");
} else {
Serial.println("✗ GPIO loopback FAILED - pin configuration issue");
}
}
Next Steps
- Enable Serial Output: Change USB CDC On Boot to ENABLED
- Rebuild & Flash: Use updated Arduino IDE settings
- Monitor Serial: Watch boot output during NFC probe
- Share Output: Post the serial output here for analysis
Expected Timeline:
- Checking serial output: ~5 minutes
- Physical verification: ~10 minutes
- Analyzing results: ~5 minutes
- Total: ~20 minutes to identify root cause