In this illustration we will going to wire the HMC5883 III AXIS Magnetometer, this module is capable of sensing 3 directions. It’s communicate with the HMC5883L Chip onI2c interface with on-board logic level converter. The HMC588L is using 3.3 or 6v should be supplied.

The HMC5883L Chip is develop by Honeywell Aerospace, a multi-chip module designer for low-field magnetic sensing with the digital interface for applications such as compassing and magnetometry. The HMC5883L includes high-resolution HMC118X series magneto-resistive sensors plus an ASIC contacting amplification, automatic degaussing strap drivers, offset cancellation, and a 12 bit ADC that enables 1 degree Celsius to 2 degree Celsius compass heading accuracy.

The i2c serial bus on-board allows for easy interface to the chip. The HMC5883L 3.0×3.0x0.9mm surface mount 16pin leadless chip carrier (LCC). These sensor is a solid-state construction with very low cross-axis sensitivity designed to measure both the direction and magnitude of the Earth magnetic fields.

CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100


The HMC5883L mostly used in Navigation System, Mobile Phones, Netbooks, Consumer Electronics, and Personal Navigation Device.

Note: You cannot get the exact data without calibration. For measuring the magnetic field there will be two categories of distortion.

Hard Iron Distortion – The hard iron distortions refer to the presence of magnetic fields around the sensor the magnets, power supply, cables and wires.

Soft Iron distortion – The soft iron distortion refer to the presence of ferromagnetic materials around the sensor, which skew the density of the earth’s magnetic field locally and related to scaling offset errors.


A magnetometer is a type of sensor that measures the strength and direction of the local magnetic field. The magnetic field measured will be a combination of both the earth’s magnetic field and any magnetic field created by nearby objects. The magnetic field is measured in the sensor reference frame.

Earth’s Magnetic Field

The earth’s magnetic field is a self-sustaining magnetic field that resembles a magnetic dipole with one end near the Earth’s geographic North Pole and the other near the earth’s geographic South Pole. The strength of this magnetic field varies across the Earth with strengths as low as 0.3 Gauss in South America to over 0.6 Gauss in northern Canada. Although this magnetic field is relatively stable over time, electric currents in the ionosphere can cause daily alterations which can deflect surface magnetic fields by as much as one degree. Normally daily variations in field strength are on the order of 0.25 mGauss, which would equate to about a 0.03 degree variation in heading. This small of a change in heading is on the same order of magnitude as the resolution of most MEMS
based magnetometers, so in most cases the Earth’s magnetic field can be considered constant with respect to time.

Read More >

As you may know to get the exact magnetometer data you should calibrate the magnetometer. TO resolve this issue you should apply the bias to the vector of the non-calibrated data of X, Y, Z coordinates and multiply the transformation matrix by the result vector.

Calibrating with a box



Place the HMC5883L on the top of a box shown on the illustration above and click (Point 180) button of the Axix X+.

1. “Point 0”, “Axis X+”
2. “Point 180”, “Axis X+”
3. “Point 0”, “Axis X-”
4. “Point 180”, “Axis X-”
5. “Point 0”, “Axis Y+”
6. “Point 180”, “Axis Y+”
7. “Point 0”, “Axis Y-”
8. “Point 180”, “Axis Y-”
9. “Point 0”, “Axis Z+”
10.”Point 180″, “Axis Z+”
11.”Point 0″, “Axis Z-”
12.”Point 180″, “Axis Z-”



As you can see above the magnetometer calibration is the process of getting the transformation matrix and the bias. To acquire these data you need to use the MAGMASTER.exe software which can be downloaded here.

Wiring Component:

  • Arduino Board
  • HMC5883L Digital Compass Module Board
  • Jumper / DuPont Wires
  • Solder less Bread Board

Wiring Diagram:


Arduino Sketch



You need to fill the table to MagMaster then click “Calculate Transformation Matrix and Bias and get the required matrix & bias. As you can see on the MagMaster Windows the transformation matrix and the bias are acquired.  you can now calculate the calibrated magnetometer data in your device in a real time using the matrix and the bias. The test code can be found in TestResult below.

You can now apply the sphere radius stablization algorithm to your program download the RadiusStablization below or can be found inside MagMaster.Zip file.

Below are the calibrated magnetometer vector coordinates in 3D space with radius stabilization

3D Magnetormoter Alghoritm Simulation

Download MagMaster Software here | Zip
Download Arduino Sketch Code  Radius Stabilization | Zip
Download Arduino Sketch Code Test Result | Zip
Download Arduino HMC588L Code Library | Zip
Download MHC588X Datasheet here | Pdf
Download MHC588 Module Schematics | Pdf

Wiring the 3 AXIS Digital Compass Magnetometer HMC5883L
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *