MPU6050 SparkFun Breakout to Arduino Uno - No Communication

Obakemono I simplified my wiring and tried your code. I keep getting a constant stream of 5883. Thanks for all your help thus far.

chazm: ...I keep getting a constant stream of 5883...

Can you try my sketch : http://arduino.cc/playground/Main/MPU-6050 It checks for every error that could occur during the i2c communication.

Thank you Krodal for your sketch. I tried your sketch without resistors and then with resistors, at address 0x68 and 0x69, and the result was the same:

InvenSense MPU-6050 June 2012 WHO_AM_I : 3, error = 2 PWR_MGMT_2 : 3, error = 2

MPU-6050 Read accel, temp and gyro, error = 2 accel x,y,z: -31117, 283, 2288 temperature: 38.035 degrees Celsius gyro x,y,z : -3838, -16640, -29695,

MPU-6050 Read accel, temp and gyro, error = 2 accel x,y,z: 29574, 6913, -4088 temperature: 42.535 degrees Celsius gyro x,y,z : 753, 191, 396,

MPU-6050 Read accel, temp and gyro, error = 2 accel x,y,z: -31117, 283, 2288 temperature: 38.035 degrees Celsius gyro x,y,z : -3838, -16640, -29695,

MPU-6050 Read accel, temp and gyro, error = 2 accel x,y,z: 29574, 6913, -4088 temperature: 42.535 degrees Celsius gyro x,y,z : 753, 191, 396,

You don't have I2C communication (or the sensor is broken).

I read that you already did the scanner sketch. As I wrote in the other thread: I used this code by user RandallR for scanning. See here: http://arduino.cc/forum/index.php/topic,96952.msg738703.html#msg738703 Can you try the scanner sketch once more? Do you have any other I2C device, to test the I2C bus with the scanner sketch ? I use a I2C EEPROM to test the I2C bus, that chip operates at 3.3V, but also at 5V.

Is your AD0 soldered on the sensor board to either one (ground or 3.3V)? Just as in the photo of Obakemono ?

Meanwhile in the other thread, the pull-up resistors seem critical: http://arduino.cc/forum/index.php/topic,111698.msg840273.html#msg840273

I ran the scanner test and this was the result:

I2C Scanner Scanning I2C bus from 0 to 127... 00 2 01 2 02 2 03 2 04 2 05 2 06 2 07 2 08 2 09 2 0A 2 0B 2 0C 2 0D 2 0E 2 0F 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 1A 2 1B 2 1C 2 1D 2 1E 2 1F 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 2A 2 2B 2 2C 2 2D 2 2E 2 2F 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 3A 2 3B 2 3C 2 3D 2 3E 2 3F 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 4A 2 4B 2 4C 2 4D 2 4E 2 4F 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 5A 2 5B 2 5C 2 5D 2 5E 2 5F 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 6A 2 6B 2 6C 2 6D 2 6E 2 6F 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 7A 2 7B 2 7C 2 7D 2 7E 2 7F 2


Possible devices:

done

I don't currently have any other I2C devices, but I will have one by Friday. My AD0 is soldered just like Obakemono, I don't know if that's ground or 3.3v though. I'm currently using 4k7 ohm resistors for my pull-up resistors. So when my other I2C device comes in I should be able to find out if it's my Arduino or the mpu 6050.

I've executed the I2C scanner and it finds a device in 0x68 as expected, but if i disconnect VIO from VDD voltage supply it gives the same output than the one from chazm.

Check this connection chazm it's fundamental in spark fun's board.

Yellow cable 3.3v to VDD and green cable VDD to VIO works for me.

|1024x768

I have some great news, I think that my connections were loose. My friend and I soldered the headers to the board. I ran the scanner code and I found a port.

