I'm using the python serial module to try to read a rotary encoder. I am receiving something but I am not sure what it is?
When not turning the encoder I get the following bytes:
b'y\xf6\xf6\xf6\xf6\x16\xd6\x16\xb6\xd6\x06\x00'
When I turn the encoder I get a much longer sequence of bytes:
b'y\xf6\xf6\xf6\xf6\x16\x96\x16\xb6\xb6\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x16\xb66\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x16v\xd6\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x16Vv\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x16V\x16\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x166V\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\x16\xf6\x96\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\xf6\xd6\xd6\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\xf6\x966\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\xf6V\xf6\x06\x00y\xf6\xf6\xf6\xf6\x16\x96\xd6\xd6\xd6\x06\x00y\xf6\xf6\xf6\xf6\x16v\xf6\xd6\xf6\x06\x00y\xf6\xf6\xf6\xf6\x16v\xd6\xd6v\x06\x00y\xf6\xf6\xf6\xf6\x16v\xb6\xb6\x16\x06\x00y\xf6\xf6\xf6\xf6\x16v\x96\xb6\xf6\x06\x00y\xf6\xf6\xf6\xf6\x16vv\xd66\x06\x00y\xf6\xf6\xf6\xf6\x16vV\x96\xd6\x06\x00y\xf6\xf6\xf6\xf6\x16v6v6\x06\x00y\xf6\xf6\xf6\xf6\x16v\x16\x96\x16\x06\x00y\xf6\xf6\xf6\xf6\x16v\xf6\xd6V\x06\x00y\xf6\xf6\xf6\xf6\x16v\xf6v\x96\x06\x00y\xf6\xf6\xf6\xf6\x16v\xf6\xf6\xb6\x06\x00y\xf6\xf6\xf6\xf6\x16v\xd6vV\x06\x00y\xf6\xf6\xf6\xf6\x16V\xf6\xd6v\x06\x00y\xf6\xf6\xf6\xf6\x16V\xf6\xd6V\x06\x00y\xf6\xf6\xf6\xf6\x16V\xb6\xd6V\x06\x00y\xf6\xf6\xf6\xf6\x16V\x96v\xb6\x06\x00y\xf6\xf6\xf6\xf6\x16Vvvv\x06\x00y\xf6\xf6\xf6\xf6\x16VV\x966\x06\x00y\xf6\xf6\xf6\xf6\x16V6v\x16\x06\x00y\xf6\xf6\xf6\xf6\x16V\x16vv\x06\x00y\xf6\xf6\xf6\xf6\x16V\xf6\xf66\x06\x00y\xf6\xf6\xf6\xf6\x16V\xf6\x16\xb6\x06\x00y\xf6\xf6\xf6\xf6\x166\xf6\xd66\x06\x00y\xf6\xf6\xf6\xf6\x166\xd6\x96v\x06\x00y\xf6\xf6\xf6\xf6\x166\xb6\xf6\xd6\x06\x00y\xf6\xf6\xf6\xf6\x166\xb6\xf6\xf6\x06\x00y\xf6\xf6\xf6\xf6\x166\xb6\xf6\xf6\x06\x00y\xf6\xf6\xf6\xf6\x166\xb6\xf6\xf6\x06\x00'
The python code that I use is:
import serial
ser = serial.Serial(
port='/dev/ttyAMA0',
baudrate = 9600,
#parity=serial.PARITY_NONE,
#stopbits=serial.STOPBITS_ONE,
#bytesize=serial.EIGHTBITS,
timeout=1
)
cnt = 0
while 1:
try:
x=ser.readline()
print(x)
cnt += 1
except Exception as e:
print(e)
I have tried x.decode() x.decode("utf8") x.decode("utf16") also 32 and latin1. Honestly I just don't understand what I am looking at. Any help would be appreciated.