We will learn that how to use MPU6050 accelerometer and gyroscope sensor module. Specially we will learn MPU6050 pinout and MPU6050 wiring diagram. Afterwards we will share sample MPU6050 open source projects.
MPU-6050 Six-Axis (Gyro + Accelerometer) pinout
- The MPU-6050™ designed for smartphones, tablets and wearable technologies.
- Power consumption is low. It also has a low cost.
- MPU-6050 includes 3-axis gyroscope and 3-axis accelerometer.
Mpu6050 is widely used in many robot projects such as flying vehicles, balance robots. It has 3-axis gyro and 3-axis angular accelerometer. Supports I2C communication protocol. Built-in voltage regulator. In this way, it is supplied with voltage values between 3v and 5v. The angular acceleration meter range is ± 2 ± 4 ± 8 ± 16 g, and the Gyro measuring range is + 250 500 1000 2000 ° / s.
MPU-6050 Arduino Wiring Diagram
MPU-6050 is generally used with arduino. That’s why we share the arduino wiring diagram with the MPU-6050 as an example.
Arduino connection with MPU-6050 should be done as above. In accordance with the I2C communication protocol, the SCL pin must be connected to the analogue pin A5 of the arduino, the SDA pin to the analogue pin A4 of the arduino, the VCC pin to the arduino 5V pin, the GND pin to the arduino GND pin, and the INT pin to the arduino digital pin 2.
MPU-6050 sample codes
You can download the library of the mpu 6050 accelerometer sensor:Â MPU 6050 library
#include <Wire.h> #include <I2Cdev.h> //I2C library added #include <MPU6050.h> //Mpu6050 library added MPU6050 ivme_sensor; // renamed our sensor as ivme_sensor int16_t ax, ay, az; //acceleration definition int16_t gx, gy, gz; //gyro definition void setup() { Wire.begin(); Serial.begin(9600); Serial.println("I2C devices starting..."); ivme_sensor.initialize(); Serial.println("Test device starting..."); Serial.println(ivme_sensor.testConnection() ? "MPU6050 connection success" : "MPU6050 connection unsuccess"); } void loop() { ivme_sensor.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // read the acceleration and gyro values //Write to serial monitor Serial.print(ax); Serial.print("\t"); Serial.print(ay); Serial.print("\t"); Serial.print(az); Serial.print("\t"); Serial.print(gx); Serial.print("\t"); Serial.print(gy); Serial.print("\t"); Serial.print(gz); Serial.println("\t"); delay(500); //wait 0.5 second to see changing values well }
MPU-6050 class
Click to view the classes of the MPU 6050 Accelerometer sensor.
These are some important classes:
int16_t MPU6050::getAccelerationX | ( | ) |
Get X-axis accelerometer reading.
- Returns:
- X-axis acceleration measurement in 16-bit 2’s complement format
- See also:
- getMotion6()
- MPU6050_RA_ACCEL_XOUT_H
bool MPU6050::getAccelXSelfTest | ( | ) |
Get self-test enabled setting for accelerometer X axis.
- Returns:
- Self-test enabled value
- See also:
- MPU6050_RA_ACCEL_CONFIG
uint8_t MPU6050::getClockSource | ( | ) |
Get clock source setting.
- Returns:
- Current clock source setting
- See also:
- MPU6050_RA_PWR_MGMT_1
- MPU6050_PWR1_CLKSEL_BIT
- MPU6050_PWR1_CLKSEL_LENGTH
MPU 6050 Alternatives
MPU 6050 isn’t alone in this field. There are some MPU 6050 alternatives in industry. These alternatives uses commonly too.
ADXL335 (Adafruit)
With this very low power consumption sensor module, you can collect angular data in 3 axes.
You can output via analog communication channel. The module generates a separate analog voltage for each axis. Since the board has an internal voltage regulator circuit, you can operate it with a supply voltage of 3V to 5V.
LIS3DH Triple-Axis Accelerometer Module (SpurkFun)
The LIS3DH Breakout is an intelligent, low-power, three-axis, capacitive, micro-machined accelerometer with 12-bit resolution that you can use to add translation detection to your project. It is classified as either 3D or 3 degrees of freedom.
Top 10 MPU- 6050 Projects
MPU 6050 is great tool. A lot of projects are using this sensor. Especially, it uses about balance projects (like balancing robots), drone projects and robot projects (for balancing). We also see this sensor being used frequently in wearable technologies.
A perfect and comprehensive article. This topic is very very useful. Thanks a lot.
I am pleased that I discovered this blog , precisely the right info that I was looking for! .
Thanks for your beautiful comment
Pretty nice article, thank you for sharing.