I am using the MPU-6050 with the Arudino Mega 2560. I have the I2Cdev Library installed and am running the MPU6050_DMP6 example sketch. The connections are as shown.
VCC --> 5V
GND --> GND
SDA --> SDA
SCL --> SCL
INT --> Pin 2
The sketch works fine and gives me the values for roll, pitch, and yaw but after about 5-20 minutes I start to get extraneous values coming through the serial monitor. I have attached a picture below.
The MPU is mounted on a shield that plugs into the Arduino Mega and my guess is that one of the signal wires doesn't have a good connection and momentarily becomes disconnected. To test this I got another Arduino Mega and MPU-6050 and pulled on the SDA, SCL, and INT pins to see if I could replicate the results.
I was able to sometimes replicate the values but not consistently. Sometimes when I pulled and put back in the SDA line the data would just stop, keep the same value but still be transmitting, or go back to working just fine. I am assuming that when I pull signal wire it depends on what the Arduino code is doing at that exact moment that determines the result.
Does this sound like an issue that could be a bad connection? And the fix would be to bypass the pin header connection and solder directly to the Arduino? Or does this look like another issue?
There is anti-creep logic included in the MPU-6050 library.
Absolutely needed. (On my 6050, there is substantial creep in the Y axis and the logic nicely takes care of that)
There is a possibility that your MPU-6050 has got substantial creep and that in the logic there is some value overflowing. Such an event would explain the time delay between arduino start and problem appearance.
If you want to analyze further, there are some printf instructions commented out. Uncomment them to print raw angle values and watch them increasing over time.
So I decided to solder the pins of the shield directly to the pins of the Arduino through some extra wires and I have ran the test for about 1 hour and 30 minutes with no problem. I assume this means a bad connection between the male headers and the female headers to be the corporate. This design will be based on a mobile platform and will be (and has been) exposed to vibrations which is what I believe made the connection "spotty" in the first place.
Is there a way to improve the connection between the male headers of the shield and the female headers of the Arduino without soldering a wire directly between the connections? Maybe add some solder the male headers to make them slightly thicker and have a better connection?
2 hours into the test I got the extraneous values showing up.
Another thing I forgot to mention is that I did enable I2C Fast Wire in the I2Cdev.h library. Could this cause instability's in the program?
I have never had it be an issue in any of my other projects.