I'm using Sparkfun Razor IMU 9DOF sensor which incorporates accelerometer, gyroscope, and magnetometer, for giving the Euler's angles (yaw, pitch, and roll). I'm using the firmware at this link. It has Processing sketch for calibration of magnetometer, but it doesn't give the precise measurements. Especially, the yaw is imprecise. I'm using this sensor for measuring azimuth and altitude of stellar objects. The altitude is mostly correct, but azimuth (yaw) isn't.

I have several questions:

  • Is there a better way to calibrate magnetometer? Is the calibration sufficient, without using the Madgwick or Kalman filter?
  • Is there some nonlinearity present in the sensor? Since the yaw offset isn't constant, it changes (around -12 degrees up north to almost correct value at southwest). And if it is, how could I measure that nonlinearity and apply to the yaw measurements?
  • If I have to use Madgwick or Kalman, do I have to apply them on quaternions? I believe that applying them at the final yaw measurements wouldn't do the job.
  • 1
    \$\begingroup\$ Ahh silly question: Are you compensating for the difference between magnetic and geographic north. www1.appstate.edu/~goodmanj/4401/notes/magnets/mnvsgn.html \$\endgroup\$ Sep 6, 2016 at 14:14
  • \$\begingroup\$ That has come to my mind, but now I've checked that from my location the difference is approximately 4 degrees. If it was constant error that wouldn't be the problem, but sensor readings vary from 1 to 12 degrees on errors (12 degrees up north to 1 or less on south-west). \$\endgroup\$
    – yode
    Sep 6, 2016 at 14:50
  • \$\begingroup\$ Local magnetic fields can vary greatly do to pieces of iron in the environment. Especially indoors. Try taking it to an area free of iron... A field perhaps. \$\endgroup\$ Sep 6, 2016 at 15:15
  • \$\begingroup\$ That's exactly how I performed measurement, outdoor, on the field, and made sure no nearby magnetic disturbances existed. Some people say that nonlinearity of the sensor is the problem, but I don't know how to do that, and incorporate that in the code. \$\endgroup\$
    – yode
    Sep 6, 2016 at 15:19
  • 1
    \$\begingroup\$ @Jogitech No, only low current wiring. It turns out that the IMU used is not precise enough for such type of navigation. \$\endgroup\$
    – yode
    Nov 11, 2017 at 19:56

1 Answer 1


May be the magnetometer is influenced by iron or steel parts nearby. The compass of large steel ships was compensated against the influence of the steel hull. There were flag signals given: I am regulating my compass.

  • \$\begingroup\$ It is not the case. I've put the sensor far enough from all objects that can interact with magnetic field. Again, there are nonlinear errors, from 1 to 12 degrees in yaw. I was said that maybe I should do the nonlinearity test (circle the sensor in 1 degree until full circle), thus I get some data that can be approximated, but I don't know how to use such results. \$\endgroup\$
    – yode
    Sep 6, 2016 at 13:07
  • \$\begingroup\$ @dejan current-carrying wires (for example - to motors) influence magnetometer too. A circular-path test setup shows ellipses instead of circles. Not much current is required to upset the expected circles. \$\endgroup\$
    – glen_geek
    Nov 5, 2016 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.