The video below shows using a Magnetometer to accurately determine the orientation of a Rover. The video also demonstrates the IONOTRONICS Robot Commissioning Tool which has a built in capability for both Magnetometer measurement capture, for calibration, and the display of the orientation with a Compass Java Bean.
A detailed Youtube video will be published soon. The Rover uses the I2C Magnetometer sensor using an Adafruit Part which uses the ST Micro Magnetometer and other sensors.

The orientation of the Rover is displayed on the Compass Bean in the Robot Commissioning Tool.

Note that the interface also supports making raw measurements from the Magnetometer and storing them in a file. To obtain the raw measurements, the Rover was tanking, thus rotating about a fixed axis. The Rover is controlled and data from sensors is collected using a WiFi connection. The WiFi module on the Rover operates in AP mode.
Magnetometer Calibration
For details on how to calibrate a Magnetometer see this link.
For the following results the Rover was tanking while the Magnetometer X,Y and Z axis where measured and recorded at 300ms intervals. The calibration parameters where obtained and used in the Video, with the orientation shown in the Java Compass Bean as the Rover tanked at different speeds.


