本次WIFI门禁控制器的总体设计:首先通过ESP8266 WiFi模块连接手机,然后利用RC-522模块非接触读取IC卡的卡号,经过单片机判断该卡号是否正确。如果正确,则继电器闭合打开电子锁开门,蜂鸣器通电提示开门;如果卡号错误,则继电器断开,蜂鸣器不响。通过OLED输出卡号和提示信息。用户可以通过WiFi连接手机对卡号进行查询、删除、添加等操作,卡号存储在单片机内部flash,刷卡的提示信息通过串口传送到电脑上,这样就可以实时了解门禁控制器的情况。
单片机源程序如下:
- #include "stm32f10x.h"
- #include "bsp_gpio.h"
- #include "bsp_usart1.h"
- #include "bsp_usart2.h"
- #include "wifi_config.h"
- #include "wifi_function.h"
- #include "bsp_SysTick.h"
- #include "wifi_data.h"
- #include "flash.h"
- #include <string.h>
- #include "rc522_function.h"
- #include "rc522_config.h"
- #include "bsp_TiMbase.h"
- #include "OLED_I2C.h"
- #include "bsp_i2c_gpio.h"
- #include "codetab.h"
- #include <stdbool.h>
-
- extern char IC_id[20][8];
- extern char * Re_ID[3];
- void Oled_INIT(void)//初始化OLED界面
- {
- OLED_Fill(0x00);//全屏灭;
- for(i=0;i<4;i++)
- {
- OLED_ShowCN(30+i*16,0,F16x16,i);
- }
- for(i=0;i<3;i++)
- {
- OLED_ShowCN(i*16,3,F16x16_1,i);
- }
- }
- /**
- * @brief 主函数
- * @param 无
- * @retval 无
- */
- int main(void)
- {
- /* 初始化 */
- WiFi_Config(); //初始化WiFi模块使用的接口和外设
- SysTick_Init(); //配置 SysTick 为 1ms 中断一次
- i2c_CfgGpio(); /*I2C总线的GPIO初始化*/
- OLED_Init(); /* OLED初始化 */
- Oled_INIT(); //OLED界面初始化
- Beep_GPIO_Config();//蜂鸣器和继电器初始化
- PC_Usart("\r\n即将进行的测试是:1.STA模式: TCP Client\r\n");
- ESP8266_STA_TCP_Client ();
- RC522_Init (); /*RC522模块所需外设的初始化配置*/
- PcdReset ();
- M500PcdConfigISOType ( 'A' );/*设置工作方式*/
- Read_Flash();//读取卡号
-
- BASIC_TIM_Init();//定时器3初始化
-
- while (1)
- {
- WIFI_operate_data();
- if( (strcmp( Re_ID[1],"1")==0)|(strcmp(Re_ID[1],"2")==0))//如果是删除和添加就进行flash操作
- {
- InternalFlash_Test();//向flash写入保存的数据
- }
- }
- }
- /*********************************************END OF FILE**********************/
复制代码
所有资料51hei提供下载:
课设程序3.0.7z
(214.33 KB, 下载次数: 194)
|