I am currently working on a hobby project, for which I would need a reliable compass that should work in as wide a range of environments as possible (i.e.: In a field, in a car, on a train, possibly even on an airplane)
I chose the LSM303DLMTR tilt compensated compass (datasheet here)
It was easy to set it up with an Arduino board and then make a calibration (using a predefined set of steps, using a library. The Arduino periodically prints a heading, but now the problem arises that if there is even a small magnetic field around, it will make the heading reading useless.
Even in my room, which shouldn't have any strong magnetic fields around, the compass only printed junk. This is frustrating, since an ordinary compass isn't nearly as bothered by nearby fields or ferromagnetic materials.
Thus, I have two questions:
Is it possible to shield the compass effectively against minor interference (I realize that a strong, local magnetic field will always ruin the compass functionality) and against ferromagnetic materials nearby? (Ideally, I would like to be able to use the compass in a train, which creates magnetic fields through the electric lines.)
Related to this: Can minor perturbations be avoided by using a "smart" calibration, and does this need to be repeated every time a strong field perturbs the compass?