Configure an MPU-6050 Gyroscope/Accelerometer

The gyro-mpu6050 movement sensor model supports a combination gyroscope and accelerometer manufactured by TDK InvenSense.

Navigate to the Config tab of your robot’s page in the Viam app. Click on the Components subtab and navigate to the Create component menu. Enter a name for your movement sensor, select the movement-sensor type, and select the gyro-mpu6050 model.

Click Create Component.

Creation of an gyro-mpu6050 movement sensor in the Viam app config builder.

Edit and fill in the attributes as applicable.

{
  "components": [
    {
      "name": "<your-sensor-name>",
      "type": "movement_sensor",
      "model": "gyro-mpu6050",
      "attributes": {
        "board": "<your-board-name>",
        "i2c_bus": "<your-i2c-bus-name-on-board>",
        "use_alt_i2c_address": <bool>
      },
      "depends_on": []
    }
  ]
}
{
  "components": [
    {
      "name": "local",
      "type": "board",
      "model": "pi",
      "attributes": {
        "i2cs": [
          {
            "name": "default_i2c_bus",
            "bus": "1"
          }
        ]
      }
    },
    {
      "name": "my_accelgyro",
      "type": "movement_sensor",
      "model": "gyro-mpu6050",
      "attributes": {
        "use_alt_i2c_address": true,
        "i2c_bus": "default_i2c_bus",
        "board": "local"
      }
    }
  ]
}

Attributes

NameTypeInclusionDescription
boardstringRequiredThe name of the board to which the device is wired.
i2c_busstringRequiredThe name of the I2C bus configured on your board wired to this device.
use_alt_i2c_addressbooleanRequiredDepends on whether you wire AD0 low (leaving the default address of 0x68) or high (making the address 0x69). If high, set true. If low, set false.
Default: false


Have questions, or want to meet other people working on robots? Join our Community Discord.