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.
/dev/ttyAMA0
doesn't refer to them. See the answers on the duplicate question. Everything else should be the same. – goldilocks♦ Jun 14 '16 at 10:37/dev/ttyS0
but now the UnicodeDecodeError appears immediately, how do I check the/boot/cmdline.txt
file to make sure the console output is properly disabled for that node. Sorry but I am new to python and raspberry pi – Carl03 Jun 14 '16 at 11:58raspi-config
. The two components are the reference incmdline.txt
(the only mention of a console there should beconsole=tty1
, make sure afterward) and the spawning of a terminal line by the init system, which on jessiesystemctl disable serial-getty@ttyS0.service
should get rid of... – goldilocks♦ Jun 14 '16 at 12:06