0

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: Protocol SPo2

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

2

2 Answers 2

0

actually I don't think it is all mixed up

as per geometrikal use the markers to parse the data stream

I believe your above sample data started mid-stream during the 0xF8 of the wave form.

F8,...
...,7C,74,6B,62,5A,51,4A,42,3B,34,30,2E,2F,30,31,33,0,36,38,3B,3E,3D,3C,3C,3B,3B,38,34,2F,2C,2B,2B,29,0,24,21,1E,1D,1E,1E,1F,20,22,24,26,28,2B,2D,30,32,0,35,37,39,3C,3E,40,42,44,45,4A,4F,53,55,57,59,5C,0,5E,60,61
F9,0
FA,0
FC,1A
FB,0
F8,62,62,62,63,0,...

I believe reading this as a finite length does not portray the data for easy interpetation. Given that 0xF8 is a variable length protocol.

Where the reparse of your data initially appears to be legitimate parse.

That said I do read the SPO2, Pulse as zero. Where it may be likely the sensor has not finished its reading and auto gain cycles.

0

I have used the source code available on the Medlab web, and do some "modifications" to be Arduino compatible. I dont wanna the waveform data, because my final program will do the waveforms acording the data received, so I don't "listen" to the waveform packet

boolean startbyte = false; 
byte buf = 0;

  while (Serial1.available() > 3)
  {
    buf = Serial1.read();
    if (buf > 0xfc)
    {
      buf = Serial1.read();
    }


    if ((startbyte == true) && buf > 0xF7)
    {
      startbyte = false;
    }

    if (buf > 0xf7 && startbyte == false)
    {
      //startbyte = true;
      if (buf == 0xf8)
      {
        startbyte = true;
      }

      if (buf > 0xf8)
      {
        byte RX = buf;
        buf = Serial1.read();
        if (buf > 0xfc)
        {
          buf = Serial1.read();
        }

        if (RX == 0xf9)
        {
          //SPO = buf;
          Serial.print("SV:");
          Serial.print(buf, DEC);
          Serial.println();
        }

        else if (RX == 0xfa)
        {
          //Pulse = buf;
          Serial.print("SPV:");
          Serial.print(buf, DEC);
          Serial.println();
        }
        else if (RX == 0xfb)
        {
          //Status = buf;
          Serial.print("StV:");
          Serial.print(buf, DEC);
          Serial.println();
        }

        else if (RX == 0xfc)
        {
          //quality = buf;
          Serial.print("QV:");
          Serial.print(buf, DEC);
          Serial.println();
          Serial.println();
        }
        else { }
      }


    }
    else if (startbyte == true)
    {
     //Waveform data
    }
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.