Krodal

I used the datasheet(s) as a framework to set up a basic sketch.The idea is that if the code has been proven to be okay (it is), someone might use it to extend it and put it in a class.

So all the defines are the registers and the bits in the registers. I named them the same as in the datasheet(s).You have to keep the datasheet next to it, to know what it is about.

But that is not all, there are also undocumented registers.If you take a look at the code by Jeff Rowberg, you see he has more registers.http://www.i2cdevlib.com/https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h

WilliamW

I will add my experience in case it is helpful to someone. I also had trouble getting my Arduino to recognize the GY-521 at all (and then, when I first got it recognized, I would get the error code = 2).

Like appears to have been the case for a couple others here, my troubles all turned out to be due to poor connections.

Using a breadboard, I set up my pins as other have outlined here, but could not get I2CScanner or anything else to recognize the sensor. Eventually with much jiggling of wires and pin/connections, I was able to get the Arduino to intermittently recognize the sensor - but I was now getting "error code = 2" and bad readings. I also noticed that the LED light on the GY-521 was weak and pulsing, which didn't seem right.

Eventually I chucked the breadboard and connected the sensors directly (i.e., no breadboard, just pins right through the holes on the GY-521), and everything works - a nice steady bright LED on the GY-521, no error code, and readings that appear to be accurate.

Not sure if the GY-521's connections are finicky, or if it was just my lack of experience.