Accéder au contenu principal

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 :


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.


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




Download library here


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)


Yassine Tout afficher

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

15 commentaires sur “Interfacing HMC5883L / QMC5883 Digital compass with Arduino Laisser un commentaire

    • 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


  1. Thank you for the video and information. I also had the same problem. I thought I damaged by board, but then found this info and realized they sent me the module with the fake chip. I complained and got a refund.


  2. I would love to make a puppet head that mimics man head in 3axis .Using 3 servos that puppet moves its head same as the master person moves his head. Where the 3 axis sensor is put on the person head and sends the signal through RF or bluetooth to a recever arduino that controls 3 servo of puppet head. Can anyone please heal with this code ?


    • Hello, it depends on what movements are you trying to mimic, don’t forget there are 3 translations and 3 rotations, this module only picks up the translating ones, if you’re willing to detect the head tilt and node you’ll need a gyro module like « L3G4200 », or the six of them by using « MPU-6050 ».
      Sorry I still haven’t tried them for projects but I recommend you to check some « Gesture controlled cars » projects.



Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google

Vous commentez à l'aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

%d blogueurs aiment cette page :