I got a simple rfid reader (brand unknown) connected to the serial0 rx port of a Pi4. Uploaden the following code and works perfect.
class RFID():
def __init__(self):
self.ser = serial.Serial(port="/dev/serial0",
baudrate = 9600,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_ONE,
xonxoff=True
def Read(self):
while 1:
received_data = None
received_data = self.ser.read()
time.sleep(0.03)
data_left = self.ser.inWaiting()
received_data += self.ser.read(data_left)
self.received_data = received_data
def returnTag(self):
return self.received_data
The output is very neatly displayed with only giving an output after presenting the tag: b'?\xe6\xa6f\xa6\xcc\x99\x97\x97ff\xa6)\xd6\xf2\x00
Since the scanner eventually will be connected to a Pi3B I conducted the same steps strangely enough with with different result. The Pi3B is the flooding the terminal with b\x00
if nothing is detected and if the tag is presented sometimes the correct but most of the time incorrect tag values.
To check if I maybe made a setting error, I conducted the steps at the same time with both a clean installed Buster on a Pi4 and a Pi3, again with the same result.
Anybody a clue what's happening?