SparkFun will be closed Monday 7/4 for the holiday. All orders placed after 2pm MT on Friday 7/1 will be shipped out next week.


Member Since: November 17, 2011

Country: United States

  • You can correct the measurements by subtracting an offset from the measurements ( the offset for each axis is (max_measurement + min_measurement)/2 ). This should give you good enough readings. But if you want to be more accurate then you can collect readings while rotating the magnetometer in every direction and fit the measurements to a ellipse. An ellipse is described by the equation x'Ax = 1, where x are your measurements. You need to find, using least squares, the values for the matrix A. After that, you can find the transformation that rotates and scales the ellipse into a circle by taking the Cholesky decomposition of A = L'L. With that, for every measurement x you get, you can get x_corrected = L*(x-offset_vector), and your measurements of the heading will be much more accurate. The only thing that is missing is to add an accelerometer to compensate for tilt

  • With either this or the HMC5883L there would be distortion is you put it near a magnet or a ferromagnetic material. That is why you need to calibrate the measurements you get from these. Freescale has provided an application note which explains how to correct this effects.

  • A magnetometer is not necessarily a compass. There are applications where it is useful to know the direction of a magnetic field.

  • Hi,

    Your problem is due to calibration. You need to correct the offset values, either by writing to the offset registers of the device (OFF_X_MSB ,etc) or by subtracting the offset from the measurements you get. This is caused by hard iron effects. Freescale has an application note (AN4246, i think) which explains this effect and how to correct it.

No public wish lists :(