Connecting a PN532 directly to Raspberry Pi – SPI and UART
Wire a PN532 NFC reader to MuPiBox NG using the Raspberry Pi GPIO header, enable SPI or UART and assign tags.
The PN532 reads 13.56 MHz NFC tags such as MIFARE Classic and NTAG. MuPiBox NG can use PN532 over USB serial, SPI0 GPIO or GPIO UART. The direct GPIO drivers are implemented; a user successfully tested FTDI USB-UART and GPIO UART with a physical PN532 and tag on 14 November 2026. Physical SPI testing is still pending. PN532 over I²C is not available as a selectable reader.
SPI0 (hardware test pending)
UART has now been verified with real hardware. SPI works the same way on Raspberry Pi 4 and Pi 5 without involving Bluetooth or the serial login console, but is not yet hardware-verified. On the red PN532 module pictured in the discussion, switch to SPI (DIP switch 1 OFF, switch 2 ON). Confirm that this matches your board's revision.
| PN532 pin | Physical Pi pin | BCM function |
|---|---|---|
| VCC | 1 | 3.3 V |
| GND | 6 | GND |
| SCK | 23 | GPIO11 / SCLK |
| MOSI | 19 | GPIO10 / MOSI |
| MISO | 21 | GPIO9 / MISO |
| SS | 24 | GPIO8 / CE0 |
For CE1, wire SS to physical pin 26 / GPIO7 and select /dev/spidev0.1 instead. No separate IRQ or reset wire is required by the NG SPI driver.
In the existing boot config.txt (/boot/firmware/config.txt or /boot/config.txt) add once under [all]:
dtparam=spi=on
Reboot, then check ls -l /dev/spidev0.0. Seeing the device only confirms that the SPI interface is enabled; it does not prove the PN532 is connected. The installer configures the spi group and device access but does not switch on SPI without consent.
Alternative: UART (GPIO14/15)
Use the HSU/UART mode (on the pictured DIP board, both switches OFF). Cross TX/RX:
| PN532 pin | Physical Pi pin | BCM function |
|---|---|---|
| VCC | 1 | 3.3 V |
| GND | 6 | GND |
| TXD | 10 | GPIO15, Pi RXD |
| RXD | 8 | GPIO14, Pi TXD |
UART runs at 115200 baud, 8N1, no flow control. Set enable_uart=1 in the existing boot config, disable any serial login/kernel console using that port, and reboot. Before editing boot arguments, make a backup; check cat /proc/cmdline and any enabled serial-getty@ service.
- Pi 3/4: GPIO14/15 typically use
/dev/serial0(often/dev/ttyS0). Bluetooth can remain enabled, but the mini-UART needs a stable clock. - Pi 5:
/dev/serial0may point to ttyAMA10 on the separate debug header, not GPIO14/15. Afterenable_uart=1use /dev/ttyAMA0 for the 40-pin GPIO header and verify the pin mapping.
Check ls -l /dev/serial0 /dev/ttyAMA0 /dev/ttyS0; pinctrl get 14 15 can help. The mupibox service user must be in dialout, configured by the installer.
Activate the reader in MuPiBox NG
- Open Hardware → RFID, enable RFID and select PN532 GPIO SPI or PN532 GPIO UART.
- Click Scan for readers. The list contains available Linux interfaces, not positively detected PN532 chips.
- Select
/dev/spidev0.0for SPI CE0 (or/dev/spidev0.1for CE1),/dev/serial0for a typical Pi 4 UART, or/dev/ttyAMA0for the Pi 5 header UART. - Click Connect. The driver queries the PN532 firmware and configures the reader. A successful connection verifies communication.
- Hold a compatible 13.56 MHz tag to the antenna. The Last card field should show its UID; then assign it to media or actions as described in RFID setup.
Only one reader can be active at a time. The selected transport and device path are saved and restored after a reboot.
Troubleshooting
| Symptom | Check |
|---|---|
No spidev0.0 | SPI boot setting and reboot |
| SPI initialization fails | DIP setting, 3.3 V, CE pin, SCK/MOSI/MISO, ground, other SPI devices |
| UART initialization fails | Crossed TX/RX, UART DIP setting, 115200 baud, disabled serial console; Pi 5 must not use ttyAMA10 |
| Permission denied | Service user's spi or dialout group and udev rules |
| No UID | Use a 13.56 MHz card: PN532 cannot read 125-kHz tags |
| Pin conflict | Review GPIO inventory for SPI GPIO7–11 or UART GPIO14/15 |
I²C: MuPiHAT already uses GPIO2/3. I²C permits multiple addresses, but PN532 I²C timing/clock-stretching needs specific support; MuPiBox NG does not implement this transport yet. Use SPI or UART.
See also GPIO reference, RC522 SPI and RFID setup.