Page 1 of 1

Convert raw data to tilt angle value

Posted: 21:02, 04 Jul 2015
by robypez
Hello, I'm creating my app.
I obtain with your api from the sensortag some value +/- 2.5, but I need to convert these value to degree. I want to check the tilt angle...

Any idea?


Re: Convert raw data to tilt angle value

Posted: 02:14, 09 Jul 2015
by ardiri
the tilt raw value should be between -1.0 and +1.0

you would need to understand what the raw data values actually mean; there is a good discussion of this on another forum: ... gyrometer/

you will need to figure out if the relationship between 0 and +1 and -1 and 0 are linear in nature and map them to an angle between 0 and 90. maybe you can start a logging of raw values.. with different degree increments.. either find a pattern; or use a lookup table to convert the raw data into angles. there was a similar discussion on stack overflow which may shed some better light into how to map between raw and angles. ... elerometer

Code: Select all

float calcInclinationAngle(int iDataPos)
  float xVal = fAccel[0][iDataPos];
  float yVal = fAccel[1][iDataPos];
  float zVal = fAccel[2][iDataPos];
  float pitch = 0;
  //Pitch in radians
  pitch = atan2(xVal, sqrt(pow(yVal,2)+pow(zVal,2)));
  //Pitch in degrees
  pitch = pitch * 180/PI;
  return pitch;

you need to make sure the raw values are between -1.0 and +1.0 - if you are receiving other values you'll need to map them to this range.