1

I used the following code from this post

import serial
import time

serial = serial.Serial("/dev/ttyAMA0", baudrate=2400)
while True:
    if serial.inWaiting() > 0:
        read_result = serial.read(12)
        print("Read card {0}" . format(read_result.decode(encoding='utf-8')))
        print("Sleeping 2 seconds")
        time.sleep(2)
        serial.flushInput() # ignore errors, no data

but still get the same problem as the original poster where the initial tag scan reads and any subsequent tries are unsuccessful

output is as follows with error:

Read card 04193DCBD7
Sleeping in 2 seconds
Read card                      # notice second read empty
Sleeping in 2 seconds
Traceback (most recent call last):
  File "/home/pi/Desktop/Test/TestRFID2.py", line 8, in <module>
   print("Read card {0}" . format(read_result.decode(encoding='utf-8')))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3: invalid start byte

Errors fall in different positions (i.e. 1, 2, or 3)

Have tried different scripts as well with same outcome. I have also disabled the serial console as described here.

My schematic with all connections

Carl03
  • 11
  • 5

1 Answers1

0

Besides changing changing the port from /dev/ttyAMA0 to /dev/ttyS0 because the default device node for the Pi 3 is different.

I figured out what my problem was and it lies within the config.txt file, I added the line enable_uart=1, this will enable the device itself. Tested it and it works 100% for me.

Carl03
  • 11
  • 5