# Sensor Interfacing

## Session 02: IMU Sensors และ Motion Processing

***

### วัตถุประสงค์การเรียนรู้

หลังจบ Session นี้ นิสิตจะสามารถ:

1. เข้าใจการทำงานของ IMU Sensor (BMI270) และการอ่านค่าผ่าน I2C
2. แปลงค่า Raw Data เป็นหน่วยทางฟิสิกส์ (m/s², rad/s)
3. เพิ่มฟังก์ชันประมวลผลข้อมูล (Magnitude, Motion Detection, Filtering)
4. ใช้ C Programming - Arrays, Structs, Pointers กับข้อมูล Sensor

***

### โปรเจกต์หลัก (Base Project)

```
mtb-example-psoc-edge-sensor-hub-imu
├── proj_cm33_s/              # Secure Project
├── proj_cm33_ns/             # Non-Secure Project (เราทำงานที่นี่)
│   ├── main.c
│   ├── sensor_hub_daq_task.c # <-- ไฟล์หลักที่เราจะเรียนรู้และต่อยอด
│   └── sensor_hub_daq_task.h
└── proj_cm55/                # CM55 Project
```

> **สำคัญ:** Labs ทั้งหมดจะเป็นการเพิ่มฟังก์ชันเข้าไปใน `sensor_hub_daq_task.c` ไม่ใช่การสร้างโปรเจกต์ใหม่!

***

### โครงสร้างการเรียนรู้ (3 ชั่วโมง)

<table><thead><tr><th width="100" align="center">ลำดับ</th><th>หัวข้อ</th></tr></thead><tbody><tr><td align="center">1</td><td>ภาพรวม IMU Sensor และ I2C</td></tr><tr><td align="center">2</td><td>Lab 1: ทำความเข้าใจโค้ด Sensor Hub</td></tr><tr><td align="center">3</td><td>Lab 2: คำนวณ Acceleration Magnitude</td></tr><tr><td align="center">4</td><td>Lab 3: ตรวจจับการเคลื่อนไหว</td></tr><tr><td align="center">5</td><td>Lab 4: Moving Average Filter</td></tr><tr><td align="center">6</td><td>Lab 5: ระบบ Motion Detection สมบูรณ์</td></tr><tr><td align="center">7</td><td>สรุปและแบบทดสอบ</td></tr></tbody></table>

### ภาพรวม IMU Sensor (Accelerometer + Gyroscope)

<figure><img src="https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MClo3nC-1US0rbK8Qau%2Fuploads%2FjlOcpU7TrAwCDDvaJHqy%2FScreenshot%202569-01-18%20at%2012.07.25.png?alt=media&#x26;token=5bf9fcde-6130-441d-95be-fddd688f7e0b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MClo3nC-1US0rbK8Qau%2Fuploads%2Ff7zGOkcOe5uXjKYCSkDN%2FMEMS.gif?alt=media&#x26;token=7aefbdb0-2a86-4c33-8082-6595b0ba6724" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MClo3nC-1US0rbK8Qau%2Fuploads%2FRc96yWyhtS8XzF2rlb9S%2FScreenshot%202569-01-18%20at%2012.06.24.png?alt=media&#x26;token=baa83501-b066-4f44-85e0-8fecbbf4f67d" alt=""><figcaption></figcaption></figure>

**จบ Session 2** | **ต่อไป:** Session 3: LVGL Display
