MPU 6050- Pinouts, Specs and Best Projects

0
3

One of the most used materials by people who make robot and drone projects is MPU6050. In this article we will talk about:

  • What is MPU6050?
  • MPU 6050 Usage areas
  • MPU 6050 Pinout
  • MPU 6050 Arduino Connection
  • MPU 6050 Arduino Code
  • Best MPU 6050 projects

What is MPU 6050?

Mpu6050 is a sensor board with 3 axis gyro and 3 axis angular accelerometer on it, often used in air vehicles, balance robots. It has I2C pins on it. It can be used with Arduino etc. microcontrollers. Thanks to the voltage regulator on it, it can work in the range of 3-5V.

The measurement ranges are as follows:

  • for angular accelerometer: ± 2 ± 4 ± 8 ± 16 g
  • for gyro: + 250 500 1000 2000 ° / s.

What can you do with Mpu6050?

When you look at the sample projects at the end of the topic, you can also see the usage areas of the MPU 6050. There are 2 usage areas of MPU 6050 usually.

  • Measure angular accelerometer
  • Measure gyro

For example; You can use MPU 6050 for balancing drones.

 

MPU 6050 Pinout

VCC: Power supply pin. Connect this pin to +5V DC supply.

GND: Ground pin. Connect this pin to ground connection.

MPU-6050 module has Slave address (When AD0 = 0, i.e. it is not connected to Vcc) as,

Slave Write address(SLA+W): 0xD0

Slave Read address(SLA+R): 0xD1

INT: Interrupt digital output pin.

XDA: Auxiliary Serial Data pin. This pin is used to connect other I2C interface enabled sensors SDA pin to MPU-6050.

SCL: Serial Clock pin. Connect this pin to microcontrollers SCL pin.

XCL: Auxiliary Serial Clock pin. This pin is used to connect other I2C interface enabled sensors SCL pin to MPU-6050.

SDA: Serial Data pin. Connect this pin to microcontrollers SDA pin.

AD0: I2C Slave Address LSB pin. This is 0th bit in 7-bit slave address of device. If connected to VCC then it is read as logic one and slave address changes.

MPU 6050 Arduino Connection

MPU 6050 Sample Arduino Code

/*
    MPU6050 Triple Axis Gyroscope & Accelerometer. Simple Accelerometer Example.
    Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html
    GIT: https://github.com/jarzebski/Arduino-MPU6050
    Web: http://www.jarzebski.pl
    (c) 2014 by Korneliusz Jarzebski
*/	

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

void setup() 
{
  Serial.begin(115200);

  Serial.println("Initialize MPU6050");

  while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }

  // If you want, you can set accelerometer offsets
  // mpu.setAccelOffsetX();
  // mpu.setAccelOffsetY();
  // mpu.setAccelOffsetZ();
  
  checkSettings();
}

void checkSettings()
{
  Serial.println();
  
  Serial.print(" * Sleep Mode:            ");
  Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled");
  
  Serial.print(" * Clock Source:          ");
  switch(mpu.getClockSource())
  {
    case MPU6050_CLOCK_KEEP_RESET:     Serial.println("Stops the clock and keeps the timing generator in reset"); break;
    case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break;
    case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break;
    case MPU6050_CLOCK_PLL_ZGYRO:      Serial.println("PLL with Z axis gyroscope reference"); break;
    case MPU6050_CLOCK_PLL_YGYRO:      Serial.println("PLL with Y axis gyroscope reference"); break;
    case MPU6050_CLOCK_PLL_XGYRO:      Serial.println("PLL with X axis gyroscope reference"); break;
    case MPU6050_CLOCK_INTERNAL_8MHZ:  Serial.println("Internal 8MHz oscillator"); break;
  }
  
  Serial.print(" * Accelerometer:         ");
  switch(mpu.getRange())
  {
    case MPU6050_RANGE_16G:            Serial.println("+/- 16 g"); break;
    case MPU6050_RANGE_8G:             Serial.println("+/- 8 g"); break;
    case MPU6050_RANGE_4G:             Serial.println("+/- 4 g"); break;
    case MPU6050_RANGE_2G:             Serial.println("+/- 2 g"); break;
  }  

  Serial.print(" * Accelerometer offsets: ");
  Serial.print(mpu.getAccelOffsetX());
  Serial.print(" / ");
  Serial.print(mpu.getAccelOffsetY());
  Serial.print(" / ");
  Serial.println(mpu.getAccelOffsetZ());
  
  Serial.println();
}

void loop()
{
  Vector rawAccel = mpu.readRawAccel();
  Vector normAccel = mpu.readNormalizeAccel();

  Serial.print(" Xraw = ");
  Serial.print(rawAccel.XAxis);
  Serial.print(" Yraw = ");
  Serial.print(rawAccel.YAxis);
  Serial.print(" Zraw = ");

  Serial.println(rawAccel.ZAxis);
  Serial.print(" Xnorm = ");
  Serial.print(normAccel.XAxis);
  Serial.print(" Ynorm = ");
  Serial.print(normAccel.YAxis);
  Serial.print(" Znorm = ");
  Serial.println(normAccel.ZAxis);
  
  delay(10);
}

 

Different 10 Example MPU 6050 Projects

1. DIY Gimbal | Arduino and MPU6050

2. Arduino Gyro Projects

 

3. ESP32 Web Server with MPU-6050 Accelerometer and Gyroscope (3D object representation)

 

4. Homemade Distance, Angle, Level and RPM meter

 

5. Small QuadCopter MPU-6050 & Arduino

 

6. Arduino RC Airplane | 100% DIY

 

7. Hand Gesture Controlled Car Using Arduino

 

8. Arduino Project-Self Balancing Robot

Also look: Best 10 Open Source Self Balancing Robot Projects

 

9. Self balancing humanoid robot using MPU-6050 sensor

 

10. Spider Robot, ESP 8266, Mpu 6050, Auto Balancing

 

Sources:

LEAVE A REPLY

Please enter your comment!
Please enter your name here