bolderflight / invensense-imu

Arduino and CMake library for communicating with the InvenSense MPU-6500, MPU-9250 and MPU-9255 nine-axis IMUs.
MIT License
508 stars 213 forks source link

wrong heading angle from the magnetometer #58

Closed alieng1994 closed 3 years ago

alieng1994 commented 5 years ago

Hi , thanks for the great job you doing my problem is I'm getting wrong value for heading angle and I,m using your library and calibration method to calculate the headeing so can you help me? thanks

bevinhex commented 4 years ago

first make sure you get the right axis, if you rotate the sensor on z axis, z axis magnetometer value should stay pretty much same, same goes for other axis, so that you can map the output of the library to right axis for your program. in my case Y & X is switched. secondly, you need to find the right direction of each axis, I install and app on android for seeing magnetometer data, its x axis should be right side, so I move a magnet closer to right side of the phone, see the sensor output change on x axis, then I do the same for sensor's determined x axis, if it is increasing as phone did, it is correct, if it is doing opposite, just put minus to the library output. In case you want to calibrate it afterwards, there is a program called "magneto1.2", it was for windows, but I'm able to use it with wine. Hope this helps.

Ananfruit commented 4 years ago

Can you share the code when you calibrate your accel and gyro, please? Thanks in advance!

alieng1994 commented 4 years ago

first make sure you get the right axis, if you rotate the sensor on z axis, z axis magnetometer value should stay pretty much same, same goes for other axis, so that you can map the output of the library to right axis for your program. in my case Y & X is switched. secondly, you need to find the right direction of each axis, I install and app on android for seeing magnetometer data, its x axis should be right side, so I move a magnet closer to right side of the phone, see the sensor output change on x axis, then I do the same for sensor's determined x axis, if it is increasing as phone did, it is correct, if it is doing opposite, just put minus to the library output. In case you want to calibrate it afterwards, there is a program called "magneto1.2", it was for windows, but I'm able to use it with wine. Hope this helps.

Thank you for your help the was my sensor is fake one

alieng1994 commented 4 years ago

Can you share the code when you calibrate your accel and gyro, please? Thanks in advance!

I used app on widows called magneto 1.2 to calibrate