I am trying to read potential meter data from Arduino using python, with the program on Arduino as follows :
#include <cvzone.h>
SerialData serialData;
int sendVals[2];
void setup() {
serialData.begin(9600);
}
void loop() {
int potVal = analogRead(A0);
sendVals[0]= potVal;
serialData.Send(sendVals);
}
the program on the arduino side is running fine
and program in python as follows
from cvzone.SerialModule import SerialObject
arduino = SerialObject("COM7")
while True:
data = arduino.getData()
print(data[0])
but I get this error:
Traceback (most recent call last):
data = arduino.getData()
File "C:...\site-packages\cvzone\SerialModule.py", line 68, in getData
data = data.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf7 in position 0: invalid start byte
How to solve it?
startup()
before it starts sending data in theloop()
.