Electronics

Accelerometer Gyro 3 Axis Module GY-521 MPU6050

AED 19.95

1

Description

The GY-521 MPU-6050 Sensor Module is a versatile device built around an IC that incorporates a 3-axis MEMS accelerometer and a 3-axis MEMS gyroscope. This module enables precise measurements of angular acceleration around a body's axis, as well as linear acceleration along a specific direction. Its remarkable accuracy is attributed to its 16-bit Analog-to-Digital (AD) converter for each channel, allowing simultaneous capture of data from the x, y, and z axes. The module boasts compatibility with the Arduino board through a standard I²C communication protocol, making it a straightforward choice for various applications.

 

Package Includes:

  • 1 x Accelerometer Gyro 3 Axis Module GY-521 MPU6050

 

Features:

Gyroscope Features:

  • Angular Rate Sensors: The module includes digital-output X-, Y-, and Z-Axis angular rate sensors, also known as gyroscopes, which can measure angular velocity.
  • Full-Scale Range Options: Users can choose from a range of full-scale options, including ±250, ±500, ±1000, and ±2000 degrees per second (°/sec), allowing flexibility in sensitivity.
  • External Sync Signal: It supports an external sync signal connected to the FSYNC pin, which is useful for synchronization in applications like image and video processing, as well as GPS data acquisition.
  • Integrated 16-bit ADCs: Each gyroscope axis is equipped with a 16-bit Analog-to-Digital Converter (ADC), which enables precise and simultaneous sampling of gyroscope data.
  • Temperature Stability: The gyroscope offers enhanced bias and sensitivity temperature stability, reducing the need for manual calibration and ensuring accurate measurements across temperature variations.
  • Low-Frequency Noise Reduction: It features improved low-frequency noise performance, ensuring more reliable data in various conditions.
  • Digitally Programmable Filter: A digitally programmable low-pass filter allows users to tailor the filter settings to their specific application requirements.
  • Power Efficiency: The gyroscope operates at a current of 3.6mA while having a standby current of only 5µA, helping to conserve power.
  • Factory Calibrated: The sensitivity scale factor is factory calibrated, which ensures consistent and accurate measurements.
  • User Self-Test: The module provides a self-test feature that allows users to check the gyroscope's functionality and performance.

Accelerometer Features:

  • Triple-Axis Accelerometer: This module includes a digital-output triple-axis accelerometer, which measures acceleration in three directions (X, Y, and Z).
  • Programmable Full-Scale Range: The accelerometer offers programmable full-scale range options, including ±2g, ±4g, ±8g, and ±16g, giving users the flexibility to select the suitable range for their application.
  • Integrated 16-bit ADCs: Similar to the gyroscope, the accelerometer also includes integrated 16-bit ADCs, allowing simultaneous sampling of accelerometer data without requiring external multiplexers.
  • Power Efficiency: It operates at low power in normal operating conditions (500µA), and it has low-power modes for further power savings, making it suitable for battery-powered applications.
  • Advanced Features: The accelerometer offers features like orientation detection, tap detection, user-programmable interrupts, and a high-G interrupt, enhancing its versatility for motion-sensing applications.
  • User Self-Test: Just like the gyroscope, the accelerometer also includes a self-test feature for functional verification.

Additional Features:

  • 9-Axis MotionFusion: The module incorporates on-chip Digital Motion Processor (DMP) for 9-Axis MotionFusion, which combines data from both the gyroscope and accelerometer for more comprehensive motion analysis.
  • Auxiliary I2C Bus: It features an auxiliary master I2C bus for reading data from external sensors, such as magnetometers, providing compatibility with a wide range of sensors.
  • Operating Current: When all 6 motion sensing axes and the DMP are enabled, the module operates at a current of 3.9mA.
  • Supply Voltage Range: It can operate within a supply voltage range of 2.375V to 3.46V, accommodating different power supply configurations.
  • Flexible VLOGIC Reference Voltage: This feature supports multiple I2C interface voltages, enhancing the module's adaptability.
  • Compact Form Factor: It comes in a small and thin QFN package, making it suitable for portable and space-constrained devices.
  • FIFO Buffer: The 1024-byte FIFO buffer helps reduce power consumption by allowing the host processor to read data in bursts and then enter a low-power mode.
  • Digital-Output Temperature Sensor: The module includes a digital-output temperature sensor, which can be valuable for temperature compensation in sensor applications.
  • Digital Filters: Users can program digital filters for the gyroscope, accelerometer, and temperature sensor, enabling data preprocessing.
  • Shock Tolerance: The module is highly shock-tolerant, with a rating of 10,000 g.
  • Communication Interfaces: It supports communication through a 400kHz Fast Mode I2C for reading all registers and a 1MHz SPI serial interface for communicating with registers (specifically for the MPU-6000 variant) and a 20MHz SPI serial interface for reading sensor and interrupt registers (MPU-6000 only).


 

