Serial Controlled Sensor help

Hi guys,

So ive got this light sensor (PPF) and it uses a serial communication protocol to send the value of data to the arduino. Im looking at making a little LCD screen and placing it somewhere where i can read the output without having to check a serial monitor on my computer.

The sensor recieves the term "measure" of which it then returns the value as a series of numbers ( e.g 12.1256)

how can i make the code wait (without using a delay which seems very primative) until all the numbers have been sent before sending the 'measure' term again. (p.s i dont know exactly how many terms the light value will be)

Kind Regards,

Isaac.

Wait how long?

Something like this? Adjust delayInterval to your liking.

void loop()
{
  static unsigned long timer;
  const unsigned long delayInterval = 1000; // 1 second in milliseconds
  if(millis() - timer >= delayInterval)
  {
    timer += delayInterval;
    // send 'measure'
    // display results
  }  
}

"how can i make the code wait (without using a delay which seems very primative) until all the numbers have been sent before sending the 'measure' term again. (p.s i dont know exactly how many terms the light value will be)"

A delay might be ok, it just depends what else is going on in your program. A 3ms delay between reading of the serial input buffer for new characters seems to work at 9600 baud.

What do you mean by a series of numbers?

To me, 12.1256 looks like a series of digits in a single number. Then you talk of the number of terms... What's that;

Maybe you should show a longer piece of incoming data. How do you know it's finished?