Table of Contents

lamaPLC: MPU-6050 (HW-123, GY-521) 6-axis MotionTracking device

MPU-6050 6-axis MotionTracking device The MPU-6050 (HW-123, GY-521) is a popular 6-axis motion-tracking sensor that combines a 3-axis gyroscope and a 3-axis accelerometer on a single chip. It is a MEMS device created to measure acceleration, rotational velocity, and orientation.

Key Technical Specifications

Notable Features

Pinout Table (HW-123, GY-521)

Pin NameDescriptionNote
VCCPower SupplyTypically 3V to 5V (due to onboard regulator).
GNDGroundCommon ground for the system.
SCLI²C Serial ClockConnect to MCU clock line (e.g., A5 on Uno).
SDAI²C Serial DataConnect to MCU data line (e.g., A4 on Uno).
XDAAux Serial DataFor connecting external I²C sensors (optional).
XCLAux Serial ClockFor connecting external I²C sensors (optional).
AD0Address SelectLow (default) = 0x68; High = 0x69.
INTInterrupt OutputSignals the MCU when new data is available.

Pin Functions & Wiring Tips

Arduino example code

To connect the MPU-6050 to an Arduino, the simplest method is to use the Adafruit MPU6050 library, which handles I²C communication and converts raw data to standard units (mls² for acceleration and rad/s for rotation).

This code initializes the sensor and prints real-time movement data to the Serial Monitor at 115200 baud.

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
 
Adafruit_MPU6050 mpu;
 
void setup(void) {
  Serial.begin(115200);
  if (!mpu.begin()) {
    while (1) { delay(10); } // Loop if sensor not found
  }
  // Optional: Set ranges
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}
 
void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);
 
  // Print accel and gyro data to Serial Monitor
  Serial.print(a.acceleration.x); Serial.print(", ");
  Serial.print(g.gyro.x); Serial.println();
  delay(500);
}

Tips for Better Results

I2C topics on lamaPLC

PageDateTags
2026/04/23 21:51, , , , , , ,
2025/09/23 21:25, , , , , ,
2026/04/15 19:34, , , , , , ,
2026/03/22 03:14, , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/03/28 23:50, , , , , , ,
2026/04/12 00:34, , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , ,
2026/03/22 00:08, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2025/05/31 23:32, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2025/11/22 00:07, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2023/07/01 17:29, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2026/03/22 01:44, , , , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , ,
2026/04/23 21:51, , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , , , , , , , , , , ,
2026/04/11 19:54, , , , , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/02/14 18:27, , , , , , , , , ,
2026/04/23 21:52, , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/15 19:41, , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/02/14 23:47, , , ,
2026/02/14 23:51, , , , , ,
2026/02/14 18:26, , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/03/05 21:19, , , , , , , , , , , , , , , , ,
2026/02/14 18:27, , , , , , ,

This page has been accessed for: Today: 2, Until now: 13