Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

LIS3MDL compass

Hello.
I recently purchased the “AltIMU-10 v5 Gyro, Accelerometer, Compass, and Altimeter (LSM6DS33, LIS3MDL, and LPS25H Carrier)”

How do you convert the values ​​to a compass heading?

The LSM303 library does it for another type of sensor I think, but it is incompatible with mine.

Any solution please?

Hello.

We do not have an example sketch for displaying the heading for the AltIMU-10 v5. Calculating the heading requires both the accelerometer and magnetometer, so you will have to utilize readings from both the LSM6DS33 and LIS3MDL. You can look at the LSM303 header file for details on the algorithm for calculating the heading.

If you run into any issues, you can post your code here and I would be happy to take a look.

– Jeremy

At the end of this tutorial: Correcting the Balboa magnetometer
I posted code for a tilt compensated compass using the LIS3MDL magnetometer and the LSM6DS33 accelerometer on the Balboa robot. It may work “out of the box” with the AltIMU10V5, but if not, it should be rather easy to make any changes required.

Download the Arduino code, Balboa_compass2.zip at https://forum.pololu.com/uploads/default/original/2X/5/5fe1cc2523ed554e6271a7426eb1795c19ea29f9.zip

You will need to calibrate at least the magnetometer for the compass to be at all useful, so consult the above tutorial.

2 Likes

Thank you very much, Jim for your help and try to solve my problem. The Balboa solution does not work for me because my application is running on Teensy 4.0. This is the error:

Balboa32U4.h: 13: 2: error: #error "This library only supports the ATmega32U4.

Thanks Jeremy, I don’t have enough level and time to adapt the program with the help of the “LSM303 header file”.
I think the simplest thing is going to be to resort to another more powerful system to do the calculations, such as the:
"BNO055 Intelligent 9-axis absolute orientation sensor " from Bosch.

You don’t need the Balboa library to run the basic compass code. It is needed only for the LCD display.

But do you have ANY libraries for those sensors that work with the Teensy 4.0?

BTW the BNO055 is convenient, but it really does not work very well. The sensor calibration is crude and unstable, so don’t expect heading accuracy better than about +/- 5 to 10 degrees.