# Intermittent ArrayIndexOutOfBoundsException reading thermopile over serial

**URL:** <https://discourse.processing.org/t/intermittent-arrayindexoutofboundsexception-reading-thermopile-over-serial/32361>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [September 22, 2021, 2:55am UTC](https://discourse.processing.org/t/intermittent-arrayindexoutofboundsexception-reading-thermopile-over-serial/32361 "2021-09-22T02:55:03Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [September 22, 2021, 10:33pm UTC](https://discourse.processing.org/t/intermittent-arrayindexoutofboundsexception-reading-thermopile-over-serial/32361/7 "2021-09-22T22:33:12Z")

</div>

Hello @The_Wolf_of_Walmart ,

Seems to work with this Arduino test code:

> **Arduino Code**
>
> ```auto
> 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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b806662e22bda5cab38e688f63a4774acbc7b9ee.png)

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:

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

```

Another topic that may be of interest:

> [@Problem with the use of several sensors, Arduino / Processing](https://discourse.processing.org/t/problem-with-the-use-of-several-sensors-arduino-processing/18118/5):
>
> Hello, Some code I wrote to explore Arduino transmitting data to Processing. It runs fine at a BAUD rate of 1000000. slight_smile I use an Arduino MEGA 2560 R3. 
> 
> > **Arduino Code**
> >
> > // Serial Incoming Test (Arduino Tx) // v1.0.0 // GLV 2020-02-29 long count; void setup() { //Serial.begin(9600); Serial.begin(1000000); delay(1000); Serial.print('\n'); //same as Serial.println() Serial.print("incoming"); Serial.print('\n'); //same as Serial.println() } void loop() …

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.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/intermittent-arrayindexoutofboundsexception-reading-thermopile-over-serial/32361)._
