## Idea
Use an inexpensive and small PN532 NFC Board + SPI to make a tappable pad on the printer and take the users cell phone browser directly to the Klipper Web Page.
## Resources
- [RPi microcontroller - Klipper documentation](https://www.klipper3d.org/RPi_microcontroller.html?h=spi#optional-enabling-spi)
- [Amazon.com: HiLetgo PN532 NFC NXP RFID Module V3 Kit Near Field Communication Reader Module Kit I2C SPI HSU with S50 White Card Key Card for Arduino Raspberry Pi DIY Smart Phone Android Phone : Electronics](https://amzn.to/4hoStaj)
- [GitHub - covertpluto/klipper-plugin-template: Simple template for a klipper host plugin](https://github.com/covertpluto/klipper-plugin-template)
- [GitHub - gassajor000/pn532pi: Python interface for ndef communication using PN532 chip on raspberry pi](https://github.com/gassajor000/pn532pi)
- [GitHub - AdamLaurie/RFIDIOt: python RFID / NFC library & tools](https://github.com/AdamLaurie/RFIDIOt)
- Specifically: [RFIDIOt/pn532emulate.py at master · AdamLaurie/RFIDIOt · GitHub](https://github.com/AdamLaurie/RFIDIOt/blob/master/pn532emulate.py)
- [GitHub - elechouse/PN532: NFC library for Arduino using PN532](https://github.com/elechouse/PN532)
[Raspberry Pi GPIO Pinout](https://pinout.xyz/)
## TODO
- Hook up the PN532 Board to the Raspberry Pi and get a quick and dirty Python script working to set the current IP + Klipper URL
- TEST! It may be able to read it from BEHIND te
- Design a NFC Pad Printed Mount and integrate into the printer?
- ==Wings on the HDMI5 Touchscreen Mount?==
- Setup auto-update from erikbuild GitHub in Mainsail updater thing
![[Pasted image 20251017095630.png]]
![[PN532_ Manual_V3.pdf]]
## Hardware
[Amazon.com: HiLetgo PN532 NFC NXP RFID Module V3 Kit Near Field Communication Reader Module Kit I2C SPI HSU with S50 White Card Key Card for Arduino Raspberry Pi DIY Smart Phone Android Phone : Electronics](https://amzn.to/3KSSIhO)
## Manual Installation
```bash
~/klippy-env/bin/pip install pn532pi
cd ~
git clone https://github.com/erikbuild/klippyNFC.git
systemctl stop klipper
ln -s ~/klippyNFC/klippy_nfc.py ~/klipper/klippy/extras/klippy_nfc.py
systemctl start klipper
```
Add a configuration section to `printer.cfg`:
```
[klippy_nfc]
# I2C Configuration
i2c_bus: 1 # Default: 1 (I2C bus 1 on Raspberry Pi)
port: 80 # Port to add to URL string, 80 for Mainsail, 7125 for Moonraker
# url: http://printer.local:80 # Optional: Override auto-detected URL
uid: 010203 # NFC Tag UID (hex string, 3 bytes)
```
## SPI Communication Testing
Both DIP switches must be on to set SPI mode
```bash
sudo raspi-config
# enable SPI interface
sudo reboot
sudo apt install libnfc-bin libnfc-examples libnfc-dev
```
Confirm you see the SPI device:
```bash
ls /dev/spidev0.*
> /dev/spidev0.0 /dev/spidev0.1
```
Edit the libnfc configuration:
```
sudo nano /etc/nfc/libnfc.conf
```
```
# Allow device auto-detection (default: true)
# Note: if this auto-detection is disabled, user has to set manually a device
# configuration using file or environment variable
allow_autoscan = true
# Allow intrusive auto-detection (default: false)
# Warning: intrusive auto-detection can seriously disturb other devices
# This option is not recommended, user should prefer to add manually his device.
allow_intrusive_scan = false
# Set log level (default: error)
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
# Note: if you compiled with --enable-debug option, the default log level is "debug"
log_level = 1
# Manually set default device (no default)
# To set a default device, you must set both name and connstring for your device
# Note: if autoscan is enabled, default device will be the first device available in device list.
#device.name = "microBuilder.eu"
#device.connstring = "pn532_uart:/dev/ttyUSB0"
#device.name = "_PN532_I2c"
#device.connstring = "pn532_i2c:/dev/i2c-1"
device.name = "_PN532_SPI"
device.connstring = "pn532_spi:/dev/spidev0.0:50000"
```
Check to see if NFC is working:
```bash
nfc-list
```
```bash
nfc-poll
# Tap an NFC card on it -- it should read it!
```
[PN532 NFC Module for Raspberry Pi - Wiki](http://wiki.sunfounder.cc/index.php?title=PN532_NFC_Module_for_Raspberry_Pi)