MPU6500 6DOF SPI not working

Keep getting status error (-5) with my current wiring. I assume I have to change some things because the code I’m using is for the 9dof sensor MPU9250 and I’m using a MPU6500. Seem to have no problem getting I2C to work however for my project I want to use SPI.

Wiring is as follows:
• SDA / SDI: connect to MOSI. 11
• SCL / SCLK: connect to SCK. 13
• AD0 / SDO: connect to MISO. 12
• nCS: connect to chip select pin. Pin 10
Vcc to 5v
Ground to ground

Does anyone have an idea how i can get spi to work on my 6500 sensor

See code below.

/*
Basic_SPI.ino
Brian R Taylor
brian.taylor@bolderflight.com

Copyright (c) 2017 Bolder Flight Systems

Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
and associated documentation files (the "Software"), to deal in the Software without restriction, 
including without limitation the rights to use, copy, modify, merge, publish, distribute, 
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or 
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "MPU9250.h"

// an MPU9250 object with the MPU-9250 sensor on SPI bus 0 and chip select pin 10
MPU9250 IMU(SPI,10);
int status;

void setup() {
  // serial to display data
  Serial.begin(115200);
  while(!Serial) {}

  // start communication with IMU 
  status = IMU.begin();
  if (status < 0) {
    Serial.println("IMU initialization unsuccessful");
    Serial.println("Check IMU wiring or try cycling power");
    Serial.print("Status: ");
    Serial.println(status);
    while(1) {}
  }
}

void loop() {
  // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelY_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelZ_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroX_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroY_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroZ_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagX_uT(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagY_uT(),6);
  Serial.print("\t");
  Serial.print(IMU.getMagZ_uT(),6);
  Serial.print("\t");
  Serial.println(IMU.getTemperature_C(),6);
  delay(100);
}

The MPU6050 is a 3.3V only device. If you are using a 5V Arduino, you must have level shifters.

jremington:
The MPU6050 is a 3.3V only device. If you are using a 5V Arduino, you must have level shifters.

You're right about this the MPU6500 (not 6050) has a VDD Supply voltage range of 1.71-3.45V. I've tried a different MPU6500 6dof sensor with the 3.3 supply voltage of the arduino but I have gotten the same error.

As far as I know the entire MPUxxxx family from InvenSense consists of 3.3V devices.

with the 3.3 supply voltage of the arduino

If the Arduino is 5V and you don't use level shifters on the I/O lines, you will destroy the sensor and possibly damage the Arduino.

Use a 3.3V Arduino and your troubles should go away (although you may need new sensors as well).

jremington:
As far as I know the entire MPUxxxx family from InvenSense consists of 3.3V devices.
If the Arduino is 5V and you don't use level shifters on the I/O lines, you will destroy the sensor and possibly damage the Arduino.

Use a 3.3V Arduino and your troubles should go away (although you may need new sensors as well).

I see thank you i will try it out with a new arduino, new sensor and a level shifter in order to rule out some possible damage to my arduino or sensor.

With a 3.3V Arduino, you don't need level shifters.

Alternatively, if you are very careful, you can use I2C between a 5V and 3.3V device without level shifters. This is because the I/O lines are not actively driven HIGH. However, you must make certain that the required pullup resistors on SDA and SCL are connected to 3.3V and not to 5V.

With SPI, the I/O lines are driven to 5V by the 5V device, which is why you can destroy 3.3V devices by trying to use SPI from a 5V device without level shifters.

jremington:
With a 3.3V Arduino, you don't need level shifters.

Alternatively, if you are very careful, you can use I2C between a 5V and 3.3V device without level shifters. This is because the I/O lines are not actively driven HIGH. However, you must make certain that the required pullup resistors on SDA and SCL are connected to 3.3V and not to 5V.

With SPI, the I/O lines are driven to 5V by the 5V device, which is why you can destroy 3.3V devices by trying to use SPI from a 5V device without level shifters.

Since i do not have a arduino that has i/o lines with 3.3V nor do i plan on conversing my Arduino Uno to a 3.3volt i/o device and since i don't own a level shifter i tried to replicate the level shifters effect with a voltage divider consisting of 3.3k ohm resistors and 1.7k ohm resistors.
• SDA / SDI:
• SCL / SCLK:
• AD0 / SDO:
• nCS:
so al these are connecter to a voltage divider (so not all on the same).

Using the same wiring as above but switching Vcc to 3.3V i'm getting status error -1. Would you happen to know if this is a hardware issue or this is due to the fact that i'm using a code for the mpu9250 or a way for me to find this out?