本文主要是介绍【毕业设计】基于Stm32的智能疫情防控门禁系统 - 单片机 嵌入式 物联网,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 0 前言
- 1 简介
- 2 主要器件
- 3 实现效果
- 4 设计原理
- 5 部分核心代码
- 5 最后
0 前言
🔥 这两年开始毕业设计和毕业答辩的要求和难度不断提升,传统的毕设题目缺少创新和亮点,往往达不到毕业答辩的要求,这两年不断有学弟学妹告诉学长自己做的项目系统达不到老师的要求。
为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的是
🚩 基于Stm32的智能疫情防控门禁系统
🥇学长这里给一个题目综合评分(每项满分5分)
- 难度系数:3分
- 工作量:3分
- 创新点:5分
🧿 选题指导, 项目分享:
https://gitee.com/dancheng-senior/project-sharing-1/blob/master/%E6%AF%95%E8%AE%BE%E6%8C%87%E5%AF%BC/README.md
1 简介
针对当前的疫情形势,设计一款智能防疫门禁系统。本系统由STM32F103C8T6单片机核心板、彩屏液晶显示电路、语音播报电路、非接触测温传感器电路、舵机驱动电路、WIFI模块、按键电路及电源组成,能够采集人体温度、记录人流量,测量温度对比温度阈值,当测量温度低于温度阈值时,液晶显示“状态:正常”,语音播报“温度正常”,舵机动作(相当于打开闸门);如果测量温度超过设置阈值,液晶显示“状态:注意!异常”,语音播报“请注意 温度异常”,舵机不动作(不允许通过)。
2 主要器件
- STM32F103C8T6单片机核心板
- 彩屏液晶显示电路
- 语音播报电路
- 非接触测温传感器电路
- 舵机驱动电路
- WIFI模块
- 按键电路及电源
3 实现效果
4 设计原理
总体方案设计图
彩屏液晶显示
采用1.8寸128X160像素tft屏幕,该屏幕采用ST7735S驱动芯片,通过14pin、0.5mmFPC接口(本来是想直接自己焊接FPC连接座的,然鹅技术不达标,焊了两个都报废了,于是换成了直插的)与单片机相连,通过SPI串口与单片机进行通信,用来显示所测温度或显示其它必要信息。
语音播放芯片
采用NV020C-SOP8语音芯片,该芯片内置一组PWM输出器可直推0.5W喇叭,支持13bit的DAC输出,也可外接功放模块;采用灵活的多种操作模式(边沿按键触发,电平触发、随机按键播放、顺序按键播放等);外围电路简单,仅需一个耦合电容。静态电路小于2uA;本系统中采用一线制控制模式,单片机仅需1个IO口输出时序信号,即可控制该芯片输出音频。
非接触测温传感器
采用GY-906-DCC模块,该模块体积小巧,内部自带环境温度补偿和线性校准算法,通过SPI通信与单片机进行数据交换,当温度超过设定的阈值时,单片机进行及时的显示和逻辑处理,本模块精度非常之高,完全可以满足无接触测温功能需求(本项目用的是10cm精度的)。
WIFI模块
ESP12F 系列模组是深圳市安信可科技有限公司开发的一系列基于乐鑫ESP8266的低功耗UART-WiFi芯片模组,可以方便地进行二次开发,接入云端服务,实现手机3/4G全球随时随地的控制,加速产品原型设计。模块核心处理器 ESP8266 在较小尺寸封装中集成了业界领先的 Tensilica L106 超低功耗 32 位微型 MCU,带有 16 位精简模式,主频支持 80 MHz 和 160 MHz,支持 RTOS,集成 Wi-Fi MAC/ BB/RF/PA/LNA,板载天线。支持标准的 IEEE802.11 b/g/n 协议,完整的 TCP/IP 协议栈。用户可以使用该模块为现有的设备添加联网功能,也可以构建独立的网络控制器。本系统采用该模块进行数据的上传,可以实时将数据上传给后台服务器,进行数据的存储和大数据处理等。
主控模块
STM32F103C8T6(STM32F103C6T6也可以)是一款基于ARM Cortex-M 内核STM32系列的32位的微控制器,程序存储器容量是64KB,需要电压2V~3.6V,本系统采用stm32f103c8t6当主控模块,实时采集红外传感器获取温度,如果温度低于或高于指定阈值时,操作TFT显示屏显示温度异常和语音模块播报,同时控制舵机关闭,模拟门闸关闭状态,并将温度信息通过wifi模块上传至后台,提醒后台工作人员进行上报和处理。主模块原理图如下:
5 部分核心代码
/* USER CODE BEGIN Header */
/********************************************************************************* @file : main.c* @brief : Main program body******************************************************************************* @attention** Copyright (c) 2022 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "dma.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "lcd.h"
#include "GUI.h"
#include "mlx90614.h"/* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
uint8_t error_flag;
uint32_t peoples;
/* USER CODE END PTD *//* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD *//* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*//* USER CODE BEGIN PV *//* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void delay_us(uint32_t us){uint32_t cnt = us * 8; uint32_t i = 0;for(i = 0; i < cnt; i++)__NOP();
}void yuyin(uint8_t data){uint8_t i;while(HAL_GPIO_ReadPin(busy_GPIO_Port,busy_Pin) == 0){HAL_Delay(1);};HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_RESET);HAL_Delay(5);for(i=0;i<8;i++){if(data & 0x01){HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_SET);delay_us(1800);HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_RESET);delay_us(600);}else{HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_SET);delay_us(600);HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_RESET);delay_us(1800);}data <<= 1;}HAL_GPIO_WritePin(data_GPIO_Port,data_Pin,GPIO_PIN_SET);HAL_Delay(50);
}void Test_Color(void){//DrawTestPage("测试1:纯色填充测试");LCD_Fill(0,0,lcddev.width,lcddev.height,WHITE);Show_Str(20,30,BLUE,YELLOW,"BL Test",16,1);HAL_Delay(800);LCD_Fill(0,0,lcddev.width,lcddev.height,RED);Show_Str(20,30,BLUE,YELLOW,"RED ",16,1);HAL_Delay(800);LCD_Fill(0,0,lcddev.width,lcddev.height,GREEN);Show_Str(20,30,BLUE,YELLOW,"GREEN ",16,1);HAL_Delay(800);LCD_Fill(0,0,lcddev.width,lcddev.height,BLUE);Show_Str(20,30,RED,YELLOW,"BLUE ",16,1);HAL_Delay(800);
}//舵机angle:角度值,0~180
void Servo_Control(uint16_t angle){float temp;temp =(1.0 / 9.0) * angle + 5.0;//占空比值 = 1/9 * 角度 + 5__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, (uint16_t )temp);
}void display_init(){LCD_Fill(0,0,lcddev.width,lcddev.height,WHITE);GUI_DrawFont16(16,10,BLACK,WHITE,"智",0);GUI_DrawFont16(32,10,BLACK,WHITE,"能",0);GUI_DrawFont16(48,10,BLACK,WHITE,"防",0);GUI_DrawFont16(64,10,BLACK,WHITE,"疫",0);GUI_DrawFont16(80,10,BLACK,WHITE,"门",0);GUI_DrawFont16(96,10,BLACK,WHITE,"禁",0);GUI_DrawFont16(16,48,BLACK,WHITE,"温",0);GUI_DrawFont16(32,48,BLACK,WHITE,"度",0);GUI_DrawFont16(48,48,BLACK,WHITE,":",0);GUI_DrawFont16(16,80,BLACK,WHITE,"状",0);GUI_DrawFont16(32,80,BLACK,WHITE,"态",0);GUI_DrawFont16(48,80,BLACK,WHITE,":",0);GUI_DrawFont16(16,112,BLACK,WHITE,"人",0);GUI_DrawFont16(32,112,BLACK,WHITE,"流",0);GUI_DrawFont16(48,112,BLACK,WHITE,"量",0);GUI_DrawFont16(64,112,BLACK,WHITE,":",0);LCD_ShowNum(72,112,peoples,4,16);
}/* USER CODE END 0 *//*** @brief The application entry point.* @retval int*/
int main(void)
{/* USER CODE BEGIN 1 */float temp=0.0;peoples = 0;error_flag = 0;/* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_DMA_Init();MX_USART2_UART_Init();MX_TIM1_Init();MX_USART1_UART_Init();MX_TIM2_Init();/* USER CODE BEGIN 2 */LCD_Init();LCD_ShowString(5,60,16,"initializing...",0);__HAL_TIM_CLEAR_IT(&htim2, TIM_IT_UPDATE); // 使能定时器2更新中断并启动定时器2HAL_TIM_Base_Start_IT(&htim2);HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1); //启动定时器1 PWM舵机Servo_Control(45); //舵机调到45度HAL_Delay(1000); display_init();/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){HAL_GPIO_TogglePin(led_GPIO_Port,led_Pin);temp = mlx90614_read_temp()+2; //获取温度LCD_Fill(64,48,lcddev.width,64,WHITE); //清空温度显示LCD_Fill(64,80,lcddev.width,96,WHITE); //清空状态显示if(temp >= 33){ //>=30度才会显示if(temp < 37.4){LCD_ShowFloatNum1(64,48,temp,4,GREEN,WHITE,16);GUI_DrawFont16(96,48,GREEN,WHITE,"℃",0);GUI_DrawFont16(64,80,GREEN,WHITE,"正",0);GUI_DrawFont16(80,80,GREEN,WHITE,"常",0);yuyin(0);peoples++;LCD_Fill(72,112,lcddev.width,128,WHITE); //清空人数显示LCD_ShowNum(72,112,peoples,4,16); //显示人数Servo_Control(135); //舵机调到135度 模拟开门HAL_Delay(3000);Servo_Control(45); //舵机调到45度 模拟关门}else if(temp >= 37.4 && temp <= 42){LCD_ShowFloatNum1(64,48,temp,4,RED,WHITE,16);GUI_DrawFont16(96,48,RED,WHITE,"℃",0);LCD_Fill(0,80,lcddev.width,lcddev.height,WHITE); //清空状态显示GUI_DrawFont16(24,96,RED,WHITE,"注",0);GUI_DrawFont16(40,96,RED,WHITE,"意",0);GUI_DrawFont16(56,96,RED,WHITE,"!",0);GUI_DrawFont16(72,96,RED,WHITE,"异",0);GUI_DrawFont16(88,96,RED,WHITE,"常",0);error_flag = 1;while(error_flag){yuyin(1);HAL_Delay(1500);}display_init();}}/* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}/*** @brief System Clock Configuration* @retval None*/
void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct = {0};RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};/** Initializes the RCC Oscillators according to the specified parameters* in the RCC_OscInitTypeDef structure.*/RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;RCC_OscInitStruct.HSEState = RCC_HSE_ON;RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;RCC_OscInitStruct.HSIState = RCC_HSI_ON;RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK){Error_Handler();}/** Initializes the CPU, AHB and APB buses clocks*/RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK){Error_Handler();}
}/* USER CODE BEGIN 4 */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){if(GPIO_Pin == k1_Pin){HAL_GPIO_TogglePin(led_GPIO_Port,led_Pin);Servo_Control(45);error_flag = 0;HAL_GPIO_WritePin(beep_GPIO_Port,beep_Pin,GPIO_PIN_RESET);}if(GPIO_Pin == k2_Pin){HAL_GPIO_TogglePin(led_GPIO_Port,led_Pin);Servo_Control(135);}if(GPIO_Pin == k3_Pin){HAL_GPIO_TogglePin(led_GPIO_Port,led_Pin);}if(GPIO_Pin == k4_Pin){HAL_GPIO_TogglePin(led_GPIO_Port,led_Pin);}
}void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){if(htim->Instance == TIM2){if(error_flag){HAL_GPIO_TogglePin(beep_GPIO_Port,beep_Pin);}}
}
/* USER CODE END 4 *//*** @brief This function is executed in case of error occurrence.* @retval None*/
void Error_Handler(void)
{/* USER CODE BEGIN Error_Handler_Debug *//* User can add his own implementation to report the HAL error return state */__disable_irq();while (1){}/* USER CODE END Error_Handler_Debug */
}#ifdef USE_FULL_ASSERT
/*** @brief Reports the name of the source file and the source line number* where the assert_param error has occurred.* @param file: pointer to the source file name* @param line: assert_param error line source number* @retval None*/
void assert_failed(uint8_t *file, uint32_t line)
{/* USER CODE BEGIN 6 *//* User can add his own implementation to report the file name and line number,ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) *//* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
5 最后
这篇关于【毕业设计】基于Stm32的智能疫情防控门禁系统 - 单片机 嵌入式 物联网的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!