# Inaccurate heading from Qwiic Micro Magnetometer - MMC5983MA

**URL:** <https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784>\
**Category:** IMU & Motion\
**Created:** [November 26, 2022, 2:37am UTC](https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784 "2022-11-26T02:37:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![UnsolicitedEmails](https://avatars.discourse-cdn.com/v4/letter/u/919ad9/32.png) [@UnsolicitedEmails](https://community.sparkfun.com/u/UnsolicitedEmails)\
**Post date:** [November 26, 2022, 2:37am UTC](https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784/1 "2022-11-26T02:37:57Z")

</div>

I bought 2 and I think I’m having trouble with both. 1 definite problem with one, and a possible problem with the other.

My setup: Arduino IDE → I2C Digital Compass example → RedBoard Qwiic → Qwiic cable → Qwiic Micro Magnetometer - MMC5983MA

1st problem, maybe a redboard problem:

Readings are hovering around one of 3 positions.

Here’s a snippet of the readout from the serial monitor in Arduino IDE:

Heading: 132.9

Heading: 132.9

Heading: 132.8

Heading: 132.8

Heading: 132.8

Heading: 132.7

Heading: 151.1

Heading: 150.9

Heading: 150.7

Heading: 150.9

No matter what direction I point, it will be one of these 2 positions, or sometimes about 118.

Strangely, the problem does not occur on my other RedBoard, but both boards and both magnetometers are new.

Second problem (with a different magnetometer) / maybe not a problem?:

Running the Digital Compass example in Arduino IDE, When I point North, I see approx 360 degrees, but when I point the opposite direction (what I would assume to be South) I get about 220 degrees. I.e. North and South do not appear to be opposite. However, when I point at 180 degrees according to the magnetometer, and then 270 degrees, it is almost a perfect right angle (measured on paper).

Any help would be appreciated! Thanks 😃

---

<div class="post-metadata">

**Author:** ![jremington](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/jremington/32/6595_2.png) [@jremington](https://community.sparkfun.com/u/jremington)\
**Post date:** [November 26, 2022, 3:16am UTC](https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784/2 "2022-11-26T03:16:51Z")

</div>

Magnetometers don’t work out of the box as a compass, and need to be calibrated.

Simple tutorial: [https://diydrones.com/profiles/blogs/ad … or-dummies](https://diydrones.com/profiles/blogs/advanced-hard-and-soft-iron-magnetometer-calibration-for-dummies)

Best overview and advanced guide: [https://thecavepearlproject.org/2015/05 … r-arduino/](https://thecavepearlproject.org/2015/05/22/calibrating-any-compass-or-accelerometer-for-arduino/)

---

<div class="post-metadata">

**Author:** ![UnsolicitedEmails](https://avatars.discourse-cdn.com/v4/letter/u/919ad9/32.png) [@UnsolicitedEmails](https://community.sparkfun.com/u/UnsolicitedEmails)\
**Post date:** [November 28, 2022, 5:20am UTC](https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784/3 "2022-11-28T05:20:42Z")

</div>

I was working my way through these tutorials, but had no success. Are you sure this method works for the MMC5983MA? Is there something I need to do for this to work with the MMC5983MA? If you are sure the tutorial is sufficient I will continue trying to work it out 🙂

The Arduino sketch mentioned in the Simple tutorial doesn’t seem to do anything or create any output in the Arduino IDE serial monitor for my RedBoard Qwiic.

---

<div class="post-metadata">

**Author:** ![jremington](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/jremington/32/6595_2.png) [@jremington](https://community.sparkfun.com/u/jremington)\
**Post date:** [November 28, 2022, 4:25pm UTC](https://community.sparkfun.com/t/inaccurate-heading-from-qwiic-micro-magnetometer-mmc5983ma/44784/4 "2022-11-28T16:25:27Z")

</div>

The methods described work for any magnetometer.

Use Serial.print() to output raw measurements on the Arduino serial monitor (or use a terminal program to log them to a file) and process the data with other programs.

See this forum post for more examples: [https://forum.pololu.com/t/correcting-t … eter/14315](https://forum.pololu.com/t/correcting-the-balboa-magnetometer/14315)
