I'm trying to receive data (arrays) from Arduino into my Python script, everything seems to be working fine until I try receiving a 5 or more digit number. Some searching suggests this probably has to do with Pyserial reading only a certain number of bytes at a time, but I am unable to understand what I need to change to be able to read my arrays. Please take a look at my codes: Arduino code:
int data[] = {1245,2211,33498,4212,5235};
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i=0; i<5; i++)
{
Serial.println(data[i]);
}
//Commented this out because it'd give me garbage value in python
//delay(1000);
}
Python Code:
import serial
ser1 = serial.Serial('COM6', 9600)
#receive some data
for i in range(5):
arduinoData = ser1.readline().decode('ascii')
print(arduinoData)
Upon running this code I get:
1245
2211
-32038 (Why was this value converted into a negative number?)
4212
5235