Need Help with (GY-521 / MPU-6050) Read other forms and still problems.

Hello Everyone,

Ok, my problem is I am trying to get my GY-521 to give me proper reading but can't seem to figure it out. I must be missing something small somewhere.

Here is everything I have done and know at this very moment:

  • I2C Scanner is not reading the chip ( Can't figure out why either)
  • I am getting reading from the chip tho. (See below)
  • I have read through other forms with this chip and the problems they had but still not working.
  • I am using a Leonardo clone off ebay.

Aslo here is a picture of my setup:

![](http://MPU-6050 GY-521)

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 747, 512, 17154
temperature: 24.459 degrees Celsius
gyro x,y,z : 778, 5085, 940,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: -5374, 2, 579
temperature: 37.212 degrees Celsius
gyro x,y,z : 2563, -8941, -21501,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 747, 512, 17154
temperature: 24.459 degrees Celsius
gyro x,y,z : 778, 5085, 940,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: -5374, 2, 579
temperature: 37.212 degrees Celsius
gyro x,y,z : 2563, -8941, -21501,

You are not getting data from the chip. The error is 2, so you don't see the chip at all.

The Leonardo has the I2C bus on diferent pins than the Uno.
Use pin 2 and 3 (the digital pins), as you can read here:

The first thing to do is to run an i2c scanner
http://playground.arduino.cc/Main/I2cScanner

If that is okay, you can try to read the data from the chip.

Hello,

Thank you for your reply, I knew there was something I was missing. I change to D2 and D3 and I2C scanner picked it up :slight_smile:

Also raw data seemed to be stable.....BUT then I tried to rotate it and things went down hill again.

Here is my data string as I started to move it:

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -168, -104, 15788
temperature: 23.659 degrees Celsius
gyro x,y,z : -52, 252, -252,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -164, -48, 15824
temperature: 23.706 degrees Celsius
gyro x,y,z : -37, 233, -241,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 364, -1280, 17200
temperature: 23.706 degrees Celsius
gyro x,y,z : -3392, 1024, -7822,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 27649, 251, 12355
temperature: 37.209 degrees Celsius
gyro x,y,z : -16142, 4, 29409,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 0, 0, 0
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 0, 0,

The first 2 are when it was still flat and stable then something happened and not to sure.....

p.s. this is my first time working with any of this stuff learning on the fly :smiley:

Also is there any processor you would recommend to just be able to see a box rotating. I have seen a few listed is other forums, just not sure which one to try.

That error is not good.
Is the connection failing when you rotate it ?
Many breadboards cause connection problems.

Whay do you mean by processor ? The Arduino Uno can be used for it, but also the Nano, Leonardo, Micro, Mini, Pro Mini and so on.
To see something rotating, it is best to use a combination of the gyro and the accelerometer with a filter.
This is a guide about that.
http://forum.arduino.cc/index.php?topic=58048.0

This is the i2cdevlib for it.
http://www.i2cdevlib.com/devices/mpu6050

Hello,

Thanks again for the quick reply. That is what I was starting to think too. But didn't have a lot of time to troubleshoot before head out to work.

I will give everything a try when I get home tonight a keep you posted.

Ya, by processor I was meaning the visual object that you can watch spin around as to move the chip.

Hello again,

Well it seems I have made progress and everything seems to be working.

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 876, 260, 16340
temperature: 27.847 degrees Celsius
gyro x,y,z : -59, 317, 38,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 896, 288, 16420
temperature: 27.894 degrees Celsius
gyro x,y,z : -27, 311, 29,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 976, 228, 16572
temperature: 27.847 degrees Celsius
gyro x,y,z : -58, 340, 2,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 844, 248, 16428
temperature: 27.847 degrees Celsius
gyro x,y,z : -56, 288, 28,

Everything looks pretty stable to me. What do you think? also I don't get any errors or bad readings when moving it around.

The only thing that was weird was when I got home to retry everything I noticed that the I2C Scanner was not see it anymore.

BUT when I can the pins from A4 and A5 to SCL and SDA it started working again.....
Seems like I have to troubleshoot those 2 pins now...

I added a picture of the setup just in case anyone wants to see it.

Those values are pretty stable.

I don't know why it didn't work. Perhaps still some bad connection. Or perhaps a (static) voltage spike. It should be able to run for many years.

When you move it around, the wires become loose.

Where are your pull-up resistors? In a drawer ?

Im sorry, I am still new to this stuff. I didn't know I needed any and where should they go?

google "i2c pullup" -pictures (use 2k2 ..10 k)

The GY-521 board has already pull-up resistors for the I2C bus. You don't need to add extra pull-up resistors.

But it is good that you know what they do. The I2C depends on the pull-up resistors to pull the signal high.

Ok, Thank you both very much. Will keep that in mind