using a temperature, humidity sensor, touch, digit display and a buzzer to create an organ monitoring and alert system which communicates with an app via bluetooth

Dependencies:   DHT DigitDisplay mbed

Fork of Seeed_Grove_Temp_Humidity_Example by Seeed

Files at this revision

API Documentation at this revision

Comitter:
imomoh
Date:
Wed Mar 07 17:39:13 2018 +0000
Parent:
1:6bcb143683f3
Commit message:
Organ_Transplant_Monitoring_via_bluetooth

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
GettingStarted.htm Show annotated file Show diff for this revision Revisions of this file
Makefile Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Wed Mar 07 17:39:13 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GettingStarted.htm	Wed Mar 07 17:39:13 2018 +0000
@@ -0,0 +1,1 @@
+<meta http-equiv="refresh" content="0; url=http://mbed.org/handbook/Getting-Started-mbed-Exporters#gcc_arm"/>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Wed Mar 07 17:39:13 2018 +0000
@@ -0,0 +1,88 @@
+# This file was automagically generated by mbed.org. For more information, 
+# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
+
+GCC_BIN = 
+PROJECT = Mbed_Sensors_Example_3
+OBJECTS = ./main.o ./DHT/DHT.o 
+SYS_OBJECTS = ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/board.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/cmsis_nvic.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/mbed_overrides.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/retarget.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/system_MK64F12.o 
+INCLUDE_PATHS = -I. -I./DHT -I./mbed -I./mbed/TARGET_K64F -I./mbed/TARGET_K64F/TARGET_Freescale -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/TARGET_FRDM -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/device -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/device/MK64F12 -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/common -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/common/phyksz8081 -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/clock -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/clock/src -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/interrupt -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/pit -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/can -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/dmamux -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/dspi -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/edma -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/enet -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/flextimer -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/gpio -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/i2c -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/mcg -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/osc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pit -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pmc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/port -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/rtc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sai -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sdhc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sim -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/smc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/uart -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/wdog -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/utilities -I./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM 
+LIBRARY_PATHS = -L./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM 
+LIBRARIES = -lmbed 
+LINKER_SCRIPT = ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld
+
+############################################################################### 
+AS      = $(GCC_BIN)arm-none-eabi-as
+CC      = $(GCC_BIN)arm-none-eabi-gcc
+CPP     = $(GCC_BIN)arm-none-eabi-g++
+LD      = $(GCC_BIN)arm-none-eabi-gcc
+OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
+OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
+SIZE    = $(GCC_BIN)arm-none-eabi-size 
+
+ifeq ($(HARDFP),1)
+	FLOAT_ABI = hard
+else
+	FLOAT_ABI = softfp
+endif
+
+
+CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) 
+CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP
+CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -DCPU_MK64FN1M0VMD12 -DTARGET_KPSDK_MCUS -DTARGET_FRDM -DTARGET_CORTEX_M -DMBED_BUILD_TIMESTAMP=1452815708.69 -D__FPU_PRESENT=1 -DTARGET_Freescale -DTARGET_M4 -D__MBED__=1 -DTARGET_K64F -DTARGET_KPSDK_CODE -D__CORTEX_M4 -DFSL_RTOS_MBED -DTARGET_MCU_K64F -DARM_MATH_CM4 
+
+LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref
+LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
+
+
+ifeq ($(DEBUG), 1)
+  CC_FLAGS += -DDEBUG -O0
+else
+  CC_FLAGS += -DNDEBUG -Os
+endif
+
+.PHONY: all clean lst size
+
+all: $(PROJECT).bin $(PROJECT).hex size
+
+
+clean:
+	rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS)
+
+
+.asm.o:
+	$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
+.s.o:
+	$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
+.S.o:
+	$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
+
+.c.o:
+	$(CC)  $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99   $(INCLUDE_PATHS) -o $@ $<
+
+.cpp.o:
+	$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
+
+
+
+$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
+	$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
+
+
+$(PROJECT).bin: $(PROJECT).elf
+	$(OBJCOPY) -O binary $< $@
+
+$(PROJECT).hex: $(PROJECT).elf
+	@$(OBJCOPY) -O ihex $< $@
+
+$(PROJECT).lst: $(PROJECT).elf
+	@$(OBJDUMP) -Sdh $< > $@
+
+lst: $(PROJECT).lst
+
+size: $(PROJECT).elf
+	$(SIZE) $(PROJECT).elf
+
+DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
+-include $(DEPS)
+
+
--- a/main.cpp	Tue Mar 10 21:33:31 2015 +0000
+++ b/main.cpp	Wed Mar 07 17:39:13 2018 +0000
@@ -1,28 +1,117 @@
-
+/*******************************************************************************
+ECE 595 2018 Spring
+Project 1
+Group 10
+last Update @ 
+memo:   ?????????
+        ??????//app????
+        ????? for timer
+*******************************************************************************/
 #include "mbed.h"
 #include "DHT.h"
