I am using RFID reader MFRC522 NFC Reader kit and would like read and print the tag Record number which indicated below at the bottom. What I would like to print is Record 0 section. I couldn't understand it reads only some numbers other than this tag which recorded on the related card.
My code is below:
from PyQt5.QtCore import QThread, pyqtSignal
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
import time
reader = SimpleMFRC522()
class RFIDThread(QThread):
change_text_signal = pyqtSignal(list)
def __init__(self):
super().__init__()
self._run_flag = True
def run(self):
try:
while (True):
id, text = reader.read()
self.change_text_signal.emit([id, text])
time.sleep(2)
finally:
GPIO.cleanup()
def stop(self):
"""Sets run flag to False and waits for thread to finish"""
self._run_flag = False
self.wait()
I need to know how I could read the value that I need on it. Does anyone know how I could do that?
This is quite a large subject, so this question really needs more focus.
But to start you off in the right direction you need to understand how the Card (looks like a Mifare Classic) you are using stores it's data, so read it's datasheet https://www.nxp.com/docs/en/data-sheet/MF1S70YYX_V1.pdf and particularly Section 9 of that doc that details the command that the card understands.
Then you need to understand how an Ndef
message is stored on a Mifare Classic card which is detailed in https://www.nxp.com/docs/en/application-note/AN1304.pdf
The data format also shown is Ndef
so you need to understand how that is organised. The high level structure of records is defined in the NDEF spec at https://github.com/haldean/ndef/blob/master/docs/NFCForum-TS-NDEF_1.0.pdf
The Text Record format is defined at https://github.com/haldean/ndef/blob/master/docs/NFCForum-TS-RTD_Text_1.0.pdf
You should be able to use the library https://pypi.org/project/ndef/ for this
You also need to know how to send and receive data to the card reader, this is done by the library you are using.
So if you know look at what you example is asking the library to do. This is to read the UID and then authenticate with a default key and read a few hard coded block addresses.
What you need to do at a high level is to read the UID and then authenticate with right key then read the right blocks to get the whole Ndef
message and then parse it.