kriswiner/MPU9250

Cannot connect to MPU-9250. It returns 0x73 instead of 0x71

Opened this issue ยท 63 comments

So everytime i try to connect, it prints this message -

MPU9250 I AM 73 I should be 71
Could not connect to MPU9250: 0x73

I have completed i2c scans and received raw data from my sensor before so i'm not sure what i'm doing wrong. Thanks in advance

Change the check to 0x73 and see if the sensor data appears. It's likely you
changed a register address or have some other typo there.

-----Original Message-----
From: Poley09 [mailto:notifications@github.com]
Sent: March 7, 2016 10:12 AM
To: kriswiner/MPU-9250
Subject: [MPU-9250] Cannot connect to MPU-9250. It returns 0x73 instead of
0x71 (#47)

So everytime i try to connect, it prints this message -

MPU9250 I AM 73 I should be 71
Could not connect to MPU9250: 0x73

I have completed i2c scans and received raw data from my sensor before so
i'm not sure what i'm doing wrong. Thanks in advance

Reply to this email directly or view it on GitHub
#47 .
<https://github.com/notifications/beacon/AGY1qknCKI7YEQekWKGRA3uH69f5888sks5
prGqNgaJpZM4HrByj.gif>

it now displays

MPU9250 I AM 73 I should be 73
Could not connect to MPU9250: 0x73

https://github.com/Poley09/9250/tree/master/_9250_code

thats what im using, it should be the exact same without the display.

It checks that the byte read in the register is what is expected. Change the
expected value to 0x73 not the display value.

-----Original Message-----
From: Poley09 [mailto:notifications@github.com]
Sent: March 7, 2016 10:37 AM
To: kriswiner/MPU-9250
Cc: Kris Winer
Subject: Re: [MPU-9250] Cannot connect to MPU-9250. It returns 0x73 instead
of 0x71 (#47)

it now displays

MPU9250 I AM 73 I should be 73
Could not connect to MPU9250: 0x73

Reply to this email directly or view it on GitHub
#47 (comment) .
<https://github.com/notifications/beacon/AGY1qioCCYnYeX8ddg5gK8c9N4vF09W7ks5
prHBLgaJpZM4HrByj.gif>

// Read the WHO_AM_I register, this is a good test of communication

byte c = readByte(MPU9250_ADDRESS, WHO_AM_I_MPU9250); // Read WHO_AM_I
register for MPU-9250

Serial.print("MPU9250 "); Serial.print("I AM "); Serial.print(c, HEX);
Serial.print(" I should be "); Serial.println(0x73, HEX);

if (c == 0x71) // WHO_AM_I should always be 0x68

{

Serial.println("MPU9250 is online...");

Change this to 0x73; what MPU9250 module are you using?

-----Original Message-----
From: Poley09 [mailto:notifications@github.com]
Sent: March 7, 2016 10:44 AM
To: kriswiner/MPU-9250
Cc: Kris Winer
Subject: Re: [MPU-9250] Cannot connect to MPU-9250. It returns 0x73 instead
of 0x71 (#47)

https://github.com/Poley09/9250/tree/master/_9250_code

thats what im using, it should be the exact same without the display.

Reply to this email directly or view it on GitHub
#47 (comment) .
<https://github.com/notifications/beacon/AGY1qhZx1ae3FrYo0mxA9P4Dk0ER079gks5
prHIJgaJpZM4HrByj.gif>

Yep, sorry I was being stupid and looking in the complete wrong part, it all works now thank you

I was wondering if you could help me with another problem. when perfectly still at rest, i get values around yaw = 128.5 pitch = 3.2 and roll = -1/1 how would i go about getting them to 0 on rest? and im wanting them to control pan/tilt servos with yaw and pitch. However the yaw doesnt seem to be changing when moving it in any direction not just the y axis. i dont know whether there is a mistake somewhere as my pitch and roll seem to be mixed up aswell. thanks

How did you calibrate your sensors?

-----Original Message-----
From: Poley09 [mailto:notifications@github.com]
Sent: March 7, 2016 3:08 PM
To: kriswiner/MPU-9250
Cc: Kris Winer
Subject: Re: [MPU-9250] Cannot connect to MPU-9250. It returns 0x73 instead
of 0x71 (#47)

I was wondering if you could help me with another problem. when perfectly
still at rest, i get values around yaw = 128.5 pitch = 3.2 and roll = -1/1
how would i go about getting them to 0 on rest? and im wanting them to
control pan/tilt servos with yaw and pitch. However the yaw doesnt seem to
be changing when moving it in any direction not just the y axis. i dont know
whether there is a mistake somewhere as my pitch and roll seem to be mixed
up aswell. thanks

Reply to this email directly or view it on GitHub
#47 (comment) .
<https://github.com/notifications/beacon/AGY1qnESWBJ4sWGu-RDKwUuO2bPvLpOQks5
prK_UgaJpZM4HrByj.gif>

You can PM me at onehorse@earthlink.net.

Take a look here:

https://github.com/kriswiner/MPU-6050/wiki/Simple-and-Effective-Magnetometer
-Calibration

Kris

-----Original Message-----
From: Poley09 [mailto:notifications@github.com]
Sent: March 7, 2016 3:58 PM
To: kriswiner/MPU-9250
Cc: Kris Winer
Subject: Re: [MPU-9250] Cannot connect to MPU-9250. It returns 0x73 instead
of 0x71 (#47)

not correctly im guessing, im not too experienced with these sensors. do you
have an email address i could speak to you on? or send one to
matthewpole@hotmail.co.uk and ill reply back to that? please and thank you.

Reply to this email directly or view it on GitHub
#47 (comment) .
<https://github.com/notifications/beacon/AGY1ql7igXZVR7IMUusb_H-XgFAJdFM7ks5
prLttgaJpZM4HrByj.gif>

I am having a similar issue. I can communicate with the board. But I get 0xA0 as the who am i value. What can change this ?

There is something very wrong if you are not reading 0x71. Can you verify with an I2C scanner that you are getting an ACK from the MPU9250? You should see 3V3 on the SDA/SCL lines and finf I2C device 0x68 or 0x69 with an I2C scan. Can you read any of the data registers?

Hi Kris,

Thanks for your response. I do get an Ack from 0x68. Which indicates
something else is wrong with the chip or it is a counterfeit. I will try
another from the batch then get more from a different sipplier.
On 4 May 2016 2:43 am, "Kris Winer" notifications@github.com wrote:

There is something very wrong if you are not reading 0x71. Can you verify
with an I2C scanner that you are getting an ACK from the MPU9250? You
should see 3V3 on the SDA/SCL lines and finf I2C device 0x68 or 0x69 with
an I2C scan.

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

It could be a bad board but if you are getting an I2C ACK this is unlikely;
it could still be that you have something wrong with the I2C read software,
or you are not supplying the proper voltage to the chip. Can you check these
things? Can you write to a control register and read it back to verify that
you are able to write?

What do you get when you read the whoami register? 0xFF?

-----Original Message-----
From: Tisham Dhar [mailto:notifications@github.com]
Sent: May 3, 2016 4:19 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

Hi Kris,

Thanks for your response. I do get an Ack from 0x68. Which indicates
something else is wrong with the chip or it is a counterfeit. I will try
another from the batch then get more from a different sipplier.
On 4 May 2016 2:43 am, "Kris Winer" notifications@github.com wrote:

There is something very wrong if you are not reading 0x71. Can you verify
with an I2C scanner that you are getting an ACK from the MPU9250? You
should see 3V3 on the SDA/SCL lines and finf I2C device 0x68 or 0x69 with
an I2C scan.

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)
<https://github.com/notifications/beacon/AGY1qui4JfwoafegUzLKTgQ-Hb2CkfU-ks5
p99fzgaJpZM4HrByj.gif>

I get 0xA0. I am using your MPU9250 demo code. Will check voltages.
On 4 May 2016 10:10 am, "Kris Winer" notifications@github.com wrote:

It could be a bad board but if you are getting an I2C ACK this is unlikely;
it could still be that you have something wrong with the I2C read software,
or you are not supplying the proper voltage to the chip. Can you check
these
things? Can you write to a control register and read it back to verify that
you are able to write?

What do you get when you read the whoami register? 0xFF?

-----Original Message-----
From: Tisham Dhar [mailto:notifications@github.com]
Sent: May 3, 2016 4:19 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

Hi Kris,

Thanks for your response. I do get an Ack from 0x68. Which indicates
something else is wrong with the chip or it is a counterfeit. I will try
another from the batch then get more from a different sipplier.
On 4 May 2016 2:43 am, "Kris Winer" notifications@github.com wrote:

There is something very wrong if you are not reading 0x71. Can you verify
with an I2C scanner that you are getting an ACK from the MPU9250? You
should see 3V3 on the SDA/SCL lines and finf I2C device 0x68 or 0x69 with
an I2C scan.

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)
<
https://github.com/notifications/beacon/AGY1qui4JfwoafegUzLKTgQ-Hb2CkfU-ks5
p99fzgaJpZM4HrByj.gif>

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

I think you are reading the wrong register. Try reading some other
registers, after you write to them

-----Original Message-----
From: Tisham Dhar [mailto:notifications@github.com]
Sent: May 3, 2016 10:44 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

I get 0xA0. I am using your MPU9250 demo code. Will check voltages.
On 4 May 2016 10:10 am, "Kris Winer" notifications@github.com wrote:

It could be a bad board but if you are getting an I2C ACK this is
unlikely;
it could still be that you have something wrong with the I2C read
software,
or you are not supplying the proper voltage to the chip. Can you check
these
things? Can you write to a control register and read it back to verify
that
you are able to write?

What do you get when you read the whoami register? 0xFF?

-----Original Message-----
From: Tisham Dhar [mailto:notifications@github.com]
Sent: May 3, 2016 4:19 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

Hi Kris,

Thanks for your response. I do get an Ack from 0x68. Which indicates
something else is wrong with the chip or it is a counterfeit. I will try
another from the batch then get more from a different sipplier.
On 4 May 2016 2:43 am, "Kris Winer" notifications@github.com wrote:

There is something very wrong if you are not reading 0x71. Can you
verify
with an I2C scanner that you are getting an ACK from the MPU9250? You
should see 3V3 on the SDA/SCL lines and finf I2C device 0x68 or 0x69
with
an I2C scan.

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)
<

https://github.com/notifications/beacon/AGY1qui4JfwoafegUzLKTgQ-Hb2CkfU-ks5
p99fzgaJpZM4HrByj.gif>

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)
<https://github.com/notifications/beacon/AGY1qgp3Nxj9hjvCzWgrPPmKk9a-m3Yuks5
p-DI0gaJpZM4HrByj.gif>

Hi,

Which register will be good control register test case. This was my first QFN soldering attempt and there might be dry joints etc. I will continue testing. Thanks for the assistance.

Make sure you set Power1 to 0x00 and then 0x01 to wake from sleep and set the clock. You could try to write to the CONFIG register. Write 0x00, then read, then write 0x03, then read. You could easily have cold solder joints which prevent power from getting to the ASIC even if you are getting an I2C ACK. Verify your code with a known good sensor. Check your solder joints for contact with the QFN side pads.

Hi, I also read the 0x73 in my WhoAmI register.
Is different MPU9250 sensor has unique value? Can I change this value myself?

The WHO_AM_I register is read only, you cannot change the MPU9250 value, but
you can change the value you compare with in the sketch to 0x73.

-----Original Message-----
From: YanJenHuang [mailto:notifications@github.com]
Sent: May 26, 2016 12:00 AM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

Hi, I also read the 0x73 in my WhoAmI register.
Is different MPU9250 sensor has unique value? Can I change this value
myself?

You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#47 (comment)
<https://github.com/notifications/beacon/AGY1qhiwuN8ycuGRxQkVTFmqu872-_Udks5
qFUTSgaJpZM4HrByj.gif>

Hi, I've been getting a similar error - the WHO_AM_I register returns "0" when I set the AD0 to 0, and "0xFF" when I set AD0 to 1. Now, I ran the I2C scanner and the device is at 0x68 - meaning, AD0 should be 0, right?
Anyway, no one else seems to have gotten "0" as the return value so I'm kinda stuck and would appreciate your help.

It sounds like there is a problem with your i2c read function or with integer types. Please tell me more about your set up, which MCU, which mpu9259 breakout and what does the i2c read code look like and maybe I can help.

Sent from my iPhone

On Jul 2, 2016, at 2:43 AM, Guy Lalkin notifications@github.com wrote:

Hi, I've been getting a similar error - the WHO_AM_I register returns "0" when I set the AD0 to 0, and "0xFF" when I set AD0 to 1. Now, I ran the I2C scanner and the device is at 0x68 - meaning, AD0 should be 0, right?
Anyway, no one else seems to have gotten "0" as the return value so I'm kinda stuck and would appreciate your help.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Thanks!

OK, so I'm using Teensy 3.2, and that Chinese purple breakout board
everyone seems to have (
http://www.play-zone.ch/en/mpu-9250-accelerometer-gyro-kompass.html).

And regarding the I2C scan - it just says "device found at address 0x68".
Seems to be recognized.

One thing I changed from the default code is the interrupt pin - I'm
connecting it to pin 22 on my Teensy, so I changed the code accordingly,
but I don't think that's the culprit, ha.

Thanks again.

On Sat, Jul 2, 2016 at 5:14 PM, Kris Winer notifications@github.com wrote:

It sounds like there is a problem with your i2c read function or with
integer types. Please tell me more about your set up, which MCU, which
mpu9259 breakout and what does the i2c read code look like and maybe I can
help.

Sent from my iPhone

On Jul 2, 2016, at 2:43 AM, Guy Lalkin notifications@github.com wrote:

Hi, I've been getting a similar error - the WHO_AM_I register returns
"0" when I set the AD0 to 0, and "0xFF" when I set AD0 to 1. Now, I ran the
I2C scanner and the device is at 0x68 - meaning, AD0 should be 0, right?
Anyway, no one else seems to have gotten "0" as the return value so I'm
kinda stuck and would appreciate your help.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/APmwYEwNega4GffYBtOC0vNmtVMaG-etks5qRnJLgaJpZM4HrByj
.

Are you pulling NCS HIGH?

-----Original Message-----
From: Guy Lalkin [mailto:notifications@github.com]
Sent: July 2, 2016 7:50 AM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

Thanks!

OK, so I'm using Teensy 3.2, and that Chinese purple breakout board
everyone seems to have (
http://www.play-zone.ch/en/mpu-9250-accelerometer-gyro-kompass.html).

And regarding the I2C scan - it just says "device found at address 0x68".
Seems to be recognized.

One thing I changed from the default code is the interrupt pin - I'm
connecting it to pin 22 on my Teensy, so I changed the code accordingly,
but I don't think that's the culprit, ha.

Thanks again.

On Sat, Jul 2, 2016 at 5:14 PM, Kris Winer notifications@github.com wrote:

It sounds like there is a problem with your i2c read function or with
integer types. Please tell me more about your set up, which MCU, which
mpu9259 breakout and what does the i2c read code look like and maybe I can
help.

Sent from my iPhone

On Jul 2, 2016, at 2:43 AM, Guy Lalkin notifications@github.com wrote:

Hi, I've been getting a similar error - the WHO_AM_I register returns
"0" when I set the AD0 to 0, and "0xFF" when I set AD0 to 1. Now, I ran
the
I2C scanner and the device is at 0x68 - meaning, AD0 should be 0, right?
Anyway, no one else seems to have gotten "0" as the return value so I'm
kinda stuck and would appreciate your help.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment),
or mute the thread

<https://github.com/notifications/unsubscribe/APmwYEwNega4GffYBtOC0vNmtVMaG-
etks5qRnJLgaJpZM4HrByj>
.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment) ,
or mute the thread
<https://github.com/notifications/unsubscribe/AGY1quOgw91j7U84DHlVxv-oVuGzck
sFks5qRnqcgaJpZM4HrByj> .
<https://github.com/notifications/beacon/AGY1qiT6FfH11nPUbUCVwDtb6NI1M29nks5
qRnqcgaJpZM4HrByj.gif>

It's not connected to anything, so I guess... not? Oops.
My connections are VCC (3.3v), GND, SCL & SDA and then the INT pin. I haven't connected anything else because all of the codes I've seen only require these five.

You have to pull NCS HIGH to put the MPU into I2C mode. Try it. And read the
data sheet.

-----Original Message-----
From: Guy Lalkin [mailto:notifications@github.com]
Sent: July 2, 2016 8:14 AM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

It's not connected to anything, so I guess... not? Oops.
My connections are VCC (3.3v), GND, SCL & SDA and then the INT pin. I
haven't connected anything else because all of the codes I've seen only
require these five.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment) ,
or mute the thread
<https://github.com/notifications/unsubscribe/AGY1qlt6D9MqNwIEbq2h4cmSYjJe5K
4fks5qRoBNgaJpZM4HrByj> .
<https://github.com/notifications/beacon/AGY1qqik1NlR5TQ9VgsUrZKI2pSxDHmtks5
qRoBNgaJpZM4HrByj.gif>

Will do. Thanks a bunch for the help!

0x73 comes from the MPU9255 in case anyone else is wondering.

I have asked Invensense about this and they haven't replied. How do you know
this, is it in the MPU9255 data sheet? I'll check...

-----Original Message-----
From: Julien Heimann [mailto:notifications@github.com]
Sent: August 22, 2016 11:05 AM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

0x73 comes from the MPU9255 in case anyone else is wondering.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment) ,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qsxyE7Ia_RhsCsHr2VW8F
tkIAeAiks5qieTggaJpZM4HrByj> .
<https://github.com/notifications/beacon/AGY1qmAnogxFtAGEa2VYdzIffIj1T0dmks5
qieTggaJpZM4HrByj.gif>

