So using LibGDX accelerometer methods, I'm able to get the rotation of the device in the X and Z axes in degrees with this code:
@Override
public void render(float delta) {
float accX = Gdx.input.getAccelerometerX(),
accY = Gdx.input.getAccelerometerY(),
accZ = Gdx.input.getAccelerometerZ();
float moduleValue = (float) Math.sqrt(accX * accX + accY * accY + accZ * accZ);
//Here I do the gravity compensation
accX /= moduleValue;
accY /= moduleValue;
accZ /= moduleValue;
float xRotation = (float) Math.atan2(accY, accZ) * MathUtils.radiansToDegrees,
zRotation = (float) Math.atan2(accY, accX) * MathUtils.radiansToDegrees;}
However, get the rotation in the Y axis is not that easy to obtain, and if I try to get it by this way, it returns erroneus values.