Files
Arduino_code_OLIMEX_Locatio…/olimex_ESP32-C5-EVB/nfc_diagnostics.py
T

77 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
NFC Pin Mapping Diagnostic for ESP32-C5-EVB
Verifies the UEXT connector GPIO assignments
"""
import requests
import json
import sys
DEVICE_IP = sys.argv[1] if len(sys.argv) > 1 else "192.168.0.240"
WEB_USER = "Ske087"
WEB_PASS = "Matei@123"
print("=" * 70)
print("ESP32-C5-EVB UEXT Pin Mapping Diagnostic")
print("=" * 70)
# Try to get device info
try:
resp = requests.get(f"http://{DEVICE_IP}/",
auth=(WEB_USER, WEB_PASS),
timeout=2)
if resp.status_code == 200:
print(f"\n✓ Device reachable at {DEVICE_IP}\n")
else:
print(f"\n✗ Device responded with {resp.status_code}")
except Exception as e:
print(f"\n✗ Cannot reach device: {e}")
sys.exit(1)
# Check NFC status
try:
resp = requests.get(f"http://{DEVICE_IP}/nfc/status",
auth=(WEB_USER, WEB_PASS),
timeout=2)
nfc_status = resp.json()
print("NFC Module Status:")
print(f" Initialized: {nfc_status.get('initialized', False)}")
print(f" Enabled: {nfc_status.get('nfc_enabled', False)}")
print(f" Access State: {nfc_status.get('access_state', 'unknown')}")
if not nfc_status.get('initialized'):
print("\n⚠️ NFC module NOT initialized!")
print("\nDiagnostic Checklist:")
print(" 1. Is PN532 physically connected to UEXT connector?")
print(" 2. Are DIP switches set to HSU mode (DIP1=0, DIP2=0)?")
print(" 3. Check 3.3V power on UEXT Pin 2 (multimeter)")
print(" 4. Verify TX/RX wiring:")
print(" - UEXT Pin 3 (GPIO26) → PN532 RXD")
print(" - UEXT Pin 4 (GPIO25) ← PN532 TXD")
print(" 5. Some PN532 boards need 100Ω resistor on TX line")
except Exception as e:
print(f"✗ Cannot get NFC status: {e}")
print("\n" + "=" * 70)
print("C5-EVB vs C6-EVB UEXT Pin Mapping Reference:")
print("=" * 70)
print("""
C6-EVB (for reference):
UEXT Pin 3 → GPIO4 (UART1 TX)
UEXT Pin 4 → GPIO5 (UART1 RX)
C5-EVB (current board):
UEXT Pin 3 → GPIO26 (UART1 TX)
UEXT Pin 4 → GPIO25 (UART1 RX)
UEXT Pin 1 → GND
UEXT Pin 2 → +3V3 (power)
If you previously worked with C6 and connected PN532 to GPIO 4/5,
you MUST move it to GPIO 26/25 on the C5!
""")
print("=" * 70)