Rasp Pi 3a+ not detecting NFC hat pn532

Hi there,

I have been trying to get a 3a+ to detect a pn532 Hat. I have tested the UART, I2C and SPI, and could not detect any. I have gone through troubleshooting with a range of different code and even attempted a VE. Wondering if anyone has had this trouble / managed to get these to connect?

Cheers, Ren

Some PN532 boards default to UART even if you think you’re using I²C/SPI. Always set the DIP/jumper explicitly.
If i2cdetect shows nothing, but wiring + config are right, your board might be stuck in HSU (UART) mode.

Thanks, I ended up defaulting to set it up on UART but still could not get it to detect, have you managed to get these to work before?

1 Like

Hi @Renee294992,

I am very sorry for the delay in my response. There has been a lot of sickness in the office this past week. However, I can say that ater experimenting some more with the Waveshare code, I was able to get UID’s of NFC cards read from PN532 connected to a Pi 3 A+ via UART, including from my phone’s own NFC chip.

Steps to replicate:

  1. Place device in UART mode likeso:

  2. Do the below steps:
    sudo raspi-config
    Set Interfacing Options > Serial > Yes

  3. Do each of the below commands in the BASH shell:

sudo apt-get install p7zip-full python3-lgpio
wget https://files.waveshare.com/upload/6/66/Pn532-nfc-hat-code.7z
7z x Pn532-nfc-hat-code.7z -r -o./Pn532-nfc-hat-code
sudo chmod 777 -R Pn532-nfc-hat-code/
  1. cd into /PN532-nfc-hat-code/raspberrypi/python
  2. Edit example_get_uid.py so that the SPI and I2C sections are hashed out so that PN532 is recognised as UART.
  3. Run python3 example_get_uid.py
  4. Read a NFC tag.

EDIT: All the examples worked after running example_get_uid.py first. The system must need something in its code to initialise.

Amazing, thanks so much Jane I will give it a try! Hope you have a spectacular weekend!

1 Like

Hi Jane, I tried the above and once I got to sudo chmod 777 -R Pn532-nfc-hat-code/ I got the following message “chmod: cannot access ‘Pn532-nfc-hat-code/’: Not a directory - did this come up for you at all?

Hi Renee,

Ooph, sorry, I do remember that happening to me.

Replace:

7z x Pn532-nfc-hat-code.7z -r -o./Pn532-nfc-hat-code

With:

7z x Pn532-nfc-hat-code.7z

That should extract the .7z archive in the same directory that you’re currently in. Then proceed with the next steps.

As an aside, I was reading the 7z manual page to double check this and they actually advice not to use -r as, in the manual’s words, ‘It does not do what you think it does.’

Thanks Jane, I tried again with the above suggested and still got the chmod: cannot access msg. I think I might have to look into get some different kit for the project I am doing.

1 Like

You won’t need to specify the folder and change permissions with that command (as Jane pointed out, you didn’t extract it to that folder by omitting that argument)

1 Like

Just updating everyone on this one. I purchased a new NFC hat with Raspberry Pi 3b+ and got this working easy testing UIDs. I then tested the old NFC hat on the new Pi with the same UID’s and it still could not be detected, so this was probably a hardware issue. Thanks so much for all your support.

1 Like