I am struggling to read in data from an Arduino and save this data as a csv file I could meddle with in Python later. Right now my code reads.
import serial
serial_port = '/dev/ttyUSB0'
baud_rate = 9600
file_path = "output.csv"
ser = serial.Serial(serial_port,baud_rate)
done = False
data = []
while done == False:
raw_bytes = ser.readline()
decoded_bytes = float(raw_bytes.decode("utf-8"))
data.append(decoded_bytes)
if (len(data) > 10) :
done = True
import numpy as np
np.savetxt(file_path, data, delimiter = ',', fmt='%s')
but I'm running into the error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 1: invalid continuation byte
I want to decode into UTF-8 don't I? What is going wrong? I have checked the Serial Monitor on the Arduino IDE and I am getting correct outputs there. Thanks in advance.