I'm working on a device that relies on data from a magnetometer. Unfortunately, the device also needs to have a fairly powerful magnet on it. Given that the design is fairly flexible, and within manufacturing tolerance I can know precisely where the magnet is and the layout of the magnetic field it should produce, is there a way to compensate for having a magnet in the device?
Is there some mathematical means of cancelling out the contribution of the inbuilt magnet, or perhaps shielding the magnet from the remainder of the device somehow, as the magnet is only needed for mounting the device to metal surfaces and nothing else?