I2C Scanner Scanning I2C bus from 0 to 127... 00 2 01 2 02 2 03 2 04 2 05 2 06 2 07 2 08 2 09 2 0A 2 0B 2 0C 2 0D 2 0E 2 0F 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 1A 2 1B 2 1C 2 1D 2 1E 2 1F 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 2A 2 2B 2 2C 2 2D 2 2E 2 2F 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 3A 2 3B 2 3C 2 3D 2 3E 2 3F 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 4A 2 4B 2 4C 2 4D 2 4E 2 4F 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 5A 2 5B 2 5C 2 5D 2 5E 2 5F 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 found! 69 2 6A 2 6B 2 6C 2 6D 2 6E 2 6F 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 7A 2 7B 2 7C 2 7D 2 7E 2 7F 2


Possible devices: 68 = DS1307

done

I'm going to start running some more code, hopefully my problems are done.

Good!

My sketch http://arduino.cc/playground/Main/MPU-6050 should work now without any problem. If the sketch needs more comment, or more explanation or so, please let me know. For serious use, you could use Jeff Rowberg's library.

¡Great! You should be fine now.

I'm on the process of filtering data now, as the use of DMP seems quite complex atm, i'm going with the good old raw data.

Krodal, you seem to be quite experienced with MPU-6050, i have a couple of doubts i hope you can help me with.

As far as i have understanded from the datasheet ¿it auto calibrates to 0g right?, i mean, i don't need to substract any 0g value from my output ¿right?.

And at +-2g scale the sensitivity is 16384 LSB/g so, to get acceleration in g's, at 16bits, (rawAxis - 32767)/16384 ¿am i right?

Thx.

Obakemono: ...As far as i have understanded from the datasheet ¿it auto calibrates to 0g right?, i mean, i don't need to substract any 0g value from my output ¿right?.

And at +-2g scale the sensitivity is 16384 LSB/g so, to get acceleration in g's, at 16bits, (rawAxis - 32767)/16384 ¿am i right?

My sketch is ment to give a quick start. On this page http://arduino.cc/playground/Main/MPU-6050 I mention to use the library by Jeff Rowberg for serious use.

The MEMS sensors are a great invention, but they have a large offset and the sensitivity is inaccurate. Lucky for us, the sensitivity of the MPU-6050 is calibrated. The gyro sensitivity scale and the accelerometer scale are factory calibrated. But not the offset (I can't read it in the datasheet). So when using the raw values, the offset could be taken care of in software. Or by using the undocumented offset registers in the MPU-6050. When using DMP firmware, the offset compensation could be in the firmware.

Accelerator with +/-2g range = 16384 LSB/g. So a value of 16384 is 1 g. Get the accelerator value during setup(), and save it in rawOffset. In the loop() get the value and calculate the 'g' value:

double g;
g = (double) (rawAxis - rawOffset ) / 16384.0;

And that for all 6 values (3 gyro, 3 accel).

During setup() the z-axis gets 1 'g' of the earth gravity. So you have to add 1 'g' after the offset compensation.

I alread mentioned my sketch : http://arduino.cc/playground/Main/MPU-6050 And it is easier then the Jeff Rowberg code. It doesn't need the interrupt. On the page there is a link to a i2c_scanner, the device must be visible on the I2C-bus first. If my sketch is working, you can try the serious code by Jeff Rowberg.

Hi Krodal,

Thanks for your very informative playground article I bought a GY-52 breakout board which seems rather similar to yours (same manufacturer):

I connected as follow: VCC - 5V GND - GND SCL - A5 SDA - A4

and loaded your code http://arduino.cc/playground/Main/MPU-6050 Amazingly enough, it worked first time

Now, I try to understand why it works :P :P No additional pull up resistors on SDA/SCL ADO seem to be pulled down (0X68)

Would you mind checking your onboard regulator output, mine is 4.3V with 5V or 3.3V supply according to datasheet, seems a bit high Please check the above photo for possible pullup resistors

My final project is a new/better Balancing Robot http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284738418

Thanks again for this great job

Answering partially my own questions Not familiar with SMD :roll_eyes: The black components with 3 digits are actually resistors (http://www.hobby-hour.com/electronics/3-digit-smd-resistors.php) 331: 330 ohms 103: 10K 472: 4.7K

So, two 10K pull up resistors Google is definitly your best friend ;) ;)

btw, this board can be had for 15 bucks shipped (Google ...)

