Example Code for Arduino-Electronic Compass

Last revision 2026/01/06

This article offers a practical guide for setting up an Arduino-based electronic compass using CurieNano and the QMC5883 library. Detailed steps for hardware and software preparation are provided, along with operational instructions to achieve accurate compass readings.

Hardware Preparation

Software Preparation

Install the Arduino/Genuino 101 plugin by following the Getting Started tutorial.

Operation Steps

  1. From "File -> Examples -> QMC5883 -> QMC5883_compass" to open "QMC5883_compass.ino", select your "board" and "port" and upload to the CurieNano in the same way you uploaded the blink sketch.

    Curie_Nano_HMC5883L_1

  2. Wait five seconds after the download is complete, open the serial monitor port and set the baud rate 9600.

Result

Rotate the CurieNano board and you should see the angle change.

Curie_Nano_HMC5883L_2

More Tutorials

Was this article helpful?

TOP