I am able to access Heart Rate of User using Optical Heart rate Sensor using SensorEventListener
:
sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE),
SensorManager.SENSOR_DELAY_NORMAL);
What I need is to get raw PPG data like: https://ars.els-cdn.com/content/image/1-s2.0-S0960077915001344-gr1.jpg
Through Google Fit or any other means can I get this data?
I looked into Google Fit API usage: https://developers.google.com/fit/android/sensors
It gives TYPE_HEART_RATE_BPM
and HEART_RATE_SUMMARY
, but not PPG raw data.
I spent some time figuring out if it's feasible to get the raw PPG signal from android API, and contrary to what some may say, it is definitely possible to do that. And here is how to do it:
1- Get the sensor type (represented by a number) of your PPG sensor (it is a constant that describes the sensor). This can be done by listing all the available sensors on your device:
2- Then, try to find the sensorType of your PPG sensor. In your output, you will find one of the sensors containing the word ppg in it's type. For instance here is what the ppg sensor of my Huawei watch 2 looks like:
3-Register your listener using the the type_number of your ppg sensor, mine is 65537 so I would do this:
4-Listen to changes in your sensor data:
And you are all set. Hope it works for you.