Swetko
Posts: 3
Joined: Mon Oct 06, 2014 2:42 am

Connect to MPU 9250 with SPI (or 6000/6500/3300) (solved)

Mon Oct 06, 2014 2:44 am

Hello,
I've been trying to connect to MPU 9250 IMU sensor. The 9250 version supports both I2C and SPI. I can successfully connect with I2C and stream data but I cannot figure out how to communicate with it via SPI. I can't even read a single register. I am debugging it with an oscilloscope and the device is not replying at all, while I can see all the communication from the Raspberry pi towards the MPU9250 + clock signal. The datasheet is kinda vague I think regarding how you have to switch between the modes.

Does anybody has experience running SPI on some of those chips (9250/6000/6500/3300). They all have the dual SPI/I2C property, and is willing to share code or any other useful experience regarding the issue.

I've been using Raspberry Pi but I am planning to try Arduino next. Eventually it's going to be read by another Microcontroller board, but I just wanted to get the initial setup with an easier platform. The raspberry pi that I am using can successfully connect with SPI to other devices.

Thank you,
Svet

User avatar
joan
Posts: 14196
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Mon Oct 06, 2014 7:37 am

Is the MPU-9250 part of a board or are you using the raw device. If it's part of a board could you link to its specs?

User avatar
jeanleflambeur
Posts: 157
Joined: Mon Jun 16, 2014 6:07 am
Contact: Website

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Mon Oct 06, 2014 10:41 am

I've spent one week trying to get a 9250 board to talk to the raspberry pi through SPI without any success. It's this Drotek IMU - http://www.drotek.fr/shop/en/home/466-i ... s5611.html and my efforts are documented here:
http://jeanleflambeur.wordpress.com/201 ... chematics/

I managed to talk to the MS5611 barometer but the 9250 never responded. The invensense forums are full of posts from ppl trying to get SPI to talk.
I switched to i2c in the mean time and it's fast enough to sample gyro and acc data at 1Khz.

Swetko
Posts: 3
Joined: Mon Oct 06, 2014 2:42 am

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Tue Oct 07, 2014 8:10 pm

Hi,
joan, it's this small pcb board: http://www.ebay.com/itm/CJMCU-116-MPU92 ... 4180948b64

My plan was to figure out the details with this prototype board and then design my own PCB, because I am quite space constrained.

jeanleflambeur, thank you for the links. I will take a loot at them later today. I hope the SPI is not a lost cause because I would really like the 8 KHz updates.

By the way, do you know of a similar sensor to MPU 9250 that has a working SPI connection: low noise 16 bit 9 DOF with high update rates for the Accelerometer and the Gyro? I like the performance of the MPU 6050 (I2C acc+gyro), which I am currently using, but it's only I2C and no magnetometer.

User avatar
joan
Posts: 14196
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Tue Oct 07, 2014 8:33 pm

What have you tried to get it into SPI mode? The obvious thing is to connect NCS to ground.

Swetko
Posts: 3
Joined: Mon Oct 06, 2014 2:42 am

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Wed Oct 08, 2014 9:39 pm

I solved the problem finally. It was very basic mistake. You have to read section 7.5 from the datasheet carefully. It says when reading registers you have to add 0x80 to the address. I wasn't doing that so all my communications were writes, hence no response from the MPU. Also the communication wasn't working when I had the oscilloscope probes attached as well.

User avatar
jeanleflambeur
Posts: 157
Joined: Mon Jun 16, 2014 6:07 am
Contact: Website

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Mon Oct 13, 2014 9:01 pm

Swetko wrote:I solved the problem finally. It was very basic mistake. You have to read section 7.5 from the datasheet carefully. It says when reading registers you have to add 0x80 to the address. I wasn't doing that so all my communications were writes, hence no response from the MPU. Also the communication wasn't working when I had the oscilloscope probes attached as well.
Glad you got it working. I think you're the second person on the whole internet to get SPI working with the 9250... I have so many questions (:
Can you post the register values you use to initialize the 9250?
Do you have to disable i2C on the 9250? If yes, how?
How did you wire the chip?
Can you sample at 8Khz?
What is the SPI mode you're using on the Raspi?

Thanks a lot!

srinivasporam
Posts: 4
Joined: Sun Sep 06, 2015 12:23 pm

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300) (solve

Sun Sep 06, 2015 12:29 pm

Dear Swetko,
I also got Raspberry pi board with which i have interfaced mpu9250 in i2c mode and could able to get the data. But i would like to try it in spi mode.

I tried connecting it in spi mode, but with no success. Can please send the code to check whether my device working properly or not.

jvdijk
Posts: 1
Joined: Thu Feb 04, 2016 1:05 pm

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300) (solve

Thu Feb 04, 2016 1:10 pm

Hi,

You have to give some delay (10 microsec) after the wake-up and after i2c disable. That worked for me with the drotek versions of the sensors 9150 and 6000.

pgrijalva
Posts: 1
Joined: Sat Aug 20, 2016 4:41 pm

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Sat Aug 20, 2016 4:48 pm

Swetko wrote:I solved the problem finally. It was very basic mistake. You have to read section 7.5 from the datasheet carefully. It says when reading registers you have to add 0x80 to the address. I wasn't doing that so all my communications were writes, hence no response from the MPU. Also the communication wasn't working when I had the oscilloscope probes attached as well.
Can you share the code?

hzaheri
Posts: 1
Joined: Fri Dec 16, 2016 9:48 am

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300) (solve

Fri Dec 16, 2016 12:26 pm

hi i want to do all these!!! can you send your code?

naswanziq
Posts: 3
Joined: Mon Mar 27, 2017 7:36 am

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300)

Mon Mar 27, 2017 7:39 am

Hey could u show a tutorial on how u get it to connect? Thank you!

gothge
Posts: 1
Joined: Mon Apr 10, 2017 10:27 pm

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300) (solve

Mon Apr 10, 2017 11:47 pm

one can use RTIMULIB.

https://github.com/RTIMULib/RTIMULib2

Otherwise simply talk the the MPU via SPI. Read/write a register by starting with the register and add 0x80, then send data to write or zeros as placeholder for each byte you want to read.

To connect it electical :

Raspi to 9250
miso - sdo
mosi - sdi
slck - sclk
cs0 - ncs (or cs1/cs2)

Runs well with either spidev0(0|1) or spidev1(0,1,2)

bobes131
Posts: 1
Joined: Mon Aug 19, 2019 10:56 pm

Re: Connect to MPU 9250 with SPI (or 6000/6500/3300) (solved)

Mon Aug 19, 2019 10:57 pm

Hello, what mode of SPI did you use?
Thank you :)

Return to “Troubleshooting”