Im using a variant of Arduino Due embedded on a ARM (Udoo). And I have connected a Medlab SPO2 Pearl 200 sensor to Serial1.
Im just trying to parse input from Serial1 to Serial, in a human-readable format (Hexadecimal).
The protocol is described in this image:
And using this Arduino code I reveice two times the "no finger detected line"
int lineLength = 16;
int spo2read[16];
int readed = 0;
if (Serial1.available()) {
int inByte = Serial1.read();
if (readed < lineLength) {
spo2read[readed] = inByte;
}
readed++;
if (readed == lineLength) {
Serial.print("SPO2: ");
for (int i = 0; i <= lineLength; i++) {
Serial.print(spo2read[i], HEX);
Serial.print( delimeter);
}
Serial.println("");
readed = 0;
}
}
Output with no finger is:
SPO2: A,FB,2,F9,0,FA,0,FC,A,FB,2,F9,0,FA,0,FC,0,
Buf if I put my finger, all is messed up:
SPO2: 7C,74,6B,62,5A,51,4A,42,3B,34,30,2E,2F,30,31,33,0,
SPO2: 36,38,3B,3E,3D,3C,3C,3B,3B,38,34,2F,2C,2B,2B,29,0,
SPO2: 24,21,1E,1D,1E,1E,1F,20,22,24,26,28,2B,2D,30,32,0,
SPO2: 35,37,39,3C,3E,40,42,44,45,4A,4F,53,55,57,59,5C,0,
SPO2: 5E,60,61,F9,0,FA,0,FC,1A,FB,0,F8,62,62,62,63,0,
Sensor doesn't sends a \n or \r so I don't know exactly how to parse the data