[SCM Graduation Project] [cl-010] Alarm for people stranded in the car | Alarm for children stranded in the car | Children accidentally lock the car

1. Basic introduction

Item name:
Design of vehicle personnel stranded alarm system based on microcontroller
Design of child stranded alarm system in car based on microcontroller
Design of children’s accidental car locking system based on microcontroller

Project name: Alarm for people staying in the car
Project number: mcuclub-cl-019
Microcontroller type: STC89C52
Specific functions:
1. Use the infrared obstacle avoidance tube to detect whether the driver has left. After leaving and locking the car by pressing the button (relay simulation), perform data monitoring
2. Monitor the temperature inside the car in real time through DS18B20
3. Real-time monitoring of CO2 concentration in the car through SGP30
4. Real-time monitoring of harmful gas concentrations in the car through MQ-135
5. Use human body pyroelectricity to detect whether there is anyone in the car. If there is someone, when the temperature exceeds the upper and lower limits, the CO2 concentration or the concentration of harmful gases exceeds the upper limit, a sound and light alarm will sound. If the temperature exceeds the upper limit, the CO2 concentration or the concentration of harmful gases Open the car window when the upper limit is exceeded (simulated by a stepper motor), and send a text message via GSM “There is someone in the car, please check quickly”
6. Set each threshold through buttons
7. Display the measured value through the display screen

2. Data Overview

Physical information

Please add an image description

Simulation data

Please add an image description

3. Display of some information on 51 microcontroller

1. Physical picture display

Microcontroller model: STC89C52
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Simulation diagram display

Simulation software version: proteus8.9
Circuit connection method: network label connection method
Note: Some physical components are not included in the simulation. They will be replaced by other components with similar working principles in the simulation. This may cause the physical program to be different from the simulation program.

3. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure diagram of the module.

4. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

IV. Display of some information on 32 microcontroller

1. Physical picture display

Microcontroller model: STM32F103C8T6
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure schematic diagram of the module.

3. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

5. System block diagram

Drawing software: VISIO

This design uses a single-chip microcomputer as the core controller, plus other modules to form the entire system of this design, including the central control part, the input part and the output part. The central control part adopts a single-chip microcomputer controller, whose main function is to obtain the data of the input part, and finally control the output part after internal processing and logical judgment. The input consists of seven parts. The first part is the air quality detection module, through which the harmful gas values in the current environment are detected; the second part is the temperature detection module, through which the temperature value in the current environment can be detected; the third part is the human body The induction detection module is used to detect whether children are stranded in the car; the fourth part is the infrared obstacle avoidance module, which is used to detect whether the driver has left; the fifth part is the CO2 detection module, which is used to detect the CO2 concentration in the car; The sixth part is the button module, through which you can switch interfaces, set thresholds, switch modes, etc.; the seventh part is the power supply module, through which the entire system can be powered. The output consists of four parts. The first part is the display module, through which the monitored data and the set threshold can be displayed. The second part is the relay module, which controls the opening or closing of the indicator light through the relay. The third part is the stepper motor module. , it is detected that a child is stranded, and it is detected that the temperature or harmful gases in the car are not within the set range, and the window is opened; the fourth part is the sound and light alarm module, when the monitoring value is not within the set threshold and a child is detected in the car Sound and light alarms are issued when stranded; the fifth part is composed of GSM and mobile phones. It detects that children are stranded in the car and detects that the air quality is not within the set range, and sends a text message to the user’s mobile phone. The specific system block diagram is shown in Figure 3.1.

6. Partial program display

Software version: keil5
Note: The logic program and driver are separated and distributed in main.c and other .c files

*******Monitoring function
*****/
void Monitor_function(void)
{<!-- -->
if(flag_display == 0) //Measurement interface
{<!-- -->
if(time_num % 2 == 0) //Detected once every 1s
{<!-- -->
if(DO == 0)
gas_value = 60*(Get_Adc_Average(0,3)*3.3/4096.0); //Get the harmful gas value (0-200)
else
gas_value = 0;
temp_value = DS18B20_Get_Temp(); //Read temperature
Sgp30_Get_Co2_Value( & amp;CO2_value);
}
}
}

