We do not engage in one-time transactions; we aim to be long-term partners in technical growth!
01
—
Physical Video Demonstration
See the end of the article for data sharing
02
—
Project Overview
DHT11 for monitoring temperature and humidity
Ultrasonic sensor to monitor the distance of individuals in the bathroom
SIM900A is the SMS module for sending messages
The ultrasonic distance measuring module monitors individuals in the bathroom. If there are unstable changes in the monitored distance during the monitoring process,
it will not trigger an alarm: when an individual in the bathroom falls and is injured, the monitored data will remain unchanged, triggering an alarm and sending an SMS to a designated phone using the GSM device. The temperature and humidity will be displayed on the OLED.

03
—
Schematic Design

04
—
PCB Hardware Design


05
—
Program Design
#include "stm32f10x.h" // Device header
#include "delay.h"
#include "lcd.h"
#include "sim900a.h"
#include "usart.h"
#include "IOput.h"
#include "dht11.h"
#include "wave.h"
extern char dispbuf[64];
// Wiring/**************************************************
1. Connect the microcontroller to the corresponding power supply
Microcontroller PB10 --- Module 3VR
Microcontroller PB11 --- Module 3VT
Microcontroller GND --- Module GND
Microcontroller 5V --- Module VCC_
2. Power the module separately
Module VCC (or VCC5V) connects to DC5V
Module GND connects to power ground
*****************************************************/
u8 show_flag,show1_flag,max_wd=30,dec_wd=20,max_sd=60,dec_sd=40,distance,mode_flag,tance=0,count,shuaidao=0,message_flag=0;
int main (void){
char English_message[]={"Fall detected!!"}; // English SMS content
char phonenumber[]={"17780467539"}; // Phone number to receive SMS
char Chinese_message[]={"4F60597D"}; // Chinese SMS content corresponding to 你好
char Unicode_phonenumber[]={"00310038003700360031003000370036003300300032"};
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Usart1_Init(115200); // Serial port 1 for printing information
Usart3_Init(38400); // Serial port 3 for driving SIM900A
OLED_Init();
delay_ms(1);
OLED_Clear();
DHT11_Init();
CH_SR04_Init();
input_init();
// sim900a_send_English_message(English_message,phonenumber);
while(1) {
// Usart_SendString2(USART1,"AT\r\n");
distance=Senor_Using();
DHT11_Read_Data(&temp,&humi);
key_scan(0,0,0);
OLED_ShowCH(0,0," Bathroom Monitoring System ");
OLED_ShowCH(0,2,"Temperature:");
OLED_ShowNum(40,2,temp,2,16);
OLED_ShowCH(64,2,"Humidity:");
OLED_ShowNum(104,2,humi,2,16);
OLED_ShowCH(0,4,"Distance:");
OLED_ShowNum(40,4,distance,2,16);
if(set_flag==1) {
set_flag=0;
mode_flag++;
if(mode_flag>=2)
mode_flag=0;
}
if(mode_flag==0) {
OLED_ShowCH(64,4,"Not Monitoring");
} else {
OLED_ShowCH(64,4,"Monitoring On");
if(distance==tance) {
count++;
if(count>=100) {
count=0;
shuaidao++;
}
if(shuaidao>=5) {
OLED_ShowCH(0,6," Fall Detected ");
shuaidao=0;
message_flag=1;
}
} else {
OLED_ShowCH(0,6," All Normal ");
message_flag=0;
shuaidao=0;
count=0;
tance=distance;
}
}
if(message_flag==1) {
message_flag=0;
sim900a_send_English_message(English_message,phonenumber);
}
}
}
06
—
Data Sharing
Baidu Cloud link:
https://pan.baidu.com/s/1u4QvCEuRuH3GATOxDiABfg?pwd=rydr Extraction code: rydr
If the link is invalid, please click on the public account to contact us!