Main Content

MPU9250 IMU Sensor

Measure acceleration, angular rate, magnetic field, and temperature along axes of MPU-9250 sensor

  • Library:
  • Simulink Support Package for Arduino Hardware / Sensors

Description

The MPU9250 IMU Sensor block reads data from the MPU-9250 sensor that is connected to the hardware.

The block outputs acceleration, angular rate, strength of the magnetic field, and temperature along the axes of the sensor. The block outputs all the values except for temperature as a 3-by-1 double-precision array. The temperature data is output as a scalar double.

Note

The output from the MPU-9250 sensor may have a finite non-negligible offset value except for the Temperature output. You may consider correcting this offset value for such cases.

This diagram shows the default orientation of the x-, y-, and z-axes of the MPU-9250 sensor.

If you simulate a model that contains the MPU9250 block without connecting it to the hardware, the block outputs zeros. For more information, see Block Produces Zeros or Does Nothing in Simulation.

Ports

Output

expand all

The Accel port outputs acceleration along the x-, y-, and z-axes of the sensor as a 3-by-1 vector. The acceleration is measured in m/s2 and also includes acceleration due to gravity.

Dependencies

The Accel port is available only when you select the Acceleration (m/s^2) parameter.

Data Types: double

The Ang rate port outputs the angle of rotation per second along the x-, y-, and z-axes of the sensor as a 3-by-1 vector. The angular rate is measured in dps.

Dependencies

The Ang rate port is available only when you select the Angular rate (dps) parameter.

Data Types: double

The Mag field port outputs the strength of the magnetic field along the x-, y-, and z-axes of the sensor as a 3-by-1 vector. The magnetic strength is measured in μT.

Dependencies

The Mag field port is available only when you select the Magnetic field (μT) parameter.

Data Types: double

The Temperature port outputs the temperature along the x-, y-, and z-axes of the sensor. The temperature is measured in degree Celsius.

Dependencies

The Temperature port is available only when you select the Temperature (deg C) parameter.

Data Types: double

The Status port outputs the status of the read operation. The port outputs the status as a uint8 value. Each value corresponds to the data transfer status.

Status ValueStatus Description
0SUCCESS
1BUSY
2ARBITRATION_LOST
4NO_ACKNOWLEDGE
8BUS_ERROR
16BUS_NOT_IN_USE
32SENSOR_INIT_ERROR

Dependencies

The Status port is available only when you select the Status parameter.

Data Types: uint8

Parameters

expand all

Select the I2C address of the sensor from which the block reads the values.

Specify how often the block read values from the sensor, in seconds. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Select outputs

When you select the Acceleration (m/s^2) parameter, the Accel port becomes available. For more information on the Accel port, see Accel.

When you select the Angular rate (dps) parameter, the Ang rate port becomes available. For more information on the Ang rate port, see Ang rate.

When you select the Magnetic field (μT) parameter, the Mag field port becomes available. For more information on the Mag field port, see Mag field.

Data Types: double

When you select the Temperature (deg C) parameter, the Euler port becomes available. For more information on the Temperature (deg C) port, see Temperature.

Select this parameter to display the status of read operation.

When you select the Status parameter, the Status port becomes available. For more information on the Status port, see Status.

Advanced sensor settings (optional)

Select a deviation in the acceleration that the accelerometer can measure. The smaller the accelerometer range, the more sensitive the readings from the accelerometer. A small range provides more detailed data, resulting in a more precise reading from the accelerometer.

Dependencies

The Accelerometer range parameter is available only when you select the Acceleration (m/s^2) parameter.

Specify the highest frequency at which the accelerometer samples the signal without aliasing.

Dependencies

The Accelerometer bandwidth parameter is available only when you select the Acceleration (m/s^2) parameter.

Specify the maximum angular velocity that the gyroscope can measure per second.

Dependencies

The Gyroscope range parameter is available only when you select the Angular rate (dps) parameter.

Specify the highest frequency at which the gyroscope samples the signal without aliasing.

Dependencies

The Gyroscope bandwidth parameter is available only when you select the Angular rate (dps) parameter.

Introduced in R2020a