Design of IMU using MPU9250 and HMC5883L

Thread Starter


Joined Apr 28, 2021
Hi. I want to design IMU using MPU9250 and HMC5883L. In MPU 9250 noisy signal coming from magnetometer causes heading oscillations. So I want to use HMC5883L as magnetometer. In the attached image you will see how I should place sensors. (red box- MPU9250, blue box- HMC5883L) . I don't know how I going to calculate rotation angles, etc. in this design because sensors will be placed in different points of drone or robot.


Deleted member 115935

Joined Dec 31, 1969
You need sensor fusion
search forum for other links to this

lots of bits on line , Arduino forum et all

BTW: Why do you believe the magnetometer on the HMC5883L has less "noise" than that built into the MPU9250 ?

Also you do realise the MPU9250 is EOL ?

Deleted member 115935

Joined Dec 31, 1969
The sensor fusion code for the MPU9250, has a smoothing function built into it,
It looking in this video as if that's not enabled.

I use the MPU9250 in a good few Android products and I can assure you that the output looks nothing like shown in that video,

have you tried the eval board

The thing also needs calibration, ( its an old design, the newer IMUs don't to the same degree )

Thread Starter


Joined Apr 28, 2021
If I use only MPU9250 it will be affected by noises coming from magnetic fields created by other electronics within drone or robot. So I want to place HMC5883L away from electronics. But I don't know math. calculations etc.

Deleted member 115935

Joined Dec 31, 1969
why not move the MPU9250 or the electronics ?

Re the maths,

3D Euclidian space I seem to remember,


Have a think, how far apart are the sensors,
what is the turn ability of the drone,
what is the accuracy of the sensors, assuming drone is flying and its not fixed ?

Assuming sensors are say 200 mm apart,
they are going to be reading the same in reality

Now if drone was strapped to a rotating table, like a record player,
and you only had rotation in a plane
then you should be able to detect a difference between the two sensors,

but in a 3D flying drone,
not a hope.

I get impression you have not tried the single MPU in the drone yet.
Id strongly suggest that you try it, with the 9DOF sensor function turned on ,
the interference to the magnetometer is going to be "random" over the second or so of smoothing you will be using,
( if you don't, then your drone will be jumping all over the place, and be totally un flyable )

What you find is the magnetometer, Inertial platform and accelerometer all work to different strengths,
The accelerometer is great at sudden changes but has a movable "DC", the inertial platform is great at direction , but drifts, and the magnetometer is great at pointing to magnetic north but suffers noise.

Sensor fusion takes all these, and applies different filtering to each , to give a running "approximation" to where your pointing, at what speed at what acceleration.

I have also previously added in the 4th input, the GPS signal. which is accurate, but limited resolution, and subject to fade / jamming.

All these give you a 3D vector , each you filter, I tend to use Kalman and simple averaging filtering

Adding another magnetometer off set is not the way forward, but to understand your system.

And as said before, the MPU9250 is very old in terms of what's around now days, and its EOL, so wont be around much longer.