# 九軸感應器 (MPU-9250)

基於 MPU-9250 晶片，IMU 9DOF v2.0 感應器可透過 I2C 或 SPI 介面，進行高效能的九軸動態感應。本文將以模組預設的連接介面 I2C 進行說明，介紹如何透過 Arduino IDE 控制此模組。更多關於此模組的說明，請參考模組[官方 WiKi ](http://wiki.seeed.cc/Grove-IMU_9DOF_v2.0/)的內容。

欲了解下載及安裝驅動程式的方法，可參閱下列連結：

* [如何安裝驅動程式](https://cavedu.gitbook.io/linkit-7697/linkit-7697-arduino-ide-kai-fa-zhi-nan/kai-fa-tao-jian-yu-kuo-chong-ban/grove-starter-kit)
* [驅動程式的 GitHub Repository](https://github.com/MediaTek-Labs/linkit-7697-peripheral-drivers-for-arduino)

驅動程式安裝完成後，依照下列操作步驟以使用此模組：

### 設置與執行 <a href="#imu9dofv2.0mpu9250-she-zhi-yu-zhi-hang" id="imu9dofv2.0mpu9250-she-zhi-yu-zhi-hang"></a>

1. 將此模組連接到 LinkIt 7697 擴充板的 **I2C** 接口。
2. 選取 Arduino IDE 的 **File / Examples / Grove\_IMU\_9DOF\_9250 / IMU9DOF\_Demo\_Compass\_Calibrated** 選單。
3. 點選工具列上的 **Upload** 按鈕編譯並上傳程式至開發板。
4. 以 baud rate 38,400 開啟 Serial Monitor 並重啓板子執行應用程式。隨著感應器的動作變化，可看見相關訊息顯示如下：

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2FlpCm4fxwZeJ8F9F3dD6U%2F9dof_screenshot.png?alt=media\&token=f3a95799-68a2-412f-8c44-3f316d920005)

### 補充資料 <a href="#imu9dofv2.0mpu9250-bu-chong-zi-liao" id="imu9dofv2.0mpu9250-bu-chong-zi-liao"></a>

若開發者直接使用模組製造商提供的驅動程式原始碼：

* [Grove - IMU 9DOF v2.0 函式庫](https://raw.githubusercontent.com/SeeedDocument/Grove-IMU_9DOF_v2.0/master/res/Grove_IMU_9DOF_9250.zip)，以及&#x20;
* I2CDev 與 MPU9250 函式庫 (<https://github.com/Seeed-Studio/IMU_10DOF>)

可依照下列步驟修改，使之移植至 LinkIt 7697 執行：

1. 從函式庫目錄開啟 **IMU\_10DOF-master/MPU9250.h** 檔案。
2. 將 **41** 行程式碼註解掉：

   ```
   #ifndef _MPU9250_H_
   #define _MPU9250_H_ 
    
   #include "I2Cdev.h" 
   //#include <avr/pgmspace.h>
    
   //Magnetometer Registers
   #define MPU9150_RA_MAG_ADDRESS 0x0C
   ```
3. 儲存檔案後即完成移植。


---

# 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://cavedu.gitbook.io/linkit-7697/linkit-7697-arduinoide/zhou-bian-yuan-jian-lian-jie-jiao-xue/jiu-zhou-gan-ying-qi-mpu9250.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.
