Missing Definitions
For anyone who needs help getting the MPU-9250 working with SPI, the library with an example is
here.
Hi BrianC, thank you for your sample code!
I know this thread is already a year and a half old, but I've been trying to get SPI to work with my MPU9250 for a while, and have been having a hard time finding any good information on this. I really need to use SPI rather than I2C because I want to read multiple MPUs, but I2C can't distinguish between them because they all have the same hardware address. I'm not sure if your code is written for multiple MPUs, but I'm thinking that if I can at least get it to work, then maybe I can tweak it to work for multiple MPUs.
However, It seems that your code is referencing some things that are not in the attached MPU9250 library. You have a line that says "MPU9250 mpu(SPI_CLOCK, SS_PIN);" but I don't see that defined anywhere in the library, and it's throwing an error...
Also, the code calls this "read_all()" function, but I noticed that read_all() starts off with I2C commands. Is this right? I'm not clear on why an SPI sketch is calling I2C commands. Should I be using a different library than the one attached maybe?
Lastly, I'm not clear about how the pins should be connected. I'm guessing I should have:
- VCC on my Arduino to VCC on my MPU
- GND on my Arduino to GND on my MPU
- SS_PIN on my Arduino to NCS on my MPU
Is that correct? And if so, what about these two?
- INT_PIN on my Arduino to ??? on my MPU
- SCK (serial clock)??? I don't see that in the code anywhere, but I read that it's needed to syncronize devices in SPI.
I really appreciate any help I can get here! Thanks!