NFC Project Notes

Active today
Viewed 40 times

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

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

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

enter image description here

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.


@tlfong01, Thank you for your reply. Have you ever used another NFC module? I’m thinking maybe my NFC module is a problem.

Below is my clearer situation. I must operate the Raspberry Pi with the NFC Tag.

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-module-for-raspberry-pi.html)

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


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.

I am grateful for your enthusiasm Thank you.

 New contributor
  • Hi @chacha, Welcome and nice to meet you. Your question is a little bit confusing. Let me summarize: (1) What you have successfully completed is “Rpi controlled I2C NFC module reading the tag.” (2) Now what you want is “Rpi controlled PN532 NFC module to be tag, and android phone to be reader”. Let me do some brainstorming: (a) Let Android phone use a BlueTooth serial app to talk to a cheapy Bluetooth serial module, which is connected to the PN532 module which talks SPI/I2C/UARTserial. Then you send AT/serial commands to BT module which relays your commands to control PN532 module. / to cont. – tlfong01 2 days ago
  • In the above gang of three config, (a) You don’t need your old friend Rpi, (2) BT module can stay perhaps 10+ feet wireless from Android, and PN532 module can be 200+ feet serial wired from BT module. Another config is to let Rpi talk to PM532 module using SPI, and use WiFi etc to talk to Android phone. Just quick and dirty brain storming suggestions. Cheers. – tlfong01 2 days ago
  • References: AliExpress SunFounder US$28 NXP PN532 3V3 SPI/I2C/UART NFC Module for Rpi: (1) Datasheet: sunfounder.com/pn532-nfc-module-for-raspberry-pi.html, (2) Tutorial: wiki.sunfounder.cc/… – tlfong01 2 days ago
  • 1
    Hi @tlfong01, Thanks for the quick answer. Sorry that the question is not clear. As you understand, what I want is the RPI PN532 NFC module to act as an NFC tag and the android phone to act as an NFC reader. My current project is not considering Bluetooth, and should only use NFC. When this communication is complete, I will work on my post-project work. What I need is to make the RPI PN532 NFC module an NFC tag and receive that tag in the Android NFC-tools App. I’m using an app called NFC-tools in the store without creating an android app. Thank you. – chacha 2 days ago
  • Hi @chacha, Ha, sorry, perhaps it is me confused between RFID and NFC, and I forgot that my SamSung Android smart phone can also be a NFC device. Please ignore my comments above, because myself have not a clear mind, mixing thing up. I think I need some time, perhaps one or two days, to clarifying things myself, before I come back to give more clear comments. See you tomorrow or day after tomorrow. My apologies. Cheers. – tlfong01 2 days ago
  • Ah, I remember one thing related to Anroid phone and NFC device. I have a Rapoo A500 NFC/BlueTooth dual connection mode speaker. I don’t like using NFC, because BT is easier. Now I know why I might have confused: My Rapoo NFC speaker is a NFC device, NOT A RFID TAG, so no need to use any service or app. In other words, I think similarly, PN532 NFC module can be configured to be a NFC device and “connect” to the Android phone, but NOT configured as a RFID tag. But I am only 20% sure, perhaps I would think harder. / to continue, … – tlfong01 2 days ago
  • PS – References: (1) androidheadlines.com/2015/01/…, (2) techwalls.com/rapoo-a500-bluetooth-portable-speaker-review, (3) rapoo.com/article/51. Please feel free to ask me to try any SamSung Galaxy C9 Pro NFC and Rapoo NFC speaker. They are on my desk! 🙂 Ah, I also have a couple of NFC/RFID readers in hand. I can also try what you suggested. Cheers. – tlfong01 2 days ago
  • Just now I skimmed the 200 page datasheet of the PN532 NFC chip and found that the chip can be configured as a “CARD”, I guess it means a RFID tag: Ref: “NFC PN532 User Manual (200 pages!)- NXP”, nxp.com/docs/en/user-guide/141520.pdf Target/PICC Mode: This mode is the one used when the PN532 is configured as target or ISO/IEC14443-4 card, Virtual Card mode. Perhaps you can google for a “config PN532 NFC as a RFID card” library 🙂 Good luck. Cheers. – tlfong01 2 days ago
  • 1
    @tlfong01, I added my situation to the original to clarify my question. If you have experienced or know, please help me. Thank you. – chacha 4 hours ago
  • Thank you for your clarification. I am not so confused now. But there are still a couple of things I need to clarify. I must first confess that I have very little experience with NFC stuff, except what I told you, using my Samsung Galaxy smart phone to connect my Rapoo A500 NFC/Bluetooth wireless speaker. Actually both connections were unreliable, and I end up using the audio 3.5mm male to male connector to connect to A500 speaker. These days I am using my SamSung Galaxy C9 Pro to connect to another BlueTooth Speaker, a Creative brand BlueTooth speaker, connection smooth and reliable. – tlfong01 4 hours ago
  • I do have a couple of PN532 NFC modules to test out things. My goal is to gain some basic NFC knowledge and skills. Let me propose a learning plan. Be warned that I am a NFC newbie and at the same time a hobbyist programmer. I do have ninja level I2C hardware and software knowledge and skills. Now let me search my junk box for the old modules which are collecting dust, read the manuals, and perhaps repeat/reproduce your libNfc experiments. I don’t mind frying one or two cheapy NFC modules. I hope you also don’t mind me going very slowly, and very likely misunderstand what your are saying. – tlfong01 4 hours ago
  • Now I have inserted a photo of my two versions of NFC module. The TaoBao shop selling me these cheap toys says the one in red is the improved V3. So I think I should test the red guy first. – tlfong01 2 hours ago
  • Now I am taking a close look at the red guy (Fig 2), with a note. Comments welcome. – tlfong01 2 hours ago
  • We need to agree on the technical terms on NFC. I have inserted two references from AdaFruit to the list of my answer. Please let me know if you have other good reference, or tutorials, or forum discussions for newbies like me. Many thanks. – tlfong01 25 mins ago
  • Just now I read the AdaFruit catalog and understand your requirement: it is the third function described below: :PN532 NFC/RFID controller breakout board – v1.6″: adafruit.com/category/55 The PN532 is the most popular NFC chip, and is what is embedded in pretty much every phone or device that does NFC. It can pretty much do it all, such as (1) read and write to tags and cards, (2) communicate with phones (say for payment processing), and (3) ‘act’ like a NFC tag. – tlfong01 10 mins ago
  • I must confess that I never though about the PN532 module CAN ACT LIKE A TAG. So that is the root cause of my confusion. It is 100% my ignorance fault, not yours. Anyway, now I have more confidence to try out your requirement, because it is one of the specified functions. – tlfong01 9 mins ago

