FemmeVerbeek / Arduino_LSM9DS1

LSM9DS1 Library for Arduino
Other
63 stars 14 forks source link

Pitch affecting Yaw #18

Closed ransa808 closed 3 years ago

ransa808 commented 3 years ago

Hi

First of all thank you very much for this library, the calibration process was very clear and looks like you invested a lot of time in it.

After a successful calibration I tried to calculate Yaw, Pitch, Roll using your Accelerometer and Magnetometer examples Looks like the pitch and roll are accurate, the magnetometer values looks good when comparing it to my iPhone's compass for example but when I pick up the board and change it's pitch the magnetometer direction seems to change with no reason. Am I missing something here ? I want to be able to measure the direction exactly like a compass.

Thank you

FemmeVerbeek commented 3 years ago

Hi Ransa808 thx for the compliment and yes it was a lot of work. My corona project. The problem you mention is caused by the vertical component of the Earth magnetic field. The example program is just a simple XY compass. Unless you live at the equator, the direction of the earth's magnetic field is not horizontal. If you tilt the sensor further than the steepness of the field the XY sensor suddenly measures a 180 degree change in direction similar to what happens if you cross the magnetic pole. My purpose was to demonstrate the use of the magnetic sensors and calibration in a simple as possible program. Feel free to make it more advanced.