Using GY-521 Accelerometer + Gyro

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.

Hope that is helpful to someone!