Languages

Menu
Sites
Language
How to increase the precision of the heart beat sensor on a Samsung Gear S

Hello, i'm trying to increase the precison of the heart rate values on a Samsung Gear S. I developed a web application that communicates with a PC thanks to a  web socket.

I tried to use the function

parseFloat(interval).toPrecision(4)

or even

interval.toPrecision(4)

with no success. I used parseFloat because i need a Float data type for my communication.

Another strange and curious thing is that, apparently, the sensor can output only even values and not the odd ones. Is it possible that the precision cannot be increased (with the most accurate values something like 1.24 or 0.84)? How can i print also the odd numbers? Is it not possible for some reason? 

I will post the entire Javascript source code below, thank you very much in advance.

Marco

 

 

document.addEventListener('tizenhwkey', function(e) {
    if(e.keyName === "back")
        window.webapis.motion.stop("HRM");
        tizen.application.getCurrentApplication().exit();
});

function Connect(){

var ip;
var connection=false;
var interval_screen = 0;
if (document.getElementById("ip").value==="")
{ 
    ip="10.42.0.1";
}
else 
{ 
    ip=document.getElementById("ip").value;
}

var ros = new ROSLIB.Ros({
    url : 'ws://' + ip +':9090'
    });

ros.on('connection', function() {
    connection=true;
    document.getElementById("Connection_status").setAttribute("color","green");
    document.getElementById("Connection_status").innerHTML = 'Connected';
    tizen.power.request("SCREEN", "SCREEN_DIM");
});

ros.on('error', function(error) {
    document.getElementById("Connection_status").setAttribute("color","orange");
    document.getElementById("Connection_status").innerHTML = 'Error';
});

ros.on('close', function() {
    document.getElementById("Connection_status").setAttribute("color","red");
    document.getElementById("Connection_status").innerHTML = 'Unconnected';
    connection=false;
    tizen.power.release("SCREEN");
});

    var RatePub = new ROSLIB.Topic({
    ros : ros,
    name : '/HeartRateData',
    messageType : 'std_msgs/Float64'
});

var IntervalPub = new ROSLIB.Topic({
    ros : ros,
    name : '/HeartRateInterval',
    messageType : 'std_msgs/Float64'
});

window.webapis.motion.start("HRM", onchangedCB);

function onchangedCB(hrmInfo)
{
   var rate = hrmInfo.heartRate;
   document.getElementById("mytext").innerHTML = 'Heart Rate= ' + rate + ' bpm';

   var interval = hrmInfo.rRInterval/1000;
   parseFloat(interval).toPrecision(4);
   }
   if (interval !== 0) {
   interval_screen = interval;
   }
   document.getElementById("mytext1").innerHTML = 'RR Interval= ' + interval_screen + ' s';

   var Float64 = new ROSLIB.Message({
            data:rate
        });

        if(connection===true)
            {
            RatePub.publish(Float64);
            }
        else
        {
            document.getElementById("mytext").innerHTML = 'Heart Rate = 0 bpm';
        }

   var Float64 = new ROSLIB.Message({
            data:interval
        });

        if(connection===true)
            { if (interval !== 0) {
            IntervalPub.publish(Float64);
            }
            else {

            }
            }
        else
        {
            document.getElementById("mytext1").innerHTML = 'RR Interval = 0 s';
        }

        }}

 

 

Responses

6 Replies
Marco Fonsato

If something it's not clear i can provide further explanations, let me know.

Armaan-Ul- Islam

If the Tizen HRM sensor API returns a float with two digits after the dot you won't be able to recover four digits, Unless it's okay with you to fill with 0s. Like for 1.24 it would be 1.2400

In that case you may use javascript 'toFIxed()' function.

Difference between toPrecision() and toFixed()

Marco Fonsato

Ok, thank you very much for the explanation. Do you have any idea about the other problem? I mean taht the odd values are not printed out by the sensor. Thabk you again,

Marco

Armaan-Ul- Islam

You're welcome.

 

I recieved 'odd' data from HRM sensor like 71.3 or 191.1. May be because, I only used wearable 2.3.2 and wearable 2.3.1, but not the earlier ones for Gear S. Most probably its API issue i guess.

http://imgur.com/FCi6VAA

Marco Fonsato

Thank you! Yes, I have used the wearable 2.3. But i don't know if i was clear in my explanation. I can see values like 67 or 75 bpm coming out from the sensor, what i cannot achieve is getting values like 811 ms or 923 ms, so the RR intervals in milliseconds or seconds.

The image that you posted shows only bpm values, did you try to get also the intervals values?

Anyway, since i don't think i can use the 2.3.1 or so, i think that you are right, i'm afraid it's an API issue.

Thank you again and sorry for the questions.

 

 

 

Marco Fonsato

I'm sorry, i checked again and on my project i'm using 2.2. And that's the highest version supported by the Samsung Gear S as far i can see; because i tried also 2.3, 2.3.1, 2.4.

I tried my code with the emulator and the 2.3.1 API, i can see the odd data too. So, it's not a code related problem, now i think it's pretty clear that is an API problem. Maybe with newer devices my app will work. what do you think?

Thank you for all your help!

Marco