MPU-6050 errors reading data

I am a complete noobie with both arduino and electronics in general.

I have and arduino due and a mpu-6050 breakout board from ebay http://www.ebay.co.uk/itm/1x-MPU-6050-Module-3-Axis-Gyroscope-3-Axis-Accelerometer-Sensor-MPU6050-Arduino-/320995455051?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item4abcd1f04b

I have connected the

3v3 pin to the 3.3v output on arduino
gnd pin to the gnd pin on arduino
scl pin to scl1 pin on arduino
sda pin to sda1 pin on arduino

I have used the following sketch Arduino Playground - HomePage

the serial output is as follows:

InvenSense MPU-6050
June 2012
WHO_AM_I : 0, error = 1
PWR_MGMT_2 : 0, error = 1

MPU-6050
Read accel, temp and gyro, error = 1
accel x,y,z: 0, 4200984, 134257412
temperature: 37.259 degrees Celsius
gyro x,y,z : 1, 0, 137590197,

MPU-6050
Read accel, temp and gyro, error = 1
accel x,y,z: 0, 1073747994, 525467
temperature: 36.509 degrees Celsius
gyro x,y,z : 1, 0, 137590197,

MPU-6050
Read accel, temp and gyro, error = 1
accel x,y,z: 0, 4200984, 134257412
temperature: 37.259 degrees Celsius
gyro x,y,z : 1, 0, 137590197,

MPU-6050
Read accel, temp and gyro, error = 1
accel x,y,z: 0, 1073747994, 525467
temperature: 36.509 degrees Celsius
gyro x,y,z : 1, 0, 137590197,

................

I can't figure out why the error is shown as 1 and there is no change in the gyro readings and the accel readings seem to jump back and forth to exactly the same readings.

can anybody please help??

Thanks

The thing that puzzles me is how you can get such a large number from a signed integer. That's at least one clue about your problem.

Check sketch and monitor baud settings to be sure they're matched.

I have checked and the baud rates are the same.

To make things more puzzling I have also run the I2C scanner sketch and it outputs

I2C Scanner
Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

When reverting back to the earlier sketch for the MPU6050 the output to serial monitor shows an error of 1 when trying to read the sensor. The error number is the output from:

Wire.endTransmission(false);

According to the Arduino reference the error codes are as follows:

0:success
1:data too long to fit in transmit buffer
2:received NACK on transmit of address
3:received NACK on transmit of data
4:other error

Therefore it looks like this is an issue with transmit buffer, whatever that is?

How do I resolve this or am I going in completely the wrong direction?

I'm at a loss also but the data size suggests a mismatch of some form. The print statements would fit if the data were long but the structure declarations show 8 and 16 bit type. I guess the first thing to do is go back to the sketch and look for typos.

I found the problem.

The issue was I think that the mpu-6050 board is set to sleep mode by default. In order to get round this I first of all added the following library for the MPU6050

http://www.i2cdevlib.com/devices/mpu6050#source

Then I had to comment out the #include <avr/pgmspace.h> in MPU6050.h

and then I had to comment out any additional relating to useProgMem in MPU6050.cpp as there is an issue with <avr/pgmspace.h> on the Arduino Due apparently.

Finally, using the example sketch for the library for raw sensor data I added the following code:

accelgyro.setSleepEnabled(false);

immediately before:

accelgyro.initialize();

It now works!

Glad you found the problem. There will likely be lots of library problems with the Due. However, progress is progress.

I'm having the exact same error as you, but the solution you stated isn't working for me, could you please paste your code?

Hello,

me and my friends are using shield BMP085 Digital Barometric Pressure Measurement Sensor Module - Green - Free shipping - DealExtreme and we are encountering the exact same problem as badben. We followed Your instructions and we are still getting same errors.
The sketches we use are located here: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050/Examples (we tried both of them), Arduino Playground - MPU-6050
We are wondering if it's our fault (however we followed the instructions precisely) or maybe it's the shield that is broken. We dropped it from about 1.5m once but since it should report +-16g I find it hard to belive that it could break after that sort of accident.

Any help would be great! Cheers!

For the ones still trying to figure out how to make this breakout board work, I found the solution on Arduino Playgroud, and posted on this page: MPU6050 connection failed - MPU-6050 6-axis accelerometer/gyroscope (InvenSense) - I2Cdevlib Forums

It seens that you need to put pull-up resistors on the SCL and SDA pins. 10K worked here.

Would it be POSSIBLE FOR YOU TO SEND ME YOUR LIBRARY? I DONT UNDERSTAND WHAT PARTS TO DELETE IN THE MPU6050.CPP.

THANKS

Hi could you mention how to manipulate the 6050.cpp and add or remove what,

I have the same problem and cant geti it worked :frowning:

#include<Wire.h>
/*const int MPU=0x68;*/
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
  Wire.begin();
  Wire.beginTransmission(0x68);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(0x68);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(0x68,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

i've eliminated MPU=0x68 variable and used 20/21 pins ( scl sda ) and it worked. hope it helps.

guys while using the code for mpu6050 by jwrowberg in i2cdevlib, i am having problem uploading the sketch for raw data. the error is like this:
Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Uno"

MPU6050_raw.cpp.o: In function setup': C:\Program Files\Arduino/MPU6050_raw.ino:1360: undefined reference to MPU6050::initialize()'
C:\Program Files\Arduino/MPU6050_raw.ino:1364: undefined reference to MPU6050::testConnection()' MPU6050_raw.cpp.o: In function loop':
C:\Program Files\Arduino/MPU6050_raw.ino:1395: undefined reference to MPU6050::getMotion6(int*, int*, int*, int*, int*, int*)' MPU6050_raw.cpp.o: In function __static_initialization_and_destruction_0':
C:\Program Files\Arduino/MPU6050_raw.ino:1322: undefined reference to `MPU6050::MPU6050()'
collect2.exe: error: ld returned 1 exit status
Error compiling.

any way to solve this?

I am very new to this so please be patient. I am trying to update firmware on a Martinez Gimbal controller using the Arduino Uno board. I think I have followed all steps in the instructions, but each time I try to update I get the following error message: exit status 1 'initMPU' was not declared in this scope.. Can anyone help me to resolve this issue?

Hello Everyone I could really use some help here.
I am trying to set up my MPU 6050 to my arduino mega2560 and the only results im getting is this

MP45, 3, 0
temperature: 37.091 degrees Celsius
gyro x,y,z : 22097, 16500, 22503,

MP temp and gyro, error = 2
accel x,y,z: 545, 3, 0
temperature: 37.091 degrees Celsius
gyro x,y,z : 22097, 16500, 22503,

MPInvenSense MPU-6050
June 2012
WHO_AM_I : 21, error = 2
PWR_MGMT_1 : 21, error = 2

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 8450, 822, 4866
temperature: 22.200 degrees Celsius
gyro x,y,z : 0, 2626, 5213,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 545, 13827, 531
temperature: 37.203 degrees Celsius
gyro x,y,z : 0, 16906, 23828,

im using Arduino Playground - MPU-6050 krodals code. Please Help anyone!

my pins are
VCC - V3.3 but i was told to use 5V
GND - GND
SDA - pin 20 SDA
SCL - PIN 21 SCL
INT - PIN 2