Hello,
I want to make a magnetic compass using MPU9250 module but after trying to document myself on the web, nothing comes up; every website tells me something different.
Thanks for your help.
Read the pinned post re 'How to get the most from the forum.' At a minimum, you need to state what you expect and what actually happens. Of course, that means connecting the sensor and using a sample sketch that comes with the MPU9250 library.
Once you have calibrated the magnetometer (which is absolutely required), following this tutorial: Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers
then a general formula for heading in degrees is
int heading = -atan2(magy,magx)*180.0/PI;
The magnetometer must be held level for that formula to work.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.