GY-521 gyroscope/accelerometer breakout board

I forgot one question about my pre-planned sketch of the wiring on my arduino mega board, is there anyway of using the pins from A15 to A10 like I told you in the last message? Its because thats how I had design my connections and a little change in that desing affects my hardware distribution.

Talking bout my other doubts, Im so much of a new in this whole connection stuff, and I can't see clearly on the sketch where are the pins selection, particularly for the XDA, XCL, ADO and INT pins. I dont know where to hook up these pins.

Im in a hurry, so i'll appreciate your fast response!

The Arduino Mega 2560 uses different pins for the I2C.
Use either the pins SCL and SDA (only on newer boards) or see the Wire library : Wire - Arduino Reference
Don't use the XDA, XCL, ADO and INT yet.

Connect the two I2C lines, and VCC to 5V and GND to GND.

Run the i2c_scanner. It must see the device. If it doesn't, check your wiring.

If the i2c_scanner detects the sensor board, write down the address.
use my sketch: Arduino Playground - MPU-6050
You may have to change the address.
You can tilt the board and see how the values change.

If my sketch is working, connect the INT to pin 2 and try the code by Jeff Rowberg.
See this page to find which pin is needed for INT 0 : http://arduino.cc/en/Reference/AttachInterrupt

Thanks Krodal, I really appreciate your time!

Your code works perfectly on my arduino board and that way the GY-521 is doing good too.

I loaded the code and serial monitor the output (acc, temp, gyro). Tilted the board and the values change, they seem to be correct.

I spent the night trying the code by Jeff Rowberg, but Im sort of a rookie on this area, and tryna figure out what memory adresses is all about was kinda of
confusing for me but at the end of the day I guess my basic background programming skills helped me out. Created the directory for the MPU6050 and I2Cdev
libraries and then they appeared on the IDE!!. But as Im tryna get a 3D visual demonstration of the board motion I ran the MPU6050_DMP6.ino code and the
displayed error is something Ive been having troubles for the last hours. It says that there's something wrong with Quaternion.h. Certainly is something about a missing library in the arduino directory, the thing I don't know which other library I need to add in order to get this code working, is it the helper_3dmath.h? if it is, is possible to create a sortof library directory with just one file in it (.h)? cause I read on the arduino hacking libraries instructions a library needs 2 or more files.

If I get this done, I mean the MPU6050_DMP6.ino working, could you please tell me the steps to run the Processing sketch? and which is the code? I guess its
the MPUTeapot.pde on the Jeff Rowberg site, am I right? By steps I mean the way of linking arduino sketch to Processing 3D sketch.

So please I'll appreciate your comments on this!!

Regards

You don't need to use all the pins on that device.

the XCL and XDA are for connecting another I2C device to the GY-521. For example, a magnetic field sensor.
Those values then become accessible to the arduino though registers in the MPU-6050. This is easier said than
done, and not something you are likely to be able to get to work without more experience.

Gentlemen

Today I tried out my GY-521 6DOF.

I ran the I2C code, and the adress was 0x68 [running the board on 5V]

I used Krodal's code to run the gyro, and I seem to be getting really unstable signals:
Just look at the gyro feedback, this is just by tilting it...

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 12928, -6376, 6420
temperature: 22.341 degrees Celsius
gyro x,y,z : -1201, -219, 814,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 8204, -10208, -8428
temperature: 22.388 degrees Celsius
gyro x,y,z : -6531, -13742, 6892,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 12260, -10812, 2188
temperature: 22.388 degrees Celsius
gyro x,y,z : -2779, -5582, 511,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 12616, -8236, 4216
temperature: 22.435 degrees Celsius
gyro x,y,z : -5167, -951, 11285,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 17116, -8, -2696
temperature: 22.482 degrees Celsius
gyro x,y,z : -138, -77, 63,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 17032, -36, -2756
temperature: 22.435 degrees Celsius
gyro x,y,z : -123, -51, 111,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 17084, -24, -2648
temperature: 22.482 degrees Celsius
gyro x,y,z : -125, -62, 104,

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 17000, 0, -2616
temperature: 22.435 degrees Celsius
gyro x,y,z : -151, -64, 74,

Am I misinterpreting the gyro signal? Is this degrees? Why is it so unstable?

I am running my arduino on USB power, is this the issue?

