Inaccurate heading from Qwiic Micro Magnetometer - MMC5983MA

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 :smiley:

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

Best overview and advanced guide: https://thecavepearlproject.org/2015/05 … r-arduino/

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 :slight_smile:

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.

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