Try   HackMD

自由軟體到物聯網智慧手錶(smart watch)

Group 2

github

Demo Video(youtube)

Memeber

F74031027 李東霖

flow control

init

Created with Raphaël 2.2.0startWear a watchArduino bluno beetle start workingcellphone connect?Time correction by cellphoneint real_time[6];real_time[0] = year_number;real_time[1] = month_number;real_time[2] = day_number;real_time[3] = hour_number;real_time[4] = minute_number;real_time[5] = second_number;unsigned long last_time = millis();Display timeyesno

Display time

Created with Raphaël 2.2.0startdetect gesture?Display heartrate、HRV、LF、HFmillis() - last_time >= 1000unsigned long append_second = (millis() - last_time)/1000;real_time[5] += append_second % 60;append_second /= 60;real_time[4] += append_second % 60;append_second /= 60;real_time[3] += append_second % 24;append_second /= 24;real_time[2] += append_second;firstPage();draw time on OLED by u8glibnextPage() == trueDisplay timeyesnoyesyesno

Display heartrate、HRV、LF、HF

Created with Raphaël 2.2.0startcellphone connect?bool IsWaveFront = getWaveFront(sensor data);IsWaveFront == true;unsigned long sample = millis();bool IsWaveFront = getWaveFront(sensor data);IsWaveFront == true;sample = millis() - sample;send sample(4 Bytes) to cellphonecellphone send message?get Message from cellphonedouble HRV = Message_HRV;double LF_HF = Message_LF_HF;calculate HeartRateint HR = 60000/sample;firstPage();draw HR on OLED by uglib8HRV LF_HF has value?draw HRV LF_HF on OLED by u8glibnextPage() == truedetect gesture?Display steps、altitudedraw "HRV LF_HF in calculate" on OLED by u8glibyesnoyesnoyesnoyesnoyesnoyesno

getWaveFront

bool getWaveFront(int sensor_data) {
    static int threshold = 512;
    static int data = -1;
    static bool first = true;
    if (threshold >= sensor_data) {
        first = true;
        return false;
    }
    else {
        if (!first)
            return false;

        if (sensor_data - data < 0) {
            first = false;
            return true;
        }
    }    
    data = sensor_data;
    return false;
}

Display steps、altitude

Created with Raphaël 2.2.0startint step = 0;bool overFlag = false;get horizontally accel from GY-80 by I2Cfilterover Threshold?overFlag == trueget air pressure from GY-80 by I2Cdouble altitude = ((double)(101325 - sensor_data)/100)*9;firstPage();draw step altitude on OLED by u8glibnextPage() == truedetect gestureDisplay timestep += 1;overFlag = trueoverFlag = false;yesnoyesnoyesnoyesno

get data from GY-80

use I2C to get

  • 加速度計 ADXL345
    • 0x53
  • 陀螺儀 L3G4200
    • 0x69
  • 電子羅盤 HMC5883
    • 0x1E
  • 氣壓計 BMP085
    • 0x77

block diagram

What functions you plan to implement in your smart watch

  • HRV + LF/HF
  • HeartRate Display
  • Gesture operation
  • Pedometer
  • OLED Display
  • Altitude Display
  • Unplug to power off
  • Three display modes

The algorithms you’re going to use to implement your functions

HRV + LF/HF

Use PulseSensor to produce PPG(Photoplethysmography) .

PPG

In PPG ,when the heart shrinks,blood vessel flow and value of PPG will rise
So PPG wave front interval, can represent the contraction of the heart interval, but also can represent the heart rate like RR interval.

Use SDNN to calculate HRV
SDNN is record all PPG wave peak interval,and calculate standard deviation of these datas;

σ=i=0N1Xi2Nu2

To deal with LF/HF, need to transform PPG wave weak interval by Discrete Fourier Transform.

Xk=n=0N1ei2πNnkXn , k=0,1,2...N1

Get LF HF LF/HF from spectrum.

To more than 5 minutes, have enough information.

To avoid second wave, we also need firs wave peak.

HeartRate Display

When calculate HRV, can record PPG wave peak interval.
Then, calculate average interval in one minute.

HR=60/(average interval in one minute)

Can get HeartRate.

Gesture operation

Judge gesture by gyroscope(L3G4200).
Then , opera watch by gesture.

It can judge gestures

  1. Arm outwart flip
  2. Arm inward flip

Fixed parallel to the arm is the Y axis.
In theory, when the outward flip, Y-axis angular velocity will rise and then decline.
When the inward flip, Y-axis angular velocity will decline and then rise.

To detect changes, you can know the user's gestures

Pedometer

Get accel of x、y、z by accelerometer(ADXL345).
Judge movement state of user by these datas.

Acceleration cyclical changes

Flow

Created with Raphaël 2.2.0startget horizontally accelfilterover Threshold?is overFlag set?increase one stepset overFlagclear overFlagyesnoyesno

OLED Display

Use u8glib to drive OLED board.
https://github.com/olikraus/u8glib

Use a loop to control pixel

firstPage();
do {
    //call u8glib to draw
    drawPixel(x,y);
    drawLine(x1,y1,x2,y2);
    drawTriangle(x1,y1,x2,y2,x3,y3);
    drawFrame(x,y,w,h);
    drawBox(x,y,w,h);
    drawCircle(x,y,r,opt);
    drawDisc(x,y,r,opt);
    setFont(...);
    drawBitmapP(x,y,cnt,h,bitmap);
    drawStr(x,y,str);
} while ( nextPage() );

Altitude Display

Get current air pressure by BMP085.
Then, calculate altitude by air pressure.

H=((101325 paPc)/100)9 m

Unplug to power off

Let the strap connect as a power switch.

Three display modes

  1. Display time
  2. Display heartrate、HRV、LF、HF
  3. Display steps、altitude

How your watch is supposed to look like

block diagram




look like

Job descriptions

  • program design
  • hardware design
  • UI/UX

Reference

基於智慧型手機之跌倒偵測與三維計步器之設計與實現
利用3軸數字加速度計實現功能全面的計步器設計
情緒偵測系統-以 LabVIEW 為平台之系統
設計

讀取 GY-80 模組:加速度計(ADXL345) 陀螺儀(L3G4200) 電子羅盤(HMC5883) 氣壓計(BMP085)
ADXL345-datasheet
L3G4200-datasheet
HMC5883-datasheet
BMP085-datasheet
U8glib Arduino OLED Tutorial 1: Hello World on Steroids
使用U8glib驱动12864图形液晶显示器(一)
逢甲大學自動控制工程學系大學部_畢業專題_ECG 與 PPG 信號之相關性研究
Pulse Sensor Amped
u8glib常用函数
ArduioFFT
PulseSensor_Amped_Arduino
arduino quadcopter
arduino bluno bettle DFR0267
arduino bluno bettle DFR0339
arduino bluno bettle DFR0339 中文