0

I'm trying to read and write data from an RFID tag using python whit this module: https://es.aliexpress.com/item/32573423210.html I can connect successfully whit serial but I don't know how to read any tag, because the datasheet from pr9200(the reader that I am working) use this: Image for pr9200 operation It's like a raw packet whit only hex address that I need to send to the module for it works

my code on python is this:

 import serial

ser = serial.Serial(port = "COM27", baudrate=115200, bytesize=8, parity='N', stopbits=1)


while(ser.is_open == True):
    rfidtag = ''
    incomingByte = ser.read(21)
    print(incomingByte)
    for i in incomingByte:
        rfidtag = rfidtag + hex(i)
Lin Du
  • 88,126
  • 95
  • 281
  • 483

2 Answers2

0

Some comments to jump start your coding:

-What you need to do is send a command to your device to ask it to start sending readings in auto mode. To do that you need to use ser.write(command). You can find a good template here.

-To prepare the command you just need to take the raw bytes (those hex values you mentioned) and put them together as, for instance a bytearray.

-The only minor hurdle remaining is to calculate the CRC. There are some nice methods here at SO, just search CRC 16 CCITT.

-Be aware that after writing you can not start immediately waiting for readings, you have to wait first for the device to acknowledge the command. Hint: read 9 bytes.

-Lastly, take a new count of the bytes you will receive for each tag. I think they are 22 instead of 21.

Marcos G.
  • 3,371
  • 2
  • 8
  • 16
0

You can use pyembedded python library for this which can give you the tag id.

from pyembedded.rfid_module.rfid import RFID
rfid = RFID(port='COM3', baud_rate=9600)
print(rfid.get_id())

https://pypi.org/project/pyembedded/

S Andrew
  • 5,592
  • 27
  • 115
  • 237