Introduction: Arduino: MPU 6050 Getting It to Work!

It seems that one of the more difficult modules to get working on the Arduino contains the MPU 6050 IC which is a 6 degrees of freedom Gyroscope and Accelerometer. After recently buying one, I found out why.

In this Instructable I walk you through the process of discovery that finally allowed me to compile and upload the sketch, get the data and display it. This Instructable in part shows you the functionality of the IC but also how to problem solve so that you do not get frustrated with learning new technologies but learn from the problems.

On to the problems...

Step 1: Making Connections Is Not Necessarily All That Easy.

A quick browse through Google reveals that many people have problems with this particular ICU. Although the truth is that the first problems arise from the sheer number of variations of breakout boards that exist for the IC. Amazingly not one of the boards above is the same as the one I am using.

My board has 4 connectors on either side. Only one side has any indication to what the connectors are which is: Gnd, Tx, Rx, Vcc. So we know what to connect to Gnd and Vcc - remember almost all these modules are 3.3v not 5v. So use the correct voltage or you may damage your kit. But where do we connect TX and Rx? Well Tx and Rx are clearly marked on the Arduino so - there of course.

Because everything we do is ultimately controlled by our Atmel chip on our Arduino which we have to write the code for, and so much code is already written for these devices that we can just use a library and its examples and we are sorted; not so.

The right time and place...

Step 2: The Right Time and Place...

Technology moves forward at great speed and although developers try to make their software and hardware backwards compatible at some point it becomes impossible. It is even harder to make software and hardware future proof. This is the case with many of the examples and libraries that are available for the 6050.

The first thing you need to do is make sure you are looking at the most recent libraries and examples and not those that are several years out of date! Google makes this easy, just select "Search Tools" and on the little extended menu that appears click on "Any Time" and choose "Past Year". That will give you nice a recent results.

But that still does not mean you are going to have a working sensor. First of all the most used library - the one you are most likely to find is out of date - even though it is still in development. It will not compile on the current Arduino IDE, you need to use 1.5 or 1.0.5 for it to work, I have forgotten which. But regardless of which it is - you should not be using out-dated software; there is a reason it is out-dated!

Also, the examples provided are all I2C based which my module appeared not to support and some other modules do not support for definite.

So let's write our own code..

Step 3: So Let's Write Our Own Code..

Ha! I wish it was that simple.

If you have a look through the documentation for the 6050 you will quickly realise you need to be an excellent developer with a good grounding in embedded systems. If you have those skills then you certainly do not need this Instructable. So, no you are not going to be writing your own code yet, and not at all in this Instructable.

Just as an aside - whilst doing my research and meandering around the internet in the hope of reaching the mother-load of information on this module I came across many fallen comrades.It reminded me that kits like Arduino are marketed in such a way that people think they can throw a couple of sensors and modules together and they will have a working Asimo. The truth is far from that, Arduino makes it easier for people to fail.

So, if it is really difficult to do for the average person how do we get the modules working. Well if you use the more expensive modules that are over 100 times more expensive than those you can get in China then you will probably get it all up and running on day one. The additional cost is there to provide the tools and support you need. However, if you go for a cheaper option with no support you need to do your own research.

Where too look for information...

Step 4: Where to Look for Information...

The website will normally have some information - they may have a link to information which will move you that little bit closer to knowledge. Look at the sources of examples - do they have links? Check them out. Eventually I found the information on a Chinese file hosting site.

Don't worry you are not going to have to go there and hope that Google translate gives you something you can understand - it won't. Here are the files you will need. The contains the Sketch you need to get the module return sensor data to the Serial Console. The also contains the and a lot more besides.

Step 5: In Summary

Don't give up!

The information is there if you look for it. It took me three days around 15 hours of non-stop looking to finally get the information I needed to get the module working. And that's not the end of it. I have still to properly interpret the data, create a 3D interface, self-testing and self-configuration functions and a lot more besides.

But I didn't give up, so don't give up either - you can and will succeed. It just takes a little time and effort.