Description:

The GY-521 MPU-6050 Sensor Module is an advanced sensor module, incorporating a plethora of features that make it an ideal choice for a wide range of applications. At its core, this module is equipped with both a 3-axis MEMS accelerometer and a 3-axis MEMS gyroscope, allowing it to accurately capture both angular and linear motion data. One of the standout features of this module is its exceptional accuracy, made possible by the inclusion of 16-bit Analog-to-Digital Converters (ADCs) for each channel. This high-precision design ensures that it can simultaneously capture data from the x, y, and z axes, providing a comprehensive view of an object's motion. Ease of integration is another key advantage, as the GY-521 MPU-6050 Sensor Module comes with a standard I²C communication protocol. This makes it seamlessly compatible with popular development platforms like the Arduino board, simplifying the process of interfacing with and utilizing the sensor's data in your projects.

 

Principle of Work:

The GY-521 MPU-6050 Sensor Module operates by combining a 3-axis MEMS (Micro-Electro-Mechanical Systems) accelerometer and a 3-axis MEMS gyroscope within a single integrated circuit (IC). These components work together to provide accurate motion sensing and orientation data:

  1. MEMS Accelerometer: The accelerometer part of the module consists of tiny, microfabricated structures (MEMS) that can measure acceleration in three dimensions: X, Y, and Z. When the module is subjected to physical motion or orientation changes, these structures move, and the displacement is converted into electrical signals. The accelerometer measures linear acceleration along these axes and converts it into digital data using built-in ADCs.
  2. MEMS Gyroscope: The gyroscope portion of the module employs MEMS technology to detect angular velocity or changes in the orientation of the sensor. When the module is rotated, the MEMS gyroscope's sensing elements move, and this movement is translated into electrical signals. These signals are also digitized using integrated ADCs.
  3. Digital Motion Processor (DMP): The GY-521 MPU-6050 Sensor Module often includes an on-chip Digital Motion Processor (DMP). The DMP combines data from both the accelerometer and gyroscope, allowing for more accurate and robust motion analysis. It can perform complex calculations to provide orientation data, quaternion data, and other useful information, making it easier for a microcontroller (MCU) to work with the sensor.
  4. Analog-to-Digital Conversion: Both the accelerometer and gyroscope have integrated 16-bit ADCs, which convert the analog signals generated by the MEMS sensors into digital data. This high-resolution data is crucial for precise motion and orientation measurements.
  5. Data Output: The module communicates with external devices, such as microcontrollers, through a standard I²C (Inter-Integrated Circuit) interface. This interface allows for the transfer of digital sensor data in a standardized format.

How to Use the GY-521 MPU-6050 Sensor Module with an MCU:

Using the GY-521 MPU-6050 Sensor Module with a microcontroller (MCU) involves several steps:

  1. Connection: Connect the GY-521 module to the MCU using the I²C interface. This typically involves connecting the SDA (data) and SCL (clock) pins of the module to the corresponding pins on the MCU. Ensure the power supply voltage of the module is within the MCU's operating range.
  2. Initialization: Write code in the MCU to initialize the I²C communication and configure the module. This typically includes setting the gyroscope and accelerometer range, enabling or disabling specific features, and configuring the DMP if available.
  3. Data Reading: Continuously read data from the GY-521 module. You can read the accelerometer and gyroscope data as well as any other processed data provided by the DMP.
  4. Data Processing: The MCU can perform additional data processing, such as converting raw sensor data into meaningful measurements, like orientation or acceleration values.
  5. Calibration: Calibrate the sensor if necessary to eliminate any bias or offset in the data. This may involve collecting data while the sensor remains still to determine its zero offset.
  6. Application-Specific Processing: Depending on your application, you can use the sensor data to control other hardware, make decisions, or provide feedback. For example, you could use the sensor data to stabilize a quadcopter, control a robot's movements, or monitor the orientation of a wearable device.

 

Pinout of the Module:

 

