一.系统概述
1. 本设计以STM32单片机为核心控制器,实现多功能健康监测系统:
2. 系统能够采集人体体温、心率、步数和血氧数据,并通过显示屏展示。
3. 集成蓝牙模块,将数据上传至手机APP,实现远程监控和数据管理功能。
4. 用户可设定定时提醒运动等操作,系统到达设定时间后会触发蜂鸣器报警。
5. 当监测到人体体温或心率异常时,系统通过语音播报提醒用户。
二.电路设计
电路图采用Altium Designer进行设计:
1. 通过STM32F103C8T6单片机作为系统主控,最小系统电路是整个电路的核心;
2. 使用ADXL345加速度传感器进行步数检测,并采用IIC总线与单片机进行通信。
3. 通过DS1302实现时钟定时,并通过SDA、SCK、DAT三个引脚与单片机进行连接;
4. 使用MAX30102进行心率血氧检测,该模块通过IIC总线与单片机进行通信;
5. 通过0.96寸的OLED12864进行数据显示,采用IIC总线的形式与单片机进行通信;
6. 使用JDY-31蓝牙模块进行无线通信,通过UART串口与单片机进行通信;
7. 使用JR6001进行语音播报,并通过UART串口与单片机进行连接;
8. 使用蜂鸣器进行报警,蜂鸣器采用的有源蜂鸣器,使用NPN三极管进行蜂鸣器进行驱动。
三.程序设计
#include "sys.h"
#include "delay.h"
#include "math.h"
#include "key.h"
#include "usart2.h"
#include "myiic.h"
#include "myiic1.h"
#include "max30102.h"
#include "ds1302.h"
#include "algorithm.h"
#include "Control_Report_To_Police.h"
void OLED_Display_Cotrol(void);
/************************************************
版权:小常硬件
公众号:微信搜索“小常硬件“在公众号免费下载相关资料
************************************************/
#define SIZE sizeof(TEXT_Buffer)
#define FLASH_SAVE_ADDR 0X0800f400
uint32_t aun_ir_buffer[500]; //IR LED sensor data
int32_t n_ir_buffer_length; //data length
uint32_t aun_red_buffer[500]; //Red LED sensor data
int32_t n_sp02; //SPO2 value
int8_t ch_spo2_valid; //indicator to show if the SP02 calculation is valid
int32_t n_heart_rate; //heart rate value
int8_t ch_hr_valid; //indicator to show if the heart rate calculation is valid
uint8_t uch_dummy;
#define MAX_BRIGHTNESS 255
unsigned int STEP=0;
char p1[16]=" ";
u16 Temperature_max=30,hr_max=90,spo_max=90;
u8 TEXT_Buffer[]={"0000000"};
u8 dis_hr=0,dis_spo2=0,mode;
static _Bool h_flag,s_flag,t_flag;
int main(void)
{
static u8 bushu;
uint32_t un_min, un_max, un_prev_data;
int i;
int32_t n_brightness;
float f_temp;
u8 temp[6],str[15];
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
delay_init(); //延时函数初始化
Usart1_Init(9600);
Usart2_Init(9600);
switch_Init();
KEY1_Init();
while(DS18B20_Init()){}
DS1302_GPIO_Init_Write_Time();
Beep_init();
while(ADXL345_IIC_GPIO_Init()) //3D加速度传感器初始化
{
}
max30102_init();
n_ir_buffer_length=100;
un_min=0x3FFFF;
un_max=0;
for(i=0;i<n_ir_buffer_length;i++)
{
while(MAX30102_INT==1); //wait until the interrupt pin asserts
max30102_FIFO_ReadBytes(REG_FIFO_DATA,temp);
aun_red_buffer[i] = (long)((long)((long)temp[0]&0x03)<<16) | (long)temp[1]<<8 | (long)temp[2]; // Combine values to get the actual number
aun_ir_buffer[i] = (long)((long)((long)temp[3] & 0x03)<<16) |(long)temp[4]<<8 | (long)temp[5]; // Combine values to get the actual number
if(un_min>aun_red_buffer[i])
un_min=aun_red_buffer[i]; //update signal min
if(un_max<aun_red_buffer[i])
un_max=aun_red_buffer[i]; //update signal max
}
un_prev_data=aun_red_buffer[i];
maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid);
// STEPS = (datatemp[0]-0x30)*10000+(datatemp[1]-0x30)*1000+(datatemp[2]-0x30)*100+(datatemp[3]-0x30)*10+(datatemp[4]-0x30);
OLED_Spi_Init();
OLED_Clear_Spi();
}