diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/README.md b/arc_design_contest/2018/NCKU_Smart-stove-knob/README.md new file mode 100644 index 00000000..83452dba --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/README.md @@ -0,0 +1,115 @@ +# Smart Stove Konb Application +We designed this product for **aging society**. Most of the old in Taiwan live alone because their children work in the city. some of them forget that they are cooking while watching TV, chating, etc. So we designed this smart stove knob to turn off the stove when detecting smoke or the user leave more than three minutes. We aim to reduce the harm from the stove. +* [Introduction](#introduction) + * [Function](#function) + * [Algorithm](#algorithm) + * [System Architecture](#system-architecture) + * [Demo Video](https://v.youku.com/v_show/id_XMzYxMzEzODU1Ng==.html?spm=a2h3j.8428770.3416059.1) +* [Hardware and Software Setup](#hardware-and-software-setup) + * [Required Hardware](#required-hardware) + * [Required Software](#required-software) + * [Hardware Connection](#hardware-connection) +* [User Manual](#user-manual) + * [Before Running This Application](#before-running-this-application) + * [Run This Application](#run-this-application) + +## Introduction + +**Smart Stove Konb** + + Smart Stove Konb reduces the possibilty of the house firing induced by the stove. + +### Function + +- Turn off the stove when + - Detecting smoke + - The user leave more than three minutes + - Times up when the user set when to turn off the stove(developing) +- Linking to the user's cellphone + - Set when to turn off the stove in the App(developing) + - Check if the stove is on when leaving home(developing) +  ![app][1] + +### Algorithm +  ![algorithm][2] + +### System Architecture +  ![architecture][3] + +## Hardware and Software Setup +### Required Hardware +- 1 [DesignWare ARC EM Starter Kit(EMSK)][4] +- 2 [HM10 module][5] +- 1 [Arduino UNO board][6] +- 1 [Digilent PMOD TMP2][7] +- 1 [MQ2 gas sensor][8] +- 1 [PIR motion sensor module:DYP-ME003][9] +- 1 [servo motor SG90][10] + +The list of haraware is shown in the picture following. + +### Required Software +- Metaware or ARC GNU Toolset +- Serial port terminal, such as putty, tera-term or minicom +- Arduino + +### Hardware Connection +1. EMSK acts as **hub** in this system. It receives stove condition from node, and sends control signal to turn off the stove. +- Connect **HM10** to **J1** +2. Arduino acts as **node** in this system. It gets the condition around the stove with temperature sensor, motion sensor, and smoke sensor. The Arduino board concludes received data, and send the judgement to hub. +- Connect **HM10** to Arduino board as the table below + +| HM10 | Arduino | +|------|---------| +| RXD | D9 | +| TXD | D8 | +| GND | GND | +| VDD | 5V | +- Connect **PMOD TMP2** to Arduino board as the table below + +| TMP2 | Arduino | +|------|---------| +| SCL | A5 | +| SDA | A4 | +| GND | GND | +| VDD | 5V | +- Connect **MQ2 gas sensor** to Arduino board as the table below +- Connect **motion sensor** to Arduino board as the table below + +| motion sensor | Arduino | +|---------------|---------| +| OUT | D5 | +| GND | GND | +| VDD | 5V | +- Connect **servo motor** to Arduino board as the table below + +| servo motor | Arduino | +|------------------------|---------| +| PWM input(orange line) | D3 | +| GND(brown line) | GND | +| VDD(red line) | 5V | + +## User Manual +### Before Running This Application +Download src code from github and upload them to EMSK and Arduino board respectively. +### Run This Application +Upload src code to EMSK and Arduino board respectively, and open the terminal to observe how they communicate with each other. + +| Source Folder | Board | +|------------------|---------| +| src/ARC | EMSK | +| src/Arduino/node | Arduino | + + +[1]:./doc/pic/app.png "app" +[2]:./doc/pic/algorithm.png "algorithm" +[3]:./doc/pic/system_architecture.png "system_architecture" + +[4]:https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit "DesignWare ARC EM Starter Kit(EMSK)" +[5]:https://goods.ruten.com.tw/item/show?21726620422161 "Ble HM10 module" +[6]:https://goods.ruten.com.tw/item/show?21404239751648 +[7]:https://store.digilentinc.com/pmod-tmp2-temperature-sensor/ +[8]:https://goods.ruten.com.tw/item/show?21209142783548 +[9]:https://goods.ruten.com.tw/item/show?21210114921071 +[10]:https://goods.ruten.com.tw/item/show?21211166622336 + diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/hardware_graph.pdf b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/hardware_graph.pdf new file mode 100644 index 00000000..da51c236 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/hardware_graph.pdf differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/algorithm.png b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/algorithm.png new file mode 100644 index 00000000..e8f2bb60 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/algorithm.png differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/app.png b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/app.png new file mode 100644 index 00000000..9665d837 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/app.png differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/desktop.ini b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/desktop.ini new file mode 100644 index 00000000..15d3462f --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/desktop.ini @@ -0,0 +1,5 @@ +[.ShellClassInfo] +InfoTip=³o¬O¦b½u¤W¦@¥Îªº¸ê®Æ§¨¡C +IconFile=C:\Program Files\Google\Drive\googledrivesync.exe +IconIndex=12 + \ No newline at end of file diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/system_architecture.png b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/system_architecture.png new file mode 100644 index 00000000..f949ee77 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/pic/system_architecture.png differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/circuit.jpg b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/circuit.jpg new file mode 100644 index 00000000..116e35f7 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/circuit.jpg differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/desktop.ini b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/desktop.ini new file mode 100644 index 00000000..15d3462f --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/desktop.ini @@ -0,0 +1,5 @@ +[.ShellClassInfo] +InfoTip=³o¬O¦b½u¤W¦@¥Îªº¸ê®Æ§¨¡C +IconFile=C:\Program Files\Google\Drive\googledrivesync.exe +IconIndex=12 + \ No newline at end of file diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/front.jpg b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/front.jpg new file mode 100644 index 00000000..31960974 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/front.jpg differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_1.jpg b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_1.jpg new file mode 100644 index 00000000..e7f57227 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_1.jpg differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_2.jpg b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_2.jpg new file mode 100644 index 00000000..a3165fb8 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/side_2.jpg differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/up.jpg b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/up.jpg new file mode 100644 index 00000000..4240d55a Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/product_pic/up.jpg differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/desktop.ini b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/desktop.ini new file mode 100644 index 00000000..15d3462f --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/desktop.ini @@ -0,0 +1,5 @@ +[.ShellClassInfo] +InfoTip=³o¬O¦b½u¤W¦@¥Îªº¸ê®Æ§¨¡C +IconFile=C:\Program Files\Google\Drive\googledrivesync.exe +IconIndex=12 + \ No newline at end of file diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.docx b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.docx new file mode 100644 index 00000000..7e14bcaf Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.docx differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.pdf b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.pdf new file mode 100644 index 00000000..90028b28 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/doc.pdf differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/ppt.pdf b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/ppt.pdf new file mode 100644 index 00000000..a533f626 Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/technical file/ppt.pdf differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/video_ppt.pdf b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/video_ppt.pdf new file mode 100644 index 00000000..220e8b4e Binary files /dev/null and b/arc_design_contest/2018/NCKU_Smart-stove-knob/doc/video_ppt.pdf differ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/main.c b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/main.c new file mode 100644 index 00000000..b1685aea --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/main.c @@ -0,0 +1,50 @@ +#include "embARC.h" +#include "embARC_debug.h" + +#include "board.h" +#include "dev_uart.h" + +//uint32_t baudrate_list[] = {4800, 9600, 19200, 38400, 57600, 115200}; + +int main(void) +{ + uint8_t state; + uint8_t motor; + uint32_t rcv_cnt; + uint32_t baudrate = UART_BAUDRATE_9600; + uint8_t stove_on_cnt = 0; + int t0 = 0; + + /** change the init baudrate according to your ble module settings */ + EMBARC_PRINTF("Init HM1X with baudrate %dbps\r\n", baudrate); + hm1x_init(baudrate); + + while (1) { + rcv_cnt = hm1x_read(&state, sizeof(state)); + if (rcv_cnt) { + if (state == 'h') { //stove is on + if (stove_on_cnt < 1) { + EMBARC_PRINTF("STOVE ON!\n"); + stove_on_cnt++; + } + t0 = 0; + EMBARC_PRINTF("Cook is in the kitchen\n"); + } else if (state == 's') { + EMBARC_PRINTF("It's smoking\n"); + } else if (state == 'n') {//no human + t0++; + EMBARC_PRINTF("Cook has leaved for %d seconds\n", t0); + } + if((state == 's') || (t0 >= 10)){ + EMBARC_PRINTF("Turn off the stove\n"); + motor = 'r'; + hm1x_write(&motor, sizeof(motor)); + break; + } + } + } + + return E_SYS; /* system error */ +} + +/** @} */ diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/makefile b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/makefile new file mode 100644 index 00000000..62d4dff2 --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/ARC/makefile @@ -0,0 +1,24 @@ +# Application name +APPL ?= ARC_contest + +# +# root dir of embARC +# +EMBARC_ROOT = ../../.. + +MID_SEL = common + +# application source dirs +APPL_CSRC_DIR = . +APPL_ASMSRC_DIR = . + +# application include dirs +APPL_INC_DIR = . + +# include current project makefile +COMMON_COMPILE_PREREQUISITES += makefile + +### Options above must be added before include options.mk ### +# include key embARC build system makefile +override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) +include $(EMBARC_ROOT)/options/options.mk \ No newline at end of file diff --git a/arc_design_contest/2018/NCKU_Smart-stove-knob/src/Arudino/node/node.ino b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/Arudino/node/node.ino new file mode 100644 index 00000000..edec47e5 --- /dev/null +++ b/arc_design_contest/2018/NCKU_Smart-stove-knob/src/Arudino/node/node.ino @@ -0,0 +1,109 @@ + +#include // call library +#define ADT7420_Adresse 0x4B // I2C adress of the Pmod TMP2 +#define BT1_RxD 8 +#define BT1_TxD 9 +#define infrared_pin 5 +#define smoke_pin 11 + +//Déclaration d'un port série +#include +#include +Servo myservo; +SoftwareSerial BT1(BT1_RxD,BT1_TxD); + +int MSB; +int LSB; +int valeur; +int temperature; +int stove_on_cnt=0; +char stove_condition=0; +int pos = 180; // variable to store the servo position +char dirction = 0; +int runtime = 0; +int smoke=0; +int human_state; + +void setup() +{ + Serial.begin(9600); // initialization of serial communication + myservo.attach(3); // attaches the servo on pin 9 to the servo object + myservo.write(pos); + Wire.begin(); // initialization of I2C communication + Init_ADT7420(); // initialisztion of Pmod AD2 module + BT1.begin(9600); +} + +void loop() +{ + if(runtime<1) + { + BT1.begin(9600); + if(BT1.available()>0) + { + dirction = BT1.read(); + if(dirction == 'r') + { + for(pos = 180; pos >= 0; pos -= 1) // goes from 0 degrees to 180 degrees + { // in steps of 1 degree + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(20); // waits 15ms for the servo to reach the position + runtime++; + } + Serial.println("Stove has been turned off"); + } + } + } + Wire.beginTransmission(ADT7420_Adresse); // Launch of the measure + Wire.endTransmission(); + delay(10); + Wire.requestFrom(ADT7420_Adresse, 2); // Recovery of the two bytes MSB and LSB + if(Wire.available() <=2) + { + MSB = Wire.read(); + LSB = Wire.read(); + } + valeur=(MSB<<8)|LSB ; + temperature=valeur/128; + /*if (((valeur>>15)&1)==0) // If the temperature is positive + { + temperature=valeur/128; + } + else // If the temperature is negative + { + temperature=(valeur-65535)/128; + } +/* Serial.print("MSB="); // display in serial monitor + Serial.println(MSB); + Serial.print("LSB="); + Serial.println(LSB); + Serial.print("Valeur="); + Serial.println(valeur); +*/ Serial.print("Temperature="); + Serial.println(temperature); + //delay(100); + //if(temperature>=40) + //{ + if(stove_on_cnt<1){ + Serial.println("STOVE ON!"); + stove_on_cnt++; + } + human_state = digitalRead(infrared_pin); + smoke = digitalRead(smoke_pin); + if(smoke == LOW) stove_condition = 's'; + else if(human_state == HIGH) stove_condition = 'h'; + else stove_condition = 'n'; + //} + //else stove_condition = 'l'; + BT1.write(stove_condition); + delay(1000); +} +// Initialization of Pmod TMP2 module +void Init_ADT7420(void)//temp +{ +// Configuring the ADT7420 in 16 bit mode + Wire.beginTransmission(ADT7420_Adresse); + Wire.write(0x03); + Wire.write(0x80); + Wire.endTransmission(); +} diff --git a/main.c b/main.c new file mode 100644 index 00000000..b1685aea --- /dev/null +++ b/main.c @@ -0,0 +1,50 @@ +#include "embARC.h" +#include "embARC_debug.h" + +#include "board.h" +#include "dev_uart.h" + +//uint32_t baudrate_list[] = {4800, 9600, 19200, 38400, 57600, 115200}; + +int main(void) +{ + uint8_t state; + uint8_t motor; + uint32_t rcv_cnt; + uint32_t baudrate = UART_BAUDRATE_9600; + uint8_t stove_on_cnt = 0; + int t0 = 0; + + /** change the init baudrate according to your ble module settings */ + EMBARC_PRINTF("Init HM1X with baudrate %dbps\r\n", baudrate); + hm1x_init(baudrate); + + while (1) { + rcv_cnt = hm1x_read(&state, sizeof(state)); + if (rcv_cnt) { + if (state == 'h') { //stove is on + if (stove_on_cnt < 1) { + EMBARC_PRINTF("STOVE ON!\n"); + stove_on_cnt++; + } + t0 = 0; + EMBARC_PRINTF("Cook is in the kitchen\n"); + } else if (state == 's') { + EMBARC_PRINTF("It's smoking\n"); + } else if (state == 'n') {//no human + t0++; + EMBARC_PRINTF("Cook has leaved for %d seconds\n", t0); + } + if((state == 's') || (t0 >= 10)){ + EMBARC_PRINTF("Turn off the stove\n"); + motor = 'r'; + hm1x_write(&motor, sizeof(motor)); + break; + } + } + } + + return E_SYS; /* system error */ +} + +/** @} */