hideakitai / MPU9250

Arduino library for MPU9250 Nine-Axis (Gyro + Accelerometer + Compass) MEMS MotionTracking™ Device
MIT License
279 stars 92 forks source link

I2C bus error code 3 and WHOAMI_ = 0x75; #93

Closed brightproject closed 1 year ago

brightproject commented 1 year ago

I have difficulties with MPU9250 sensors When using the library can not use the sensor. Error initializing communication with IMU When using this library, I also get an error, and in addition also an error code

MPU connection failed. Please check your connection with `connection_check` example.
I2C ERROR CODE : 3
MPU connection failed. Please check your connection with `connection_check` example.

Скриншот 10-07-2023 21 33 51 What kind of error code 3 is it, only in your library I encountered this. I have been using the I2C bus for many years, and I see this for the first time. But, this example works fine, although when compiling it warns that the code was written for the SAMD platform. Скриншот 10-07-2023 15 48 13 The signal analyzer shows that the MPU9250 responds to the request 0x75 with 0x70, although it should respond with 0x71. Скриншот 10-07-2023 21 33 33 Fake, fake chip, non-working chip? But why then does the example from SparFan work so well? I check the presence of the module on the bus I2C using the code:

#include <Wire.h>

//UART1 TX - PA9, RX - PA10
#define SerialOne Serial1

void setup(){
    Wire.begin();

    SerialOne.begin(115200);
    while (!SerialOne);
    SerialOne.println("\nI2C Scanner");
} 

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

    SerialOne.println("Scanning...");

    nDevices = 0;
    for(address = 8; address < 127; address++ ){
        Wire.beginTransmission(address);
        SerialOne.print(address,HEX);
        SerialOne.println("+");
        error = Wire.endTransmission();

        if (error == 0){
            SerialOne.print("I2C device found at address 0x");
            if (address<16)
                SerialOne.print("0");
            SerialOne.print(address,HEX);
            SerialOne.println(" !");

            nDevices++;
        }
        else if (error==4) {
            SerialOne.print("Unknow error at address 0x");
            if (address<16)
                SerialOne.print("0");
            SerialOne.println(address,HEX);
        } 
    }
    if (nDevices == 0)
        SerialOne.println("No I2C devices found\n");
    else
        SerialOne.println("done\n");

    delay(1000);
}

I receive an address I2C device found at address 0x68 ! or I2C device found at address 0x69 ! Depending on whether AD0 is connected to ground or to 3.3 volt.

hideakitai commented 1 year ago

This library does not support fake chips apparently (strictly) by seeing WHO_AM_I. Please use other libraries to use with the fake chip.