[SCM Graduation Project] [cl-023] In-vehicle environment monitoring

1. Basic introduction

Item name:
Design of vehicle interior environment monitoring system based on single-chip microcomputer

Project name: In-car environment monitoring
Microcontroller type: STM32F103C8T6
Specific functions:
1. Detect temperature and humidity through DHT11
2. Detect harmful gas concentration through MQ-135
3. Use human body pyroelectricity to detect whether there is someone. If there is someone, if the concentration of harmful gases is greater than the set maximum value, an audible and visual alarm will be issued and the ventilation system will be automatically turned on.
4. Set the maximum concentration of harmful gases and manually control ventilation through buttons
5. Display measurement data through the display screen
Extended functions: Send data to the mobile phone via Bluetooth and remotely control ventilation

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. These include 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 five parts. The first part is the temperature and humidity detection module, through which the temperature and humidity of the current environment are detected; the second part is the (ammonia, benzene) air quality detection module, through which the ammonia in the current environment can be detected. and benzene concentration; the third part is the human body pyroelectric detection module, through which it can detect whether there is anyone in the car; the fourth part is the button module, through which the interface can be switched, thresholds can be set, etc.; the fifth part is the power supply module, through which the entire system can be powered. The output consists of three 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 detects someone in the car and detects that the concentration of harmful gases in the car is greater than the set maximum. It is worth setting up an audible and visual alarm and turning on the ventilation relay. In addition, the Bluetooth module serves as both input and output. The Bluetooth module is connected to the mobile phone and can transmit the monitored data to the user’s mobile phone. The user can also send instructions through the mobile phone to control the work of the relay and its mode switching. 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)
{<!-- -->
char fasong[32];
if(flag_display == 0) //Measurement interface
{<!-- -->
if(time_num % 2 == 0) //Detected once every 400ms
{<!-- -->
Dht11_Get_Temp_Humi_Value( & temp_value , & humi_value ); //Get temperature and humidity
if(DO == 0)
gas_value = 60*((Get_Adc_Average(0,1)/4096.0)*3.3); //Get the harmful gas value
else
gas_value = 0;
}
}
if(time_num % 15 == 0) //Send once every 3 seconds
{<!-- -->
sprintf(fasong,"Temperature:%d.%d℃\r\\
",temp_value/10,temp_value );
UsartPrintf(USART1,fasong);
sprintf(fasong,"Humidity:%d.%d%%%%\r\\
",humi_value/10,humi_value );
UsartPrintf(USART1,fasong);
sprintf(fasong,"Hazardous gas:%dppm\r\\
",gas_value);
UsartPrintf(USART1,fasong);
}
if(USART1_WaitRecive() == 0)
{<!-- -->
if(strstr((char*)usart1_buf,"A") != NULL) //Switch to automatic mode
{<!-- -->
flag_mode = 0;
}
else if(strstr((char*)usart1_buf,"B") != NULL) //Ventilation relay control
{<!-- -->
RELAY_TF =~RELAY_TF;
flag_mode = 1;
}
USART1_Clear();
}
}

/****
*******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_ShowCHinese(1, 0, "Temperature:");
sprintf(display_buf,"%d.? ",temp_value/10,temp_value );
Oled_ShowString(1, 6, display_buf);
Oled_ShowCHinese(2, 0, "Humidity:");
sprintf(display_buf,"%d.%d%% ",humi_value/10,humi_value );
Oled_ShowString(2, 6, display_buf);
Oled_ShowCHinese(3, 0, "Hazardous gas:");
sprintf(display_buf,"%dppm ",gas_value);
Oled_ShowString(3, 10, display_buf);

\t\t
// Oled_ShowCHinese(4, 0, "Mode:");
if(flag_mode == 0)
Oled_ShowCHinese(4,1,"automatic");
else
Oled_ShowCHinese(4,1,"Manual");
\t\t\t
if(RELAY_TF == 1)
Oled_ShowCHinese(4,5,"Open");
else
Oled_ShowCHinese(4,5,"Close");
\t\t\t
break;

case 1: //Interface 1: Display and set the maximum value of harmful gases
Oled_ShowCHinese(1,1,"Set harmful gases");
Oled_ShowCHinese(2,2,"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_mode == 0) //If in automatic mode
    {<!-- -->
if(gas_value > gas_max & amp; & amp; MAN == 0) //There are people and the harmful gas is greater than the set maximum value, the ventilation relay is closed and the sound and light alarm
      {<!-- -->
        RELAY_TF = 1;
        if(time_num % 2 == 0)
        {<!-- -->
          LED = ~LED;
          BEEP = ~BEEP;
        }
      }
      else
      {<!-- -->
        RELAY_TF= 0;
        LED = 1;
        BEEP = 0;
      }
    }
    else //In manual mode, turn off the sound and light alarm
    {<!-- -->
      LED = 1;
      BEEP = 0;
    }
}
else //Set the interface and turn off all relays and sound and light alarms
{<!-- -->
LED = 1;
    BEEP = 0;
    RELAY_TF = 0;
}
}