Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›MPU6050 Accelerometer and Gyroscope
Step 15 of 18 in Sensors and measurementPart of a learning path.
Next

Component guide · Intermediate · 3 min read

MPU6050 Accelerometer and Gyroscope

Guide, Wiring and Code

By Geekobot Learning Team · Updated 24 Oct 2026

On this page
Short answerWhat the accelerometer and gyroscope measureGY-521 pinoutRead the MPU6050 with Arduino or ESP32Calibration and driftMPU6050 alternativesCommon mistakesFAQsParts and next steps
Short answer

The MPU6050 is a 6-axis motion sensor that combines a 3-axis accelerometer and a 3-axis gyroscope on one chip and talks over I2C at address 0x68. On the popular GY-521 module it runs from 3.3 to 5 V. It is used for self-balancing robots, tilt sensing, gesture control and drone stabilisation.

Key specs at a glance

Sensors
3-axis accelerometer + 3-axis gyroscope + temperature
Accelerometer range
±2, ±4, ±8 or ±16 g
Gyroscope range
±250, ±500, ±1000 or ±2000 °/s
Resolution
16-bit for each axis
Interface
I2C up to 400 kHz, address 0x68 (0x69 with AD0 high)
Supply
GY-521 module: 3.3 to 5 V (onboard 3.3 V regulator)
Extras
INT pin, Digital Motion Processor (DMP), auxiliary I2C
01

What the accelerometer and gyroscope measure

The accelerometer measures acceleration, including gravity. Held still, it tells you which way is down, so you can calculate tilt (pitch and roll). It is noisy when the sensor vibrates or moves.

The gyroscope measures rotation speed in degrees per second. Integrating it over time gives an angle that is smooth over short periods but slowly drifts.

Combining both with a complementary filter or the chip's DMP gives a stable angle. The MPU6050 has no magnetometer, so heading (yaw) always drifts; use an MPU9250-class or BNO055 sensor if you need a compass.

02

GY-521 pinout

PinConnect toPurpose
VCC3.3 V or 5 VPower (module regulates to 3.3 V)
GNDGND
SCLUno A5, ESP32 GPIO 22, Pico GP5I2C clock
SDAUno A4, ESP32 GPIO 21, Pico GP4I2C data
XDA, XCLOptionalAuxiliary bus for an external magnetometer
AD0GND or leave open (0x68), 3.3 V (0x69)Address select
INTOptional interrupt pinData-ready or motion interrupt
VCC
Connect to:
3.3 V or 5 V
Purpose:
Power (module regulates to 3.3 V)
GND
Connect to:
GND
SCL
Connect to:
Uno A5, ESP32 GPIO 22, Pico GP5
Purpose:
I2C clock
SDA
Connect to:
Uno A4, ESP32 GPIO 21, Pico GP4
Purpose:
I2C data
XDA, XCL
Connect to:
Optional
Purpose:
Auxiliary bus for an external magnetometer
AD0
Connect to:
GND or leave open (0x68), 3.3 V (0x69)
Purpose:
Address select
INT
Connect to:
Optional interrupt pin
Purpose:
Data-ready or motion interrupt
03

Read the MPU6050 with Arduino or ESP32

Install Adafruit MPU6050 from the Library Manager. Accelerations come out in m/s² and rotation in rad/s.

MPU6050 raw readings · Arduino C++Verify & upload in Electrolark
#include <Adafruit_MPU6050.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  if (!mpu.begin()) {                    // default address 0x68
    Serial.println("MPU6050 not found");
    while (1) delay(10);
  }
  mpu.setAccelerometerRange(MPU6050_RANGE_4_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}

void loop() {
  sensors_event_t a, g, t;
  mpu.getEvent(&a, &g, &t);
  float pitch = atan2(a.acceleration.x,
                sqrt(a.acceleration.y * a.acceleration.y +
                     a.acceleration.z * a.acceleration.z)) * 180 / PI;
  Serial.print("Pitch: "); Serial.print(pitch);
  Serial.print("  Gyro Z: "); Serial.println(g.gyro.z);
  delay(100);
}
04

Calibration and drift

Every MPU6050 has small offsets. Lay the module flat and still, average a few hundred gyro readings, and subtract that average from later readings. For the accelerometer, average readings in each orientation. Many libraries, including Electronic Cats' MPU6050 (based on i2cdevlib), include an auto-calibration routine that writes offsets into the chip.

05

MPU6050 alternatives

TDK InvenSense has listed the MPU6050 as end-of-life, so many modules now carry compatible clones. For new designs consider:

