GY-521 gyroscope/accelerometer breakout board

Greetings. I'm trying to put together a simple Arduino project with the gy-521 but I can't, here or anywhere else, find a sample circuit...and I'm too much of a noob to design one myself. Can anyone point me in the right direction?

Many thanks.

TuringFan

http://arduino.cc/playground/Main/MPU-6050

Krodal,

Thanks very much for the link. I'd actually already found it and downloaded the source and got it to compile. I did not, however, find a circuit. I did find this: Arduino Playground - HomePage. Maybe I'm an idiot, but I struggle to map it to the GY-521. How about a GY-521-specific circuit diagram that shows connections between the 521 and an Arduino? Surely such a thing must exist?

Many thanks.

Ed

1 Like

The circuit is just to show that for example the AD0 line has a pull-down resistor, and that there is a voltage regulator on the breakout board.

This is how to use the i2c-bus:
Arduino +5V to VCC
Arduino GND to GND
Arduino analog input pin A4 to SDA
Arduino analog input pin A5 to SCL

Don't forget to run the i2c_scanner : http://arduino.cc/playground/Main/I2cScanner

If the i2c_scanner 'sees' your breakout board, you are ready to test the sketch for the MPU-6050.

Take a look in a parallel universum : http://arduino.cc/forum/index.php/topic,121901.0.html

Krodal,

This is very helpful. I particularly appreciate knowing about i2c_scanner...it'll let me know whether I fried the board when I soldered the header to it.

And I did notice the alternate reality. Quite a coincidence.

Thank you very much.

Ed

Krodal,

Got it working, in a sense. i2c_scanner finds it and your code reports XYZ values. Unfortunately, the values simply oscillate (except for Z, which is stuck at zero). I rapidly rotate the board back and forth 180 degrees but the oscillation remains constant. Restarting the sketch gives me new pairs of numbers, but they're stuck, too. Am I simply unable to spin the board fast enough to change the values? Or did I break it?

Thanks.

Ed

That's weird.

Can you measure the voltage after the voltage regulator ? Is it 3.3V ?

Are both the values for both internal sensors (accel and gyro) wrong ?

Can you check very carefully all soldering points with a magnifying glass, or with a camera (with macro) ? These low priced board use the minimum amount of soldering. I have an official Arduino and an Ebay clone and the difference in the amount of solder is remarkable.

Hi there, if you are still having troubles using the MPU6050, I just commited support for generic MPU6050 breakout boards into my FreeIMU library, which, a part from giving you access to raw readings, provides you also access to calibration routines and sensor fusion.

You can have a look at varesano.net -

Krodal,

Thanks for your info. I was in another parallel universe too, and my question is related to this one,
just that in my case I have an arduino mega 2560, and there is a communication pins section, that has SDA and SCL pins, but if I hook pin A4 to SDA and A5 to SCL respectively, the scanner doesnt found any I2C devices. Even though if I connect them to the SDA and SCL pins on the arduino, it does work!!
So Im just curious why does this happen? or is there anything going wrong on my boad?.

I also had sketched up how to make the connections and had planned to hookup the GY521 pins from pins A15 to A10 on the arduino, being the A15 the SCL input and A10 the INT. Although Im new in this device I have some doubts, hope you can help me.

Im using this device to obtain orientation (x, y, theta) from a mobile autonomous robot with differential steering based on Arduino.

Cheers

Cheers

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?