Hi Dev and PaulS, thank you both for your helpful replies.
Dev, I tried your approach of emptying characters from the Paro array each time I have two messages from both sensors. I found that it works, but I did have to do one adjustment to it.
With both sensors continuously running in the background, I found that I have to do recursion in the loop to make the Arduino read and write continuously. If not, only one pair of data values gets printed to the Serial Monitor, and after that, nothing until the next reset of the Arduino board.
This is the code I'm using in the loop:
void loop(){
readParo();
readHoney();
if(newParoData == true && newHoneyData == true){
Serial.print("*"); Serial.println(paroChars);
Serial.print("?"); Serial.println(honeyChars);
newParoData = false;
newHoneyData = false;
while(Serial1.available()){ //clear the Paro data buffer
Serial1.read();
loop();
}
}
}
And this is the output, which is correct. I have added back the '*' and '?' characters to the front of the Paro and Honeywell data, for easier integration with a separate data acquisition system. I don't know if this is the most efficient way to do so.
Anyway, here is the output I get. The data rate has been dropped to the slowest rate, which is the Honeywell's 2Hz, which makes sense to me.
?01CP=0.0000
*000114.5799
?01CP=0.0001
*000114.5795
?01CP=0.0002
*000114.5799