i found it in the register map document (http://stanford.edu/class/ee267/misc/MPU-9255-Register-Map.pdf) after i ran into the same issue (and i actually purchased the 9255 without realizing it)

Thanks, I just read the register map. Apparently the MPU9250 I bought on
aliexpress.com were MPU9255 too!

Kris

-----Original Message-----
From: Julien Heimann [mailto:notifications@github.com]
Sent: August 22, 2016 1:39 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

i found it in the register map document
(http://stanford.edu/class/ee267/misc/MPU-9255-Register-Map.pdf) after i ran
into the same issue (and i actually purchased the 9255 without realizing it)

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment) ,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qi1q85fXwVh-g_rQ1ksaQ
AsK6K65ks5qigjggaJpZM4HrByj> .
<https://github.com/notifications/beacon/AGY1qr-uIRFRK7GT5zFX6DTAx6YHwZGAks5
qigjggaJpZM4HrByj.gif>

I have also 0x73 chip. Is there a difference in the registers? What is the difference?

MPU9255 has WHO_AM_I of 0x73, there is some extra capability in the ASIC
that allows some additional gesture control but otherwise this chip is
identical to the MPU9250.

-----Original Message-----
From: seandepagnier [mailto:notifications@github.com]
Sent: August 28, 2016 5:08 PM
To: kriswiner/MPU-9250
Cc: Kris Winer; Comment
Subject: Re: [kriswiner/MPU-9250] Cannot connect to MPU-9250. It returns
0x73 instead of 0x71 (#47)

I have also 0x73 chip. Is there a difference in the registers? What is the
difference?

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#47 (comment) ,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qmioaWmjpP4qaLM-kR74C
iGJGwqUks5qkiL0gaJpZM4HrByj> .
<https://github.com/notifications/beacon/AGY1qqSO4wxFnhsIyFg7iagUZJuDSmdvks5
qkiL0gaJpZM4HrByj.gif>

(Created new issue, I thought, it would be more comfortable)
#include <Wire.h>
//#include "MPU6050.h"
#include "MPU9250.h"
//MPU6050 accelgyro;
MPU9250 accelgyro;
void setup()
{
Wire.begin();
byte c = accelgyro.getDeviceID();
Serial.begin(9600);
Serial.println(c);
Serial.println("\nI2C Scanner");
}

void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknow error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}

If I use MPU6050.h -- I get 2 addresses on scanner and WHO_AM_I register returns 56
If I use MPU9250.h (by Snowda) I get same 2 addresses, but WHO_AM_I responds 0.
Some parts of code in library MPU9250:

#define MPU9250_DEFAULT_ADDRESS 0xD1
#define MPU9250_MAG_ADDRESS 0x0C
MPU9250::MPU9250() {
_address = MPU9250_DEFAULT_ADDRESS;
_mag_address = MPU9250_MAG_ADDRESS;
}
...
uint8_t MPU9250::getDeviceID(void) {
_whoami = readRegister(MPU9250_WHO_AM_I);
return _whoami;
}
...
uint8_t MPU9250::readRegister(const uint8_t register_addr) {
//call sensor by address
//call registers
uint8_t data = 0;

Wire.beginTransmission(_address); 
Wire.write(register_addr); 
Wire.endTransmission(); 

Wire.requestFrom((int)_address, 1);

while(Wire.available()) {
    data = Wire.read();    // receive a byte as character
}
return data; //return the data returned from the register

}

Where is this defined?

MPU9250_WHO_AM_I

#define MPU9250_WHO_AM_I 0x75
0x75=117 -- correct register, I think.

Well, if you get an ACK on 0x68 and you are simply reading register 0x75 and getting zero return there are two possibilities:

  1. your MPU9250 breakout is garbage

  2. you I2C read code is flawed.

But it works with MPU6050 library:
#define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
#define MPU6050_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC)
#define MPU6050_DEFAULT_ADDRESS MPU6050_ADDRESS_AD0_LOW
#define MPU6050_RA_WHO_AM_I 0x75
#define MPU6050_WHO_AM_I_BIT 6
#define MPU6050_WHO_AM_I_LENGTH 6
MPU6050::MPU6050() {
devAddr = MPU6050_DEFAULT_ADDRESS;
}
uint8_t MPU6050::getDeviceID() {
I2Cdev::readBits(devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, buffer);
return buffer[0];
}
int8_t I2Cdev::readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data, uint16_t timeout) {
// 01101001 read byte
// 76543210 bit numbers
// xxx args: bitStart=4, length=3
// 010 masked
// -> 010 shifted
uint8_t count, b;
//Serial.println("
** In readBits ***");
if ((count = readByte(devAddr, regAddr, &b, timeout)) != 0) {
//Serial.print("Byte read successful: ");
uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1);
b &= mask;
b >>= (bitStart - length + 1);
//Serial.println(b);
*data = b;
}
else
{
//Serial.println("Byte read failed");
}
return count;
}
It returns 56. Raw measurments from accels&gyros also makes sense -- but I can't read mag values due to hardware difference.

