90 degree error in yaw with magnetometer

I have just assembled a new ArduPilotMega with IMU shiled and used the APM Mission Planner to load the latest code. I have started testing with a MediaTek gps and the lastest magnetometer.The magnetometer is mounted to the shield as shown in the assembly instructions: components are down, pins are pointing forward, and long axis aligned forward.It is working very well right out of the box except for one thing: when I point the board North, the yaw reading in GCS says that I am pointing East; the error appears to be 90 degrees. I do have a declination of 16.3 degrees set and I do have gps lock.I have looked at the 2.11 code and see that there are config.h settings to accomodate various magnetometer mounting arrangements, but the Mission Planner Terminal program does not seem to allow for different magnetometer mounts. In any case, I was hoping that if I mounted the magnetometer as shown in the wiki that it would work with the default download.Where should I be looking?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Sorry folks.  The "problem" was caused by my testing in front of a big iMac display.  It apparently has a strong magnetic field.  When I walked the test rig to a neutral magnetic location, the yaw readings are what I expected.


    Newbie error.  Darn.



  • Addendum:

    The auto nulling of magnetometer offsets appears to be working well. After I pitch and roll the board for a minute or so, the yaw reading becomes almost completely insensitive to pith and roll attitudes of about 30 degrees.

    In addition, I find that if I set a declination of -47 degrees, I then get very reasonable yaw (compass) readings.

    I have been assuming that yaw is measured clockwise from geographical North. I haven't screwed that up have I?
This reply was deleted.