Kind regards

Martijn Decauter

They are the raw values from the sensor. So the values you get are normal.

@Krodal: Have been reading the forum and am new to Arduino. I have the same problem with Mardec. Am working on a project that detects the position and force impact on a ball. Am getting these raw values from my Gy-521.

Read accel, temp and gyro, error = 0
accel x,y,z: 7804, -11208, -8428
temperature: 22.388 degrees Celsius
gyro x,y,z : -7661, -34745, 7669

How do i use this information to calculate the force, distance or position of the ball. Aniticipating your reply thanks

Emeka T

You can read the datasheet for the sensitivity.

Or use the i2cdevlib and read about the functions. You still have to read the datasheet to understand how much 'g' the acceleration value is.
http://www.i2cdevlib.com/

About the distance and position, I don't know. Sorry. I never tried to calculate that.

Hi krodal,

I saw something wrong (or not ?) in your code : the gyro and accel values are inverted !
An example : when my GY-521 is on a flat surface, the "gyro" values are close to "0", and the "accel" ones are around 1.000-15.000, but if I move the module, the "gyro" values quickly go to 1500 before going back close to "0". during this time, "accel" values increased (or decreased, depending of the dirction I moved the module).

Can you take a look at this please, because your code is to complex for me ^^

thanks,
taz

PS: if my english is bad, that's normal, I'm a young french guy :slight_smile:

I don't think they are inverted, I think you are misunderstanding what the values represent.

I followed the plans you layer out , and I was getting readings yay!!!!
but then all of a sudden it just doesn't work :frowning:
nothing.
I was getting readings that were totally responding as I would expect.
I was going to see if I could hook up another board, but before I could it halted any readings and when I press reset on the Arduino it reads:

MPU-6050
InvenSense MPU-6050
June 2012

and nothing else

If I pull the:
A4 and A5 from The SDA and SCL
it scrolls, but unresponsive:

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: -5374, 2, 305
temperature: 37.212 degrees Celsius
gyro x,y,z : 2050, -13039, -29695,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 747, 512, 12545
temperature: 24.459 degrees Celsius
gyro x,y,z : 520, 4557, 396,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: -5374, 2, 305
temperature: 37.212 degrees Celsius
gyro x,y,z : 2050, -13039, -29695,

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 747, 512, 12545
temperature: 24.459 degrees Celsius
gyro x,y,z : 520, 4557, 396,

dang :frowning: did I fry my chip somehow?

I try another sensor and it scrolls

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,

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,

MPU-6050
InvenSense MPU-6050
June 2012
InvenSense MPU-6050
June 2012

then stops. and I attempted to reset twice :confused:

If you are getting all those zeros, your communication is not working. And i don't believe that it is 36 celsius in new orleans right now.

I know... I'm researching why I am getting such insane readings right now... or none at all. it's a bit unsettling, it should be pretty straight forward...

when the device is not moving, then the accelerometer readings you see represent the direction of the gravitational force ( or the opposite of it ).

@schrockstudio
Managed to solve the error of all data is zero?
I have the same problem here.

hi,
we've tried using the I2C_Scanner suggested above and another one we found elsewhere but it can't seem to find the address of our Gyro(GY-5210, Nano ATmega328)

anyone knows what might be the problem?

omryofec:
hi,
we've tried using the I2C_Scanner suggested above and another one we found elsewhere but it can't seem to find the address of our Gyro(GY-5210, Nano ATmega328)

anyone knows what might be the problem?

Hi! I can't see on the picture if the LED light on the gyroscope is lit up. My concern with your circuit is that you power up the gyroscope from Vin pin. Try to power it up from 5V pin instead. I don't have an Arduino now to check, but I suspect voltage might not be available on Vin pin when you power the Arduino from USB.

UPDATE: I think you need to use pins A4 and A5 instead of D4 and D5

For I2C, you need to the use the correct pins for I2c for the model of Arduino board and chip that you have. A4 and A5 is for I2c on a Uno. For a nano, I don't know. Look it up.

the d4 d5 pins on nano are SCLK and SDATA so they are the correct ones.
but we've come to the conclusion that we might have burned the sensor cause it needs only 3.3V and not 5V :slight_smile:
so now we're waiting for the new ones to arrive. we'll keep you posted :slight_smile: