基于单片机的智能衣柜控制系统设计(STM32)

📅 发布时间:2026/7/4 11:23:45 👁️ 浏览次数:
基于单片机的智能衣柜控制系统设计(STM32)
摘 要本文介绍了围绕STM32F103C8T6芯片研究并制作的智能衣柜的详细设计过程。衣柜作为日常生活中的必需品其功能的开发使用也因人而异。在作为单纯的衣柜使用时使用者会考虑除了存放衣物之外的利于衣物存放的功能开发而作为一个柜子最基本的储存功能结合生活中人们对贵重物品的储存习惯衣柜的安全问题也纳入了人们的考虑范围。STM32系列芯片功耗低性能高性价比高将其作为本次系统设计的核心有一定的优势。通过代码的编写来实现控制过程控制方式较为方便灵活同时减少了硬件调试的步骤降低了难度也降低了成本是为最佳的选择。本系统主要由七个部分组成分别是STM32F103C8T6芯片、触摸显示屏、供电模块、蓝牙模块、电子锁匙结构、指纹识别模块以及温湿度检测模块等。用户可以在触摸显示屏中看到智能衣柜内的温度和湿度情况通过触摸显示屏中的输入密码来对智能衣柜进行解锁也可以在触摸显示屏中进行指纹的录入和删除可以在手机中通过蓝牙串口APP向蓝牙模块发送命令打开柜子也可以直接在指纹识别模块上按下手指直接解锁等。本次系统设计的结果表明一个普通的柜子可以通过各种芯片模块的加持来变得更加灵活更加安全更好的为世人服务。关键词智能衣柜STM32指纹识别蓝牙AbstractThis article introduces the detailed design process of the intelligent wardrobe researched and manufactured around the STM32F103C8T6 chip. As a necessity in daily life, the development and use of wardrobe’s functions also vary from person to person. When we use it as a simple wardrobe, we will consider the functional development that is beneficial to clothes storage besides clothes storage. As the most basic storage function of a wardrobe, the safety of the wardrobe is also taken into consideration in combination with people’s storage habits of valuables in life.STM32 series chips have advantages of low power consumption, high performance and high cost performance as the core of this system design. The control process is realized through code writing. The control method is more convenient and flexible. At the same time, it reduces the steps of hardware debugging, difficulty and cost. It is the best choice.This system is mainly composed of seven parts, namely STM32F103C8T6 chip, touch screen, power supply module, Bluetooth module, electronic key structure, fingerprint recognition module and temperature and humidity detection module. Users can see the temperature and humidity in the smart wardrobe on the touch display, unlock the smart wardrobe by entering the password in the touch display, or enter and delete fingerprints on the touch display; In order to open the cabinet through the Bluetooth serial port APP to the Bluetooth module, you can also directly press the finger on the fingerprint recognition module to unlock it directly.The results of this system design show that an ordinary cabinet can become more flexible, safer, and better serve the world through the blessing of various chip modules.Keywords: intelligent wardrobe; STM32;BluetoothFingerprint recognition目 录摘 要 IAbstract II第一章 绪 论 11.1 选题背景与意义 11.1.1 背景 11.1.2 意义 21.2 国内外发展现状 21.3 课题研究主要内容及框架 3第二章 系统总体方案设计 42.1 系统设计目标和功能 42.1.1 系统设计目标 42.1.2 系统实现功能 42.2 系统方案选择和阐述 52.2.1 系统整体方案选择 52.2.2 系统控制器的选择 52.2.3 显示器件的选择 52.2.4 供电模块及控制器件的选择 62.2.5 电子锁匙结构的选择 62.2.6 指纹识别模块的选择 62.2.7 蓝牙控制模块的选择 72.2.8 温湿度模块的选择 72.3 本章小结 7第三章 系统硬件设计 83.1 系统硬件设计方案概述 83.2系统硬件原理图 83.3 最小系统模块 93.3.1 STM32简介 93.3.2 最小系统电路 103.4 触摸屏显示电路 123.4.1 触摸显示屏电路组成 123.4.2 触摸显示屏电路的实现原理 123.5 供电模块电路 133.5.1 供电模块电路的组成 133.5.2 供电模块电路的实现原理 133.6 电子锁匙结构控制、信号反馈电路 143.6.1 电子锁匙结构控制电路的组成 143.6.2 电子锁匙结构控制电路的实现原理 143.6.3 电子锁匙结构信号反馈电路的组成 143.6.4 电子锁匙结构信号反馈电路的实现原理 153.7 蓝牙控制模块电路 153.7.1 蓝牙控制模块电路的组成 153.7.2 蓝牙控制模块电路的实现原理 163.8指纹识别模块电路 163.8.1 指纹识别模块电路的组成 163.8.2 指纹识别模块电路的实现原理 163.9 温湿度检测模块电路 173.9.1 温湿度检测模块电路的组成 173.9.1 温湿度检测模块电路的实现原理 173.10 指示灯显示电路 183.10.1 指示灯显示电路的组成 183.10.2 指示灯显示电路的实现原理 183.11 本章小结 18第四章 系统软件设计 194.1 Keil简介 194.1.1 Keil系统概述 194.1.2 Keil软件的使用 194.2 系统软件程序分析 204.2.1 主程序的设计 204.2.2 触摸屏显示程序的设计 214.2.3 触摸屏触摸控制程序的设计 214.2.4 蓝牙模块控制程序的设计 224.2.5 指纹识别模块程序的设计 234.2.6 电子锁模块程序的设计 244.2.7 温湿度检测模块程序的设计 254.3 本章小结 26第五章 系统测试 275.1 系统调试情况 275.2 系统测试结果分析 285.2 本章小结 28结 论 29参考文献 30#includeled.h#includedelay.h#includekey.h#includesys.h#includeds18b20.h#includeusart.h#includeesp8266.h#includeOLED/oled.h//网络协议层#includeonenet.h//网络设备#includeesp8266.h//c库#includestring.hinttemp_high30;inttemp_low12;inttime_miao0;//dht11添加变量u8 humidityH;//湿度整数部分u8 humidityL;//湿度小数部分u8 temperatureH;//温度整数部分u8 temperatureL;//温度小数部分externu8 flag;chardis1[16];inttemperature;intkey;intset_flag0;intadd_miao0;voidkeyscan()//按键扫描{staticu8 key_val0;key_valKEY_Scan(1);//获取按键值if(key_val1){set_flag;if(set_flag3)set_flag0;}if(key_val2)//加键按下{if(set_flag1)temp_high;elseif(set_flag2)temp_low;}if(key_val3)//减键按下{if(set_flag1)temp_high--;elseif(set_flag2)temp_low--;}if(key_val4)//灯光按键{time_miao1;}}intmain(void){unsignedchar*dataPtrNULL;unsignedshorttimeCount0;//发送间隔变量delay_init();//延时函数初始化NVIC_Configuration();//设置NVIC中断分组2:2位抢占优先级2位响应优先级LED_Init();//LED端口初始化KEY_Init();//初始化与按键连接的硬件接口uart2_init(115200);//串口2初始化YHGUI_Config();//OLED初始化YHGUI_DispString(0,0,正在初始化,16,1);//OLED显示初始化YHGUI_DispString(0,32,正在连接onenet,16,1);ESP8266_Init();//初始化ESP8266printf(8266_INIT_END\n);RELAY1;LED01;while(DS18B20_Init())//温度初始化{}DS18B20_Get_Temp();//温度初始化while(OneNet_DevLink())//接入OneNETYHGUI_DispString(0,32,连接onenet成功 ,16,1);delay_ms(500);printf(接入onenet成功);YHGUI_DispString(0,32, ,16,1);YHGUI_DispString(0,0, ,16,1);while(1){keyscan();temperatureDS18B20_Get_Temp();//获取温度temperaturetemperature/10;if(temperature0){temperature-temperature;//转为正数}if(set_flag0){if(time_miao1)sprintf(dis1, 恒温外卖柜 %02ds ,add_miao);elsesprintf(dis1, 恒温外卖柜 );YHGUI_DispString(0,0,dis1,16,1);}elseif(set_flag1)YHGUI_DispString(0,0, 温度上限设置 ,16,1);elseif(set_flag2)YHGUI_DispString(0,0, 温度下限设置 ,16,1);sprintf(dis1, 当前温度:%02d℃ ,temperature);YHGUI_DispString(0,16,dis1,16,1);//显示sprintf(dis1, 温度上限:%02d℃ ,temp_high);YHGUI_DispString(0,32,dis1,16,1);//显示sprintf(dis1, 温度下限:%02d℃ ,temp_low);YHGUI_DispString(0,48,dis1,16,1);//显示if(temperaturetemp_low)RELAY1;if(temperaturetemp_high)RELAY0;if(timeCount5)//时间间隔1s{if(time_miao1){add_miao;LED01;}elseLED00;if(add_miao30){add_miao0;time_miao0;}delay_ms(100);humidityH11;humidityL22;temperatureHtemperature;//温度整数部分temperatureL0;//温度小数部分printf(hum temp%d .%d %d .%d\r\n,humidityH,humidityL,temperatureH,temperatureL);printf(OneNet_SendData\r\n);//通过串口1发送提示信息要开始发送数据了OneNet_SendData();//发送数据给onenetprintf(send_data_end\n);timeCount0;ESP8266_Clear();}dataPtrESP8266_GetIPD(0);//获取平台返回的数据if(dataPtr!NULL)//如果返回数据不为空OneNet_RevPro(dataPtr);//平台返回数据检测delay_ms(10);}}