I'm trying to read these RFID tags from a JRD-100 using a Raspberry Pi Pico running MicroPython (thonny as IDE) using code adapted from this blog post, which was originally written for Arduino. So far it appears to be working (I can request and get responses) except for the strangely inconsistent outputs returned by the program.
My code:
from machine import UART, Pin
import utime
RFID_cmdnub = *OMITTED FOR BREVITY. SEE BLOG POST*
class Main:
def __init__(self):
self.uart2 = UART(1, baudrate=115200, rx=Pin(5), tx=Pin(4), timeout=10)
print("UHF-Reader")
#self.Sendcommand(37)
def Sendcommand(self, com_nub):
self.uart2.write(bytes(RFID_cmdnub[com_nub]))
#self.uart2.write("\n\r")
def Readcallback(self):
while self.uart2.any():
#utime.sleep_ms(2)
temp = self.uart2.read()
if temp == b'\xbb\x01\xff\x00\x01\x15\x16~':
print(None)
else:
print(temp)
def loop(self):
#print("Polling...")
self.Sendcommand(3)
#print("Recieving:")
self.Readcallback()
utime.sleep_ms(100)
#print()
M = Main()
while True:
M.loop()
The following code includes example tag reads in the "rs" list (one line per read) where I held two tags above the reader for a few seconds. The code after that compares to the first tag that was read to highlight what is changing and where:
rs = [
b'\xbb\x02"\x00\x11\xc24\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e!~\xbb\x02"\x00\x11\xcf4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e.~',
b'\xbb\x02"\x00\x11\xce4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e-~\xbb\x02"\x00\x11\xc34\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e"~',
b'\xbb\x02"\x00\x11\xcc4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e+~\xbb\x02"\x00\x11\xc44\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e#~',
b'\xbb\x02"\x00\x11\xc44\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e#~',
b'\xbb\x02"\x00\x11\xc24\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e!~\xbb\x02"\x00\x11\xcc4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e+~',
b'\xbb\x02"\x00\x11\xcb4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e*~',
b'\xbb\x02"\x00\x11\xcb4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e*~\xbb\x02"\x00\x11\xc24\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e!~',
b'\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~',
b'\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~',
b'\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~\xbb\x02"\x00\x11\xc04\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e\x1f~',
b'\xbb\x02"\x00\x11\xcb4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e*~',
b'\xbb\x02"\x00\x11\xc94\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e(~\xbb\x02"\x00\x11\xc14\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e ~',
b'\xbb\x02"\x00\x11\xc94\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e(~',
b'\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~\xbb\x02"\x00\x11\xc44\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e#~',
b'\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~',
b'\xbb\x02"\x00\x11\xc24\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e!~\xbb\x02"\x00\x11\xca4\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e)~',
b'\xbb\x02"\x00\x11\xc24\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e!~\xbb\x02"\x00\x11\xc94\x000\x083\xb2\xdd\xd9\x01@\x00\x00\x00\x00\xc4\x1e(~'
]
R1 = [[[hex(val) for val in temp] for temp in r.split(b'~')] for r in rs]
base = R1[0][0]
for rset in R1:
print('-')
for r in rset:
if len(r) > 0:
print([f'{idx}: {v}' for idx, v in enumerate(r) if v != base[idx]])
This prints the following, which shows that the same values are varying for each reading, with the '[]' denoting perfect matches to the first tag that was read.
-
[]
['5: 0xcf', '22: 0x2e']
-
['5: 0xce', '22: 0x2d']
['5: 0xc3', '22: 0x22']
-
['5: 0xcc', '22: 0x2b']
['5: 0xc4', '22: 0x23']
-
['5: 0xc4', '22: 0x23']
-
[]
['5: 0xcc', '22: 0x2b']
-
['5: 0xcb', '22: 0x2a']
-
['5: 0xcb', '22: 0x2a']
[]
-
['5: 0xca', '22: 0x29']
-
['5: 0xca', '22: 0x29']
-
['5: 0xca', '22: 0x29']
['5: 0xc0', '22: 0x1f']
-
['5: 0xcb', '22: 0x2a']
-
['5: 0xc9', '22: 0x28']
['5: 0xc1', '22: 0x20']
-
['5: 0xc9', '22: 0x28']
-
['5: 0xca', '22: 0x29']
['5: 0xc4', '22: 0x23']
-
['5: 0xca', '22: 0x29']
-
[]
['5: 0xca', '22: 0x29']
-
[]
['5: 0xc9', '22: 0x28']
Clearly, something is not right here since I would not expect the values to vary like this for the same two tags. Can anyone shed light on what's happening here?
Edit: after changing the command from:
{0xBB, 0x00, 0x22, 0x00, 0x00, 0x22, 0x7E,} //3. Single polling instruction
to
{0xBB, 0x00, 0x39, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x08, 0x4D, 0x7E} //9. Read label data storage area
The returned values are more consistent, but I still get ~4 values per tag. I have also tried this with other tags and both types behave the same.