Pin Name Description Additional Information
VCC Voltage Supply Input Connect to either 5V or 3.3V depending on your needs. The module has an onboard voltage regulator.
GND Ground Connect to the ground (0V) reference for your system.
SCL Serial Clock Line for I2C Communication Used for the clock signal in I2C communication with the microcontroller.
SDA Serial Data Line for I2C Communication Used for the data signal in I2C communication with the microcontroller.
XDA Auxiliary Data This pin is used for auxiliary data communication, often unused in typical applications.
XCL Auxiliary Clock This pin is used for auxiliary clock signals, often unused in typical applications.
AD0 I2C Address Configuration The logic level of this pin determines the I2C address of the module. Low (GND) sets the address to 0x68, while high (VCC) sets it to 0x69. Useful when multiple devices share the same I2C bus.
INT Interrupt Digital Output This pin is used to signal events or interrupts, such as data ready or motion detection. It provides a digital output for the microcontroller to respond to specific conditions.

 

 

Applications:

  • Motion Control and Robotics: Used in robotics for monitoring the orientation of robotic arms and ensuring precise control of their movements. Enables balancing in self-balancing robots, such as Segways and two-wheeled robots.
  • Gaming and Virtual Reality: In gaming controllers and virtual reality systems to detect the player's movements for an immersive gaming experience.
  • Wearable Devices: Integrated into wearable technology like smartwatches and fitness trackers to track user activity and motion.
  • Drones and Quadcopters: Essential for stabilizing drones and quadcopters by providing data on pitch, roll, and yaw angles.
  • Smartphones and Tablets: Used for screen orientation adjustments and gesture recognition in mobile devices.
  • Gesture Recognition: Employed in gesture-controlled devices, allowing users to control applications or devices with hand movements.
  • Motion Analysis and Biomechanics: In sports and healthcare for analyzing human and athlete movements to improve performance and prevent injuries.
  • Industrial Applications: Monitors and ensures the stability of industrial machinery and equipment.
  • Navigation and GPS Enhancement: Improves GPS accuracy and provides navigation data for drones and other navigation systems.
  • IoT (Internet of Things) Devices: Included in IoT projects for tracking the movement of objects or monitoring environmental conditions.
  • Aerospace and Aviation: Used in aircraft for detecting changes in orientation and providing critical data for flight control systems.
  • Vehicle Stabilization: In automotive applications for electronic stability control (ESC) systems to help vehicles maintain stability during sudden maneuvers.
  • Medical Devices: Used in medical equipment and devices for monitoring patient movement, posture, and vital signs.
  • Educational Projects: Ideal for educational purposes to teach students about motion sensors, microcontroller interfacing, and sensor data processing.
  • Security Systems: Employed in security cameras and systems for detecting and tracking movement and orientation.
  • Weather Stations: Integrated into weather monitoring stations to measure tilt and orientation for accurate weather data.
  • Gyrostabilized Cameras: Used in cameras to stabilize images and videos, especially in action cameras and drones.
  • Vibration Analysis: Monitors vibrations in structures and machinery to assess structural integrity and safety.
  • Augmented Reality (AR): In AR headsets and devices to track the user's head movement and provide realistic augmented environments.

 

Circuit:

 

  1. Connect VCC on the GY-521 module to the 5V or 3.3V output on the Arduino (based on the voltage requirements of your module).
  2. Connect GND on the GY-521 module to the ground (GND) pin on the Arduino.
  3. Connect SCL on the GY-521 module to the A4 (analog pin 4) on the Arduino. This is for the Serial Clock Line (I2C communication).
  4. Connect SDA on the GY-521 module to A5 (analog pin 5) on the Arduino. This is for the Serial Data Line (I2C communication).
  5. Optionally, connect AD0 on the GY-521 module to VCC or GND to set the I2C address (0x68 or 0x69, respectively), depending on your requirements. If left unconnected, the default address of 0x68 is used.

 

Library:

  1. Open your Arduino IDE on your computer.
  2. In the Arduino IDE, go to the "Sketch" menu.
  3. Select "Include Library" and then click on "Manage Libraries..."
  4. In the Library Manager window, you can search for libraries. In the search bar in the upper-right corner, type "Adafruit MPU6050."
  5. Once you've typed in the library name, the Library Manager will display search results. Look for the "Adafruit MPU6050" library in the list.
  6. Click on the "Install" button next to the "Adafruit MPU6050" library.
  7. The library will be downloaded and installed in your Arduino IDE. You'll see a message indicating the successful installation.
  8. Close the Library Manager.

 

