Go Down

Topic: Looking for help with HMC5883L compass from other users (Read 20957 times) previous topic - next topic


Well it seems that if I bonk the chip with the screwdriver it stops doing it, this is both chips. I reckon I'll wait until I get more chips.


I have had no luck getting valid readings on several different boards. I ordered the Seeed Studio board which has a chip with the M883 ID and it works fine. I am going to try replacing the chip and attempt to use the least amount of heat possible to see what happens.


Oops forgot to update my results.  I switched to solely mounting the chips using Hot Air Rework and have had zero problems since.  I've assembled close to 20 boards and everything checks out. I have a little matrix I put together for checking the board with a continuity meter that seems to show whether or not the board is working before powering it up.  If anyone is interested I can post it later when I get home.

@Subpilot, keep in mind the Seeed Studio board is based off the HMC5883 not the HMC5883L, they're different chips and not pin compatible.

I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter


OK, I'm an idiot. I have a magnet in my interface assembly. It's used for a reed switch that switches to external power when the interface is connected. Moved the magnet and low and behold it's all good. :smiley-red:


OK, I'm an idiot. I have a magnet in my interface assembly. It's used for a reed switch that switches to external power when the interface is connected. Moved the magnet and low and behold it's all good. :smiley-red:

This is such good news, makes me feel normal. I am the one who took the NACK out of the last read because there wasn't a last read when the buffer was circular and forgot to put it back in when they informed me that the buffer wasn't circular. That too sorted a lot of the problems.

It's just a damn good job we aren't running countries or something similar. :)


It's just a damn good job we aren't running countries or something similar.

Maybe it is a pity...

You guys accept you made a mistake and learn from it. There are people running countries (etc) that would not do it so easily ..
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


If you guys are still struggling with this chip there is a tutorial on the HMC5883L here: https://www.loveelectronics.co.uk/Tutorials/8/hmc5883l-tutorial-and-arduino-library

Fabio Varesano

Instead of creating your own, wouldn't have been better to improve what's already available ?



To give us all a bit more clarity, I would like to reassure some facts:

hmc5883L = L883, 7bit-address = 1E
hmc5883 = M883, 7bit-address = 1E

Ther is no address difference in these two differnet chips (?!).

However, my Experience is also twofolded. My L883 responds fine at the given address, but when I read the Registers, they behave odd.

On an arduino they work fine, but when I use them with a FEZ, the MSB of the registers X,Z,Y are either 0 or 255. This depends in what direction I turn the device. LSB is fine for both devices. I believe that I configure both the same way. Continious mode and Gain 1.3.

I mean would the MSB of the axis max / min out if gain is wrong?

The only difference between these mcu is the voltage on the I2C. Is that the reason?



I understand you exactly when you say two folded - I also had same experience - but luckily solved with help of that forum.
I originaly interfaced HMC5883L with plain C from beaglebone embbeded linux platform.
I was getting strange values if I turned device for around 90 degrees - values were like 65231, etc, but originaly when device was on desk they were like normall (around 0 to 10) - I am talking about raw data obtained by:

Code: [Select]

  x=outputData[0] << 8 | outputData[1]; //Combine MSB and LSB of X Data output register
  z=outputData[2] << 8 | outputData[3]; //Combine MSB and LSB of Z Data output register
  y=outputData[4] << 8 | outputData[5]; //Combine MSB and LSB of Y Data output register

I resolved issue properly declaring x, y and z variables with:

Code: [Select]

     short x,y,z=0;

instead of:

Code: [Select]

     int x,y,z=0;

maybe that's also true for rest of you that you have similar problems.

I am attaching working code in plain C.


Apr 17, 2012, 07:03 pm Last Edit: Apr 17, 2012, 07:07 pm by sbright33 Reason: 1
I had difficulties with this chip too.  I found my heading was off by sometimes 90 degrees, other times about correct, but always the same error depending on your heading.  I'm not using tilt compensation, yet.  See my thread here.  To fix this I rotated the unit 90 degrees about the Y-axis.  Now I'm using X and Z instead of X,Y to get the heading, much better.  Don't pay attention to those specifics.  If you're having a problem like mine, try using 2 different axis instead.  Change the code by 1 char, and rotate it 90 deg.  It's that simple.  Not sure what you'd do if you wanted to see all 3.  Will let you know.

I found an easy way to do (limited) tilt compensation, without ANY additional math.
See other thread.

If you fall... I'll be there for you!

Skype Brighteyes3333
(262) 696-9619


Hello, guys. Hope that this topic is not "dead" :).
I have a trouble with HMC5883L. I bought 2 sensors, soldered on board w/o any other parts. Connected all parts as in datasheet, but still can't get this sensor working.
I have read all of this posts and checked voltage on pins 8, 12 and 10. I do not have 2V on those pins.
Is it possible that both sensors are dead (maybe burnt while soldered or something)?
Every connection is double-checked, power pins all have 3.3V on them.

Thank you all.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131