Ublox M8N compass will not calibrate

I am running firmware 3.4.6 on a PX4 with a Ublox M8N GPS/Compass. Until recently, the PX4 and Ublox compasses were both working correctly. I then had problems with the quad not taking off, but flipping over. I tried recalibrating everything, but could not get the Ublox compass to calibrate successfully in MP Live Calibration.
I then re-installed the firmware and tried again many times, to no avail. Although the PX4 compass calibrates, MP Flight Data now constantly displays Unhealthy Compass.

I tried deselecting the external compass to calibrate the PX4 compass only, this works, however, I still get the Unhealthy compass message, even after several attempts to overcome this.

Is there any way that I can test the compasses to if there are faults?

Some help would be greatly appreciated.

Just a pointer, you have the Primary compass set to 1 but you have compass 1 disabled.

Don’t forget to reboot between changes.

Correct, however, I have since changed the primary to Compass 2. I have re-booted between changes. I now have the PX4 compass working with no pre-arm errors.

The problem lies with the Ublox compass, which goes through the Live Calibration routine, but always fails. I think it is faulty, but I would like to be able to test it.

I have the Ublox Center installed , however, it does’nt seem possible to connect I2C to it for compass testing.

I do have a Ublox NEO 7M MiniAP GPS with compass. I’ll try that to see if it will calibrate, thus eliminating the PX4 as the problem - hopefully.

Note that the compass is independent from the Ublox GPS, it just happens to be installed on the same board. So the Ublox software can’t be used for compass diagnostics. The compass is usually a Honeywell HMC5883L. The best way to debug it is probably through the PX4. The easiest way to test is by doing a compass calibration, if you’re getting data points then the compass itself should be fine, and the issue is probably on the installation (alignment or magnetic interference).

I have re-mounted the PX4 on a better, less flexible mount. Both compasses calibrated on the second attempt. I can only conclude that the PX4 was wobbling on the old mount when rotating the quad during live calibration, causing compasses angular mismatch.

All is now well.

Thank you all for your input.