/****
*******Display function
*****/
void Display_function(void)
{<!-- -->
switch(flag_display) //Display different interfaces according to different display mode flags
{<!-- -->
case 0: //Interface 0: measurement interface, displaying each measurement value and mode
Oled_ShowString(1, 0, "CO2:");
sprintf(display_buf,"%dPPM ",CO2_value);
Oled_ShowString(1, 4, display_buf);
\t\t
Oled_ShowCHinese(2, 0, "Temperature:");
sprintf(display_buf,"%d.? ",temp_value/10,temp_value );
Oled_ShowString(2, 6, display_buf);
\t\t
Oled_ShowCHinese(3, 0, "Hazardous gas:");
sprintf(display_buf,"%dPPM ",gas_value);
Oled_ShowString(3, 10, display_buf);
if(flag_door_lock == 0) // Display whether the car is locked, 0: the car is not locked
Oled_ShowCHinese(4,1,"Unlocked");
else
Oled_ShowCHinese(4,1,"Locked");
if(flag_window == 1) //1: Open window
Oled_ShowCHinese(4,6,"Open"); //Display window switch status
else
Oled_ShowCHinese(4,6,"Close");
break;

case 1: //Interface 1: Display the maximum value of the set temperature
Oled_ShowCHinese(1,0,"Set the maximum temperature value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d",temp_max);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 2: //Interface 2: Display the minimum value of the set temperature
Oled_ShowCHinese(1,0,"Set the minimum temperature value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d",temp_min);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;

case 3: //Interface 3: Display and set the maximum value of CO2
Oled_ShowCHinese(1,1,"settings");
Oled_ShowString(1, 6, "CO2");
Oled_ShowCHinese(1,5,"maximum value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d",CO2_max );
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 4: //Interface 4: Display and set the maximum value of harmful gases
Oled_ShowCHinese(1,1,"Set harmful gases");
Oled_ShowCHinese(2,3,"maximum value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d",gas_max );
Oled_ShowString(3, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(3, 6, " ");
}
break;
\t\t
\t
default:
break;
}
}



/****
*******Handling function
*****/
void Manage_function(void)
{<!-- -->
if(flag_display == 0) //Measurement interface
{<!-- -->
if(flag_door_lock == 1 & amp; & MAN == 1) //If the driver leaves and the car is locked, turn on the warning light
{<!-- -->
LED = 0;
if(REDOUT ==0) //If there are children in the car
{<!-- -->
if((CO2_value > CO2_max) || (temp_value < temp_min*10) ||(temp_value > temp_max*10)|| gas_value > gas_max) //If the CO2 value/harmful gas is greater than the set maximum value, or the temperature is too high or Too low, sound alarm
{<!-- -->
if(time_num % 1 == 0)
{<!-- -->
BEEP = ~BEEP;
}
}
else // Otherwise cancel the sound alarm
{<!-- -->
BEEP = 0;
}
\t\t\t\t
if((temp_value > temp_max*10) || (CO2_value > CO2_max) || gas_value > gas_max) //If the temperature is too high, or the CO2 concentration/harmful gas is too high, open the window
{<!-- -->
if(flag_window == 0) //If the window was closed before, open the window
{<!-- -->
Motor_Foreward();
flag_window = 1;
}
if(flag_dx == 0) //Send "There is someone in the car, please check quickly"
{<!-- -->
Sim900a_Send_Chinese("13637298045","8F66518567094EBAFF0C8BF7901F901F67E5770B");
flag_dx = 1;
}
}
else // Otherwise, close the window
{<!-- -->
if(flag_window == 1)
{<!-- -->
Motor_Reversal();
flag_window = 0;
}
flag_dx = 0;
}
}
else //Otherwise, there are no children in the car, close the window, cancel the sound alarm, and set the SMS sending flag to 0 to facilitate sending text messages next time.
{<!-- -->
if(flag_window == 1)
{<!-- -->
Motor_Reversal();
flag_window = 0;
}
flag_dx = 0;
BEEP = 0;
}
\t\t\t\t
}
else //Otherwise, turn off the warning lights and alarms
{<!-- -->
LED = 1;
BEEP = 0;
}
}
else //Set the interface to close the window, turn off the alarm, and initialize the SMS sending flag to facilitate the next text message.
{<!-- -->
if(flag_window == 1)
{<!-- -->
Motor_Reversal();
flag_window = 0;
}
LED = 1;
BEEP = 0;
flag_dx = 0;
}
}