MPU9250 via SPI

Hi all,

I’m having problems accessing the magnetometer data from a MPU9250 via SPI (I’m using a RFduino). The accelerometer and gyroscope values are coming through fine via SPI but the magnetometer readings are still zero even though I’m accessing it via I2C, etc. etc. Can you guys take a look at the code and see where I’m going wrong?

Thanks!
Will

MPU9250_SPI.ino (4.38 KB)

mpu9250_spi.zip (5.35 KB)

I'm having problems accessing the magnetometer data from a MPU9250 via SPI

but the magnetometer readings are still zero even though I'm accessing it via I2C

Can you clarify how the device is attached, and how you are accessing the data? Is it SPI or I2C?

The device is attached to the GPIO2 thru GPIO 5 pins of the RFduino.

I'm accessing the data via SPI but within the IMU chip, the magnetometer is separate from the accelerometer and gyroscope. It's an AK8963 chip that can't be accessed via SPI. From my understanding, I have to set the AK8963 as an I2C slave to access the magnetometer data. Internally, the AK8963 sends data via I2C to the IMU but from the IMU to the Rfduino, it can be SPI.

I hope that made sense.

The device is attached to the GPIO2 thru GPIO 5 pins of the RFduino.

Are those the SPI pins? On an Arduino, they are not.

Internally, the AK8963 sends data via I2C to the IMU but from the IMU to the Rfduino, it can be SPI.

Then, you would be reading the data from the IMU, using SPI. How the IMU and the AK8963 communicate is no concern of yours.

PaulS: Are those the SPI pins? On an Arduino, they are not. Then, you would be reading the data from the IMU, using SPI. How the IMU and the AK8963 communicate is no concern of yours.

Yes they are the SPI pins for a Rfduino.

I'm not entirely sure if I get what you mean. I have to configure the IMU to be able to access the AK8963 data and I am unable to do that at the moment.

Hello willdeng,
i have the same problems to use internal i2C
with spi.
do you find a solution ?
tthanks

Hi pabpab,

It turns out my code was fine but on my custom board I had not connected pin 1 of the MPU9250 to VDDIO. The data sheet that invensense supplies has a discrepancy. On one page it says that it needs to be connected and on another it shows it as floating. This solved the problem for me so I hope that this might help in your situation.

Will