Configure an MPU-6050 (Micro-RDK)

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

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

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

Copy and paste the following attribute template into your movement sensor’s Attributes box. Then remove and fill in the attributes as applicable to your movement sensor, according to the table below.

{
  "board": "<your-board-name>",
  "i2c_bus": "<your-i2c-bus-name-on-board>",
  "use_alt_i2c_address": <boolean>
}
{
  "board": "local",
  "i2c_bus": "default_i2c_bus"
}
{
  "components": [
    {
      "name": "<your-sensor-name>",
      "model": "gyro-mpu6050",
      "type": "movement_sensor",
      "namespace": "rdk",
      "attributes": {
        "board": "<your-board-name>",
        "i2c_bus": "<your-i2c-bus-name-on-board>",
        "use_alt_i2c_address": <boolean>
      },
      "depends_on": []
    }
  ]
}
{
  "components": [
    {
      "name": "local",
      "model": "esp32",
      "type": "board",
      "namespace": "rdk",
      "attributes": {
        "pins": [15, 21, 22],
        "i2cs": [
          {
            "name": "default_i2c_bus",
            "bus": "i2c0",
            "data_pin": 21,
            "clock_pin": 22
          }
        ]
      }
    },
    {
      "name": "my_accelgyro",
      "model": "gyro-mpu6050",
      "type": "movement_sensor",
      "namespace": "rdk",
      "attributes": {
        "board": "local",
        "i2c_bus": "default_i2c_bus"
      }
    }
  ]
}

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_addressbooleanOptionalDepends 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

Test the movement sensor

After you configure your movement sensor, navigate to the Control tab and select the dedicated movement sensor dropdown panel. This panel presents the data collected by the movement sensor. The sections in the panel include the angular velocity and linear acceleration.

The movement sensor component in the control tab


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

If you notice any issues with the documentation, feel free to file an issue or edit this file.