Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use mpu 6050: Examples, Pinouts, and Specs

Image of mpu 6050Design with mpu 6050 in Cirkit Designer

Introduction

The MPU 6050, manufactured by ESP32 under the part ID "ESP32 Mikrokontoler," is a 6-axis motion tracking device. It integrates a 3-axis gyroscope and a 3-axis accelerometer on a single chip, enabling precise measurement of orientation, acceleration, and angular velocity. This compact and versatile sensor is widely used in applications such as robotics, drones, gaming devices, and wearable technology.

Explore Projects Built with mpu 6050

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of MPU6050-Based Servo Control System with Arduino UNO: A project utilizing mpu 6050 in a practical application
MPU6050-Based Servo Control System with Arduino UNO

This circuit features an Arduino UNO microcontroller interfaced with an MPU6050 accelerometer/gyroscope for motion sensing. Four servos are controlled by the Arduino, with their power lines connected to a 5V supply from the 7805 voltage regulator, which is powered by a 9V battery. The servos' control lines are connected to the Arduino through 200 Ohm resistors, and a ceramic capacitor is used for noise suppression on the 5V line.

Open Project in Cirkit Designer
Image of Arduino UNO-Based Sensor Data Acquisition System with Bluetooth and Wi-Fi Connectivity: A project utilizing mpu 6050 in a practical application
Arduino UNO-Based Sensor Data Acquisition System with Bluetooth and Wi-Fi Connectivity

This circuit is a multi-sensor data acquisition system with wireless communication capabilities. It utilizes an Arduino UNO to interface with an MPU-6050 gyroscope, an Adafruit ADXL345 accelerometer, an Adafruit MPR121 capacitive touch sensor, and a SparkFun Electret Microphone for audio input. The system can transmit sensor data via an HC-05 Bluetooth module and an ESP8266 WiFi module, and it includes a bi-directional logic level converter for voltage level matching between devices. The circuit is powered by a 9V battery connected to the Arduino's Vin pin.

Open Project in Cirkit Designer

Common Applications:

Technical Specifications

The MPU 6050 is a high-performance sensor with the following key specifications:

Parameter Value
Supply Voltage 2.375V to 3.46V
Operating Current 3.9 mA (typical)
Gyroscope Range ±250, ±500, ±1000, ±2000 °/s
Accelerometer Range ±2g, ±4g, ±8g, ±16g
Communication Protocol I2C (up to 400kHz) or SPI
Operating Temperature -40°C to +85°C
Package Type QFN-24

Pin Configuration and Descriptions

The MPU 6050 has 8 pins, as described in the table below:

Pin Name Pin Number Description
VCC 1 Power supply input (2.375V to 3.46V).
GND 2 Ground connection.
SCL 3 I2C clock line.
SDA 4 I2C data line.
AD0 5 I2C address select (connect to GND or VCC).
INT 6 Interrupt output for motion detection.
FSYNC 7 Frame synchronization input (optional).
RES 8 Reserved (leave unconnected).

Usage Instructions

Connecting the MPU 6050 to an Arduino UNO

To use the MPU 6050 with an Arduino UNO, follow these steps:

  1. Wiring:

    • Connect the VCC pin of the MPU 6050 to the 3.3V pin on the Arduino.
    • Connect the GND pin to the Arduino's GND.
    • Connect the SCL pin to the Arduino's A5 pin (I2C clock line).
    • Connect the SDA pin to the Arduino's A4 pin (I2C data line).
    • Optionally, connect the INT pin to a digital pin on the Arduino for motion interrupts.
  2. Install Required Libraries:

    • Install the Wire.h library (pre-installed with Arduino IDE).
    • Install the MPU6050 library from the Arduino Library Manager.
  3. Sample Code: Use the following code to read accelerometer and gyroscope data:

    #include <Wire.h>
    #include <MPU6050.h>
    
    MPU6050 mpu;
    
    void setup() {
      Serial.begin(9600); // Initialize serial communication at 9600 baud
      Wire.begin();       // Initialize I2C communication
    
      // Initialize the MPU 6050
      if (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) {
        Serial.println("Could not find a valid MPU6050 sensor!");
        while (1); // Halt execution if sensor initialization fails
      }
    
      Serial.println("MPU6050 initialized successfully!");
    }
    
    void loop() {
      Vector rawAccel = mpu.readRawAccel(); // Read raw accelerometer data
      Vector rawGyro = mpu.readRawGyro();   // Read raw gyroscope data
    
      // Print accelerometer data
      Serial.print("Accel X: "); Serial.print(rawAccel.XAxis);
      Serial.print(" | Y: "); Serial.print(rawAccel.YAxis);
      Serial.print(" | Z: "); Serial.println(rawAccel.ZAxis);
    
      // Print gyroscope data
      Serial.print("Gyro X: "); Serial.print(rawGyro.XAxis);
      Serial.print(" | Y: "); Serial.print(rawGyro.YAxis);
      Serial.print(" | Z: "); Serial.println(rawGyro.ZAxis);
    
      delay(500); // Wait for 500ms before the next reading
    }
    

Important Considerations:

Troubleshooting and FAQs

Common Issues:

  1. No Data from the Sensor:

    • Cause: Incorrect wiring or I2C address mismatch.
    • Solution: Double-check the connections and ensure the correct I2C address is used in the code.
  2. Unstable or Noisy Readings:

    • Cause: Electrical noise or improper grounding.
    • Solution: Use shorter wires and ensure a solid ground connection.
  3. Sensor Not Detected:

    • Cause: Faulty sensor or incorrect initialization.
    • Solution: Verify the sensor's power supply and try reinitializing it in the code.

FAQs:

By following this documentation, you can effectively integrate the MPU 6050 into your projects and troubleshoot common issues.