0

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?

2
  • Is Raspbian Buster fully updated - there were some serial bug fixes on the Pi4. sudo apt update, sudo apt full-upgrade
    – CoderMike
    Jan 19 '20 at 17:01
  • Thanks for replying so quick. Yes first thing I did before I continued.
    – flightkees
    Jan 19 '20 at 17:06
0

I've dun goofed myself... As the documention on the raspberryPi website states, the uart port the Rpi3 is shared with the bluetooth module.

https://www.raspberrypi.org/documentation/configuration/uart.md

After disabling the bt module in the config file everything was working perfect. Nevertheless thanks.

2
  • The website says no such thing
    – Milliways
    Jan 20 '20 at 4:12
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Jan 21 '20 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.