This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mpu9250 magnetometer zero readings

hi,

10040 nrf52dk softdevice 132 v2. keil ide I am trying to read magnetometer values so that i can calibrate it using this method. For this to happen, i need magnetometer, accelerometer and magnetometer values. However, im not able to obtain the correct magnetometer values. I'm getting 0000 as values in all directions. here is my code. Also i have used the nrf5 mpu magnetometer example code as the basis.

any help will be greatly appreciated.

edit: From trail and error, i understoood that the issue is with err_code/ret_code. But i have no idea on how to solve it.

  • No, the issue has not been resolved. Here’s what I found out about it.

    1. Mpu9250 uses imu6500 and ak8963. So, I changed the code such that the magnetometer part of app_mpu.h accepts only mpu9250.

    2. I’m unable to read or write the magnetometer. It might be because of having ak8963_adr wrongly defined. However, I verified it and it was right (0x0C). All the other registers were defined correctly.

    3. I get 0s because the magn read and write functions doesn’t work at all.

    I’m working on it continuously. Any help will be greatly appreciated.

  • No, the issue has not been resolved. Here’s what I found out about it.

    1. Mpu9250 uses imu6500 and ak8963. So, I changed the code such that the magnetometer part of app_mpu.h accepts only mpu9250.

    2. I’m unable to read or write the magnetometer. It might be because of having ak8963_adr wrongly defined. However, I verified it and it was right (0x0C). All the other registers were defined correctly.

    3. I get 0s because the magn read and write functions doesn’t work at all.

    I’m working on it continuously. Any help will be greatly appreciated.

  • I see the problem very simple: there is some embedded sensor module/chip which has defined some wired (serial) interface over TWI/I2C/SPI/QSPI/UART/whatever. You should attach logical analyzer to the wires and simply compare what you see (= what you send from nRF5x chip as master) with what is written and shown on examples in specification of that sensor. I bet you will see the problem straight away. If you want us to do this comparison job for you then at least provide us with these traces from wired interface (sorry but "I verified and it was right" doesn't look very convincing here if it doesn't work;).

  • Hi, Thank you for the help. The problem has been solved. The issue was with my mpu9250. I changed it and I was able to obtain the output.

Related