Ok I Just got a MPU-6050 and ive spent the last two weeks trying to figure out how to get readable values from it. Ive tried other people libraries and code and it just doesn't work. I Connected VCC -> 5V; GND - > GND; SCL ->A5; and SDA -> A4. I am Using a Arduino Uno. Ive tried 3 different people Codes and i got it to work at one point but then after a few seconds it displayed all zeros. Also is there a way to get it to display degrees? like 0-360? I would really appreciate the help with this.
What's a MPU-6050 (provide a link!).
Mark
Your wiring is good. I assume it is a module with a voltage regulator onboard ? Like the cheap ones from Ebay.
First thing to do is to run the i2c scanner.
http://playground.arduino.cc/Main/I2cScanner
If the scanner can't detect it, trying any code or library is useless. You should first make this work.
Can you show what the output of this sketch is ?
http://playground.arduino.cc/Main/MPU-6050
If everything is okay, you can try the library by Jeff Rowberg.
http://www.i2cdevlib.com/
Connect also INT to Arduino pin 2 for the example with dmp.
Link to the sensor is: http://www.amazon.com/Arduino-GY-521-MPU-6050-gyroscope-accelerometer/dp/B008BOPN40
Output being:
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 4116, -15396, 5264
temperature: 42.059 degrees Celsius
gyro x,y,z : -165, 38, 269,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 2840, -4032, 14888
temperature: 42.624 degrees Celsius
gyro x,y,z : 14050, 2727, 19119,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -1144, -5144, 16864
temperature: 42.906 degrees Celsius
gyro x,y,z : -2839, 4488, 1160,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -2836, -2276, 15500
temperature: 43.000 degrees Celsius
gyro x,y,z : -1230, 1796, 151,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3996, -3660, 16216
temperature: 43.235 degrees Celsius
gyro x,y,z : 209, -737, 19,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3528, -4436, 15764
temperature: 43.565 degrees Celsius
gyro x,y,z : 33, 285, 405,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3840, -4132, 15388
temperature: 43.612 degrees Celsius
gyro x,y,z : -232, 22, 355,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3648, -4524, 15848
temperature: 43.753 degrees Celsius
gyro x,y,z : -47, 256, 284,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -4032, -4396, 15256
temperature: 43.941 degrees Celsius
gyro x,y,z : -362, 348, 223,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3992, -4572, 15372
temperature: 44.082 degrees Celsius
gyro x,y,z : -256, -102, 302,
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: -3828, -4604, 15584
temperature: 44.271 degrees Celsius
gyro x,y,z : -343, 474, 230,
But thats no where near what id like it to say. Is there a way to convert that into 0-360 degrees?
That temperature seems very high. Is it really 40 degrees ?
If the sunlight was shining on the sensor, it might get that hot.
If not, something is wrong.
The accel and gyro values seem okay.
Do you want the degrees for horizontal rotation ?
Most of the time, the 3 axis are used for orientation.
Next step is using the i2cdevlib.
http://www.i2cdevlib.com/
Try the simple example sketch first, and then the 'dmp' example with INT to pin 2 connected.
Read that 'dmp' sketch carefully how the sensor values can be used. There are things like pitch and roll, but also orientation in 3D space.
Read also wikipedia about quaternions
This is a good guide.
http://forum.arduino.cc/index.php?topic=58048.0
I read the wiki but reading and understanding are two different things... Meaning i didn't understand it at all.
Also i tried the I2CLibrary and It WORKED!!!! i was all happy then it stopped working. I didn't change anything in code...
This time i connected:
VCC - > 3.3v
GND - > GND
SCL - > SCL (its a R3 Uno board)
SDA - > SDA
INT - > Digital I/O 2
Your sensor board has a voltage regulator for 3.3V.
Using 3.3V from the Arduino to power it, makes the MPU-6050 and the I2C run at 3.2V. That is not enough.
So use the 5V to power it.
You may also need pullup resistors on the I2C lines.
Mark
That sensor board has already pullup resistors.
I think i figured it out. I might have shorted the gyroscope out when i rotated it...