I have a simple python script that is listening to my serial port on which my arduino send strings.
import serial
ser = serial.Serial("/dev/ttyACM0", 9600, timeout=0.5)
while True:
print (str(ser.readline())
The connection is etablished, but I can't compare the readed line with a string, as the line comes with unwanted caracters : [value]/r/n
I want to get rid of these caracters. I've tried the following :
ser.readline().decode().strip('\r\n')
It's working fine.. until python read an unknown caracter that it is not able to decode :
0
0
0
Traceback (most recent call last):
File "/home/testserial.py", line 6, in <module>
value = ser.readline().decode().strip('\r\n')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8d in position 1: invalid start byte
I don't understand why this caracter is there. My arduino program only send bolean 0 or 1
Do you guys have any ideas ?
0and1?