I’m using an LSM303D, Arduino Mega, and NEO-6M GPS module to program an RC car. The car is hooked up to 1000mA rechargeable phone battery and also a 12V battery to power its motors.
The compass calibrates correctly (using the library code) sometimes. That’s fair enough I suppose. But that calibration is immediately lost when I put the compass anywhere near the batteries. I’ve tried shielding the batteries with all sorts of things, but it does nothing to reduce the false heading given by the compass after it is taken near the car.
I’ve tried changing the vector axes of the compass to compensate for the magnetic field caused by the batteries, but that also has no effect.
The result of the heading when putting the compass near the car is a constant or near-constant value. For example, it will remain at ~200 or similar. The axis also sometimes changes to rotate vertically around the y-axis instead of horizontally around the z-axis. Those readings are also very off though.
How do I get the compass to give a stable reading when it is on top of the car?