I've been messing around with accelerometers for Arduino for a school project. I bought the SODIAL GY-521 accelerometer + gyroscope module for Arduino. It uses de Invensense MPU 6050. I managed to connect it onto my board and successfully detect it, but it returns values of -1 on all output ports. I was expecting there to be a port for every axis of acceleration and rotation but it seems that this isn't the case. How should I connect the module into my Arduino, and how should I program the Arduino to read my data?

I tried to follow the Arduino Playground example but the result was as explained above.

Thank you for all answers.

2 Answers 2


From the Arduino playground:
This sensor board has a voltage regulator. When using 3.3V to the VCC the resulting voltage (after the onboard voltage regulator) might be too low for a good working I2C bus. It is preferred to apply 5V to the VCC pin of the sensor board. The board has pull-up resistors on the I2C-bus. The value of those pull-up resistors are sometimes 10k and sometimes 2k2. The 2k2 is rather low. If it is combined with other sensor board which have also pull-up resistors, the total pull-up impedance might be too low.

  • I am kind of new to this whole electronic thing, so I may need a little more explaining. I believe I connected the module into the 5V pin but I have no idea about the other stuff you mentioned.
    – OCA
    Mar 25, 2016 at 15:19
  • First of all you should measure the pull-up resistor values. Secondly do you have other I2C devices connected?
    – jantje
    Mar 25, 2016 at 19:29
  • My circuit consists of an Arduino Uno + accelerometer, nothing else. My question is where do I connect what and why, and how do I code it. So basically everything.
    – OCA
    Mar 26, 2016 at 10:30

I usually use the following connections for my MPU 6050: Vcc: 3.3V GND: Any arduino GND SDA: A4 SCL: A5 AD0: GND(for address 68)/ 3.3V(for address 69)

I do not usually connect any of the other pins. For the code I usually use a wonderful library written by Jeff Rowberg which can be found here(http://www.i2cdevlib.com/devices/mpu6050#source). This library enables you to also use the Digital Motion Processor on board the MPU 6050 to give you prefiltered rotation data. It also has example code which should make things easy.

You can connect at most 2 MPU 6050s to the I2C port of the arduino by using different addresses for it. If you need to hook up more, you will require a multiplexer.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.