Problem with internal magnetic sensors

During test flights I noticed that the drone does not fly the route I specified (with the help of QGroundControl), but always flies in any other direction. Several times I recalibrated all sensor systems with QGroundControl.

After a few searches, I found the cause:
One internal magnetic sensor provided data that differed greatly from the other internal magnetic sensor and the magnetic sensor of the external GPS compass module. I created plots in all three axes using FlightPlot.

Internal magnetic sensor (sensor_mag_0 & sensor_mag_1):

  • MPU-9250

External magnetic sensor (sensor_mag_2):


I can’t tell which sensor is exactly mag_0 and which is mag_1. In the plot you can see the Y-Axis of all the three sensors.

As a result, I have deactivated the magnetic sensor in QGroundControl, which has a systematic deviation (CAL_MAG1_EN set to Disabled).

Since that moment, the drone has been flying exactly as planned.

My question is this now:
Where could the error come from with the wrong signal and how can you fix it yourself?

Thanks for your help!

Regards Cédi

Can you specify the software version you are using?