> For the complete documentation index, see [llms.txt](https://chiprobotics.gitbook.io/chip-robotics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiprobotics.gitbook.io/chip-robotics/sensors/imu-sensor/api.md).

# API

USB / UART API to communicate with the IMU Sensor

### Sensor Transmit (Tx) API

The sensor transmits data continuously at 100Hz in the format below. Each messages is 19 bytes.

| Header | Index  | Yaw     | Roll    | Pitch   | <p>X-axis </p><p>accel. </p> | <p>Y-axis </p><p>accel.</p> | <p>Z-axis </p><p>accel.</p> | Reserved | Csum   |
| ------ | ------ | ------- | ------- | ------- | ---------------------------- | --------------------------- | --------------------------- | -------- | ------ |
| 2 byte | 1 byte | 2 byte  | 2 byte  | 2 byte  | 2 byte                       | 2 byte                      | 2 byte                      | 3 byte   | 1 byte |
| 0xAAAA |        | LSB-MSB | LSB-MSB | LSB-MSB | LSB-MSB                      | LSB-MSB                     | LSB-MSB                     | 0x000000 |        |

| Data                             | Description                                                                                                                               |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Header                           | Each message starts with 0xAAAA                                                                                                           |
| Index                            | 8 bit counter (0-255)                                                                                                                     |
| Yaw                              | <p>Rotation around z-axis, range -180 to 180. Clockwise is positive. </p><p>0.01 degree increments, e.g. 7435 is 74.35 degrees. </p>      |
| Roll                             | <p>Rotation around x-axis, range -90 to 90. Counter clockwise positive. </p><p>0.01 degree increments, e.g. 1222 is 12.22 degrees. </p>   |
| Pitch                            | <p>Rotation around y-axis, range -180 to 180. Counter clockwise positive. </p><p>0.01 degree increments, e.g. 1356 is 13.56 degrees. </p> |
| <p>X-axis</p><p>acceleration</p> | X-axis acceleration in mg                                                                                                                 |
| <p>Y-axis</p><p>acceleration</p> | Y-axis acceleration in mg                                                                                                                 |
| <p>Z-axis</p><p>acceleration</p> | Z-axis acceleration in mg                                                                                                                 |
| Reserved                         | 3 bytes set to 0.                                                                                                                         |
| <p>Checksum</p><p>(Csum)</p>     | Sum of index, yaw, pitch, roll, and acceleration.                                                                                         |

### Sensor Receive (Rx) API

To reset the sensor heading direction (Yaw, Pitch, Roll) to 0 send the following command to the sensor.&#x20;

```
$MIB,RESET*87
```

### Example Message&#x20;

Below is an example message sent by the IMU sensor.&#x20;

Message: 0xAA AA DE 01 00 92 FF 25 08 8D FE EC FF D1 03 00 00 00 E7

| Data     | Hex      | Value                                                                                 |
| -------- | -------- | ------------------------------------------------------------------------------------- |
| Index    | 0xDE     | 222                                                                                   |
| Yaw      | 0x00 01  | <p>0.01 degrees </p><p>multiply by -1 for counter clockwise</p><p>= -0.01 degrees</p> |
| Roll     | 0xFF 92  | -1.10 degrees                                                                         |
| Pitch    | 0x 08 25 | 20.85 degrees                                                                         |
| X-accel  | 0x FE 8D | -371 mg or -3.638 m/s2                                                                |
| Y-accel  | 0x FF EC | -20 mg or -0.196 m/s2                                                                 |
| z-accel  | 0x 03 D1 | <p>977 mg or 9.581 m/s2</p><p>multiply by -1 for Z-accel. up </p><p>= -977 mg</p>     |
| Checksum | 0xE7     |                                                                                       |
