Connecting MPU6050 Gyroscope + Accelerometer to Arduino

Here is how to connect MPU6050 Gyroscope+Accelerometer to our Hackabot Uno Robot Kit.


This is how MPU6050 look like:


Note that it shows the X & Y axes on the circuit board. Z-axis is the one perpendicular to the board. There are straight and angled header pins included in the kit.

I selected the angled ones. After soldering, it is very convenient to insert the sensor to the breadboard. Z-axis is pointing to the forward direction. X-axis points upward.

So, if the robot moves forward (from idle), the sensor will detect acceleration in Z-direction.


MPU6050 uses I2C bus to communicate to Arduino. Here is the wiring:

Sensor   :    Arduino Uno

VCC        :   +5V

GND       :   GND

SCL         :   pin A5

SDA        :   pin A4

INT         :   pin 2

Leave the ‘XCL’, ‘XDA’, and ‘ADO’ pins on the sensor unconnected. ‘XCL’ and ‘XDA’ are the pins in the auxiliary I2C bus. It is possible to hook up other sensors like magnetometer to MPU6050. We may cover this in the future.  ‘INT’ pin is for interrupts.


In this tutorial, I am using the i2cdevlib library from Jeff Rowberg. You may download and import it to your Arduino IDE.

There are excellent examples coming with Jeff’s library. You may open them in Arduino IDE as follows: ‘File’ -> ‘Examples’ -> ‘MPU6050’ -> ‘Examples’ -> …


In this example, the code simply prints the X/Y/Z acceleration and roll, pitch, yaw readings.

  • Rahul Sapare

    im getting error when i try to import the .zip file of i2cdevlib in ide so i tried to copy the files diectly to the root but then also im getting error like invalid library found. how to solve this please help me