|
| 1 | +# Smart Pillow Application |
| 2 | +*Hong-Shuo Chen National Chiao Tung University<br> |
| 3 | +Bo-Ying Chen National Tsing Hua University<br> |
| 4 | +Kuan-Cheng Chen National Chiao Tung University* |
| 5 | + |
| 6 | +Smart pillow uses the breath frequency and turns of user. The algorithms processes the information and determine what sleep stages are users in. thus we can analyze the sleep cycle, and avoid waking users when they are in deep sleep. Moreover, for those who suffer from sleep apnea, when smart pillow detect no breath for a period of time, smart pillow will vibrate gently to make user to start to breathe. |
| 7 | +The smart pillow is an innovation that are combined with Bluetooth, acoustic sensor, pressure sensor and motor. Acoustic sensor and pressure sensor are used to provide information for analyzing sleep, while motor is used to wake people and for those who have sleep apnea. Bluetooth can send message to smart phone. |
| 8 | +We hope we can popularize the smart pillow in the future, smart pillow records and analyzes the sleep habit of users, through the information, is can wake users in proper time, improve the quality of sleep, and reduce sleep problem. |
| 9 | + |
| 10 | + |
| 11 | +* [Introduction](#introduction) |
| 12 | + * [Function](#function) |
| 13 | + * [System Architecture](#system-architecture) |
| 14 | + * [APP UI](#app-ui) |
| 15 | +* [Hardware and Software Setup](#hardware-and-software-setup) |
| 16 | + * [Required Hardware](#required-hardware) |
| 17 | + * [Required Software](#required-software) |
| 18 | + * [Hardware Connection](#hardware-connection) |
| 19 | +* [User Manual](#user-manual) |
| 20 | + * [Before Running This Application](#before-running-this-application) |
| 21 | + * [Run This Application](#run-this-application) |
| 22 | + |
| 23 | +## Introduction |
| 24 | + |
| 25 | + |
| 26 | +### Function |
| 27 | + |
| 28 | +- **Analysis Sleeping status and Best Waking up Time** |
| 29 | +- **Sleep monitoring** (Alarm of no breath while sleeping) |
| 30 | +- Communicate with **APP** |
| 31 | +- **Alarm Clock** Setting |
| 32 | +- **Music** based on Uart protocol (Supports file umlimited songs) |
| 33 | +- **Alexa** Voice assistant, connecting and communicating with Wifi. |
| 34 | +- **CPU Loading** Calculate the power used by the board |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +### System Architecture |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +### APP UI |
| 44 | + |
| 45 | + |
| 46 | +| Main page | Clock | Record | |
| 47 | +| -------- | -------- | -------- | |
| 48 | +|  |  |  | |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +## Hardware and Software Setup |
| 55 | +### Required Hardware |
| 56 | +- 1 DesignWare ARC EM Starter Kit(EMSK) |
| 57 | +- 1 Sound Detect Sensor |
| 58 | +- 3 Pressure sensor |
| 59 | +- 2 Pmod AD2: 4-channel 12-bit A/D Converter(AD7991) |
| 60 | +- 1 Vibration motor |
| 61 | +- 1 DFPlayer Mini |
| 62 | +- 1 Speaker |
| 63 | +- 1 LED Light |
| 64 | +- 1 Bluetooth sensor |
| 65 | +- 1 SD Card |
| 66 | +- WiFi Hotspot |
| 67 | +- Alexa |
| 68 | + |
| 69 | + |
| 70 | +### Required Software |
| 71 | +- ARC GNU Toolset |
| 72 | +- Serial port terminal, such as putty, tera-term or minicom |
| 73 | + |
| 74 | + |
| 75 | +### Hardware Connection |
| 76 | +* Connect Bluetooth to J1 |
| 77 | +* Connect Pmod AD2 to J2 and J4 |
| 78 | +* Connect pressure sensors and Sound Detect Sensor to Pmod AD2 |
| 79 | +* Connect DFPlayer Mini to J5 |
| 80 | +* Connect LED Light and Vibration motor to J3 |
| 81 | +* Connect speaker to DFPlayer Mini |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +## User Manual |
| 88 | +### Before Running This Application |
| 89 | +In order to open **UART_2**<br> |
| 90 | +We need to modify following files |
| 91 | + |
| 92 | +* emsk_init.c (board\emsk\common) |
| 93 | +``` |
| 94 | +set_pmod_mux(mux_regs, PM1_UR_UART_0 | PM1_LR_SPI_S \ |
| 95 | + | PM2_I2C_HRI \ |
| 96 | + | PM3_GPIO_AC \ |
| 97 | + | PM4_I2C_GPIO_D \ |
| 98 | + | PM5_UR_SPI_M1 | PM5_LR_UART_2 \ |
| 99 | + | PM6_UR_SPI_M0 | PM6_LR_GPIO_A ); |
| 100 | +``` |
| 101 | +* mux.h (board\emsk\drivers) |
| 102 | +``` |
| 103 | +/** |
| 104 | + * \name PMOD 5 Multiplexor |
| 105 | + * @{ |
| 106 | + */ |
| 107 | +#define PM5_UR_GPIO_C ((0 << BIT0) << PM5_OFFSET) /*!< Pmod5[4:1] are connected to DW GPIO Port C[27:24] */ |
| 108 | +#define PM5_UR_SPI_M1 ((1 << BIT0) << PM5_OFFSET) /*!< Pmod5[4:1] are connected to DW SPI Master signals using CS1_N */ |
| 109 | +
|
| 110 | +#define PM5_LR_GPIO_A ((0 << BIT2) << PM5_OFFSET) /*!< Pmod5[10:7] are connected to DW GPIO Port A[27:24] */ |
| 111 | +#define PM5_LR_UART_2 ((1 << BIT2) << PM5_OFFSET) /*!< Pmod5[10:7] are connected to DW UART Master signals using CS2_N */ |
| 112 | +/** @} end of name */ |
| 113 | +``` |
| 114 | +* dw_uart_obj.h (board\emsk\drivers) |
| 115 | +* dw_uart_obj.c (board\emsk\drivers) |
| 116 | + |
| 117 | +In order to calculate **CPU Loading**<br> |
| 118 | +We need to modify following files |
| 119 | +* task.h (os\freertos) |
| 120 | +* task.c (os\freertos\inc) |
| 121 | +### Run This Application |
| 122 | + |
| 123 | +Here take **EMSK2.2 - ARC EM7DFPU** |
| 124 | + |
| 125 | +1. Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and *115200bps*. |
| 126 | + |
| 127 | +2. Interact using EMSK. |
| 128 | + |
| 129 | + |
| 130 | +| folder/file | Function | |
| 131 | +| ------------------- | ------------------------------------------------------------- | |
| 132 | +| FreeRTOSConfig.h | header file of FreeRTOS configurations | |
| 133 | +| main.c | main entry of embARC Application | |
| 134 | +| makefile | Makefile of embARC Application | |
| 135 | + |
| 136 | +#### Makefile |
| 137 | + |
| 138 | +- Selected FreeRTOS here, then you can use FreeRTOS API in your application: |
| 139 | + |
| 140 | + # Application name |
| 141 | + APPL ?= freertos_kernel |
| 142 | + |
| 143 | + # Selected OS |
| 144 | + OS_SEL ?= freertos |
| 145 | + |
| 146 | +- Target options about EMSK and toolchain: |
| 147 | + |
| 148 | + TOOLCHAIN=gnu |
| 149 | + BOARD=emsk |
| 150 | + BD_VER=22 |
| 151 | + CUR_CORE=arcem7d |
| 152 | + |
| 153 | +- The relative series of the root directory, here the path of the Makefile is `./embarc_osp/`: |
| 154 | + |
| 155 | + # |
| 156 | + # root dir of embARC |
| 157 | + # |
| 158 | + EMBARC_ROOT = ../embARC |
| 159 | + |
| 160 | +- The middleware used in your application: |
| 161 | + |
| 162 | + MID_SEL = common |
| 163 | + |
| 164 | + |
| 165 | + *common* for baremetal function |
| 166 | + |
| 167 | +- Directories of source files and header files: |
| 168 | + |
| 169 | + # application source dirs |
| 170 | + APPL_CSRC_DIR = . |
| 171 | + APPL_ASMSRC_DIR = . |
| 172 | + |
| 173 | + # application include dirs |
| 174 | + APPL_INC_DIR = . |
| 175 | + |
| 176 | + # include current project makefile |
| 177 | + COMMON_COMPILE_PREREQUISITES += makefile |
| 178 | + |
| 179 | + ### Options above must be added before include options.mk ### |
| 180 | + # include key embARC build system makefile |
| 181 | + override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) |
| 182 | + include $(EMBARC_ROOT)/options/options.mk |
| 183 | + |
| 184 | +## Video |
| 185 | +* [SMART PILLOW](http://v.youku.com/v_show/id_XMzYxMzUxNjE2NA==.html?spm=a2hzp.8244740.0.0) |
| 186 | +* [SMART PILLOW 1080P](http://v.youku.com/v_show/id_XMzYxMzUxMTI5Ng.html?spm=a2h0j.11185381.listitem_page1.5~A) |
| 187 | + |
| 188 | +For complete source code<br> |
| 189 | +Please go to https://github.com/max2468tw/Smart_Pillow |
0 commit comments