I'm trying to read data from an Arduino serial monitor, but I'm having problems with pyserial's readline function. Here's the simple code which prints to the monitor:
void setup() {
Serial.begin(19200);
}
void loop() {
Serial.print("helloWorld");
delay(1); // delay in between reads for stability
}
And here's the Python code I'm using to read the printed output:
import serial
arduinoSerialData = serial.Serial()
arduinoSerialData.port = "COM4"
arduinoSerialData.baudrate = 19200
arduinoSerialData.timeout = 1
arduinoSerialData.setDTR(False)
#arduinoSerialData.setRTS(False)
arduinoSerialData.open()
while(True):
b = arduinoSerialData.readline().decode('utf-8').strip().split(',')
print(b)
This is the error:
File "SerialRead.py", line 11, in <module>
str_b = b.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 7: invalid start byte
I have no clue what could be going wrong. Does anyone have any suggestions? Thank you for your time!
I have this code, and this is perfect:
Convert this data to string, and remove uneccesary character. Example:
Good luck!