Reading a Long string

Hello Everybody,

Please I need help reading a string from the serial monitor. The string is separated by commas...
0.003890451,0.00762079,0.010280163,0.010280163,0.011803206,
0.013304544,0.011967405,0.009549926,0.013931568,0.013931568,
0.015848932,0.014859356,0.012189896,0.010764652,0.010764652,
0.011967405,0.012022644,0.011534533,0.014588143,0.014588143,

It reads the only the first 5 numbers and does nothing else....

Here is my code

/* check if data has been sent from the computer: */
if(Serial.available() > 0) {

for (int j = 0; j < 31; j++)
{
first = Serial.readStringUntil(','); //reads the value in the string up to the

Serial.read();
char carray[first.length() +1];
first.toCharArray(carray, sizeof(carray));
usartArray[usartIndex] = atof(carray); // Store it
usartIndex++; // Increment where to write next
Serial.println(usartArray[j], 9); // for testing

}

You need to read the data to a comma character, convert to a C string, then convert to a floating point number, and then repeat. Something like;

// inside loop()
int charsRead;
int index;
char input[15];

index = 0;
while (Serial.available()) {
   charsRead = Serial.readBytesUntil(',', input, sizeof(input) - 1);
   input[charsRead] = '\0';          // Now it's a string
   usartArray[index++] = atof(input);
}
Serial.print("Converted ");
Serial.print(index);
Serial.println(" numbers from input stream.");

I haven't tested the code, but it will give you something to start with.

Have a look at the parse example in Serial Input Basics

...R

char carray[first.length() +1];
first.toCharArray(carray, sizeof(carray));
    usartArray[usartIndex] = atof(carray); // Store it

Or

usartArray[usartIndex] = first.parseFloat();