K_A23_001 基于STM32等单片机AT指令驱动ESP-01/ESP-01S实现手机遥控点灯

实物参考链接 直戳跳转

一、资源说明

二、基本参数

引脚说明

三、驱动说明

对应程序:
此处串口通信对应程序:
以51为例

#include "Uart.h"
#include "ESP-01S.h"
void UartInit(void)
{
			TMOD = 0x20;   //定时器工作在定时器1的方式2
			PCON = 0x00;   //不倍频
			SCON = 0x50;	//串口工作在方式1,并且启动串行接收	
			TH1 = 0xFD;    //设置波特率 9600
			TL1 = 0xFD;
			//ET1 = 0;
			TR1 = 1;		//启动定时器1

			ES = 1;		//开串口中断
			EA = 1;		//开总中断	
}

void UartSend(uint8_t dat)
{
//    while (busy);
//    busy = 1;
    SBUF = dat;
		while(TI==0);	
	  TI=0;
}

/*****************发送设置**********************************/
void ESP8266_Set(unsigned char *puf)
{
 	 unsigned char k=0;
	 while(*(puf+k)!='
#include "Uart.h"
#include "ESP-01S.h"
void UartInit(void)
{
TMOD = 0x20;   //定时器工作在定时器1的方式2
PCON = 0x00;   //不倍频
SCON = 0x50;	//串口工作在方式1,并且启动串行接收	
TH1 = 0xFD;    //设置波特率 9600
TL1 = 0xFD;
//ET1 = 0;
TR1 = 1;		//启动定时器1
ES = 1;		//开串口中断
EA = 1;		//开总中断	
}
void UartSend(uint8_t dat)
{
//    while (busy);
//    busy = 1;
SBUF = dat;
while(TI==0);	
TI=0;
}
/*****************发送设置**********************************/
void ESP8266_Set(unsigned char *puf)
{
unsigned char k=0;
while(*(puf+k)!='\0')
{
UartSend(*(puf+k));
k++;
}
}
/*************接收数据***************************************/
void UARTInterrupt(void)interrupt 4
{
if(RI)
{
RI=0;
Usart_Receive[Usart_Cnt]=SBUF;
Usart_Cnt++;
if(!Usart_Connect_Buf_Flag)
{
if(Usart_Receive[Usart_Cnt-2]=='\r'&&Usart_Receive[Usart_Cnt-1]=='\n'&&(strstr(Usart_Receive, "OK")))
{
Usart_Cnt=49;
Usart_AT_flage=1;
//ESP8266_Set(Usart_Receive);
}
else if(Usart_Cnt>=49)
{
Usart_Cnt=49;
}
}
else
{
if(Usart_Cnt>=49)
{
Usart_Cnt=0;
}
}
}
if(TI)
{
//TI=0;
}
}
') { UartSend(*(puf+k)); k++; } } /*************接收数据***************************************/ void UARTInterrupt(void)interrupt 4 { if(RI) { RI=0; Usart_Receive[Usart_Cnt]=SBUF; Usart_Cnt++; if(!Usart_Connect_Buf_Flag) { if(Usart_Receive[Usart_Cnt-2]=='\r'&&Usart_Receive[Usart_Cnt-1]=='\n'&&(strstr(Usart_Receive, "OK"))) { Usart_Cnt=49; Usart_AT_flage=1; //ESP8266_Set(Usart_Receive); } else if(Usart_Cnt>=49) { Usart_Cnt=49; } } else { if(Usart_Cnt>=49) { Usart_Cnt=0; } } } if(TI) { //TI=0; } }

四、部分代码说明

接线引脚定义

需要自定义引脚可在此处更改,STM32要自定义引脚的话也要注意引脚时钟使能的更改

1.1、STC89C52RC+ESP-01/ESP-01S模块

//ESP-01/ESP-01S模块引脚定义

UART:
(TX) ---------------P3.0
(RX)----------------P3.1


//LED引脚定义
sbit LED=P1^0;

1.2、STM32F103C8T6+ESP-01/ESP-01S模块

//ESP-01/ESP-01S模块引脚定义
UART:
#define  DEBUG_USART2_TX_GPIO_PORT       GPIOA   
#define  DEBUG_USART2_TX_GPIO_PIN        GPIO_Pin_2
#define  DEBUG_USART2_RX_GPIO_PORT       GPIOA
#define  DEBUG_USART2_RX_GPIO_PIN        GPIO_Pin_3

//LED引脚定义					
#define LED1_GPIO_PORT    	GPIOB			              /* GPIO端口 */
#define LED1_GPIO_CLK 	    RCC_APB2Periph_GPIOB		/* GPIO端口时钟 */
#define LED1_GPIO_PIN				GPIO_Pin_5			        /* 连接到SCL时钟线的GPIO */

五、基础知识学习

STC89C52RC程序下载 直戳跳转

STM32F103C8T6程序下载

1、串口下载  直戳跳转

2、ST-LINK下载  直戳跳转

3、J-LINK下载  直戳跳转

4、DAP-LINK下载  直戳跳转

OLED0.96程序说明 直戳跳转

串口助手下载与使用
1、安信可调试助手使用 直戳跳转
2、 sscom33串口调试助手使用 直戳跳转
3、STC-ISP串口调试助手使用 直戳跳转

六、视频效果展示与程序资料获取

演示视频连接 直戳跳转
资料获取 直戳跳转

实物参考链接 直戳跳转

七、注意事项

1、VCC GND请勿接反,接反易烧
2、OLED显示异常时,排除接线接触不良

八、接线说明

可参考程序main.c最上面接线说明

所有相关实物与程序套件可在我们店铺找到

X
深圳市咱们电子科技有限公司