sangsub.lim
Posts: 2
Joined: Tue Feb 18, 2020 6:11 am

NFC tags in raspberry pi

Tue Feb 18, 2020 6:14 am

I'm working on a NFC study. My development environment is as follows.

- raspberry pi 3 B
- PN532 NFC : https://www.sunfounder.com/pn532-nfc-mo ... ry-pi.html
- Android Phone (app name :nfc-tools)

I connected the PN532 NFC to my raspberry pi using i2C, referring to the link below.
http://wiki.sunfounder.cc/index.php?tit ... spberry_Pi

Since then, when I contacted the plastic tag that was bundled with the PN532 NFC, I have received something as follows.

pi@raspberrypi:~ $ 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)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): 21 29 65 0c
SAK (SEL_RES): 08
nfc_initiator_target_is_present: Target Released
Waiting for card removing...done


What I want is the PN532 NFC in my raspberry to be the tag, and the android phone to be the reader.
I've run several examples provided by libnfc and nothing happens in the android app (nfc-tools).
(Of course, if you contact Android with the round plastic tag that is included in the bundle, it will read something.)

I have some questions in this situation.

1. Does my PN532 NFC module work with an NFC tag?
2. Is there a sample code or reference site that can operate the PN532 NFC module as the NFC tag?
3. Do you have any android app to recommend when developing RPI-based NFC?

I'm currently only aiming for communication. So I just need to pass the data on the raspberry pi and receive the data on the android phone.

I hope there is someone who can help me. Note that the language uses C.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: NFC tags in raspberry pi

Tue Feb 18, 2020 11:12 am

1. Does my PN532 NFC module work with an NFC tag?
2. Is there a sample code or reference site that can operate the PN532 NFC module as the NFC tag?
3. Do you have any android app to recommend when developing RPI-based NFC?
1. The PN532 chipset do support cardemulation. But if its possible on your particular module is a very tough question to answer.
2. Libnfc is the only one I think might work... http://www.libnfc.org/api/group__target.html
3. Depends what you are really trying to do. What is the goal of your "study".

You can also do card emulation on the phone: https://github.com/grundid/host-card-emulation-sample

sangsub.lim
Posts: 2
Joined: Tue Feb 18, 2020 6:11 am

Re: NFC tags in raspberry pi

Thu Feb 20, 2020 9:02 am

topguy wrote:
Tue Feb 18, 2020 11:12 am
1. The PN532 chipset do support cardemulation. But if its possible on your particular module is a very tough question to answer.
2. Libnfc is the only one I think might work... http://www.libnfc.org/api/group__target.html
3. Depends what you are really trying to do. What is the goal of your "study".

You can also do card emulation on the phone: https://github.com/grundid/host-card-emulation-sample
@topguy
Thank you for your reply.
Have you ever used another NFC module?
I'm thinking maybe my NFC module is a problem.

What I want is raspberry pi to act as NFC Tag, like a credit card.
When I touch the NFC module on the raspberry pi with the Android phone, a particular app is executed (such as YouTube, for example).

my development environment is as follows.
- LG V30
- raspberry pi 3 B
- raspbian : 2019-07-10-raspbian-buster-lite
- NFC : PN532 module (https://www.sunfounder.com/pn532-nfc-mo ... ry-pi.html)

I've wired the raspberry pi and PN532 Module with i2c and proceeded according to the guide below.

http://wiki.sunfounder.cc/index.php?tit ... spberry_Pi

I performed nfc-pool as in the guide above, and it worked well when I contacted my credit card.
But I'm trying to get my raspberry pi to work with an NFC Tag like a credit card.

So I tried doing nfc-emulate-tag among the samples provided by libnfc.
As a result, the following error occurred.

pi@raspberrypi:/proc $ nfc-emulate-tag
nfc-emulate-tag uses libnfc libnfc-1.7.1-223-gf8b2852
NFC device: _PN532_I2c opened
nfc-emulate-tag will emulate this ISO14443-A tag:
ISO/IEC 14443A (undefined baud rate) target:
ATQA (SENS_RES): 00 04
* UID size: single
* bit frame anticollision supported
UID (NFCID3): 08 ab cd ef
* Random UID
SAK (SEL_RES): 09
* Not compliant with ISO/IEC 14443-4
* Not compliant with ISO/IEC 18092

Fingerprinting based on MIFARE type Identification Procedure:
* MIFARE Mini 0.3K
* SmartMX with MIFARE 1K emulation
Other possible matches based on ATQA & SAK values:
NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)
error libnfc.bus.i2c Error: read only -1 bytes (265 expected) (Input/output error).
nfc_target_init: Success
nfc_target_emulate_tag: Success
error libnfc.bus.i2c Error: wrote only -1 bytes (10 expected) (Input/output error).
error libnfc.driver.pn532_i2c Failed to transmit data. Retries left: 2.
error libnfc.bus.i2c Error: wrote only -1 bytes (10 expected) (Input/output error).
error libnfc.driver.pn532_i2c Failed to transmit data. Retries left: 1.
error libnfc.bus.i2c Error: wrote only -1 bytes (10 expected) (Input/output error).
error libnfc.driver.pn532_i2c Failed to transmit data. Retries left: 0.
error libnfc.driver.pn532_i2c Unable to transmit data. (TX)

Then my PN532 module wend dead.

I checked where the error came from and it's happening in "nfc_target_init.
This function is described as "Initialize NFC device as an emulated tag."

I am looking for anyone who has tried NFC Tag using raspberry pi with PN532 or anyone who can advise me about this situation.
Thank you.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: NFC tags in raspberry pi

Thu Feb 20, 2020 1:03 pm

Have you ever used another NFC module?
I have, but they are usually USB based and I haven't usually done card-emmulation with them.

I dont know enough about I2C to say if your problem is with the PN532 itself or just the I2C communication. ( which goes back to why I prefer USB devices.. )

Return to “General discussion”