Easy to use sensor to retrieve pitch and roll

Does anybody know of an easy to use sensor to get the orientation of a device in relation to the Earth surface?
For example an Euler vector?
I know the micro:bit has easy readout of its orientation, but I prefer a stand-alone module for use with another board. I could in theory have the micro:bit act as an I2C device and pass this info over, but the other board runs 5V, so it is not that easy.
Problem with most orientation-sensors is that they output acceleration and rotational acceleration, where I specifically need direct x,y,z-angle orientation readout, preferable in the 360 or 400 degree format.

Compass for x/y, accelerometer for z.
Compass will have to be adjusted for local magnetic variation, as magnetic north is not under the north pole, but somewhere under Canada and headed towards Siberia.

Or, take a couple of GPS readings and determine true heading of the path that was travelled.

For pitch and roll, any 3D accelerometer will do.

A tilt compensated compass can give you all three (yaw, pitch and roll), but usually only yaw is calculated. For that you need a sensor that combines a magnetometer and accelerometer.

I recommend the LSM9DS1, which is by far the best of any consumer grade sensors I have yet tested. LSM9DS1 code for both an AHRS (Attitude, Heading and Reference System) and tilt-compensated compass can be found at GitHub - jremington/LSM9DS1-AHRS: Mahony 3D fusion filter and tilt compensated compass, with sensor calibration code

3D orientation sensors require some effort on your part to calibrate, or you will generally find the results to be worthless. Unlike a magnetic needle compass, they DO NOT work "out of the box".

jremington:
I recommend the LSM9DS1, which is by far the best of any consumer grade sensors I have yet tested. LSM9DS1 code for both an AHRS (Attitude, Heading and Reference System) and tilt-compensated compass can be found at GitHub - jremington/LSM9DS1-AHRS: Mahony 3D fusion filter and tilt compensated compass, with sensor calibration code

Any experience with this:

This one seems to do the job. I don't need to know what's North. How does it compare to that LSM9DS1?

Yes, I've used the BNO055. It does not work very well, because the sensor calibration is poor.

Again, if you just want pitch and roll, use any modern 3D accelerometer. Here is how to get the two values.

Thanks, I alread found out using the gravity is easiest, strange thing is many libraries use .gyro objects to read these values, so I got puzzled quite a bit.
Your link did help to make the final math!

You can't measure orientation while moving without a gyro, unless the movement is slow,
since accelerations and vibrations caused by movement pollute the accelerometer signal.

A full IMU (6DoF or 9DoF) is the most general approach, these usually come with libraries to output
quaternion, DCM and Euler angles... Given quaternion or DCM any Euler angle scheme can be
generated.

Nothing is moving

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.