Skip to main content
3 of 3
replaced http://electronics.stackexchange.com/ with https://electronics.stackexchange.com/

The earth's magnetic field is not parallel with the ground. In some locations it can be pointing more down than across.

NOAA has a magnetic field calculator where you can enter you latitude and longitude. For example, I am located at approx 19deg S 147degE and the field is

North Comp    East Comp    Vertical Comp    Total magnitude
32,434.4 nT   4,280.6 nT   -36,035.1 nT     48,670.7 nT 

So the downwards strength is more than the other two combined for my location. I'm guessing the calculator will also show a very strong down component for your location.

Some other things to be aware of are that the LSM303DLHC magnetometer can have quite large offsets, up to the equivalent of 2 earth magnetic fields, and therefore requires calibration. Also hard and soft iron distortions can affect the readings.

Edit: Please see my answer here for methods to calibrate the sensor.

geometrikal
  • 2.9k
  • 15
  • 21