# 6. 陀螺仪IMU（MPU6050）

MPU6050是使用最广泛的6轴陀螺仪，不仅可以较为精确的测量3轴角速度及3轴加速度，也可以使用内置的数字运动处理器单元（DMP，Digital Motion Processor）来进行基于硬件的姿态融合计算。这样新手也可以很方便的使用。为此我们也采用的MPU6050陀螺仪。

MPU6050在Arduino UNO上的例程很多，最著名的就是jrowberg的I2Cdev和MPU6050DMP库：

{% embed url="<https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050>" %}

但是很不幸，这个库无法直接在基于ESP32的BiBoard上运行。我们找到了Github上移植好的库，方便使用。这个库增加了了ARM和ESP系列的PGMSpace的定义，增加了校准函数，去掉了FIFO溢出的处理函数（有兴趣的朋友可以使用Beyond Compare进行代码对比）。库包含了I2Cdev和MPU6050，地址和压缩包如下：

{% embed url="<https://github.com/ElectronicCats/mpu6050/tree/master/src>" %}

{% file src="/files/PtuTP6THBHxrCrqTjTB9" %}
mpu6050.zip
{% endfile %}

下载完成后，在文档/Arduino/library下建立一个MPU6050的文件夹，把压缩包里的库文件拷贝进去即可。这个修改过的MPU6050的库也是可以兼容ARM和AVR的，所以如果你的计算机中有原版的I2Cdev和MPU6050库，可以删除。

我们使用官方的MPU6050\_DMP6示例即可。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petoi.com/chinese/biboard/li-cheng/6.-tuo-luo-yi-imumpu6050.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
