I have a MPU6050 breakout board that I am trying to interface with my Due. I tried the I2Cdev library and could not get it to work AT ALL, but the I2Cdev Lib wouldn't even work on my Mega.... So I tried the code on fourms ( Arduino Playground - MPU-6050 ). It's works on my Mega just fine, but not on my Due... It gives me error 4. I assume that means It couldn't connect to the sensor. Acting on that thought I uploaded an I2C scanner. And I found the MPU6050 at it's default address.
Does anyone know what is happening, or if it's a bug??? I want to get a UDOO quad board but if the Due cant interface with any i2c devices, I may consider not buying it...
I am on the latest version of the Arduino beta. But tell me how to adapt the I2Cdev lib please! It kept erroring out saying SPI.h (or something SPI related) was not declared in this scope. Is that a problem???
That is not my issue with I2Cdev lib. My issue is it won't compile on any version of the IDE for ANY board. It says something to do with SPI is not declared properly. I will upload a screenshot ASAP. But I did get it to work before... Like a year ago. I can get my Due and my Mega 2560 to find the chip with a scanner. But the example code only works for the mega... Did you see my link for the code I'm talking about??? Thank you for your help.
No, no level shifters. But nothing is wrong with the Arduino or the MPU6050 because I can still use I2C scanner on my Due and STILL find the chip at the correct address. And I can still read values just fine with my Mega. Can I make a level shifter with a voltage divider? And which do I need the level shifter for? The Mega or the Due? Stupid question probably...
The Mega 2560 board is the only board with 10k pullup resistors to 5V. That creates a 5V I2C bus, which is too much for the MPU-6050. You must use a I2C level shifter, not a voltage divider.
The Due is 3.3V, just as the MPU-6050, no problem there.
I think my breakout board must have a resistor onboard it then. Because the mega is the only one it works with... I tried both 5V and 3.3V on the Due, neither work. Only the mega can read values...
I have a nano... But isn't the mega reading values good enough proof that there is no damage? And if there is any diagnostic I could do with an oscilloscope, I have a Rigol ds1000z-s with all decoders unlocked. (Don't ask how it got that way lol) 8)
If I read the description of the product I bought, it says it can be supplied with 3-5V because it has a regulator onboard. Could something still be wrong with the I2C bus if I can still use a scanner and find the sensor (on the Due)? And I'll try the nano in tomorrow.
I think you have a module with a MPU-6050 and a voltage regulator. The voltage regulator makes 3.3V for the MPU-6050.
However, the SDA and SCL are pins of the MPU-6050, and if you feed that with 5V, many bad things can happen =(
I did some diagnostics with my oscilloscope. And found something strange while the sensor was connected to my Due. Take a look at the picture. This may suggest something is wrong with my Due... BTW, re-tested on My Mega and it still reads values and traces on the oscilloscope were normal.
(For Due)
It does the same thing while powered by the 3.3 pin, the only difference is that the logic is also 3.3V. While the sensor is powered by 5V, the logic is also 5V. So this sensor must have a logic level converter built in somehow.
The top trace is supposed to be the data signal, and the bottom trace is the clock signal. I don't believe there is supposed to be an in between signal like that (data trace). This pic was taken while connected to the Due.
Please don't continue like this. You might even throw everything away and start again (but without the wrong connections).
Always use a level shifter for the I2C bus when you use a 3.3V chip with the Arduino Mega. Always. Without a single mistake.
You can test the MPU-6050 module with the Nano.
Do you have another I2C chip ? To test if the I2C of the Arduino Due board is still okay ?
Thanks for the photo, that signal is not okay, looks like a shortcut. Perhaps something is half-fried.
Can you make a photo of your MPU-6050 module ? I would like to see what is on it, beside the MPU-6050 and maybe a voltage regulator.
Working or not, the Due is sending a signal that is not right. Does that mean something is wrong with my due??? I will use a level shifter in the future. These sensors are cheap anyways.
That is the standard Ebay cheap MPU-6050 module. Nothing wrong with that.
The little black component at the top with 3 pins is the voltage regulator. It makes 3.3V for the MPU-6050.
The rest is just some resistors and capacitors.
For a 5V Arduino Uno (and Nano, and Leonardo and so on) : GND to GND. Apply 5V to Vcc, SDA to SDA, SCL to SCL.
For a Arduino Mega : GND to GND. 5V to Vcc, use level shifter for SDA and SCL.
For a 3.3V Due : GND to GND, 3.3V to Vcc (5V is also okay, 3.3V to 3.3V might also work), SDA to SDA, SCL to SCL.
You don't know what is working and what is reliable. You have to test everything as I wrote before. I don't know any other way. You could be spending spending hours with a faulty board or sensor. But I'm not sure that something is broken, it's just too confusing.