I have my nice new BNO086, and the example programs are working fine on a Mega.
However, it is not immediately clear to me that any of these include my principal goal, which is a nice, stabilized, magnetic compass heading. At the very least, tilt compensated.
Of course I can do the math in the app, but the BNO086 is supposed to handle that.
Normally, that would be the yaw angle, which may or may not be corrected for your local magnetic declination. Ignore pitch and roll.
The magnetometer is the only source of information for the direction of North, and it must be calibrated to remove offsets, as well as corrected for your location. If you want yaw (heading) to be indexed to magnetic North, input zero for your magnetic declination.
Right. That is how the WT901 does it as well. But what I am not seeing is an example of retrieving such a yaw value from the device. I am sure I am missing something obvious, but am stumped.
I have connected the SparkFun VR IMU Breakout - BNO086 (Qwiic) to an Arduino Mega via I2C. I have been running various example sketches from the Arduino library provided by SparkFun (SparkFun_BNO08x_Arduino_Library).
Each of these examples appears to run properly as designed, giving me raw values and stabilized ones. The rotation vectors, however, are not magnetic, but reset to straight ahead with each repower or restart.
Here is the output from one:
BNO08x Read Example
I2C address found
-0.01,0.99,0.00,-0.00,0.00
-0.11,0.07,-0.01,0.99,0.02,-0.00,0.00
0.00,0.00
That is the GyroIntegratedRotationVector, for example.
Will contain no information regarding the direction of North or Up/Down.
Run the Euler Angles demo instead to get yaw, pitch and roll, which SHOULD BE relative to the magnetic North and down (Earth). You can also run the magnetometer example to see where the Earth’s magnetic field is pointing (which is steeply down at mid latitudes in the northern hemisphere).
Note that the Sparkfun example does not report the IMU calibration, so if the yaw readings don’t agree with true magnetic North, the magnetometer is not properly calibrated. See the BNO086 data sheet for how to do that.
That is how it SHOULD act according to the comments in the Euler Vector sketch, but it is not geomagnetic after all. Power up and it says yaw is 0, rotate to new yaw, re-power up, and it now reports yaw as 0. So it’s relative to startup, not to mag north.
In fact, as I dig into the Sparkfun library, it looks like querying that data is not even supported… Hmm.
If all you want is a tilt compensated compass, you bought the wrong board. The BNO086 has all kinds of options intended for game playing, which aren’t useful for much else, and the built in calibration methods do not work very well.
Any 9DOF sensor can be turned into a tilted compensated compass with very simple code. For example, here is an example for the ICM-20948: https://github.com/jremington/ICM_20948-AHRS
All magnetometers must be properly calibrated to be useful as compasses, and the above Github repo features calibration code.
Thank you both for your work on this issue/forum-post. We have created a new branch of the library that enables the use of the geomagnetic rotation vector data.