MPU60X0 Class
- ID: mpu60x0
- Name: 3-axis Gyroscope and 3-axis Accelerometer
- Category: accelerometer compass
- Manufacturer: seeed
- Connection: i2c gpio
- Link: https://www.invensense.com/products/motion-tracking/6-axis/mpu-6050/
The MPU60X0 devices provide the world's first integrated 6-axis motion processor solution that eliminates the package-level gyroscope and accelerometer cross-axis misalignment associated with discrete solutions. The devices combine a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die.
While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required.

Item Index
Methods
- MPU60X0
- init
- update
- readReg
- readRegs
- writeReg
- setSleep
- setClockSource
- setGyroscopeScale
- setAccelerometerScale
- setDigitalLowPassFilter
- setSampleRateDivider
- getSampleRateDivider
- getAccelerometer
- getGyroscope
- getTemperature
- enableTemperatureSensor
- setExternalSync
- enableI2CBypass
- setMotionDetectionThreshold
- getInterruptStatus
- setInterruptEnables
- getInterruptEnables
- setInterruptPinConfig
- getInterruptPinConfig
- installISR
- uninstallISR
- get_gpioIRQ
Properties
- REG_SELF_TEST_X
- REG_SELF_TEST_Y
- REG_SELF_TEST_Z
- REG_SELF_TEST_A
- REG_SMPLRT_DIV
- REG_CONFIG
- REG_GYRO_CONFIG
- REG_ACCEL_CONFIG
- REG_FF_THR
- REG_FF_DUR
- REG_MOT_THR
- REG_MOT_DUR
- REG_ZRMOT_THR
- REG_ZRMOT_DUR
- REG_FIFO_EN
- REG_I2C_MST_CTRL
- REG_I2C_SLV0_ADDR
- REG_I2C_SLV0_REG
- REG_I2C_SLV0_CTRL
- REG_I2C_SLV1_ADDR
- REG_I2C_SLV1_REG
- REG_I2C_SLV1_CTRL
- REG_I2C_SLV2_ADDR
- REG_I2C_SLV2_REG
- REG_I2C_SLV2_CTRL
- REG_I2C_SLV3_ADDR
- REG_I2C_SLV3_REG
- REG_I2C_SLV3_CTRL
- REG_I2C_SLV4_ADDR
- REG_I2C_SLV4_REG
- REG_I2C_SLV4_DO
- REG_I2C_SLV4_CTRL
- REG_I2C_SLV4_DI
- REG_I2C_MST_STATUS
- REG_INT_PIN_CFG
- REG_INT_ENABLE
- REG_INT_STATUS
- REG_ACCEL_XOUT_H
- REG_ACCEL_XOUT_L
- REG_ACCEL_YOUT_H
- REG_ACCEL_YOUT_L
- REG_ACCEL_ZOUT_H
- REG_ACCEL_ZOUT_L
- REG_TEMP_OUT_H
- REG_TEMP_OUT_L
- REG_GYRO_XOUT_H
- REG_GYRO_XOUT_L
- REG_GYRO_YOUT_H
- REG_GYRO_YOUT_L
- REG_GYRO_ZOUT_H
- REG_GYRO_ZOUT_L
- REG_EXT_SENS_DATA_00
- REG_EXT_SENS_DATA_01
- REG_EXT_SENS_DATA_02
- REG_EXT_SENS_DATA_03
- REG_EXT_SENS_DATA_04
- REG_EXT_SENS_DATA_05
- REG_EXT_SENS_DATA_06
- REG_EXT_SENS_DATA_07
- REG_EXT_SENS_DATA_08
- REG_EXT_SENS_DATA_09
- REG_EXT_SENS_DATA_10
- REG_EXT_SENS_DATA_11
- REG_EXT_SENS_DATA_12
- REG_EXT_SENS_DATA_13
- REG_EXT_SENS_DATA_14
- REG_EXT_SENS_DATA_15
- REG_EXT_SENS_DATA_16
- REG_EXT_SENS_DATA_17
- REG_EXT_SENS_DATA_18
- REG_EXT_SENS_DATA_19
- REG_EXT_SENS_DATA_20
- REG_EXT_SENS_DATA_21
- REG_EXT_SENS_DATA_22
- REG_EXT_SENS_DATA_23
- REG_MOT_DETECT_STATUS
- REG_I2C_SLV0_DO
- REG_I2C_SLV1_DO
- REG_I2C_SLV2_DO
- REG_I2C_SLV3_DO
- REG_I2C_MST_DELAY_CTRL
- REG_SIGNAL_PATH_RESET
- REG_MOT_DETECT_CTRL
- REG_USER_CTRL
- REG_PWR_MGMT_1
- REG_PWR_MGMT_2
- REG_FIFO_COUNTH
- REG_FIFO_COUNTL
- REG_FIFO_R_W
- REG_WHO_AM_I
- CONFIG_DLPF_CFG0
- CONFIG_DLPF_CFG1
- CONFIG_DLPF_CFG2
- _CONFIG_DLPF_SHIFT
- _CONFIG_DLPF_MASK
- CONFIG_EXT_SYNC_SET0
- CONFIG_EXT_SYNC_SET1
- CONFIG_EXT_SYNC_SET2
- _CONFIG_EXT_SYNC_SET_SHIFT
- _CONFIG_EXT_SYNC_SET_MASK
- DLPF_260_256
- DLPF_184_188
- DLPF_94_98
- DLPF_44_42
- DLPF_21_20
- DLPF_10_10
- DLPF_5_5
- DLPF_RESERVED
- EXT_SYNC_DISABLED
- EXT_SYNC_TEMP_OUT
- EXT_SYNC_GYRO_XOUT
- EXT_SYNC_GYRO_YOUT
- EXT_SYNC_GYRO_ZOUT
- EXT_SYNC_ACCEL_XOUT
- EXT_SYNC_ACCEL_YOUT
- EXT_SYNC_ACCEL_ZOUT
- FS_SEL0
- FS_SEL1
- _FS_SEL_SHIFT
- _FS_SEL_MASK
- ZG_ST
- YG_ST
- XG_ST
- FS_250
- FS_500
- FS_1000
- FS_2000
- AFS_SEL0
- AFS_SEL1
- _AFS_SEL_SHIFT
- _AFS_SEL_MASK
- ZA_ST
- YA_ST
- XA_ST
- AFS_2
- AFS_4
- AFS_8
- AFS_16
- SLV0_FIFO_EN
- SLV1_FIFO_EN
- SLV2_FIFO_EN
- ACCEL_FIFO_EN
- ZG_FIFO_EN
- YG_FIFO_EN
- XG_FIFO_EN
- TEMP_FIFO_EN
- I2C_MST_CLK0
- I2C_MST_CLK1
- I2C_MST_CLK2
- I2C_MST_CLK3
- _I2C_MST_CLK_SHIFT
- _I2C_MST_CLK_MASK
- I2C_MST_P_NSR
- SLV_3_FIFO_EN
- WAIT_FOR_ES
- MULT_MST_EN
- MST_CLK_348
- MST_CLK_333
- MST_CLK_320
- MST_CLK_308
- MST_CLK_296
- MST_CLK_286
- MST_CLK_276
- MST_CLK_267
- MST_CLK_258
- MST_CLK_500
- MST_CLK_471
- MST_CLK_444
- MST_CLK_421
- MST_CLK_400
- MST_CLK_381
- MST_CLK_364
- I2C_SLV_ADDR0
- I2C_SLV_ADDR1
- I2C_SLV_ADDR2
- I2C_SLV_ADDR3
- I2C_SLV_ADDR4
- I2C_SLV_ADDR5
- I2C_SLV_ADDR6
- _I2C_SLV_ADDR_SHIFT
- _I2C_SLV_ADDR_MASK
- I2C_SLV_RW
- I2C_SLV_LEN0
- I2C_SLV_LEN1
- I2C_SLV_LEN2
- I2C_SLV_LEN3
- _I2C_SLV_LEN_SHIFT
- _I2C_SLV_LEN_MASK
- I2C_SLV_GRP
- I2C_SLV_REG_DIS
- I2C_SLV_BYTE_SW
- I2C_SLV_EN
- I2C_MST_DLY0
- I2C_MST_DLY1
- I2C_MST_DLY2
- I2C_MST_DLY3
- I2C_MST_DLY4
- _I2C_MST_DLY_SHIFT
- _I2C_MST_DLY_MASK
- I2C_SLV4_REG_DIS
- I2C_SLV4_INT_EN
- I2C_SLV4_EN
- I2C_SLV0_NACK
- I2C_SLV1_NACK
- I2C_SLV2_NACK
- I2C_SLV3_NACK
- I2C_SLV4_NACK
- I2C_LOST_ARB
- I2C_SLV4_DONE
- PASS_THROUGH
- CLKOUT_EN
- I2C_BYPASS_ENABLE
- FSYNC_INT_EN
- FSYNC_INT_LEVEL
- INT_RD_CLEAR
- LATCH_INT_EN
- INT_OPEN
- INT_LEVEL
- DATA_RDY_EN
- I2C_MST_INT_EN
- FIFO_OFLOW_EN
- ZMOT_EN
- MOT_EN
- FF_EN
- DATA_RDY_INT
- I2C_MST_INT
- FIFO_OFLOW_INT
- ZMOT_INT
- MOT_INT
- FF_INT
- MOT_ZRMOT
- MOT_ZPOS
- MOT_ZNEG
- MOT_YPOS
- MOT_YNEG
- MOT_XPOS
- MOT_XNEG
- I2C_SLV0_DLY_EN
- I2C_SLV1_DLY_EN
- I2C_SLV2_DLY_EN
- I2C_SLV3_DLY_EN
- I2C_SLV4_DLY_EN
- DELAY_ES_SHADOW
- TEMP_RESET
- ACCEL_RESET
- GYRO_RESET
- MOT_COUNT0
- MOT_COUNT1
- _MOT_COUNT_SHIFT
- _MOT_COUNT_MASK
- FF_COUNT0
- FF_COUNT1
- _FF_COUNT_SHIFT
- _FF_COUNT_MASK
- ACCEL_ON_DELAY0
- ACCEL_ON_DELAY1
- _ACCEL_ON_DELAY_SHIFT
- _ACCEL_ON_DELAY_MASK
- COUNT_0
- COUNT_1
- COUNT_2
- COUNT_4
- ON_DELAY_0
- ON_DELAY_1
- ON_DELAY_2
- ON_DELAY_3
- SIG_COND_RESET
- I2C_MST_RESET
- FIFO_RESET
- I2C_IF_DIS
- I2C_MST_EN
- FIFO_EN
- CLKSEL0
- CLKSEL1
- CLKSEL2
- _CLKSEL_SHIFT
- _CLKSEL_MASK
- TEMP_DIS
- PWR_CYCLE
- PWR_SLEEP
- DEVICE_RESET
- INT_8MHZ
- PLL_XG
- PLL_YG
- PLL_ZG
- PLL_EXT_32KHZ
- PLL_EXT_19MHZ
- CLK_STOP
- STBY_ZG
- STBY_YG
- STBY_XG
- STBY_ZA
- STBY_YA
- STBY_XA
- LP_WAKE_CTRL0
- LP_WAKE_CTRL1
- _LP_WAKE_CTRL_SHIFT
- _LP_WAKE_CTRL_MASK
- LP_WAKE_1_25
- LP_WAKE_5
- LP_WAKE_20
- LP_WAKE_40
Methods
MPU60X0
-
bus -
address
mpu60x0 constructor
Parameters:
-
busNumberi2c bus to use
-
addressNumberthe address for this device
Returns:
init
()
Boolean
set up initial values and start operation
Returns:
true if successful
update
()
take a measurement and store the current sensor values internally. Note, these user facing registers are only updated from the internal device sensor values when the i2c serial traffic is 'idle'. So, if you are reading the values too fast, the bus may never be idle, and you will just end up reading the same values over and over.
Unfortunately, it is is not clear how long 'idle' actually means, so if you see this behavior, reduce the rate at which you are calling update() .
readReg
-
reg
read a register
Parameters:
-
regNumberthe register to read
Returns:
the value of the register
readRegs
-
reg -
buffer -
len
read contiguous refister into a buffer
Parameters:
-
regNumberthe register to start reading at
-
bufferUint8_t *the buffer to store the results
-
lenNumberthe number of registers to read
writeReg
-
reg -
val
write to a register
Parameters:
-
regNumberthe register to write to
-
valNumberthe value to write
Returns:
true if successful, false otherwise
setSleep
-
enable
enable or disable device sleep
Parameters:
-
enableBooleantrue to put device to sleep, false to wake up
Returns:
true if successful, false otherwise
setClockSource
-
clk
specify the clock source for the device to use
Parameters:
-
clkCLKSEL_Tone of the CLKSEL_T values
Returns:
true if successful, false otherwise
setGyroscopeScale
-
scale
set the scaling mode of the gyroscope
Parameters:
-
scaleFS_SEL_Tone of the FS_SEL_T values
Returns:
true if successful, false otherwise
setAccelerometerScale
-
scale
set the scaling mode of the accelerometer
Parameters:
-
scaleAFS_SEL_Tone of the AFS_SEL_T values
Returns:
true if successful, false otherwise
setDigitalLowPassFilter
-
dlp
set the Low Pass Digital filter. This enables filtering (if non-0) of the accelerometer and gyro outputs.
Parameters:
-
dlpDLPF_CFG_Tone of the DLPF_CFG_T values
Returns:
true if successful, false otherwise
setSampleRateDivider
-
div
set the sample rate divider. This register specifies the divider from the gyro output rate used to generate the Sample Rate. The sensor registor output, FIFO output, DMP sampling and motion detection are all based on the Sample Rate.
The Sample Rate is generated by dividing the gyro output rate by this register:
Sample Rate = Gyro output rate / (1 + sample rate divider).
The Gyro output rate is 8Khz when the Digital Low Pass Filter (DLPF) is 0 or 7 (DLPF_260_256 or DLPF_RESERVED), and 1Khz otherwise.
Parameters:
-
divNumberone of the DLPF_CFG_T values
Returns:
true if successful, false otherwise
getSampleRateDivider
()
Number
get the current Sample Rate divider
Returns:
the current sample rate divider
getAccelerometer
-
x -
y -
z
get the accelerometer values
Parameters:
-
xFloat *the returned x value, if arg is non-NULL
-
yFloat *the returned y value, if arg is non-NULL
-
zFloat *the returned z value, if arg is non-NULL
getGyroscope
-
x -
y -
z
get the gyroscope values
Parameters:
-
xFloat *the returned x value, if arg is non-NULL
-
yFloat *the returned y value, if arg is non-NULL
-
zFloat *the returned z value, if arg is non-NULL
getTemperature
()
Number
get the temperature value
Returns:
the temperature value in degrees Celsius
enableTemperatureSensor
-
enable
enable onboard temperature measurement sensor
Parameters:
-
enableBooleantrue to enable temperature sensor, false to disable
Returns:
true if successful, false otherwise
setExternalSync
-
val
configure external sync. An external signal connected to the FSYNC pin can be sampled by configuring EXT_SYNC_SET. Signal changes to the FSYNC pin are latched so that short strobes may be captured. The latched FSYNC signal will be sampled at the Sampling Rate, as defined in register 25. After sampling, the latch will reset to the current FSYNC signal state.
The sampled value will be reported in place of the least significant bit in a sensor data register determined by the value of EXT_SYNC_SET
Parameters:
-
valEXT_SYNC_SET_Tone of the EXT_SYNC_SET_T values
Returns:
true if successful, false otherwise
enableI2CBypass
-
enable
enable I2C Bypass. Enabling this feature allows devices on the MPU60X0 auxiliary I2C bus to be visible on the MCU's I2C bus.
Parameters:
-
enableBooleantrue to I2C bypass
Returns:
true if successful, false otherwise
setMotionDetectionThreshold
-
thr
set the motion detection threshold for interrupt generation. Motion is detected when the absolute value of any of the accelerometer measurements exceeds this Motion detection threshold.
Parameters:
-
thrNumberthreshold
Returns:
true if successful, false otherwise
getInterruptStatus
()
Number
return the interrupt status register.
Returns:
the interrupt status word (see INT_STATUS_BITS_T)
setInterruptEnables
-
enables
set the interrupt enables
Parameters:
-
enablesNumberbitmask of INT_ENABLE_BITS_T values to enable
Returns:
true if successful, false otherwise
getInterruptEnables
()
Number
get the current interrupt enables register
Returns:
bitmask of INT_ENABLE_BITS_T values
setInterruptPinConfig
-
cfg
set the interrupt pin configuration
Parameters:
-
cfgNumberbitmask of INT_PIN_CFG_BITS_T values
Returns:
true if successful, false otherwise
getInterruptPinConfig
()
Number
get the current interrupt pin configuration
Returns:
bitmask of INT_PIN_CFG_BITS_T values
installISR
-
gpio -
level -
isr -
arg
install an interrupt handler.
Parameters:
-
gpioNumbergpio pin to use as interrupt pin
-
levelMraa::Edgethe interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin ( setInterruptPinConfig() ) properly for whatever level you choose.
-
isrFunctionthe interrupt handler, accepting a void * argument
-
argVoid *the argument to pass the the interrupt handler
uninstallISR
()
uninstall a previously installed interrupt handler