Skip to main content
20 votes
Accepted

Converting three-axis magnetometer values to degrees

The answer given by Dave X, namely az=90-atan(y/x)*180/pi is on the right track. However, it cannot work as is for two reasons: The formula fails badly whenever x = 0, It gives the same azimuth for ...
Edgar Bonet's user avatar
  • 43.3k
5 votes

Converting three-axis magnetometer values to degrees

You first need calibration (either using the device calibration method, or, by rotating it in a complete circle to ascertain the full field strengths). You can then use the X, Y, and Z readings to ...
Anon Coward's user avatar
4 votes
Accepted

Does the position in which you mount an IMU matter?

If the axes of measurement don't line up with the axes of motion, then comparing the IMU outputs to vehicle-relative (VR) coordinates will require some vector arithmetic to convert one to the other. ...
JRobert's user avatar
  • 15.3k
4 votes

Converting three-axis magnetometer values to degrees

I wanted to expand upon what Anon is getting at and provide some math as I've just gone through this process for a similar 9-axis device. First, it's good to know what the magnetic field vector means. ...
Tails86's user avatar
  • 149
3 votes

Adafruit_LSM303 tilt compensated compass

The sin() and cos() functions expect their arguments to be in radians. If you feed them with anything else, be it degrees, percent slope, or whatever, expect the result to be just crap. Edit: The OP ...
Edgar Bonet's user avatar
  • 43.3k
3 votes
Accepted

Why am I getting wrong compass heading using magnetometer readings?

Consider calibrating your magnetometer. Off the shelf, almost all magnetometers require calibration before making use of their data. The offset (commonly referred to as Hard Iron) and the magnitude (...
st2000's user avatar
  • 7,340
2 votes
Accepted

Where can I find magnetic declination lookup table?

No, the North pointed by GPS coordinates are extracted using the velocity heading which would represent the true North. If you get the ECEF (earth centered earth fixed) coordinates from the GPS you ...
brtiberio's user avatar
  • 926
2 votes
Accepted

adafruit LSM9DS0 Library - ok with Uno but compile error with LinkitOne?

The Adafruit library for the LSM9DS0 is written to run on an 8-bit Arduino. The LinkitOne isn't - it's an ARM board. Either get a different library that is written to work on ARM, write your own ...
Majenko's user avatar
  • 105k
2 votes
Accepted

FIXING BUG when Using Wire library to obtain compass heading

The problem comes from the low-pass filter you are using: // Smoothing the output angle / Low pass filter headingFiltered = headingFiltered*0.85 + headingDegrees*0.15; This filter is designed to ...
Edgar Bonet's user avatar
  • 43.3k
1 vote
Accepted

Adafruit_LSM303 tilt compensated compass

Via this Youtube movie I found a different library and made this code: #include <SPI.h> #include <Wire.h> #include <LSM303.h> const int centreX = 160; const int centreY = 120; ...
Roel's user avatar
  • 49
1 vote

How to calibrate MMC5603 magnetometer

To calibrate a magnetometer you should perform hard-iron and soft-iron calibration. There's some guides online about how to do this but I found this digikey guide to be the most informative. Adafruit ...
Richard Beattie's user avatar
1 vote
Accepted

Quaternion values from Arduino 9-axis motion shield seem very wrong

I am not familiar with this sensor, so I am just guessing. The sensor is likely giving you fixed-point numbers. Judging from the real part, there are most likely 14 bits right of the implicit radix ...
Edgar Bonet's user avatar
  • 43.3k
1 vote
Accepted

Setup/Debug affordable 9DOF IMU

I re-soldered all connections and used new wires. Now the board is recognized by the i2cdetect library. Upon multimetering all connections using the continuous mode (the one that looks like a ...
user2305193's user avatar
1 vote
Accepted

MPU-9250 compass always returns to zero

Ok, I have finally found the issue, and I am feeling very, very stupid. I needed to calibrate the magnetometer with the figure-8 movement I put a gigantic solid-metal 18650 Li-ion cell right next to ...
Twometer's user avatar
  • 123
1 vote

LSM9DS1 breakout - How to increase speed

Here is a link to the LSM9DS1 datasheet. In Chapter 3 it describes how to put the device in Accelerometer-only mode. At a quick scan of it, I believe there was timing information also, but at least ...
JRobert's user avatar
  • 15.3k
1 vote
Accepted

LSM9DS1 breakout - How to increase speed

Check the header of the library, you will find readAccel readMag readGyro and readTemp in separate public functions and looking at the implementation of read it just calls those 4 in sequence. ...
ratchet freak's user avatar
1 vote

How to read the raw data from GY-85 module?

One of the places where the datasheets for the sensors of the GY-85 module can be found is here: https://www.hotmcu.com/gy85-9dof-imu-sensor-module-p-298.html The following information comes from ...
PimV's user avatar
  • 443
1 vote

How to filter or eliminate earths magnetic field readings around 3D Magnetic sensor?

Earth magnetic field is pretty constant. In your measurements it will show up as an offset that you could subtract, but of course it will change if the sensor rotates. Whatever measurement noise you ...
Dmitry Grigoryev's user avatar
1 vote

How to filter or eliminate earths magnetic field readings around 3D Magnetic sensor?

One option is a magnetic gradiometer. This consists of two magnetometers, which are placed at different distances from the local magnet (one close, one far). You subtract the readings to eliminate ...
MichaelT's user avatar
  • 887
1 vote

Passing reference to hardware between methods in custom class

I don't think you are creating instances of these classes correctly. Instead of: CDSensors* LSensors = &CDSensors (0); CDSerialPrint* LSerialPrint = &CDSerialPrint (0); ...
Nick Gammon's user avatar
  • 38.4k
1 vote

Issue with code for SDA/SCL TC9548A Multiplexer and HMC5883L sensors

I'm sure you have, but have you connected the grounds together? Have you tried 1 sensor on SD/C0 and then moving it to SD/C1 it should stop working, so the fault has to be with SD/C0. Looking at ...
Code Gorilla's user avatar
  • 5,637
1 vote

HMC5883L - Tilt compensation without Accelerometer

You can always use the normal tilt compensation equations with a fixed value instead of a calculation from the accelerometer; Since you know the rotation beforehand the equations may not be as complex....
BrettFolkins's user avatar
  • 4,431
1 vote

MPU-9250 IMU on SPI, external sensor or magnetometer using I2C master

It turns out that my mistake was in the SPI communication code, but nevertheless here is some info because it's not very obvious. I went over the top and: Review the electrical interface to see ...
cJ Zougloub's user avatar
1 vote
Accepted

3.3v inductive proximity sensors

I don't know what voltages inductive proximity sensors use, but in general it's inexpensive to use 3.3V–5V logic level converter modules. These typically are bi-directional interfaces that use an N-...
James Waldby - jwpat7's user avatar
1 vote

Problems reading I2C sensor when using a Xbee module

I have solved the problem by adding a delay just before I select the continuous measurement mode. void setup(){ //Initialize Serial and I2C communications Serial.begin(9600); Wire.begin(); //...
Alejandro Harris Bonet's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible