Languages

Menu
Sites
Language
Raw PPG signal Samsung Gear 3
I saw in this link (https://developer.tizen.org/ko/development/guides/native-application/location-and-sensors/device-sensors?langredirect=1#hrm_green) that it is possible to access the raw PPG signal through the Heart Rate Monitor LED Green / IR / Red Sensor methods.
Did anyone try to access this data on the Samsung Gear 2/3?
If so, is it possible to access them continuously and record them in memory?

Regards

Edited by: xenos malleus on 29 Aug, 2017

Responses

12 Replies
Armaan-Ul- Islam

Yes, It is possible to access them continuously and record them in memory.

As an option, You can develop a Tizen Web Application for that and Use HRMRawData Sensor API and FileSystem API. I am sharing a Code example, which will read HRM raw sensor data and store data on a txt file. The Interval is set to 500ms in the example.

 

var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW");

function writeToFile(sensorData){
        
        tizen.filesystem.resolve("documents/testData.txt", function(testFile) {
        	 testFile.openStream("a", onOpenSuccess, null, "UTF-8"); //open file in append mode
        	 	
        	function onOpenSuccess(fs){            	
        		fs.write(sensorData.lightIntensity + " ");      // write sensor data to file
        		// opt/usr/media/documents 
            	fs.close();
           }
        });
    }

    
function onGetSuccessCB(sensorData){
    // pass sensorData to write to file
	   writeToFile(sensorData); 
}

function onerrorCB(error){
   console.log("error occurred:" + error);
}

function onsuccessCB(){
   console.log("HRMRaw sensor start");	   
   HRMrawsensor.getHRMRawSensorData(onGetSuccessCB, onerrorCB);
   HRMrawsensor.setChangeListener(onGetSuccessCB, 500,1000);
   // onGetSuccessCB function called at 500 ms Interval, batch latency 1000ms
}
	
function createFile(){
	var documentsDir,testFile;
		
    tizen.filesystem.resolve("documents", function(result) { // get to default document directory
    	documentsDir = result;
    	testFile = documentsDir.createFile("testData.txt");
	});
}
	

   
createFile();   //create the file
HRMrawsensor.start(onsuccessCB);    // start HRM raw sensor
    	

 

Add filesystem.read, filesystem.write, healthInfo privileges in config.xml.

 

You can check the file In Tizen Studio > Connection Explorer > Device > opt/usr/media/documents/testData.txt > Pull the file

 

Please check the Tizen Web Guides and Tizen Web API Documentations for details:

Device Sensor Guide

Sensor API

File System Guide

Filesystem API

xenos malleus

Thank you so much for your help.

Hyung Sun Lee

I've tried your sample code using Tizen Studio 2.1 and Samsung Wearable Extension 1.3.0,

but I'm getting exception every 500ms.

Do you have any idea what's causing this?

 

Thanks,

- Hyung Sun

 

 

Hyung Sun Lee

It seems that this callback exception only happens in Gear Sports running Tizen 3.0.0.

I ran the test code on my Gear S2(Tizen 2.3.2) and callback function was called without exceptions.

So is it a bug in Tizen 3.0.0?

Armaan-Ul- Islam

I've shared a response regarding the exception here on this post:

Samsung Gear S3 - can the sample rate of SENSOR_HRM_LED_GREEN be increased above 20 Hz?

 

Please Check it out.

Dmitry

I try this:

    try{
        var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW");
    } catch (e) {
        console.log(e.message);
    }

and i get error message: "Permission denied". But i added healthinfo privileges in config.xml.

What wrong?

Dmitry

I found that:

HRM_RAW - HRM_RAW is supported, if at least one HRM LED sensor type is supported:
tizen.systeminfo.getCapability(sensor.heart_rate_monitor.led_green),
tizen.systeminfo.getCapability(sensor.heart_rate_monitor.led_ir),
tizen.systeminfo.getCapability(sensor.heart_rate_monitor.led_red)

my device don`t supported this sensors.

how can I find out which devices support these sensors?
 

Mads Olsen

​I'm also interested in this area, and would like to add a question to the topic. 
Do you know how where to find information about the max/min sampling intervals for each sensor? Fx. would it be possible to sample the PPG sensor with 25 Hz, i.e. sampling interval 40ms ? 

 

xenos malleus

I would like to know where find this information too.
With the interval in the method setChangeListener is can configure the amount of time passing between 2 consecutive events (values from 10 to 1000 ms https://developer.tizen.org/ko/development/guides/web-application/sensors/device-sensors?langredirect=1), this means from 1 to 100 values per second but, are all this values a new sample of the PPG signal?

Armaan-Ul- Islam

To sample the PPG sensor with 25 Hz, you just need to add the 40ms interval. Try this sample Code Instead:

 

    var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW");
    
    function onGetSuccessCB(sensorData)
    {
        var date = new Date(Date.now());
    	var hours = date.getHours();
    	var minutes = "0" + date.getMinutes();
    	var seconds = "0" + date.getSeconds();   	
    	var ms = "0" +date.getMilliseconds();
    	var Time = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2) + ':' + ms.substr(-3);
    	
    	console.log("data:" + sensorData.lightIntensity + " timeStamp:"+ Time);
	   //writeToFile(sensorData); 
	}

	function onerrorCB(error)
	{
	   console.log("error occurred:" + error);
	}

	function onsuccessCB()
	{
	   console.log("HRMRaw sensor start");	   
	   HRMrawsensor.getHRMRawSensorData(onGetSuccessCB, onerrorCB);
	   HRMrawsensor.setChangeListener(onGetSuccessCB, 40);
	}
    HRMrawsensor.start(onsuccessCB); 

 

And about "are all this values a new sample of the PPG signal?" seems Yes as per as I've seen the Documentations mentioned above.

xenos malleus

yes, per as i have seen the Documentations i think so too.
thanks

Mads Olsen

Thanks a lot. I'll try it out