Files
sunny9898/_chat/notes.md
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

168 lines
5.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NOTES
- [ ] 濕度傳感器
- [ ] 溫度傳感器
- [ ] 發光二極管LED燈
- [ ] 超聲波距離傳感器
- [ ] 皮膚電反應傳感器 (https://item.taobao.com/item.htm?id=45507098393)
- [ ] 心率傳感器 (grove board not found, https://item.taobao.com/item.htm?id=820276767392)
### need to reply
- circuit pending confirmation
- need to confirm arduino mega
- potential traps
- printer
### priorized list (sensors, draft)
- [ ] 濕度傳感器
- [ ] 溫度傳感器
- [ ] 發光二極管LED燈
- [ ] 超聲波距離傳感器
- [ ] Arduino UNO
- [ ] 麵包板和跳線
- [ ] 皮膚電反應傳感器 (https://item.taobao.com/item.htm?id=45507098393)
- [ ] 心率傳感器 (grove board not found, https://item.taobao.com/item.htm?id=820276767392)
---
- [ ] 熱敏打印機
- [ ] 音頻模組
- [ ] SD卡模組
### plans
- ALL IN PLAN (all sensors, involved)
- ultrasonic sensor to sense is human nearby (ultrasonic sensor)
- 皮膚電反應傳感器
need to reply on SAT
deadline : SUN (24-Nov)
```
### 擴展專案心率變異性HRV與靜息心率分析儀
這個擴展專案將利用 Arduino 和心跳感應器來分析心率變異性HRV和靜息心率幫助使用者理解身體的疲勞和心理壓力程度並及時提供壓力狀態的提醒。
#### 所需材料:
1. Arduino Uno 或其他 Arduino 板
2. **心跳感應器**(如 MAX30100 或 Pulse Sensor
3. **OLED 顯示器**(如 0.96 吋 I2C OLED
4. **藍牙模組**(如 HC-05用於數據傳輸
5. **SD 卡模組**(可選)用於數據存儲
6. 跳線**、**面包板
7. **計算機**:用於數據分析
8. **電源**USB 或電池供電
#### 專案步驟:
1. **連接硬體**
- 將心跳感應器、OLED 顯示器和藍牙模組連接到 Arduino。
- 如果使用 SD 卡模組,亦需進行相應連接。
2. **安裝庫**
- 在 Arduino IDE 中安裝所需的庫:
- PulseSensor 或 MAX30100 庫
- Adafruit_SSD1306 和 Adafruit_GFX 庫
- SoftwareSerial 庫(用於藍牙模組)
- SD 庫(如果使用 SD 卡模組)
3. **編寫程式碼**
- 獲取心跳數據並計算每分鐘心跳BPM
- 計算 HRV 和靜息心率。
- 根據 HRV 和靜息心率推測壓力狀態。
- 將結果顯示在 OLED 屏幕上,並通過藍牙傳輸數據。
C++
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <PulseSensorPlayground.h>
#include <SoftwareSerial.h>
// 設定 OLED 顯示器
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// 設定心跳感應器
PulseSensorPlayground pulseSensor;
// 設定藍牙
SoftwareSerial bluetooth(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
display.begin(SSD1306_I2C_ADDRESS, OLED_RESET);
display.clearDisplay();
pulseSensor.analogInput(PULSE_INPUT_PIN);
pulseSensor.begin();
}
void loop() {
int bpm = pulseSensor.getBeatsPerMinute();
if (bpm > 0) {
// 計算靜息心率
static int restingHeartRate = bpm; // 初始靜息心率
static unsigned long lastUpdate = 0;
// 計算 HRV
unsigned long currentMillis = millis();
if (currentMillis - lastUpdate >= 1000) {
lastUpdate = currentMillis;
// 簡單示範如何計算 HRV
float hrv = calculateHRV(); // 你需要實作這個函數
// 顯示數據
display.clearDisplay();
display.setCursor(0, 0);
display.print("BPM: "); display.println(bpm);
display.print("HRV: "); display.println(hrv);
// 根據 HRV 判斷壓力狀態
if (hrv < 30) {
display.println("狀態: 高壓力");
bluetooth.println("壓力狀態: 高");
} else if (hrv < 60) {
display.println("狀態: 中等壓力");
bluetooth.println("壓力狀態: 中");
} else {
display.println("狀態: 低壓力");
bluetooth.println("壓力狀態: 低");
}
display.display();
bluetooth.println("BPM: " + String(bpm));
}
}
delay(100);
}
float calculateHRV() {
// 根據心跳數據計算 HRV 的邏輯
// 這裡需要實作具體的 HRV 計算方法
return random(20, 100); // 模擬 HRV 數據
}
4. **數據存儲與分析**
- 使用 SD 卡模組將心率數據存儲到文件中,便於後續分析。
- 將數據輸出到計算機進行進一步的統計分析和可視化。
5. **擴展功能**
- **手機應用**:開發一個手機應用,通過藍牙接收數據,並進行更深入的分析和可視化。
- **自動提醒**:設定閾值,當檢測到高壓力狀態時,發送通知或震動提醒使用者。
6. **注意事項**
- 確保感應器正確放置,並定期校準設備以獲得準確數據。
- 在測試過程中,重視個人隱私和數據安全,避免不必要的數據共享。
這個擴展專案不僅可以幫助使用者即時監測身體狀況,還能幫助他們理解和管理壓力,從而促進健康。希望這個設計能激發你的創意!
```