Adafruit LSM303AGR compass

I only get headings between 200 and 260 (not 0 to 360) with the board. I am using a uno board and I think I followed the adafruit instruction for the board.

Do you mean these instructions:

AdaFruit usually has example code as well. What have you tried?

Hey Mark,
Yes, those are the instructions I followed. I wired up the four wires from the board to my Uno, loaded all the libraries and uploaded the compass sketch ( Open up File -> Examples -> Adafruit LIS2MDL-> compass).

Did you calibrate the magnetometer, in its final mounting?

Unless that is done correctly, the magnetometer won't give useful results.

Not being familiar with the compass, and maybe a daft question, but your thread title says LSM303AGR but you indicated the code you are using is for an LIS2MDL? Are they interchangeable or are they 2 completely different devices?

Good point, the LSM303AGR and LIS2MDL are completely different devices.

I wondered the same thing but, the adafruit instructions say for the LSM303AGR I should open File -> Examples -> Adafruit LIS2MDL -> magsensor That is what I did.

Sorry, what I meant to say the instructions say to open File -> Examples -> Adafruit LIS2MDL -> compass for the LSM303AGR, that is what I did.

I don't see any mention or instructions for "calibrating" the sensor.

It is required to calibrate a magnetometer. They don't work out of the box.

Adafruit has tutorials and code, then there is this comprehensive tutorial:

Just had a look at the AdaFruit github page for the LIS2MDL. It says "This library is for the Adafruit LIS2MDL and LSM303AGR Breakouts" so that clears that up. The example code looks simple enough.

AdaFruit have a good support - have you checked their support forums to see if anybody else has experienced the same problem?

I did a search for LSM303AGR in their forums and there are posts on calibration. You may be able to pick up some tips.

I put my questions on Adafruit forum. Thanks for the suggestion.

I don't see any adafruit tutorial on how to calibrate a compass. They have a "calibration" sketch. But, all it does is report the minimum and maximum values for the X, Y and Z readings.

I am not sure what you are talking about.

Also, the Tutorial for the Underwater Arduino Data Logger is way beyond my capability to understand.

How could you POSSIBLY have missed this Adafruit tutorial to calibrate a magnetometer? Do brush up on your search skills!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.