1

I have a Pi Zero v1.3:

PI - pn532

5v to 5v
gnd to gnd
BCM10 to MOSI
BCM9 to MISO
BCM11 to SCK
BCM5 to SS

I think the issue is BCM5 to SS? I believe this should be CE0 or CE1?

I have closed both SEL0 and SEL1. The only other thing is instead of using the DI/O 1-6 corresponding to the "MISO/MOSI/ETC", I plugged the wire directly into the hole for MISO/MOSI/etc.

Link to the product.

karel
  • 5,489
  • 46
  • 45
  • 50
Denis
  • 570
  • 9
  • 23
  • but which tutorial says "bcm5 to ss"? – tlfong01 Apr 13 '20 at 00:48
  • 1
    I'll have to find it.Is there another it should connect to? – Denis Apr 14 '20 at 02:28
  • You might like to show us a photo of your module, similar to the photos in these NFC questions: (1) https://stackoverflow.com/questions/60819793/problem-with-detecting-badge-with-pn532-and-raspberry-pi, (2) https://raspberrypi.stackexchange.com/questions/109773/how-can-rpi-python-read-a-mfrc522-pn532-nfc-rfid-mifare-smart-card-tag. Cheers. – tlfong01 Apr 14 '20 at 03:49
  • I googled the tutorial for your module and found it is for I2C. (3) https://learn.adafruit.com/adafruit-pn532-rfid-nfc/shield-wiring. Actually your module can do I2C, SPI, and UART. My answer in Ref 1 above is for PN532 in I2C mode, and I successfully followed the libnfc tutorial to setup the mdules OK. I can show it in SPI mode if you prefer to do SPI. BTW, the tutorial in your mdoules is for Arduino, you need to find other NFC tutorials for Rpi, such as libnfc for PN532 or simpleMFRC522 etc. – tlfong01 Apr 14 '20 at 03:56
  • In case you really prefer to do SPI, you need to first make sure your SPI setup is correct, by doing the SPI loopback test. See this for more details: "SPI NFC Module Testing ***Part 3*** - Troubleshooting SPI Software and Hardware using LOOPBACK": https://raspberrypi.stackexchange.com/questions/109773/how-can-rpi-python-read-a-mfrc522-pn532-nfc-rfid-mifare-smart-card-tag. You may also like to use a python program to read/ping the NFC module's "Version" register to make sure the NFC module not bad, and more or less working OK. – tlfong01 Apr 14 '20 at 04:09
  • I have also listed demo code in my answers above on how to read a SPI "version/ID" or "config" registers. If you can show me a photo of your module, then I can give more details on how to connect MOSI to MISO in a cross-over/loop, and also how to connect the CLK/MOSI/MISO/SS to both Rpi's buses: SPI 0.0, 0.1, 1.0, 1.1, 1.2 etc. – tlfong01 Apr 14 '20 at 04:13
  • Your module and accompanying tutorials seem to be 8 years old and for Arudino only. I guess you need to find more up to date Rpi compatible tutorials such as *libnfc* or *simpleMFRC*.References:(4) Adafruit PN532 NFC/RFID Controller Shield for Arduino 2012 [Product sheet] https://www.adafruit.com/product/789 (5) Adafruit PN532 NFC/RFID Controller Shield for Arduino 2012 [Tutorial] https://learn.adafruit.com/adafruit-pn532-rfid-nfc (6) Adafruit PN532 NFC/RFID Controller Shield for Arduino 2012 [Wiring] https://learn.adafruit.com/adafruit-pn532-rfid-nfc/breakout-wiring – tlfong01 Apr 14 '20 at 04:36
  • Having said above, there is indeed update of the above tutorials more Rpi, but using CircuitPython/MicroPython. Byt I think Ccircuit does not run very smoothly in Rpi. But anyway, you can try your luck: (6) Adafruit PN532 NFC/RFID Controller Shield for Arduino 2012 [Rpi/MO Circuit/Micro Python] https://learn.adafruit.com/adafruit-pn532-rfid-nfc/python-circuitpython. Good luck and cheers. – tlfong01 Apr 14 '20 at 04:50
  • 1
    Hey thank you for all of this!! I checked the spi an that was good. Here is what I posted in the forum. I looked it up and matched the arduino connections to the shield and I have rewired up the nfc pn532. I will post a new photo tonight but it is still not workin :( https://forums.adafruit.com/viewtopic.php?f=60&t=164398 – Denis Apr 15 '20 at 02:11
  • Your forum discussion is good. If you know your SPI thing is OK, then you can try the libNFC right way. I found that AdaFruit also recommended libNFC way back in 2010! I vaguely remember Lada Ada saying that SPI is not reliable, so she chose I2C. Of course no harm trying it. By the way, I am drafting answer with some pictures, so we can compare and contrast. I only tried libNFC's I2C mode. So it would be nice if you try it first, and I will follow! :) – tlfong01 Apr 15 '20 at 03:14
  • One more thing before I forgot: You asked about the pin "D5" referred in the Arduino guide. I guess that refers to Arudono UNO R3's "D5", which means "Digital pin number 5". For Rpi, perhaps you need to read the libNFC guide which Rpi GPIO pins are referring, for the "Reset" and "Interrupt" purposes. – tlfong01 Apr 15 '20 at 03:21
  • The libNFC test in SPI mode is as easy as I2C. You may find the tutorial by the Wilfrid Laurier Uni good (Ref 6, 7). Cheers. – tlfong01 Apr 15 '20 at 10:23

1 Answers1

4

Answer

Part A - PN532 NFC testing setup

pn532 test


Part B - libnfc 1.7.1 SPI Mode tested OK

libnfc 1.7.1 test ok

/ to continue, ...


References

(1) Problem with detecting badge with PN532 and Rpi - Asked 2020mar23, Viewed 74 times

(2) How can Rpi python read a MFRC522/PN532 NFC/RFID MIFARE smart card/tag? - Asked 2020mar28 Viewed 271 times

(3) PN532 NFC Controller Datasheet Rev 3.6 — 2017nov28 NXP

(4) PN532 UM0701-02 80C51 Firmware User Manual Rev 02 - NXP 2007

(5) PN532 NFC RFID Module - Comoponents101 2018oct06

(6) Raspberry Pi Interface with PN532 NFC Module, with python demo program - Wilfrid Laurier University 2019

(7) Youtube Interfacing Raspberry Pi to PN532 NFC Module - Terry Sturtevant, Wilfrid Laurier University, 10,490 views 2017may04

(8) PN532 NFC HAT for Raspberry Pi, I2C/SPI/UART - WaveShare USD$14

(9) PN532 NFC HAT for Raspberry Pi, I2C/SPI/UART - Wiki WaveShare

(10) PN532 UM0701-02 User Manual - NXP

(11) NTAG213/215/216 Datasheet - NXP

(12) MIFARE Classic 1K Smart Card Datasheet R3.2 2018may23 - NXP

(13) PN532 Demo Code - WaveShare

(14) OsoYoo (with schematic) PN532 NFC RFID module for Raspberry Pi

/ to continue, ...


Appendices

Appendix A - Suggestion to wire AdaFruit's Arduino compatible PN532 NFC shield to Rpi.

PN532 NFC HAT for Rpi Datasheet - WaveShare

PN532 NFC HAT for Rpi Wiki - WaveShare


pn532 wiring


Appendix B - PN532 NFC Module I2C/SPI/UART Jumper Setting

i2c/spi/uart jumper setting


Appendix C - PN532 Register Map

pn532 reg map


Appendix D - PN532 Schematic

PN532 NFC RFID module for Raspberry Pi

pn532 schematic


Appendix E - PN532 UART Mode Quick testing - WaveShare

Quick testing of the module by connecting it to PC with USB to TTL cable/adapter instead of Raspberry Pi

  1. Hardware connection

PN532 NFC HAT USB to TTL Module

3V3 3.3V
GND GND
TX  RX
RX  TX
  1. Set L0 to L and L1 to L by jumpers

  2. Connect USB to TTL Module to PC by USB cable

  3. Open Serial assistant software, set it

    Baud rate:115200 Data bits:8 Stop bits:1 Parity:None Flow control:None

  4. Check "HEX send” and “HEX display”

  5. Select correct serial port and open

  6. Send data below to wake up FN532 module:

    55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 03 FD D4 14 01 17 00

(Please refer to PN532 User Manual HSU wake up condition Chapter)

The response from PN532 module should be:

00 00 FF 00 FF 00 00 00 FF 02 FE D5 15 16 00
  1. Send data below to scan Mifare Classic card(The blue card provided, hereafter called as "card")

    00 00 FF 04 FC D4 4A 01 00 E1 00

Closing card to coil part of module, module scan it and response:

00 00 FF 0C F4 D5 4B 01 01 00 04 08 04 XXXXXXXXXX 00

XXXXXXXXXX in response data is ID (3 bytes) and checksum (1 byte) of card.

(Please refer to PN532 User Manual InListPassiveTarget Chapter)

def wakeup():
  # Send command to wake up PN532
  uart.write(b'\x55\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') # wake up!
  return

/ to continue, ...


End of answer


tlfong01
  • 340
  • 5
  • 9
  • 1
    Hey, so I switched back to try i2c. I'll use all your info. Your amazing really. Taking this time just to help me. Thank You. Your setup is incredible! I'd love to ask you some business questions? Can you email me? denis@harpangell.com – Denis Apr 17 '20 at 05:10
  • But I am not interested in business at all. Perhaps you can try StackOverflow: https://stackoverflow.com/jobs/remote-developer-jobs. Cheers. – tlfong01 Apr 17 '20 at 08:31