SensorAxesWhy choose it
MPU6500 / ICM-20600 series6Drop-in successors, SPI and I2C
ICM-42688-P6Low noise, used in modern flight controllers
BMI160 / BMI2706Very low power, wearables
BNO055 / BNO0859 with fusionOutputs ready-made orientation; no filter code needed
MPU6500 / ICM-20600 series
Axes:
6
Why choose it:
Drop-in successors, SPI and I2C
ICM-42688-P
Axes:
6
Why choose it:
Low noise, used in modern flight controllers
BMI160 / BMI270
Axes:
6
Why choose it:
Very low power, wearables
BNO055 / BNO085
Axes:
9 with fusion
Why choose it:
Outputs ready-made orientation; no filter code needed
06

Common mistakes to avoid

  • !Expecting a stable yaw (compass heading); without a magnetometer it drifts.
  • !Sharing address 0x68 with a DS3231 RTC; pull AD0 high to move the MPU6050 to 0x69.
  • !Mounting it on a vibrating motor frame without soft mounting or filtering.
  • !Integrating the gyroscope alone for angles, which drifts within seconds.
  • !Ignoring the 'not found' message: usually SDA/SCL are swapped or the module is unpowered.
07

Frequently asked questions

What is the MPU6050 used for?

Tilt and orientation sensing in self-balancing robots, gimbals, gesture controllers, step counters, vehicle crash detection and drone flight controllers.

What is the I2C address of the MPU6050?

0x68 by default, or 0x69 when the AD0 pin is pulled high, so two can share one bus.

Can the MPU6050 run on 5 V?

The chip itself is a 3.3 V part, but GY-521 modules include a regulator and pull-ups, so they accept 3.3 to 5 V on VCC.

What is the difference between MPU6050 and MPU9250?

The MPU9250 adds a 3-axis magnetometer, giving 9 axes and a stable compass heading. The MPU6050 has 6 axes only.

Why are my MPU6050 angles drifting?

Gyroscope integration accumulates small errors. Calibrate offsets at start-up and fuse accelerometer and gyro data with a complementary or Kalman filter, or use the DMP.

Parts for this guide

  • 4-DOF Robotic Arm Kit (for SG90 / MG90S)
    ₹562View
Shop Motion & Position SensorsShop Flight Controllers & GPS

Terms in this guide

IMUInertial measurement unit: a combined accelerometer and gyroscope, sometimes with a magnetometer.AccelerometerA sensor that measures acceleration, including gravity, along one or more axes; used to detect tilt, vibration and movement.GyroscopeA sensor that measures rotation rate, in degrees per second.I2CInter-Integrated Circuit: a two-wire bus (SDA and SCL) that connects many devices by address.Complementary filterA simple way to combine gyroscope and accelerometer readings into a stable angle by blending their strengths.

Projects that use it

Put this into practice: 39 step-by-step builds in our project library use parts from this guide.

Advanced · 5–6 hoursTwo-wheel self-balancing robotView projectIntermediate · 3–4 hoursGyro-guided square-path robotView projectIntermediate · 2–3 hoursTwo-axis phone camera gimbalView project
Browse all 39 projects

Keep learning

Concept explainerIntermediateI2C ExplainedI2C is a two-wire bus that lets one microcontroller talk to many sensors and displays using a data line (SDA) and a clock line (SCL).4 min read · Electronics FundamentalsComponent guideBeginnerESP32 GuideThe ESP32 is a low-cost 3.3 V microcontroller from Espressif with built-in Wi-Fi and Bluetooth, used for IoT devices, smart-home controllers and web dashboards.5 min read · Boards & MicrocontrollersComponent guideBeginnerArduino UnoThe Arduino Uno is a beginner-friendly microcontroller board that reads sensors and controls LEDs, motors and relays using simple C++ programs called sketches.5 min read · Boards & MicrocontrollersComponent guideBeginnerServo Motors GuideA hobby servo is a small motor with a gearbox, position sensor and control circuit that moves to an angle you set with a pulse signal.3 min read · Motors & Motion

Sources

  • MPU-6000/MPU-6050 Product Specification and Register Map (TDK InvenSense)
  • Adafruit MPU6050 library documentation

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the accelerometer and gyroscope measureGY-521 pinoutRead the MPU6050 with Arduino or ESP32Calibration and driftMPU6050 alternativesCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹562

4-DOF Robotic Arm Kit (for SG90 / MG90S)

Run itChange the inputs and watch the output
Pitch 105°
Serial monitor115200 baud
Pitch: 14.80  Gyro Z: -0.01

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question