In NDOF mode, pitch and roll drift and compensated by the accelerometer sensing earth's gravity, and heading drift is compensated by the magnetometer sensing earth's magnetic field. In most cases this is not related to the part itself, but rather to environmental factors. Keep a lookout for the magnetometer calibration status. anything less than 3/3 indicate a problem. Keep the device away from large electrical currents, and metal objects. Large buildings also often contain a steel structure which distorts the magnetic field. To validate that the sensor is operating properly, you can rotate it until it shows 0 degree heading and place a compass nearby. They should point the same direction. If this is not magnetic North, then the field is distorted in the location you are (usually indoors is not very reliable).
... View more