本設(shè)計(jì):
基于STM32老人防跌倒報(bào)警GSM短信GPS定位設(shè)計(jì)(程序+原理圖+PCB)
編號(hào)C0025
下載鏈接
C0025 完整資料下載鏈接:https://pan.baidu.com/s/1QR9G8q5qC0Tj4n8T60XGkw?pwd=ysss 提取碼:ysss
功能描述:
本系統(tǒng)由基于STM32單片機(jī)的核心板、ADXL345加速度傳感器、GSM、GPS模塊、指示燈、按鍵電率+蜂鳴器報(bào)警及電源組成。
1、板子正常情況下是豎直裝在口袋里的(adxl345模塊在下角豎直立著),一旦傾角傳感器檢測(cè)到平放即摔倒,蜂鳴器報(bào)警,且摔倒的時(shí)間持續(xù)超過(guò)15秒短信報(bào)警(15秒是為了確定老人已經(jīng)跌倒且15秒鐘都沒有自行爬起來(lái),需要報(bào)警提醒周圍的人幫忙)。如果老人沒有跌倒,而是彎腰等等,這屬于誤報(bào)警,則老人可以自己用按鍵取消鍵取消警報(bào)。
2、觸發(fā)GSM模塊實(shí)現(xiàn)短信的發(fā)送, 設(shè)備將會(huì)向人員發(fā)送信息,包括所在位置經(jīng)緯度信息。
3、短信處理及初始化有狀態(tài)指示燈指示。
注:GSM上電有幾秒初始化,系統(tǒng)供電電源至少要支持5V/2A,GPS天線必須放到漏天位置。
原理圖:
PCB:
源程序:
#include “led.h”
#include “delay.h”
#include “sys.h”
#include “timer.h”
#include “key.h”
#include “usart.h”
#include <string.h>
#include “adxl345.h”
unsigned char BufTab[10]; //wifi數(shù)據(jù)暫存
unsigned char Count; //串口數(shù)據(jù)計(jì)數(shù)
unsigned char UartBusy=0; //盤忙
unsigned char ReadFlag=0;//讀取標(biāo)志
unsigned char sendDataFlag=0;//發(fā)送短信標(biāo)志
unsigned char i ;
unsigned char ReadAdxl345; //定時(shí)讀取adxl345數(shù)據(jù)
unsigned char ErrorNum=0; //記錄錯(cuò)誤次數(shù)
unsigned char CheckNum=0; //檢測(cè)次數(shù)
unsigned long ReportLater=0; //上報(bào)延時(shí)
unsigned long KeyLater=3; //按鍵延時(shí)計(jì)數(shù)
unsigned long Mid_Du; //經(jīng)緯度處理 度
unsigned long Mid_Fen; //經(jīng)緯度處理 分
unsigned long Mid_Vale; //經(jīng)緯度處理 中間變量
char Lin0_No[16]=“N:000.000000”;//存儲(chǔ)緯度
char Lin1_Ea[16]=“E:000.000000”;//存儲(chǔ)經(jīng)度
char Crtl_Z[1]={0x1a}; //發(fā)送短信標(biāo)志
void dealGps(void) ;//gps數(shù)據(jù)處理
int main(void)
{
delay_init(); //延時(shí)函數(shù)初始化
NVIC_Configuration();//設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
LED_Init(); //初始化與LED連接的硬件接?
KEY_Init();
uart_init(9600);
uart2_init(9600) ;
TIM3_Int_Init(499,7199);//10Khz的計(jì)數(shù)頻率,計(jì)數(shù)到500為50ms
BUZZER = 1;delay_ms(100);BUZZER = 0; //初始化
GSM_LED = 0;
i=5;
while(i--) delay_ms(100);//延時(shí)
Init_ADXL345();
if(Single_Read_ADXL345(0X00)==0xe5)
{
delay_ms(5);
}
else
{
delay_ms(3);
}
UART_SendStr(USART1 ,"AT+CMGF=1rn",11); //設(shè)置字符集
i=10;
while(i--) delay_ms(100);//延時(shí)
UART_SendStr(USART1 ,"AT+CSCS="GSM"rn",15);//設(shè)置文本?
i=10;
while(i--) delay_ms(100);//延時(shí)
GSM_LED =1; //關(guān)閉LED指示
while(1)
{
if(ReadAdxl345== 1) //定時(shí)讀取adxl345數(shù)據(jù)
{
ReadAdxl345= 0;
ReadData_x(); //三軸檢測(cè)函數(shù)
CheckNum++;
if((temp_X<550)||(temp_X>10000)) //方位值判斷 查看正常次數(shù)
{
ErrorNum++;
}
if(CheckNum>=5) //進(jìn)行5次處理
{
if(KeyLater>=3) //非按鍵下
{
if(ErrorNum>=1) //角度出現(xiàn)錯(cuò)誤 5次出息1次情況
{
BUZZER = 1; //打開蜂鳴器
}
else
{
BUZZER = 0; //關(guān)閉蜂鳴器
ReportLater=0; //上報(bào)延時(shí)計(jì)數(shù)
}
}
ErrorNum=0; //清空濾波計(jì)數(shù)
CheckNum=0;
}
}
if(ReportLater>=15) //15s
{
GSM_LED = 0;
UART_SendStr(USART1 ,"AT+CMGF=1rn",11); //設(shè)置字符集
i=3;
while(i--) delay_ms(100);//延時(shí)
UART_SendStr(USART1 ,"AT+CSCS="GSM"rn",15);//設(shè)置文本
i=3;
while(i--) delay_ms(100);//延時(shí)
UART_SendStr(USART1 ,"AT+CMGSM="+8615555183057"rn",26); //測(cè)試號(hào)//**All notes can be deleted and modified**//
// UART_SendStr(USART1 ,“AT+CMGS=”+8615542546521"rn",26); //測(cè)試號(hào)
i=2;
while(i–) delay_ms(100);//延時(shí)
UART_SendStr(USART1 ,"help me!",8); //發(fā)送經(jīng)度
if(sysmode_GPS==1) //gps有效
{
sysmode_GPS=0;
dealGps();
UART_SendStr(USART1 ,Lin0_No,12); //發(fā)送緯度
UART_SendStr(USART1 ,Lin1_Ea,12); //發(fā)送經(jīng)度
}
else
{
UART_SendStr(USART1 ,"gps linking...",14); //gps無(wú)信號(hào)
}
delay_ms(200);//延時(shí)
UART_SendStr(USART1 ,( char *)Crtl_Z, 1); //發(fā)送
i=40;
while(i--) delay_ms(100);//延時(shí)
GSM_LED =1; //led關(guān)閉
ReportLater=0; //上報(bào)標(biāo)志清空
KeyLater=0; //按鍵清零延時(shí)處理
}
if(key==0) //按鍵處理
{
delay_ms(3); //按鍵消抖動(dòng)
if(key ==0) //按鍵處理
{
ReportLater=0; //按鍵延時(shí)上報(bào)
BUZZER = 0; //關(guān)閉蜂鳴器
KeyLater=0; //按鍵延時(shí)處理
}
}
}
}
void dealGps(void)
{
Mid_Du=(gps_infor_weijing[0]-0x30)*10000000+(gps_infor_weijing[1]-0x30)*1000000; //處理經(jīng)度擴(kuò)大10000000
Mid_Fen=(gps_infor_weijing[2]-0x30)*10000000+(gps_infor_weijing[3]-0x30)*1000000+
(gps_infor_weijing[4]-0x30)*100000+(gps_infor_weijing[5]-0x30)*10000+
(gps_infor_weijing[6]-0x30)*1000+(gps_infor_weijing[7]-0x30)*100;
Mid_Fen=Mid_Fen/60; //分秒換算為小數(shù)位
Mid_Vale=Mid_Du+Mid_Fen; //最終為度格式000.00000000 非度分秒格式
Lin0_No[0]='N';
Lin0_No[1]=':';
Lin0_No[2]='0';
Lin0_No[3]=Mid_Vale/10000000+0x30; //轉(zhuǎn)化為字符
Lin0_No[4]=(Mid_Vale/1000000)%10+0x30;
Lin0_No[5]='.';
Lin0_No[6]=(Mid_Vale/100000)%10+0x30;
Lin0_No[7]=(Mid_Vale/10000)%10+0x30;
Lin0_No[8]=(Mid_Vale/1000)%10+0x30;
Lin0_No[9]=(Mid_Vale/100)%10+0x30;
Lin0_No[10]=(Mid_Vale/10)%10+0x30;
Lin0_No[11]=Mid_Vale%10+0x30;
Mid_Du=(gps_infor_weijing[8]-0x30)*100000000+(gps_infor_weijing[9]-0x30)*10000000+(gps_infor_weijing[10]-0x30)*1000000; //處理經(jīng)度擴(kuò)大10000000
Mid_Fen=(gps_infor_weijing[11]-0x30)*10000000+(gps_infor_weijing[12]-0x30)*1000000+
(gps_infor_weijing[13]-0x30)*100000+(gps_infor_weijing[14]-0x30)*10000+
(gps_infor_weijing[15]-0x30)*1000+(gps_infor_weijing[16]-0x30)*100;
Mid_Fen=Mid_Fen/60; //分秒換算為小數(shù)位
Mid_Vale=Mid_Du+Mid_Fen; //最終為度格式000.00000000 非度分秒格式
Lin1_Ea[0]='E';
Lin1_Ea[1]=':';
Lin1_Ea[2]=Mid_Vale/100000000+0x30; //轉(zhuǎn)化為字符
Lin1_Ea[3]=(Mid_Vale/10000000)%10+0x30;
Lin1_Ea[4]=(Mid_Vale/1000000)%10+0x30;
Lin1_Ea[5]='.';
Lin1_Ea[6]=(Mid_Vale/100000)%10+0x30;
Lin1_Ea[7]=(Mid_Vale/10000)%10+0x30;
Lin1_Ea[8]=(Mid_Vale/1000)%10+0x30;
Lin1_Ea[9]=(Mid_Vale/100)%10+0x30;
Lin1_Ea[10]=(Mid_Vale/10)%10+0x30;
Lin1_Ea[11]=Mid_Vale%10+0x30;
}
下載方式關(guān)注 下方中間的微信公眾號(hào),任意回復(fù)