Intermittent ArrayIndexOutOfBoundsException reading thermopile over serial

Hello @The_Wolf_of_Walmart ,

Seems to work with this Arduino test code:

Arduino Code
int count;

void setup() 
  {
  Serial.begin(115200);
  delay(1000);
  }

void loop() 
  {
  Serial.print(count++); // First element is a counter! Useful when debugging code.
  Serial.print(",");
  for(unsigned char i = 0; i < 63; i++){
    Serial.print((i+1)*1.01);
    Serial.print(",");
  } 
  Serial.println();
  delay(500);
  }

I got this from the numbers I was sending:

image

My use of trim in topic provided was incorrect!
I spotted that right away! Live and learn…
It did not matter in this case since we did not use last element of array.
Will go back and fix it in original post.

This is correct:

myString = trim(myString);
String splitString[] = splitTokens(myString, ",");
printArray(splitString);
if (splitString.length == 64)

Another topic that may be of interest:

You may have been experiencing some “garbage” in the buffers if you were just stopping and running Processing.
There are better ways to do things like handshaking between devices… when you are ready.

:)

1 Like