Interfacing HMC5883L / QMC5883 Digital compass with Arduino

 

Hi, and welcome

Before I start, I want to mention an important thing: I recently bought an Arduino module which is HMC5883L (GY-273) I tried it with its library but unfortunatley it doesn’t work, after some research on the internet I found out that they are actually QMC5883 modules.

How to know it’s a real HMC5883L:

-If you try after wiring it with arduino with i2c scanner you gonna find that the address is “0x1E

-Or if you look on the chip itself it’s marked L883

How to know it’s a fake one:

-If you try after wiring it with arduino with i2c scanner you gonna find that the address is “0x0D” as i found out or something else

-Or if you look on the chip itself it’s marked DA5883

A picture I took from : https://www.reddit.com/r/AskElectronics/comments/5xo3md/problem_with_hmc5883l_magnetometer/

IUgHbx8

But actually it’s not a fake but it’s the QMC5883 which is a similar module but cheaper and not stable, and in this post I’m using one of them.

 

So the HMC5883L or QMC5883 are called digital compass, they are detecting the magnetic north and calculate the value comparing to it while moving, and they are very sensitive, but the cheap version which is QM5883 is more sensitive and difficult to calibrate.

While sensing the magnetic north the module can know in which direction its moving and comparing to which axis, this module has 3 axis (x, y and z) gives you three values and they change while moving, and they can be positive or negative depending on the orientation of your module, similar to the gyro that I interface it before: Interfacing L3G4200 triple axis gyro module with Arduino, but here we are detecting translating and movement, not tilting.

Wiring

to not be confused I let the HMC5883L module in the wiring because the “fake” one is marked like the real one

1

 

Library

Download library here

Codes

For i2c scan:

i2c Scanner:  Download here (it’s a separate code that uses “wire.h” library that you already have and it works with i2c devices)

For using the module:

Since the code I used is just an example of the library all you have to do after installing the library is to go to examples

(MechaQMC5883lmaster -> example -> raw)

2 thoughts on “Interfacing HMC5883L / QMC5883 Digital compass with Arduino

Add yours

    1. Hello, the main problem solved here is the issue of interfacing it with the Arduino board, for calibration you can fix your own reference then add some math operations to make it like 0,0,0 and the values will change proportionally to this reference

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: