侧边栏壁纸
博主头像
百晓生 博主等级

Keep Share Keep Geek

  • 累计撰写 10 篇文章
  • 累计创建 19 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

树莓派PN532上复制门禁卡

Administrator
2025-06-14 / 0 评论 / 0 点赞 / 14 阅读 / 0 字

物品清单

1.树莓派4x1

2.T型面包板x1

3.PN532 NFC模块x1

4.可改写0扇区的rfid卡

以上所有材料均可在淘宝采购

接线

该模块分为I2C与SPI两种接线模式,我使用的是I2C模式,所以本文只讲I2C 改为i2c模式

SEL0

SEL1

H

L

对应的映射为

PN532

Raspberry

5V

5V

GND

GND

SDA

SDA0(3V3下方)

SCL

SCL0(SDA0下方)

具体可参考PN532 WIKI.

环境配置

  • 如果之前配置过NFC 执行sudo rm -rf /etc/nfc删除之前的配置

  • 打开树莓拍i2c接口 Interfacing Options -> I2C -> yes.

  • 安装依赖

sudo apt-get update
sudo apt-get install libusb-dev libpcsclite-dev i2c-tools`
  • 下载libnfc

cd ~
wget http://dl.bintray.com/nfc-tools/sources/libnfc-1.7.1.tar.bz2
tar -xf libnfc-1.7.1.tar.bz2  
  • 编译

cd libnfc-1.7.1
./configure --prefix=/usr --sysconfdir=/etc
make
sudo make install 
  • 配置libnfc

cd /etc
sudo mkdir nfc
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 = "_PN532_SPI"
#device.connstring = "pn532_spi:/dev/spidev0.0:500000"
device.name = "_PN532_I2c"
device.connstring = "pn532_i2c:/dev/i2c-1"
  • 接好线配置好后重启设备,检测是否成功

i2cdetect –y 1 
nfc-list

破解

automake
autoconf
autoreconf -is
./configure
make
make install
  • 修改UID 由于国内大部分门禁卡只是基于UID做识别,所以只需要修改RFID的UID,也就是0扇区,就行了,所以我们需要去采购0扇区可写的rfid卡,复制改写就行了,具体参考nfc-mfsetuid

nfc-mfsetuid [ UID ]

写完uid后再运行

nfc-list

比对新老卡 uid 是否一致,一致则大功告成!

参考文献 PN532 WIKInfc-mfsetuid

0

评论区