You were right. I've changed underlying Wire.h library to I2Cdev, made necessary changes to my code, and everything is working now.
If there is anyone with same problem -- I can share my code.

One more question -- this time about your code:)
Lines 407-409:
magbias[0] = +470.; // User environmental x-axis correction in milliGauss magbias[1] = +120.; // User environmental y-axis correction in milliGauss magbias[2] = +125.; // User environmental z-axis correction in milliGauss
Why this numbers? It's not related to magnetic inclination and declination, if I understand correctly.

Ok, thanks.

Kriswiner i need you help!
I am programming the mpu9250 with the mpu432 in CodeComposer. At the moment I just want to be able to read the WHO-I-AM register. Do you have an example to help me?
Thanks

IS your code going to work on with the MPU9255 or are there other problems I might run into. Ive had some of the code running but the Yaw values are inconstant, for example seem to want to return to around 90.

hi kris i am new and i would like to know why it is important to check the connectivity of mpu 9250 and AK8963. Since previously I was testing a code in which I did not do this check and obtained the sensor readings without any problem.

thank you very much for answering kris

I have a much improved unified drive for mpu9250 and mpu9255:
https://github.com/seandepagnier/RTIMULib2

It actually utilizes the fifo for all the sensors and has lower noise with reduced cpu usage.

