Digital Compass Using Arduino and HMC5883L Magnetometer

Hi guys,

This sensor could indicate the geographic North, South, East, and West, we humans could also use it at times when required. So. In this article let us try to understand how Magnetometer sensor works and how to interface it with a microcontroller like Arduino. Here we will build a cool Digital Compass which will help us in finding the directions by glowing an LED pointing North Direction.

This Digital Compass is neatly fabricated on PCB by LIONCIRCUITS. Try them out, guys. Their PCB quality is really good.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Required Hardware

The following components have been used:

  • Arduino Pro mini
  • HMC5883L Magnetometer sensor
  • LED lights - 8Nos
  • 470Ohm Resistor – 8Nos
  • Barrel Jack
  • A reliable PCB manufacturer like LionCircuits
  • FTDI Programmer for mini
  • PC/Laptop

Step 2: What Is a Magnetometer and How Does It Work?

Before we dive into the circuit, let’s understand a bit about magnetometer and how they work. As the name suggests the term Magneto does not refer to that crazy mutant in marvel who could control metals by just playing piano in the air. Ohh! But I like that guy he is cool.

A magnetometer is actually a piece of equipment that could sense the magnetic poles of the earth and point the direction according to that. We all know that Earth is a huge piece of a spherical magnet with North Pole and South Pole. And there is a magnetic field because of it. A Magnetometer senses this magnetic field and based on the direction of the magnetic field it can detect the direction we are facing.

Step 3: How the HMC5883L Sensor Module Works?

The HMC5883L being a magnetometer sensor does the same thing. It has the HMC5883L IC on it which is from Honeywell. This IC has 3 magneto-resistive materials inside which are arranged in the axes x, y, and z. The amount of current flowing through these materials is sensitive to the earth’s magnetic field. So by measuring the change in the current flowing through these materials, we can detect the change in Earth’s magnetic field. Once the change is a magnetic field is absorbed the values can then be sent to any embedded controller like a microcontroller or processor through the I2C protocol.

Step 4: Circuit Diagram

The circuit for this Arduino based Digital Compass is pretty simple, we simply have to interface the HMC5883L sensor with the Arduino and connect 8 LEDs to the GPIO pins of the Arduino Pro mini. The complete circuit diagram is shown in the image above.

The Sensor module has 5 pins out of which the DRDY (Data Ready) is not used in our project since we are operating the sensor in continuous mode. The Vcc and ground pin is used to power the Module with 5V from the Arduino board. The SCL and SDA are the I2C communication bus lines that are connected to the A4 and A5 I2C pins of the Arduino Pro mini respectively. Since the module itself has a pull high resistor on the lines, there is no need to add them externally.

To indicate the direction we have used 8 LEDs all of which are connected to the GPIO pins of the Arduino through a current limiting resistor of 470 Ohms. The Complete circuit is powered by a 9V battery through the barrel Jack. This 9V is provided directly to the Vin pin of the Arduino where it is regulated to 5V using the on-board regulator on Arduino. This 5V is then used to power the sensor and the Arduino as well.

Step 5: Parameter Consideration for PCB Design

1. Trace width thickness is minimum 8 mil.

2. The gap between plane copper and copper trace is a minimum of 8 mil.

3. The gap between a trace to trace is a minimum of 8 mil.

4. Minimum drill size is 0.4 mm.

5. All the tracks which have current path need thicker traces.

Step 6: Fabrication

You can draw the PCB Schematic with any software as per your convenience.

Here, I have my own design and Gerber file attached. After you generate the Gerber file you can send it to any PCB manufacturer.

Personal opinion: Upload it onto LIONCIRCUITS and you can place an online order. It is very easy to upload and order on their automated platform.

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    Discussions