sparkfun / SparkFun_Bio_Sensor_Hub_Library

25 stars 33 forks source link

Getting raw PPG readings #30

Open s1nisteR opened 8 months ago

s1nisteR commented 8 months ago

Hello. How to go about using this sensor and this library to get raw PPG signals from the sensor? I've seen a library from https://github.com/Protocentral/protocentral-pulse-express which has a separate configRawMode function that outputs raw PPG signals. How would I go about doing such a thing using your library?

s1nisteR commented 8 months ago

Apparently this is how the other library is doing it.

bool max32664::configRawdataMode(){

  //enter app mode
  bool ret = writeByte(0x01, 0x00, 0x00);
  delay(10);
  if(!ret){
    Serial.println("enter app mode cmd failed");
    return false;
  }

  //Set output mode to sensor data 
  ret = writeByte(0x10, 0x00, 0x01);
  delay(10);
  if(!ret){
    Serial.println("Set output mode to sensor data cmd failed");
    return false;
  }

  //Set sensor hub interrupt threshold
  ret = writeByte(0x10, 0x01, 0x0f);
  delay(10);
  if(!ret){
    Serial.println("Set interrupt threshold cmd failed");
    return false;
  }

  //Enable AFE
  ret = writeByte(0x44, 0x03, 0x01);
  delay(10);
  if(!ret){
    Serial.println("Enable AFE cmd failed");
    return false;
  }

  //Enable BPT algorithm in Estimation mode
  ret = writeByte(0x52, 0x04, 0x02);
  delay(10);
  if(!ret){
    Serial.println("Enable AFE cmd failed");
    return false;
  }

  //Disable AGC.
  ret = writeByte(0x52, 0x00, 0x00);
  delay(200);
  if(!ret){
    Serial.println("Disable AGC cmd failed");
    return false;
  }

  //led1
  ret = writeByte(0x40, 0x03, 0x0c, 0x7f);
  delay(10);
  if(!ret){
     Serial.println("LED1 (red) current set failed");
    return false;
  }

  //led2
  ret = writeByte(0x40, 0x03, 0x0d, 0x7f);
  delay(10);
  if(!ret){
    Serial.println("LED2 (IR) current set failed");
    return false;
  }

  Serial.println("Device configured in rawdata mode");
  return true;
}