Code:

This code initializes the MPU6050 sensor, configures its settings, and continuously reads and prints temperature, acceleration, and gyroscope data to the serial monitor. This allows you to monitor the sensor's measurements in real time via the Arduino's serial interface.

    /*
  GY-521 (MPU6050) 3-Axis Accelerometer-Gyroscope Sensor
  modified on 28 Sep 2020
  by Mohammad Reza Akbari @ Electropeak
  Home

  Based on Adafruit Example
*/

#include "Adafruit_MPU6050.h"
#include "Adafruit_Sensor.h"
#include "Wire.h"

Adafruit_MPU6050 mpu;

void setup(void) {
  Serial.begin(115200);
  while (!Serial) {
    delay(10); // will pause Zero, Leonardo, etc until serial console opens
  }

  // Try to initialize!
  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) {
      delay(10);
    }
  }

  mpu.setAccelerometerRange(MPU6050_RANGE_16_G);
  mpu.setGyroRange(MPU6050_RANGE_250_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
  //Serial.println("");
  delay(100);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  Serial.print("Temperature:");
  Serial.print(temp.temperature);
  Serial.print("\tx-acceleration:");
  Serial.print(a.acceleration.x);
  Serial.print("\ty-acceleration:");
  Serial.print(a.acceleration.y);
  Serial.print("\tz-acceleration:");
  Serial.print(a.acceleration.z);
  Serial.print("\tx-gyro:");
  Serial.print(g.gyro.x);
  Serial.print("\ty-gyro:");
  Serial.print(g.gyro.y);
  Serial.print("\tz-gyro:");
  Serial.println(g.gyro.z);

  delay(10);
  }

 

  1. Include Libraries:

    • The code includes the necessary libraries for working with the MPU6050 sensor and using Adafruit's sensor functions.
    • #include : This library is used to interface with the MPU6050 sensor.
    • #include : This library provides common sensor functionality.
    • #include : This library is required for I2C communication.
  2. Create an MPU6050 Object:

    • Adafruit_MPU6050 mpu;: This line creates an instance of the Adafruit_MPU6050 object called mpu. This object is used to interact with the MPU6050 sensor.
  3. Setup Function:

    • Initialize the serial communication with a baud rate of 115200.
    • Wait for the serial console to open before continuing with the program. This is a common practice to ensure that the serial monitor is ready for data output.
    • Attempt to initialize the MPU6050 sensor using mpu.begin(). If the initialization fails, it prints an error message and enters an infinite loop.
  4. Sensor Configuration:

    • Configure the sensor with specific settings:
      • mpu.setAccelerometerRange(MPU6050_RANGE_16_G): Set the accelerometer range to ±16 G (gravity).
      • mpu.setGyroRange(MPU6050_RANGE_250_DEG): Set the gyroscope range to ±250 degrees per second.
      • mpu.setFilterBandwidth(MPU6050_BAND_21_HZ): Set the filter bandwidth to 21 Hz. This affects sensor data filtering.
  5. Loop Function:

    • Inside the loop, the code continuously reads sensor data and prints it to the serial monitor.
    • mpu.getEvent(&a, &g, &temp): Read sensor data and store it in the sensors_event_t structures a (acceleration), g (gyroscope), and temp (temperature).
  6. Serial Output:

    • The code then prints the following sensor data to the serial monitor:
      • Temperature (in degrees Celsius) from temp.temperature.
      • Acceleration data (in m/s²) along the X, Y, and Z axes from a.acceleration.x, a.acceleration.y, and a.acceleration.z.
      • Gyroscope data (in degrees per second) along the X, Y, and Z axes from g.gyro.x, g.gyro.y, and g.gyro.z.
  7. Delay:

    • The code includes a delay(10) to control the rate at which sensor data is read and printed. It introduces a 10-millisecond delay between sensor readings.

 

Technical Details:

  • IC (Integrated Circuit): MPU-6050
  • Sensor Type: 3-axis MEMS accelerometer and 3-axis MEMS gyroscope
  • Communication Protocol: I²C (Inter-Integrated Circuit)
  • Operating Voltage: 3.3V to 5V (Typically supplied with 3.3V or 5V)
  • Power Consumption:
    • Gyroscope operating current: 3.6mA
    • Standby current: 5µA

