一.系统概述
系统采用STM32单片机进行主控,系统内采用温度传感器、心率传感器以及加速度传感器进行人体的体温、心率以及是否摔倒的检测,检测到的数据以及阈值等数据会在显示屏端进行显示。检测到的数据还会实时上传到上位机端,还会实时显示异常情况,如果异常还会报警提醒。
二.仿真概述
1. OLED12864显示屏上显示检测的体温、心率以及摔倒等数据,通过虚拟串口会将检测到数据进行上传,如果没有超过阈值就会显示各项指标正常,虚拟串口助手链接如下所示:
波特律动 串口助手https://serial.keysking.com/
2. 当检测到其中一个数据超过设定的阈值,在报警的同时还会再上位机端进行异常提醒。
三.程序设计
#include <main.h>
//
u8 Key;//按键检测
u8 set;
u8 AIN1,AIN2,AIN0,AIN3;//
u8 th=39,hl=60,hh=80,pl=0,ph=10;
//
//
void Init_Test(void);
void Test(void);
void Display(void);
//
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//2:2
Init_Test();
while(1)
{
Key_Scan(&Key);
AIN0=PCF8591_ADC_Input(0x90,0);
AIN1=PCF8591_ADC_Input(0x90,1);
AIN2=PCF8591_ADC_Input(0x90,2);
if(Key==3)
{
set++;
if(set>1) set=0;
Key=0;
}
if(set==1)
{
OLED_ShowString(2,11," ");
if(Key==1)
{
th++;
Key=0;
}
if(Key==2) {th--;Key=0;}
}
if(Key==4)
{
set=0;
Key=0;
}
OLED_ShowString(1,2,"smart bracelet");
OLED_ShowString(2,1,"Temp:");OLED_ShowNum(2,6,AIN1,2);OLED_ShowString(2,8,"c");OLED_ShowNum(2,11,th,2);//AIN0
OLED_ShowString(3,1,"Hear:");OLED_ShowNum(3,6,AIN2,2);OLED_ShowString(3,8,"d");OLED_ShowNum(3,11,hl,2);OLED_ShowString(3,13,"-");OLED_ShowNum(3,14,hh,2);//AIN1
OLED_ShowString(4,1,"Post:");OLED_ShowNum(4,6,AIN0,2);OLED_ShowString(4,8," "); OLED_ShowNum(4,11,pl,2);OLED_ShowString(4,13,"-");OLED_ShowNum(4,14,ph,2);//AIN2
if(AIN1>th){ printf("体温异常\r\n");Beep_1;}
else { printf("体温正常\r\n");Beep_0;}
if(AIN2>hh|AIN2<hl){ printf("心率异常\r\n");Beep_1;}
else { printf("心率正常\r\n");Beep_0;}
if(AIN0<2){ printf("摔倒了\r\n");Beep_1;}
else { printf("没有摔倒\r\n");Beep_0;}
// delay_s(3);
}
}