can't read data from MPU9250

Hi everyone,
I recently received my Arduino Due and my Drotek IMU 10DOF with MPU9250 and MS5611...
I interfaced them using I2C serial port, as follows:

Arduino Due IMU 10DOF
3.3v <=> VDD
GND <=> GND
SDA pin 20 <=> SDA
SCL pin 21 <=> SCL

I scanned the I2C serial port and got the address 0x69 for my Drotek sensor..but when I try to read accel/gyro data and displays it on the serial monitor I get:

assertion "(address & 0x80) == 0" failed: file "../source/twi.c", line 271, function: TWI_StartWrite
Exiting with status 1.

this is my code, anyone who can helps ? I'm stuck for days...

#include "Wire.h"
#include "MPU9250.h"

#define    MPU9250_ADDRESS            0x69

#define LED_PIN 13 

int16_t ax, ay, az;
int16_t gx, gy, gz;

MPU9250 accelgyro ;
void setup() 
{
  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(9600);
  delay (100);

    // initialize device
    Serial.println("Initializing I2C devices...");
    Serial.println ("");
    Wire.beginTransmission (MPU9250_ADDRESS);
    accelgyro.initialize();
    Wire.endTransmission ();
 
    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
}

void loop() 
{
  // blink LED to indicate activity
    digitalWrite(LED_PIN, HIGH);
    delay (50);
    digitalWrite(LED_PIN, LOW);
    delay (500);

    accelgyro.getAcceleration(&ax, &ay, &az);
    accelgyro.getRotation(&gx, &gy, &gz);

    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
    Serial.print(az); Serial.print("\t");
    Serial.print(gx); Serial.print("\t");
    Serial.print(gy); Serial.print("\t");
    Serial.print(gz); Serial.print("\t");
    Serial.println("");
}

Thanks..

I've tried to compile your code and I can't reproduce the error. I don't have the MPU9250 library handy, so I just commented out all references to it.

Do you know what this error means? The way that I2C works that it requires that bit to be zero?

I'm not sure why the TWI library has this assertion because - as I understand it - the assertion is checked at compile time only and the address might be something that changes during the run time.

thanks for answering..

I don't have a compilation problem, but instead of reading data (ax, ay, az, gx, gy, gz) from the MPU9250 sensor in the serial monitor, I get that "assertion" message..I don't know what that means !

It seems like every related function to the MPU9250 library causes that "assertion" message !
However, I'm using the MPU9250 Snowda library that is mentioned in Drotek website, from which I bought my sensor (I'm using the IMU 10DOF -MPU9250+MS5611)

Since couple days ago, I have been able to connect with my motion sensor, I don't know how to explain that...I'm just not using the MPU9250 library...I only use the Wire library and develop my own functions for communication...

For those who may have the same problem..just don't use the MPU9250 library with Arduino Due !!

Hi kkny,

Kris Winer has published some excellent code for the MPU-9250 that works with both the Arduino Due and the Drotek MPU-9250/MS5611, 10 DOF breakout board. It's located here: GitHub - kriswiner/MPU9250: Arduino sketches for MPU9250 9DoF with AHRS sensor fusion.

Hi MartinL,

Thanks a lot :smiley: