hideakitai / MPU9250

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

I2C error code 2 #89

Closed Anneruha closed 1 year ago

Anneruha commented 1 year ago

While trying to read out this IMU with the provided code, In the beginning it was working perfectly fine, however now I get the error message I2C error code 2. Does anyone know how this can be solved? I have the IMU 9250 and the I2C adress is 0x68.

#include "MPU9250.h"
MPU9250 mpu; // You can also use MPU9255 as is

void setup() {
    Serial.begin(115200);
    Wire.begin();
    delay(2000);

    mpu.setup(0x68);  // change to your own address
}

void loop() {
    if (mpu.update()) {
        Serial.print(mpu.getYaw()); Serial.print(", ");
        Serial.print(mpu.getPitch()); Serial.print(", ");
        Serial.println(mpu.getRoll());
    }
}
ibrahimseleem commented 1 year ago

This error message appears if there is a fault in connection. I faced the same problem, and the solution I found was that you should remove the Arduino cable and reconnect it again.

andreevnikola commented 1 year ago

I have the same problem and the issue was not solved by just unplugging the cable. I still have no clue what to do. Can somenoene help?

hideakitai commented 1 year ago

The fault of the hardware connection mainly causes this.

2:received NACK on transmit of address

Please check your hardware connection.