-
-DHT sensor(D4, DHT11);
+#include "DigitDisplay.h"
 
-int main()
-{
-    int error = 0;
-    float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
+DHT sensor(D4, DHT11); 
+DigitalOut buzzer(D2);
+Timer tOverheat;
+DigitalOut ledred(LED_RED);//or LED1 try both
+DigitalIn touch(D7);
+DigitDisplay display(D5, D6);
+
+Serial bluetooth(PTC15, PTC14); //wireless bluetooth connection to Android Device for output
+Serial pc(USBTX,USBRX);
+
+int timeflag = 0;
+int timeread = 0;
+int on = 1, off = 0; 
 
-    while(1) {
-        wait(2.0f);
-        error = sensor.readData();
-        if (0 == error) {
-            c   = sensor.ReadTemperature(CELCIUS);
-            f   = sensor.ReadTemperature(FARENHEIT);
-            k   = sensor.ReadTemperature(KELVIN);
-            h   = sensor.ReadHumidity();
-            dp  = sensor.CalcdewPoint(c, h);
-            dpf = sensor.CalcdewPointFast(c, h);
-            printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
-            printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
-        } else {
-            printf("Error: %d\n", error);
+void stemp(float FFF){
+    uint8_t FF = FFF;
+    display.setColon(0);
+    display.write(2, FF / 10);
+    display.write(3, FF % 10);
+    display.write(0, 0);
+    display.write(1, 0);
+}
+
+void stime(int ootime){
+    uint8_t otime = ootime;
+    display.setColon(0);
+    display.write(2, otime / 10);
+    display.write(3, otime % 10);
+    display.write(0, 0);
+    display.write(1, 0);
+}
+
+void sdisplay(int sw, int tm, float tp){
+    if(sw==1){
+        stime(tm);
         }
+    else if(sw==0){
+        stemp(tp);
     }
 }
+
+void blink(){
+     buzzer = on;
+     ledred = 1;       
+     wait(.3);      
+     buzzer = off;
+     ledred = 0;
+     }
+
+int main() 
+{ 
+    int error = 0; 
+    float h = 0.0f, f = 0.0f;
+    ledred = 1;//?????0???1?,??????
+    
+    pc.baud(9600);
+    bluetooth.baud(9600);
+    wait(2.0f);
+    
+    while(1) 
+    { 
+        error = sensor.readData(); 
+        if (0 == error)
+        { 
+            f = sensor.ReadTemperature(FARENHEIT); 
+            h = sensor.ReadHumidity(); 
+            sdisplay(touch,timeread,f);
+            pc.printf("Temperature in F: %4.2f\n",f);
+            pc.printf("Humidity is: %4.2f\n",h); 
+            bluetooth.printf("%4.2f %4.2f",f,h);
+            if(f>33)
+            {      
+                if(timeflag==0){
+                    timeflag = 1;
+                    blink();
+                    pc.printf("Over Heat!!\n");
+                    tOverheat.start();
+                    }
+                else if(timeflag==1){
+                    timeread = tOverheat.read();
+                    if(timeread >= 10){
+                        buzzer = on;
+                        pc.printf("Game Over\n");
+                        ledred = 0;
+                        }
+                    else{
+                        blink();
+                        pc.printf("Hurry Up, still have chance\n");
+                        }
+                 }                      
+            }
+            else if(f<=33){
+                timeflag = 0;
+                tOverheat.reset();
+                timeread = 0;
+                buzzer = off;
+                ledred = 1;
+            }
+        }
+        else{
+           // pc.printf("Woops, Sensor Error: %d\n", error);
+        }
+    }   
+} 
\ No newline at end of file