MPU-6050 Gyroscope Introduction & Teapot 3D simulation

What is MPU-6050 ?

This sensor have 6 DOF sensing capability, which means it gives 6-axis output like acceleration output for 3 axis as well as Gyroscope value of 3 axis.

This sensor is widely used in where balancing are required like Self balancing robots, drone, quadcopter, 3D simulation

In this tutorial, I will give you a basic introduction to the MPU 6050, demonstrate how it can be interfaced to an Arduino, and show you how to make a 3D simulation model using the data from your Arduino MPU 6050.

Required material

How Does it Work?

IMU sensors usually consist of two or more parts. Listing them by priority, they are the accelerometer, gyroscope, magnetometer, and altimeter. The MPU 6050 is a 6 DOF (Degrees of Freedom) or a six-axis IMU sensor, which means that it gives six values as output. Three values from the accelerometer and three from the gyroscope. The MPU 6050 is a sensor based on MEMS (Micro Electro Mechanical Systems) technology. Both the accelerometer and the gyroscope are embedded inside a single chip. This chip uses I2C (Inter-Integrated Circuit) protocol for communication.

Connecting the Arduino & MPU 6050

The MPU 6050 communicates with the Arduino through the I2C protocol. The MPU 6050 is connected to Arduino as shown in the following diagram. If your MPU 6050 module has a 5V pin, then you can connect it to your Arduino’s 5V pin. If not, you will have to connect it to the 3.3V pin. Next, the GND of the Arduino is connected to the GND of the MPU 6050.

The program we will be running here, also takes advantage of the Arduino’s interrupt pin. Connect your Arduino’s digital pin 2 (interrupt pin 0) to the pin labeled as INT on the MPU 6050. Next, we need to set up the I2C lines. To do this, connect the pin labeled SDA on the MPU 6050 to the Arduino’s analog pin 4 (SDA) and the pin labeled as SCL on the MPU 6050 to the Arduino’s analog pin 5 (SCL). That’s it, you have finished wiring up the Arduino MPU 6050!

Video demonstration

Teapot 3D Simulation Demo using Processing platform

To visualize the 3D model in processing, first, you have to upload the Arduino code for MPU 6050 (MPU6050_DMP6). Before doing that, you need to comment the line in the Arduino MPU6050_DMP6 code which says:

Type string of the last argument to method println(object) doesn’t exactly match the vararg parameter type. Cast to object[] to confirm the non-vararg invocation, or pass the individual arguments of type objects for vararg invocations in line 68:

ok I changed 68 to printArray(Serial.list()); and got the plane drawn in the java window, but it doesnt move at all. The line 60 error remains. Oh wait, it needed time to start sending I guess…I can see garbage in the processing console below and now I can control the plane in the java window.