meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sensor:mpu_6050 [2026/03/22 01:24] – created vamsansensor:mpu_6050 [2026/03/22 02:13] (current) – [Pinout Table (HW-123, GY-521)] vamsan
Line 1: Line 1:
-====== lamaPLC: MPU-6050 6-axis MotionTracking device ====== +====== lamaPLC: MPU-6050 (HW-123, GY-521) 6-axis MotionTracking device ====== 
-The MPU-6050 is a widely used 6-axis MotionTracking device that combines a 3-axis gyroscope and a 3-axis accelerometer on a single silicon die. It is a Micro-Electro-Mechanical System (MEMS) designed to measure acceleration, rotational velocity, and orientation.+{{ :sensor:mpu_6050.png?150|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** **Key Technical Specifications**
Line 9: Line 10:
     * **Gyroscope:** ±250, ±500, ±1000, and ±2000 °/sec.     * **Gyroscope:** ±250, ±500, ±1000, and ±2000 °/sec.
     * **Accelerometer:** ±2g, ±4g, ±8g, and ±16g.     * **Accelerometer:** ±2g, ±4g, ±8g, and ±16g.
-  * **Communication:** Primary interface is I2C (up to 400 kHz).+  * **Communication:** Primary interface is [[com:basic_i2c|I²C]] (up to 400 kHz).
   * **Operating Voltage:** 2.375V to 3.46V for the raw chip; common breakout modules like the GY-521 include a 3.3V regulator for 5V compatibility.   * **Operating Voltage:** 2.375V to 3.46V for the raw chip; common breakout modules like the GY-521 include a 3.3V regulator for 5V compatibility.
   * **I²C Addresses:** 0x68 (default) or 0x69 (selectable via the AD0 pin).   * **I²C Addresses:** 0x68 (default) or 0x69 (selectable via the AD0 pin).
  
 +**Notable Features**
 +
 +  * **Digital Motion Processor (DMP):** An on-chip co-processor that offloads complex sensor fusion calculations (like converting raw data into quaternions or Euler angles) from the main microcontroller.
 +  * **FIFO Buffer:** A 1024-byte buffer that allows the system processor to read data in bursts, reducing power consumption by letting the host stay in sleep mode longer.
 +  * **Auxiliary I²C Bus:** Allows the MPU-6050 to act as a master to external sensors, such as a 3rd-party magnetometer, to provide full 9-axis //"MotionFusion"// output.
 +
 +==== Pinout Table (HW-123, GY-521) ====
 +|< 100%>|
 +^Pin Name^Description^Note|
 +^VCC|Power Supply|Typically 3V to 5V (due to onboard regulator).|
 +^GND|Ground|Common ground for the system.|
 +^SCL|I²C Serial Clock|Connect to MCU clock line (e.g., A5 on Uno).|
 +^SDA|I²C Serial Data|Connect to MCU data line (e.g., A4 on Uno).|
 +^XDA|Aux Serial Data|For connecting external I²C sensors (optional).|
 +^XCL|Aux Serial Clock|For connecting external I²C sensors (optional).|
 +^AD0|Address Select|Low (default) = 0x68; High = 0x69.|
 +^INT|Interrupt Output|Signals the MCU when new data is available.|
 +
 +**Pin Functions & Wiring Tips**
 +
 +  * **I²C Communication:** The module acts as a slave. SCL and SDA pins are essential for all basic operations.
 +  * **Multi-Sensor Setup:** Use the AD0 pin to change the I²C address if you need to use two MPU-6050s on the same bus.
 +  * **External Master:** The XDA and XCL pins allow the MPU-6050 to act as a master to a secondary sensor, such as a magnetometer, to create a 9-axis fusion system.
 +  * **Interrupts:** The INT pin can be programmed to trigger on specific events, such as //"Data Ready"// or //"Motion Detected,"// allowing the MCU to perform other tasks until needed. 
 +
 +==== 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.
 +
 +<code c>
 +#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);
 +}
 +</code>
 +
 +**Tips for Better Results**
 +
 +  * **Calibration:** For precise motion tracking, calculate offsets (the average reading when the sensor is perfectly still) and subtract them from your raw data.
 +  * **Filtering:** If your readings are //"noisy,"// a Complementary Filter can help combine accelerometer and gyroscope data to produce a smoother orientation (tilt) estimate. 
 +
 +===== I2C topics on lamaPLC =====
 +{{topic>i2c}}
 +
 +{{tag>MPU-6050 HW-123 GY-521 6-axis_MotionTracking DMP temperature sensor MEMS arduino_code Arduino accelerometer gyroscope tilt}}
 +
 +This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}