MPU9150 Accelerometer, Gyro, Temperature, Compass

How to add the MPU9150 Accelerometer, Gyro, Temperature, Compass robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the I2C category tab.
  5. Press the MPU9150 Accelerometer, Gyro, Temperature, Compass icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the MPU9150 Accelerometer, Gyro, Temperature, Compass robot skill.

How to use the MPU9150 Accelerometer, Gyro, Temperature, Compass robot skill

The MPU9150 EZ-Bit module is an all-in-one Compass/Gyro/Accelerometer/Temperature sensor over an i2c connection. This ARC control will read data from the sensor and set EZ-Script Variables, respectively. The control will require an Initialization (INIT) before the sensor will return data. If the sensor is not connected, the EZ-B v4 will lock up. This control will not read data automatically. We have provided a ControlCommand() for querying the device and setting the variables. Each time you wish to receive data from the MPU9150, you must ask the control to RUN ONCE with ControlCommand().

Here is an example code for looping every 100 milliseconds to request data from the MPU9150. The data from the MPU9150 will be stored in EZ-Script Variables. You may press the CONFIG button on the control to see what variables are being set with data. Ensure you have an MPU9150 ARC control added, an MPU9150 connected to the i2c of the EZ-B, and paste this code into an EZ-Script control. When this script is running, the MPU9150 will continually update the specified variables with data every 100ms... Check the Variable Watcher to view the data from the sensor.

ControlCommand("MPU9150", Init)


ControlCommand("MPU9150", RunOnce)



If the MPU9150 is returning strange compass heading values, the magnetometer may need to be calibrated. This can be done by waving the module/robot in a figure 8 pattern, much like how your phone will occasionally ask to be calibrated. See this video that demonstrates calibrating the compass in an iPhone, which is the similar process required for your robot's MPU9150.

*Note: Disable probing the MPU9150 with ControlCommand(RunOnce) during calibration. This means if you have a script running that sends the RunOnce command to the MPU, stop it during calibration.

How It Works

Interested in how the IMU Sensor works? Find out by reading this fantastic article HERE.



Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.