kas: ... Thanks for your very informative playground article ... Would you mind checking your onboard regulator output, mine is 4.3V with 5V or 3.3V supply ...

I'm glad my sketch did help.

I have a good multimeter. My +5V is 4.95V and the 3.3V of the breakout board is 3.31V. Also the XDA and XCL of the sub-I2C-bus pins are 3.31V (I think they have a pull-up somewhere). My MPU-6050 is connected to the I2C via a level shifter, so I have not current flow from the I2C to the MPU-6050 voltage. Can you measure the SDA and SCL (while not active), and check the XDA and XCL ?

Your breakout board has 10k pull-up resistors to the 3.3V. That should be 4k7 to be safe. I think that it might perhaps cause the higher voltage. Can you add another two pull-up resistors of 10k from the SDA and SCL to the 3.3V of the Arduino board ?

The 4k7 prevents that the internal pull-up resistors in the avr chip (on the Arduino board) raises the voltage of the I2C too high for 3.3V devices.

I have added your GY-52 breakout board : http://arduino.cc/playground/Main/MPU-6050

Thanks,

Rechecked voltage: 3.32V
go figure :roll_eyes: I should add some water in my Bordeaux…

I will put additional resistors on SDA and SCL, on the Arduino side
I guess the original 10K’s are OK when more sensors are added to the I2C Bus

Hey guys, who can explain what VLOGIC at 3.3V does to I2C? Does it bring the binary logic level up to 6.6V? Thanks

Obakemono:
This is my wiring, all direct connections, no resistors. The simplest wiring possible i think.

VDD ----> 3.3v
GND ----> GND
SDA ----> A4
SCL ----> A5
VIO ----> 3.3v (same VDD supply)

chazm try this exactly this wiring, take out the resistors, and try to disconnect not mentioned pins.
I may be wrong about the sleep bit, so this is a little more complex code which solves that, it should output accelerometer x values.

This is a video of me executing this code.

http://youtu.be/mtuQPSGQCHE

#include <Wire.h>

#define MPU6050_ACCEL_XOUT_H  0x3B
#define MPU6050_ACCEL_XOUT_L  0x3C
#define MPU6050_ACCEL_YOUT_H  0x3D
#define MPU6050_ACCEL_YOUT_L  0x3E
#define MPU6050_ACCEL_ZOUT_H  0x3F
#define MPU6050_ACCEL_ZOUT_L  0x40
#define MPU6050_GYRO_XOUT_H   0x43
#define MPU6050_GYRO_XOUT_L   0x44
#define MPU6050_GYRO_YOUT_H   0x45
#define MPU6050_GYRO_YOUT_L   0x46
#define MPU6050_GYRO_ZOUT_H   0x47
#define MPU6050_GYRO_ZOUT_L   0x48
#define MPU6050_PWR_MGMT_1    0x6B

#define MPU6050_I2C_ADDRESS   0x68

uint16_t ax, ay, az, gx, gy, gz;

void setup() {
 uint8_t c = 0;
 
 Serial.begin(9600);
 Wire.begin();
 
 MPU6050_write(MPU6050_PWR_MGMT_1, &c, 1); //Stop device from reseting/sleeping

Serial.println(“START”);
}

void loop() {
 
 ax = calculate_value(MPU6050_ACCEL_XOUT_H, MPU6050_ACCEL_XOUT_L, 1);
 ax = (ax-32500)/8.192;
 
 Serial.println(ax);
}

uint16_t calculate_value(int address_h, int address_l, int size) {
 
 uint8_t hi, lo;
 uint16_t value;
 
 hi = MPU6050_read(address_h, size);
 lo = MPU6050_read(address_l, size);
 
 value = ((hi)<<8);
 value |= lo;
 
 return(value);
 
}

uint8_t MPU6050_read(int address, int size) {
 
 uint8_t value;
 
 Wire.beginTransmission(MPU6050_I2C_ADDRESS);
 Wire.write(address);
 Wire.endTransmission(false);

Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true);
 while(Wire.available()) {
   value = Wire.read();
 }
 
 return (value);
}

