Measure acceleration, angular rate, magnetic field, and temperature along axes of MPU-9250 sensor
Simulink Support Package for Arduino Hardware / Sensors
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.
Accel — Acceleration including force of gravity along axes of sensor 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.
The Accel port is available only when you select the Acceleration (m/s^2) parameter.
Data Types: double
Ang rate — Angle of rotation per second along axes of sensorThe 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.
The Ang rate port is available only when you select the Angular rate (dps) parameter.
Data Types: double
Mag field — Strength of magnetic field along axes of sensorThe 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.
The Mag field port is available only when you select the Magnetic field (μT) parameter.
Data Types: double
Temperature — Temperature along axes of sensorThe Temperature port outputs the temperature along the x-, y-, and z-axes of the sensor. The temperature is measured in degree Celsius.
The Temperature port is available only when you select the Temperature (deg C) parameter.
Data Types: double
Status — Status of read operationThe 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 Value | Status Description |
|---|---|
0 | SUCCESS |
1 | BUSY |
2 | ARBITRATION_LOST |
4 | NO_ACKNOWLEDGE |
8 | BUS_ERROR |
16 | BUS_NOT_IN_USE |
32 | SENSOR_INIT_ERROR |
The Status port is available only when you select the Status parameter.
Data Types: uint8
I2C address — I2C slave address of sensor0x68 (default) | 0x69Select the I2C address of the sensor from which the block reads the values.
Sample time — Interval to read values from sensor0.1 (default) | -1 | any nonnegative valueSpecify 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.
Acceleration (m/s^2) — Acceleration including force of gravity along axes of sensoron (default) | offWhen you select the Acceleration (m/s^2) parameter, the Accel port becomes available. For more information on the Accel port, see Accel.
Angular rate (dps) — Angle of rotation per second along axes of sensoron (default) | offWhen you select the Angular rate (dps) parameter, the Ang rate port becomes available. For more information on the Ang rate port, see Ang rate.
Magnetic field (μT) — Strength of magnetic field along axes of sensoron (default) | offWhen 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
Temperature (deg C) — Temperature along axes of sensoroff (default) | onWhen you select the Temperature (deg C) parameter, the Euler port becomes available. For more information on the Temperature (deg C) port, see Temperature.
Status — Status of read operationoff (default) | onSelect 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.
Accelerometer range — Range of acceleration deviation measured by accelerometer4G (default) | 2G | 8G | 16GSelect 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.
The Accelerometer range parameter is available only when you select the Acceleration (m/s^2) parameter.
Accelerometer bandwidth — Frequency response of accelerometer1 (default) | 0 | 2 | 3 | 4 | 5 | 6 | 7Specify the highest frequency at which the accelerometer samples the signal without aliasing.
The Accelerometer bandwidth parameter is available only when you select the Acceleration (m/s^2) parameter.
Gyroscope range — Maximum angular velocity measured by gyroscope250 dps (default) | 500 dps | 1000 dps | 2000 dpsSpecify the maximum angular velocity that the gyroscope can measure per second.
The Gyroscope range parameter is available only when you select the Angular rate (dps) parameter.
Gyroscope bandwidth — Frequency response of gyroscope1 (default) | 0 | 2 | 3 | 4 | 5 | 6 | 7Specify the highest frequency at which the gyroscope samples the signal without aliasing.
The Gyroscope bandwidth parameter is available only when you select the Angular rate (dps) parameter.