Assistance Re Getting Pitch and Roll data from Sensor

Former Member
Former Member
I am interested in getting Pitch and Roll data from the VivoactiveHR. I just want to get the angles as you tilt your device. From what I have seen that is pitch and roll data.

I can get acceleration data .. but would like to get the pitch and roll data (in degrees). I assume that they would be from -180 to 180 degrees.
Btw ... is Pitch on the x Axis and Roll on the yAxis ?

This is what I have so far .. but think that it is wrong.

var movement = Sensor.getInfo();

if (movement has :accel && movement.accel != null && start == 1 and pause == 0 and bye == 0)
{
accel = movement.accel;
xAccel = accel[0];
yAccel = accel[1];
zAccel = accel[2];


Roll = Math.atan2(yAccel,zAccel);
Pitch = Math.atan2( xAccel, Math.sqrt( yAccel * yAccel + zAccel * zAccel));
}


Any help would be appreciated. Thanks
Kevin