user81519: 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?

user38721: I would embed the call to .getData() into a try block and handle this specific exception with except UnicodeDecodeError. There can always be a transmission error, especially when the script is started.
However, I would do it differently:
void loop() {
  Serial.println(analogRead(A0));
}

...and on the python side use serial.readline() from pyserial instead.
But I don't know cvzone and you might have a reason to use this instead of the commonly used pyserial.

81519: <p>I am trying to <strong>read potential meter data from Arduino using python</strong>, with the program on Arduino as follows :</p>
<pre><code>#include &lt;cvzone.h&gt;

SerialData serialData;
int sendVals[2];

void setup() {
  serialData.begin(9600);
}

void loop() {
  int potVal = analogRead(A0);
  sendVals[0]= potVal;
  serialData.Send(sendVals);
}
</code></pre>
<p>the program on the arduino side is running fine</p>
<p>and program in python as follows</p>
<pre><code>from cvzone.SerialModule import SerialObject

arduino = SerialObject(&quot;COM7&quot;)

while True:
   data = arduino.getData()
   print(data[0])
</code></pre>
<p>but I get this error:</p>
<pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    data = arduino.getData()
  File &quot;C:...\site-packages\cvzone\SerialModule.py&quot;, line 68, in getData
    data = data.decode(&quot;utf-8&quot;)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf7 in position 0: invalid start byte
</code></pre>
<p>How to solve it?</p>
 38721: <p>I would embed the call to <code>.getData()</code> into a <code>try</code> block and handle this specific exception with <code>except UnicodeDecodeError</code>. There can always be a transmission error, especially when the script is started.</p>
<p>However, I would do it differently:</p>
<pre><code>void loop() {
  Serial.println(analogRead(A0));
}
</code></pre>
<p>...and on the python side use <code>serial.readline()</code> from pyserial instead.
But I don't know cvzone and you might have a reason to use this instead of the commonly used pyserial.</p>