Question (v0.1 Last update 2020 Feb20 Hkt1800)

How to use Rpi3B to setup and configure a PN532 NFC module as a NFC tag that an Android smart phone can connect and read data from it.

/ to continue, …

Answer (v0.1 Last update 2020 Feb20 Hkt1804)

1. Introduction

I am a NFC newbie with very little NFC knowledge and skills. I found the OP’s problem very interesting, so I am thinking of start learning the basic things, then reproduce the OP’s situation. In other words, I have little confidence that my writing up here would become a proper answer. But I am confident that me and the OP are going to do something called PBL (Problem Base Learning) on the subject NFC. But I would warn the readers to my writing up that I won’t end up any answer, but guarantee that the read would learn how the project failed. In other words, FBL (Failure Based Learning)

/ to continue, …

2. Testing Procedure

I need to wiki and google a lot, before I can be sure to draft a not too amateurish project plan. So I will stall this procedure until I have read the stuff in the following references.

/ to continue, …

3. Testing Results

/ to continue, …

4. Discussion, Conclusion, and Recommendation

/ to continue, …


(1) PN532 NFC/RFID Catalog – AdaFruit US$40

(2) PN532 NFC/RFID controller breakout board v1.6 – AdaFruit US$40

(3) RFID/NFC Guides – AdaFruit

(4) Build a Babel Fish Language Toy – AdaFruit

(5) YouTube Build a Babel Fish Language Toy with Adafruit RFID and Wave Shields for Arduino – AdaFruit 2012aug02

(6) libfnc Main Page – nfc-tools.org

/ to continue, …


Appendix A …

/ to continue, …

Figures, Images, Photos

Fig 1 – The PN532 Modules (Red one is V3, claimed to be an improved version


Fig 2 – HW147 (Die 5321 DB) NFC Module V3 (Jumper setting, 00 = HSU, 10 = I2C, 01 = SPI)

Note 1 – The OP tried I2C with no luck. Perhaps I should try SPI first, and if no luck then I fall back to HSU (High Speed UART) If SPI ok, I can upgrade to I2C. So I should bear this possible SPI/I2C change in mind, so to write the python functions to be easily switching between I2C/SPI/UART.

532 module V3

/ to continue, …

End of answer


Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: