char sensorData[10];
int index = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
// While there is data, and we have read less than 9 characters
while(Serial.available() > 0 && index < 9)
{
char inChar = Serial.read(); // Read a character
sensorData[index] = inChar; // Store it
index++;
sensorData[index] = '\0'; // Null terminate the string
}
// Serial.print("Sensor data: ");
Serial.println(sensorData);
// Do whatever else you need to do to parse the string and use the data
index = 0;
}