int MPU6050_write(int address, uint8_t *data, int size) {
 
 Wire.beginTransmission(MPU6050_I2C_ADDRESS);
 
 Wire.write(address);        // write the start address

Wire.write(data, size);  // write data bytes

Wire.endTransmission(true); // release the I2C-bus
 
 return (0);         // return : no error
}

hi OBAKEMONO! I have a mpu6050. I want to use for myquadcopter.I use PIC16F877 as process.I use CCS C as program language.But I dont know how to use this sensor.which pin connect to PIC16F877.is the INT pin used? can you tell me which pin connect to where? wait your answer!!
THANKS…

Krodal: Check your wiring once more. AD0 must be connected to ground or 3.3V (with solder jumper). Connect it to ground for I2C address 0x68. SCL and SDA are connected directly to the Arduino, but you could add extra pull-up resistors to the 3.3V. The resistors could be 4k7 or 10k (the board already has 10k pull-up resistors, but I prefer 4k7). You don't need the INT, you could leave it open. The CLKIN and FSYNC can be tied to ground, because they are not used.

If you have all this, the scanner sketch should be able to find it.

I'm confused ! Is this crossposting ? http://arduino.cc/forum/index.php/topic,111698.0.html If you bought a new sensor module, and started a new topic, you should have mentioned at the beginning that you made this posting before. It's okay, as long as you let us know.

hi KRODAL! I have a mpu6050. I want to use for myquadcopter.I use PIC16F877 as process.I use CCS C as program language.But I dont know how to use this sensor.which pin connect to PIC16F877.is the INT pin used? can you tell me which pin connect to where? wait your answer!! THANKS...

That is the Sparkfun breakout board, https://www.sparkfun.com/products/11028

Connect it as written a few posts earlier. Vcc and Vio to 3.3V SDA and SCL are the I2C bus. The Sparkfun board has already 10k pull-up resistors. Gnd to Gnd.

I don't know PIC microcontrollers. Do they have a I2C bus ?

hello guys…

i have a problem with the “MPU6050_DMP6” sketch from GitHub that Jeff has posted…and just with that… (https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino).

I have a MPU6050 SparkFun Breakout connected to an Arduino MEGA 2560 and i’ve followed all the instructions for wiring and all as well as looking at almost all the posts of this and Arduino’s forum for, but haven’t really found a solution:

so basically, once finished uploading the sketch "MPU6050_DMP6, i see on the Arduino Mega
the TX led going ON for about 1 second, and then stopping any transmission. On the Serial Monitor,
instead, i see a short message like “Myÿ£eæÇô¸”.

The “RAW” example sketch works giving me some weird digit values on the Serial Monitor like:
°°gŵ 40ű°Åµ0¥?ű°§40ű°•Ì §%Å°°Åµ†4%°1…and goes on forever

the “I2CScanner.pde” sketch from Tod E. Kurt (http://todbot.com/blog/) something like:
òö(åà÷s a÷s à÷sL»÷sLà÷s à÷s (à÷sL»÷sLà÷såà÷s…

while instead the example sketch from Krodal (http://playground.arduino.cc/Main/MPU-6050?action=sourceblock&num=1) is actually working perfectly:

Inyro, error = 0
accel x,y,z: 304, -532, 17572
temperature: 30.153 degrees Celsius
gyro x,y,z : -169, -49, 204,
l, temp and gyro, error = 0
accel x,y,z: 304, -532, 17572
temperature: 30.153 degrees Celsius
gyro x,y,z : -169, -49, 204,
InvenSense MPU-6050
June 2012
WHO_AM_I : 68, error = 0
PWR_MGMT_1 : 0, error = 0

and on and on with correct the data readings…

as well as working are all the patches from this previous page of the forum:

I’m sorry but i really cannot figure out what is the problem, i’ve tried to #include the “Wire.h”,
#define whatever MPU6050_ACCEL_XOUT_H 0x3B and so on, but the Main patch gives me always
those unreadable values on the Serial Monitor…

Do you maybe have a clue on what is wrong?

thanx a lot!

Federico