Gyroscope Specifications:

  • Angular Rate Sensors (Gyroscopes): X-, Y-, and Z-Axis
  • User-Programmable Full-Scale Range: ±250, ±500, ±1000, and ±2000°/sec
  • External Sync Signal Support: FSYNC pin for image, video, and GPS synchronization
  • Integrated 16-Bit ADCs: Enables simultaneous sampling of gyros
  • Bias and Sensitivity Temperature Stability: Reduces the need for user calibration
  • Low-Frequency Noise Performance: Improved low-frequency noise characteristics
  • Digitally-Programmable Low-Pass Filter: Allows customization of filter settings
  • Factory Calibrated Sensitivity Scale Factor
  • User Self-Test: Built-in self-test capability for gyroscope
  • Operating Current: 3.6mA

Accelerometer Specifications:

  • Triple-Axis Accelerometer: X-, Y-, and Z-Axis
  • User-Programmable Full-Scale Range: ±2g, ±4g, ±8g, and ±16g
  • Integrated 16-Bit ADCs: Enables simultaneous sampling of accelerometers without external multiplexer
  • Normal Operating Current: 500µA
  • Low Power Accelerometer Mode Current:
    • 10µA at 1.25Hz
    • 20µA at 5Hz
    • 60µA at 20Hz
    • 110µA at 40Hz
  • Orientation Detection and Signaling
  • Tap Detection
  • User-Programmable Interrupts
  • High-G Interrupt
  • User Self-Test: Built-in self-test capability for accelerometer

Additional:

  • 9-Axis MotionFusion: Enabled by the on-chip Digital Motion Processor (DMP)
  • Auxiliary Master I2C Bus: For reading data from external sensors like magnetometers
  • Operating Current: 3.9mA when all 6 motion sensing axes and the DMP are enabled
  • Supply Voltage Range: 2.375V to 3.46V
  • Flexible VLOGIC Reference Voltage: Supports multiple I²C interface voltages (MPU-6050 only)
  • Package Size: Smallest and thinnest QFN package for portable devices: 4x4x0.9mm
  • Minimal Cross-Axis Sensitivity: Between the accelerometer and gyroscope axes
  • FIFO Buffer: 1024-byte FIFO buffer for reducing power consumption by allowing data to be read in bursts
  • Digital-Output Temperature Sensor
  • User-Programmable Digital Filters: Available for gyroscope, accelerometer, and temperature sensor
  • Shock Tolerance: Up to 10,000 g
  • I²C Communication: Supports Fast Mode I²C (400kHz) for communicating with all registers
  • SPI Interface: Supports 1MHz SPI for communicating with all registers (MPU-6000 only)
  • Reading Sensor and Interrupt Registers: Supports 20MHz SPI serial interface (MPU-6000 only)

 

 

Resources:

Datasheet

 

Comparisons:

The GY-521 MPU-6050 and the GY-50 L3G4200D are both sensor modules, but they serve different purposes and have different features, The GY-521 MPU-6050 is a versatile sensor module that combines a 3-axis accelerometer and a 3-axis gyroscope, offering a wide range of sensor ranges for both components. It uses I²C for communication, can be powered with 3.3V or 5V, and has additional features like a Digital Motion Processor, auxiliary I2C bus, and a temperature sensor. The GY-50 L3G4200D is a dedicated 3-axis gyroscope module with a user-programmable gyroscope range. It supports both I²C and SPI for communication and is typically powered with 3.3V. Your choice between the two modules should depend on your specific project requirements, as the GY-521 MPU-6050 is suitable for a wider range of applications due to its combination of an accelerometer and a gyroscope, while the GY-50 L3G4200D is more focused on gyroscopic motion measurements:

Feature GY-521 MPU-6050 GY-50 L3G4200D
Sensor Type 3-Axis MEMS Accelerometer and Gyroscope 3-Axis MEMS Gyroscope
Sensor Ranges Accelerometer: ±2g, ±4g, ±8g, ±16g Gyroscope: ±250°/sec, ±500°/sec, ±1000°/sec, ±2000°/sec Gyroscope: ±250°/sec, ±500°/sec, ±2000°/sec
Communication Protocol I²C (Inter-Integrated Circuit) I²C, SPI
Voltage Range Typically 3.3V or 5V Typically 3.3V
Applications Motion and orientation sensing, robotics, gaming, drones, wearables, etc. Gyroscopic motion measurement, image stabilization, orientation sensing, etc.
Additional Features - Digital Motion Processor (DMP) - Auxiliary I2C bus - Temperature sensor - Programmable digital filters N/A