Pages: [1]   Go Down
Author Topic: MPU-6050 errors reading data  (Read 5396 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://playground.arduino.cc//Main/MPU-6050

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
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
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?
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
#include <avr/pgmspace.h>
in MPU6050.h

and then I had to comment out any additional relating to
Code:
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:

Code:
accelgyro.setSleepEnabled(false);

immediately before:

Code:
accelgyro.initialize();

It now works!
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

me and my friends are using shield http://dx.com/p/gy-521-mpu-6050-module-3-axis-gyroscope-accelerometer-for-arduino-162646 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), http://playground.arduino.cc/Main/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!
« Last Edit: August 12, 2013, 09:08:06 pm by PolskiKutz » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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: http://www.i2cdevlib.com/forums/topic/8-mpu6050-connection-failed/#entry352

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

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

THANKS
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad
Logged

Pages: [1]   Go Up
Jump to: