Triple Axis Magnetometer HMC5883L + Arduino

One of the first articles we did was on the hmc6352 digital compass. Well this is his older brother (or younger but smarter). I really don’t know what to say about the HMC5883L other than it is a three axis magnetometer, so it is capable of sensing in 3 directions.Triple Axis Magnetometer HMC5883L + Arduino

That doesn’t mean that it is tilt compensated, because you really don’t know how it is orientated when the reading comes in. For that, you would need to combine this with an accelerometer to do that. But this can get you one step closer. If you are looking at using this as a digital compass, make sure to read the following section.

Magnetic Declination

Something I found interesting and obvious once I thought about it, is that all compasses point to magnetic north, and not true north. The difference between them is called Magnetic declination. And how much they vary depends on where you are, and… when it is, because as weird as it is, it changes over time (awesome animation of that). You can look up your Magnetic declination here.

Hooking it up

Hooking you HMC5883L up to your arduino is pretty simple. The HMC5883L is an I2C device, a type 2-wire serial connection, so we just need to connect the SDA (Data) and SCL (Clock) lines to your Arduino for communication. On your Arduino (everything but the mega) SDA is on analog pin 4, and SCL is on analog pin 5. On an arduino mega, SDA is digital 20, and SCL is digital 21. (The Arduino Leonardo will also be different). Other than these 2 lines, we just need to connect power(3.3v), ground and we are all set.Schematic Triple Axis Magnetometer HMC5883L + Arduino

For more detail: Triple Axis Magnetometer HMC5883L + Arduino

This Post / Project can also be found using search terms:

  • Connect HMC5883L to Arduino Uno Board

Leave a Comment

= 5 + 0

(Spamcheck Enabled)

Read previous post:
NE555 timer sparks low-cost voltage-to-frequency converter
NE555 timer sparks low-cost voltage-to-frequency converter

In 1971, Signetics—later Philips—introduced the NE555 timer, and manufacturers are still producing more than 1 billion of them a year....

Scroll to top