【问题标题】:Impossible to scan RFID tags using libnfc, PN532, and RPi3无法使用 libnfc、PN532 和 RPi3 扫描 RFID 标签
【发布时间】:2017-02-28 21:07:11
【问题描述】:

我最近买了这个 NFC/RFID 阅读器PN532 module V3

我想将它与我的树莓派 3 一起使用。我已经安装并配置了库 libnfc。 PN532 与 I2C 连接。我已经在我的 RPi 上很好地启用了它。

我的问题是我无法扫描任何东西。事实上,当我在控制台中运行 nfc-poll 函数时,我得到了这个:

nfc-poll uses libnfc 1.7.1
NFC reader: pn532_i2c:/dev/i2c-1 opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
nfc_initiator_poll_target: Success

在投票期间,我在 PN532 附近经过了很多不同的标签,甚至是那些随它一起到达的标签。但从来没有任何检测。尽管如此,RPi 似乎与 PN532 正确通信,如第二行所示。


i2cdetect -y 1 命令返回良好:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

PN532 接线如下:

  • GND --> GPIO 6
  • VCC --> GPIO 4
  • SDA --> GPIO 3
  • SCL --> GPIO 5

我检查了接线(我的黄色 LED 灯亮,如果我移除 SDA 或 SCL 连接,我会收到一条错误消息,尝试 nfc-poll,表明连接正常)


我已经检查了 PN532 上两个开关的位置以启用 I2C 通信。


我的 libnfc 配置文件 (/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 (dehttp://www.jamesrobertson.eu/pages/2014/mar/30/rfid-module.htmlfault: 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 = "Itead_PN532_SPI"
device.connstring = "pn532_i2c:/dev/i2c-1"

我尝试将参数allow_intrusive_scan 设置为true,但它并没有改变任何东西。


你有什么想法吗? 非常感谢您。

【问题讨论】:

  • 在我看来,您的问题不是与从您的 raspi 到您的 PN532 的 i2c- 连接有关。看看你是否能从中得到一些状态答案会很有趣,但我相信你会的。根据PN532 的工作方式,我预计需要一些必要的步骤来检测和读取您连接的标签。压缩:我猜你现在在说“你在 PN532 那里吗”?但是你需要说“嘿 PN532,有标签吗?它的内容是什么?”
  • 我看到here 如果连接良好,至少 nfc-poll 应该确实显示一些数据。然而,这并不完全是一个硬件板。你可能会在raspberrypi.stackexchange.com 这样的地方得到更好的答案。

标签: python nfc raspberry-pi3 rfid lib-nfc


【解决方案1】:

“Raspberry Pi 没有提供足够的电流来驱动PN532 chip。如果您尝试从Raspberry Pi 运行PN532,它将随机重置并且可能无法响应命令。相反,您需要@987654325 @。”

我找到了这篇文章,它可能会有所帮助。 https://pypi.org/project/pn532pi/

【讨论】:

  • 我相信这是一个常见的问题来源,所以是一个合法的答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-22
  • 2018-06-08
  • 1970-01-01
  • 1970-01-01
  • 2019-03-30
  • 1970-01-01
相关资源
最近更新 更多