Introduction: Arduino 3D Printed Compass

In this Instructables guide I will show you how to make your own Arduino based digital magnetic compass.

In this guide you will also find the .stl files of the 3d printed case/box.

Let's get started!

Step 1: ​What You Will Need - Hardware

For this project you will need:

If you want to make the whole circuit to fit inside our 3D printed box you must buy:

You will also need the Arduino uno board for the programming procedure.

If you want to make it super easy, without the 3d printed case or if you want to make it bigger to your own box you will need:

Tools:

  • 3D printer (for the box/case of your compass)
  • Soldering iron if you want to make your own small circuit
  • Glue

Step 2: The Circuit

Above you will find the breadboard and electronic circuit schematic. Ι suggest you to build your circuit on (small) breadboard first. The connections are easy, just follow the pinout.

Here you can find the electronic circuit schematic on better detail than above image

About the HMC5883 sensor:

The HMC5883L sensor is a 3-axis digital magnetometer IC designed for low-field magnetic sensing. The sensor has a full-scale range of +8 to -8 Gauss and a resolution of up to 5 milli-Gauss. Communication with the HMC5883L is simple and all done through an I2C interface. That means you will need to connect power, ground and only two cables to Arduino uno board (SDA,SCL).

Note!

Because this is a magnetic compass if you put it near to battery, motors, metallic surface or magnetic field, the result will diverge from the actual.

Also make sure to use it on a flat surface!

Step 3: The Code

Download the code from here and open it with Arduino IDE. Inside you will also find all necessary libraries!

Program the ATmega328p with your Arduino uno board, detach it from it and plug it on your custom circuit.

(if you are using a breadboard for testing, here you must see that everything working fine)

Special note: Code line: 60 to 63

// Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the compassnetic field in your location.
// Find yours here: http://www.magnetic-declination.com/ // Mine is: -13* 2' W, which is ~13 Degrees, or (which we need) 0.22 radians

float declinationAngle = 0.22; //<--Change 0.22 with yours. If you can't find your declination just delete those lines ;)

Step 4: 3D Printer Files

Use full support on your printing procedure.

Above image will help you to understand how you can fit them all inside it.

Make sure that the sensor is glued well on the bottom part - lid and the "x" label looking to the same direction as "N" letter on the top of the main part.

Step 5: Well Done!

Well...that's it!

I hope you liked this, let me know in the comments!
I would also like to see some photos with your new 3D printed Arduino Compass!

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017