I am using an Arduino Uno R3 to send instructions to a serial monitor in a Python program with Serial.println. But when I send a specific line, I get a a UnicodeDecodeError
.
The line in the Arduino code that causes this error is:
Serial.println("Press '1,2,3,4,5' to run motor at 10%, 20%, 30%, 40%, 50% for 2 seconds");
My Python code to read the serial data is:
def get_serial_data(self):
while 1:
try:
serial_data = self.serial_connection.readline().decode('Ascii')
filtered_serial_data = serial_data.strip('\r\n')
self.serial_monitor.insert(END, filtered_serial_data)
except TypeError:
pass
and is called from a thread:
thread1 = threading.Thread(target=self.get_serial_data)
thread1.daemon = True
thread1.start()
But I get the following error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x85 in position 36: ordinal not in range(128)
Can anyone help why this is happening or how to fix, I saw a stackoverflow post to use a try, except block to get it to ignore this line, but I want to print it out, and I want to understand why I get this error.