Punctual STM32F407 core board + ESP8266 to achieve simple communication (detailed explanation)

1. Burning of ESP8266 firmware library

If you use the serial port assistant to connect to the board and send AT commands to 8266 and find that it always reports an error, you can re-burn the firmware library.

Punctual ESP8266 data download URL:

http://www.openedv.com/thread-308397-1-1.html

 Then unzip the decompression package under this folder (I only used the FLASH programming tool and Atom Cloud firmware):

 Then open the programming tool first, select ESP8266DownloadTool:

In the next window, first select the two bin files to be programmed

The locations of the two bin files are as follows 

 

For the other configurations, just look at my configuration. Note:

ESP8266 is best to connect the USB to TTL on the development board. I feel that the USB to TTL module of several pieces is not as easy to use on the board. I also have a problem when I send the AT command after the firmware library is successfully programmed, so later Directly use the USB to TTL on the f407 core board

 When my ESP8266 started to burn the firmware library, there was no such information as DETECTED INFO and MAC Address, and it kept failing.

 The reason is that there is no land for land!

So I can directly use the USB to TTL on the f407 to detect these information later, and then the programming is successful.

Here is the picture above (my ESP8266 is connected to the f407 development board):

 The 5v and GND of ESP8266 are connected to the 5V and GND on the board, and the RX and TX are connected to the TX and RX of the board

Note here: io_0 must be grounded when programming the firmware library, and rst can be grounded first and then unplugged to reset when there are fewer firmware libraries (hanging to high level).

Then later, when the computer uses the serial port assistant to communicate with the ESP8266, io_0 and rst must be suspended!

Otherwise, normal communication cannot be performed.

2. The computer uses the serial port assistant to send AT commands to ESP8266

First, ESP8266 is only connected to 5V, GND, RX, TX four wires

The instructions are as follows, for everyone to paste

AT
AT+CWMODE=0    //设置模块 WIFI 模式为 AP 模式  
AT+CWMODE=1    //设置模块 WIFI 模式为 STA 模式  
AT+CWMODE=2    //设置模块 WIFI 模式为 STA+AP 模式  
AT+RST        //重启生效
AT+CWJAP="iPhone","123456"    //加入 WIFI 热点:iPhone,密码为:123456
AT+CIPMUX=1        //开启多连接   1是多连接 0是单连接
AT+CWLIF            //查看已接入设备的 IP 这个是AP模式下的
AT+CIFSR            //查看本模块的 IP 地址 这个是STA模式下的
AT+CWMODE?        //查看本机配置模式
AT+CIPMUX?         //查询本模块是否建立多连接
AT+CIPMODE?        //查询本模块的传输模式
AT+CIPSTART="TCP","192.168.1.XXX",8086           //建立 TCP 连接到” 192.168.1.XXX”,8086
AT+CIPMODE=1        //开启透传模式
AT+CIPSEND           //开始传输 


Practical diagram of the computer serial port assistant:

 3. The development board is connected to ESP8266 through the serial port

I first looked at the routines of the punctual atom ESP8266, and found that things were written too much and too complicated. Their test program wrote three modes, and then it was too different from my actual situation.

Because my board is an f407 core board and there is no supporting routine, I made some modifications with the regular explorer routine, and wrote a function to realize the serial port to send commands to ESP8266AT to realize communication.

The main code is as follows

int main(void)
{      
	u8 key,fontok=0; 
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
	delay_init(168);  //初始化延时函数
	uart_init(115200);		//初始化串口波特率为115200
	usart3_init(115200);  //初始化串口3波特率为115200
	LED_Init();					//初始化LED  
 	LCD_Init();					//LCD初始化  
 	KEY_Init();					//按键初始化  
	
	while(1){
		esp8266_start_trans();
	}	
}

This is common.c

void esp8266_start_trans(void)
{
    atk_8266_send_cmd("AT+CWMODE=1","OK",50);//设置为STA模式
    atk_8266_send_cmd("AT+RST","ready",100);//重启并生效
	delay_ms(1000);
	delay_ms(1000);
	delay_ms(1000);
	delay_ms(1000);
	while(atk_8266_send_cmd("AT+CWJAP=\"TP0_LAB\",\"3+1cxsys\"","WIFI GOT IP",800));//WIFI
	//while(atk_8266_send_cmd("AT+CWJAP=\"iPhone\",\"123123123\"","WIFI GOT IP",800));	
	atk_8266_send_cmd("AT+CIPMUX=1","OK",20);
	
	atk_8266_send_cmd("AT+CIPSTART=\"TCP\",\"192.168.1.100\",8086","OK",200);
	//while(atk_8266_send_cmd("AT+CIPSTART=\"TCP\",\"192.168.1.100\",8086","OK",200));//WIFI
	//while(atk_8266_send_cmd("AT+CIPSTART=\"TCP\",\"172.20.10.10\",8086","OK",200));
	atk_8266_send_cmd("AT+CIPMODE=1","OK",200);
	atk_8266_send_cmd("AT+CIPSEND","ND",50);	
}

other places such as

Function atk_8266_send_cmd() and u3_printf(), I made a little modification, changed serial port 3 to serial port 1

(Because my core board PA9 PA10 is TX and RX of serial port 1 respectively)

If the computer and SEP8266 cannot communicate with each other after the code is run, you can use the serial port to send AT commands to the ESP8266 first, and then debug and change the code later

The serial port sends these instructions to ESP8266:


AT+CWMODE=1    //设置模块 WIFI 模式为 STA 模式  
AT+RST        //重启生效
AT+CWJAP="iPhone","123456"    //加入 WIFI 热点:iPhone,密码为:123456
AT+CIPSTART="TCP","192.168.1.XXX",8086           //建立 TCP 连接到” 192.168.1.XXX”,8086
AT+CIPMODE=1        //开启透传模式
AT+CIPSEND           //开始传输 

The following is the effect of communication between the computer and ESP8266:

I chose the STA mode, and the network debugging assistant on the computer side logs in with the local ip. Note that the computer and ESP8266 must be connected to the same WIFI

Guess you like

Origin blog.csdn.net/qq_54508596/article/details/125628160