@seandepagnier Where can I find your files for Arduino?

Did you ever figure out the whoami value of 0x40? I'm reading the same value (over spi) from a sensor which should be a MPU9250...
(The sensor is on some GNSS-receiver I bought, so I guess/hope the hardware is good. Meanwhile I've asked the vendor to confirm the sensor model is MPU9250)

inv-mpu6050-i2c 1-0068: invalid whoami 0x40 expected 0x71 (MPU9250)

za3k commented

Hey, I don't have any answers but thought I'd make a note as I saw this.

0x68 is documented as the "reset value" for WHO_AM_I in the MPU9250 register spec. So it's possible a reset got issued somehow, if that's accurate. (I haven't seen 0x68 returned, I just noticed this in the spec)

I forgot to post a follow up on this (sorry).
The vendor of my device confirmed the IMU-chip was changed from MPU9250 to ICM20948. With that information, everything started to make sense ๐Ÿ˜ƒ

Don't know what 0x40 is. 0x71 is MPU9250 and 0x73 is MPU9255. There might be others, but not that I know of....
"10DOF โ€“ GY-91 4-in-1 MPU-9250 and BMP280 Multi-Sensor Module" gives me 0x73
"MPU 9250 6500" & "MPU-92/65" both gives me 0x71
This should be wrong... butI used many sensors from these models from the same seller. They all reply in the same way. This is opposite to the datasheet. Could you explain why ?