Go Down

Topic: GY-521 gyroscope/accelerometer breakout board (Read 35910 times) previous topic - next topic

TuringFan

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

Krodal

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

TuringFan

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: http://arduino.cc/playground/uploads/Main/MPU6050-V1-SCH.jpg.  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

Krodal

#3
Sep 08, 2012, 01:24 am Last Edit: Sep 08, 2012, 01:28 am by Krodal Reason: 1
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

TuringFan

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

TuringFan

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

Krodal

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.

Fabio Varesano

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 http://www.varesano.net/projects/hardware/FreeIMU#library

rodolf0

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
Rodolfo Aguilar

rodolf0

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!
Rodolfo Aguilar

Krodal

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 : http://arduino.cc/en/Reference/Wire
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: http://arduino.cc/playground/Main/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

rodolf0

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
Rodolfo Aguilar

michinyon

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.

Mardec

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


Krodal

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


Go Up