If you're finding that the magnetometer fails self-testing, there could be a couple of different factors at play.
1. You could be in a strong magnetic field or indoor. Move to another location and try again.
2. The magnetic field may have changed, and you will need to recalibrate. Please refer to the below video for a tutorial on calibration.