Qwiic Micro Magnetometer - MMC5983MA Hookup Guide

Pages
Contributors: Ell C
Favorited Favorite 2

Example 2: I2C Digital Compass

Example 2 shows how to compute the heading based on the basic X/Y/Z readings from the sensor over Qwiic. To find this example, go to File -> Examples -> SparkFun MMC5983MA Magnetometer Arduino Library -> Example2-I2C_Digital_compass.

Image shows menu pulldown as described above

Having a hard time seeing the image? Click the image for a closer look.

Make sure you have the correct board and port selected. For this tutorial, your selections should look something like this:

Select the SparkFun RedBoard and the correct COM port

Having a hard time seeing the image? Click the image for a closer look.

Once you're ready to go, go ahead and hit the upload button (the right facing arrow button under the "Edit" menu item). Once your code is uploaded, open the Serial Monitor and you'll see compass readings start printing out.

Serial Monitor Output

Having a hard time seeing the image? Click the image for a closer look.

If you look at the above image, you'll see where I abruptly changed the direction the sensor was pointing.