Compass calibration never succeeds

I’ve been trying to calibrate my external BN-880 compass for my third flight (having rebuilt the craft after a crash) and I keep getting failures. Arming won’t work due to bad gyro health, and trying the onboard calibration always reports that the threshold is under the confidence threshold.

I also tried live calibration and the points do show up, but the offsets are three-digit long at best, and the controller still keeps reporting bad gyro health with those.

I tried calibrating in an open field at least 30m away from anything metal or power wires but it kept failing. I’m at my wits’ end, how can I debug this?

There might be magnetic interference from other components. Try increasing the COMPASS_OFFS_MAX parameter to 1000 or 1200 and try to do compass calibration. Also, It would help to keep the compass on a mount so that its far away from other components especially the motors.

Hmm, I’ll try that, thanks. The compass is far out on the wing but the servo wire runs under it. If I calibrate with the servo disconnected and then connect it, will it fly acceptably?

You need good gyro (accelerometer calibration) before a good compass calibration is possible.
Think of it, it needs to know it’s attitude in order to collect/store valid compass offsets.

I tried that as well, but keep getting “bad gyro health” as well. I’m not sure what’s up with that or how I can debug it.

It turns out that “bad gyro health” causes the compass problems, not the other way around. I thought that error was because the compass wasn’t calibrated, but it turns out that I need to reboot a few times until the gyro connects (I don’t know why it only connects sometimes) and then try the calibration or whatnot.

Does anyone know why my BN-880 gyro won’t connect reliably?

It’s also possible that I have the wrong magnetometer orientation, would anyone know the correct one?

The BN-880 datasheet shows the magnetometer pointing to the edge opposite the cable connector.

Solved: I2C was plugged into the CAN port and caused some issues.

Yep, that was it, thank you!