MPU-9150 Hookup Guide

Pages
Contributors: .Brent.
Favorited Favorite 0

Installing the Arduino Library

Download and Install the Library

Visit the GitHub repository to download the most recent version of the libraries, or click the link below:

For help installing the library, check out our Installing an Arduino Library tutorial. You'll need to move/copy the both the I2Cdev and MPU6050 directories inside the firmware directory into the libraries directory within your Arduino sketchbook. If you don't have a directory called libraries, create one and drop both directories in there.

The example Arduino code allows you to do things like print raw accelerometer, gyro, and magnetometer data. The original library came from i2cdevlib.com and was based on the very similar MPU-6050, which only used an accelerometer and gyro. The MPU-6050 device library was modified to include raw magnetometer data for the MPU-9150.

Running the MPU6050_DMP6 Example

Now, you can now run the example sketches. Open File ⇒ Examples ⇒ MPU6050 ⇒ Examples ⇒ MPU6050_DMP6. By default, this sketch is configured to do a fun teapot demo that uses processing. That's a little more involved than the scope of this hookup guide. We will output the acceleration components with gravity removed.

Uncomment line 102 //#define OUTPUT_READABLE_REALACCEL. Comment out line 112 #define OUTPUT_TEAPOT. Compile and upload the sketch. When it finishes uploading, open the serial monitor, and set the baud rate to 115200 baud. You should see this:

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful

Send any character to begin DMP programming and demo:

At the top of the serial monitor type any 'normal' character (such as alphanumeric) and press Send. Your system should respond with:

Initializing DMP...
Enabling DMP...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP ready! Waiting for first interrupt...

If you have the interrupt line connected properly, you should see lines similar to this:

areal   -8680   1460    -1448
areal   -9721   1460    -1463
...