Exercise: MPU6050 IMU I2C Module¶
Communicate digital data between an Arduino and a MPU6050 inertial motion sensor over a I2C bus.
Please be sure to review the general information about I2C and SPI in the previous exercise prior to starting this one.
This exercise will use a MPU6050 I2C Accelerometer/Gyro inertial sensor module from Sparkfun. This modules is based on the InvenSense MPU-6050 Motion Processing Unit. Example Arduino code is available from github as part of the larger i2cdevlib, which provides drivers for many I2C devices.
Steps and observations¶
Download or find the complete MPU6050_DMP6 sketch. This is an example from i2cdevlib, reorganized into a self-contained sketch. Be sure to fetch all top-level files.
Plug the IMU module into a breadboard and use solid wire to make the following five connections from the Arduino to the module. Note carefully that this module uses 3.3V, unlike the previous example:
3.3V -> VCC
GND -> GND
A4 -> SDA
A5 -> SCL
D2 -> INT
Attach the Arduino to your computer and install the sketch.
Open the Arduino IDE Serial Monitor and make sure it is set to 115200 baud.
Reset the Arduino. You should see a wakeup message on the console followed by the following prompt:
Send any character to begin DMP programming and demo:
Type a character in the input box and press enter.
You should see a rapid series of messages in the following form:
ypr -87.92 74.39 1.85
Physically rotate the IMU and watch the numbers change.