1

I'm working on a python project that requires reading data from NFC tags- specifically URLs.

I purchased a USB NFC reader and am using the libnfc library. I have my raspberry pi recognizing the reader and tags properly, and it correctly identifies when a tag is present using nfc-poll. However, it only gives me information on the tag's ID, ATQA, and SAK (I'm not sure what the last two are). It doesn't give me the data/url itself.

Any help would be appreciated in reading the tag data, either with libnfc or something else. I'm experienced in Python but have never done a project anything like this before so as simple as possible would be appreciated.

My python code is pretty simple:

from subprocess import call

while True:
   try:
      call('nfc-poll')
   except:
      print('Error')
      break

And the output when a tag is presented looks like this:

ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_REF): 00 44
       UID (NFC1D1): 04 7b a7 2c d0 6c 80
      SAK (SEL_RES): 00
llllbbbbllll
  • 443
  • 1
  • 3
  • 10
  • 1
    Is there any data stored in an NFC tag at all ? I thought you could only scan it to get its ID (and your system would then do whatever that ID is authorized to) – Stijn B Mar 05 '22 at 00:46
  • 1
    You would be much better off using a better Python module to interface with the reader instead of trying libnfc direct. See https://nfcpy.readthedocs.io/en/latest/ for the module, the ACR122U is well supported. You don't specify the make and model of the Tag which is key if you want to read/write at the low level, But you don't say if the Tag has any data on it and what format the data, I guess it will be the NDef data format for which there is a module as well https://ndeflib.readthedocs.io/en/stable/. I suggest you look at the source code of the tagtool.py from the nfcpy module. – Andrew Mar 05 '22 at 17:04
  • The NFCPY module worked, thank you! The tag did have data as a text record. Not sure any specifics beyond that :) – llllbbbbllll Mar 07 '22 at 00:41

0 Answers0