cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus TCP using STM32F446 Nucleo board and ESP8266

wkim.4
Associate II

hello.
This is my first time using TCP communication, my first time using ESP8266, and I am barely able to follow STM32. There's something I want to make, but it doesn't work out, so I'm posting it here.

After configuring the ESP8266 with the AT command (Server), if you request data from the server using the Modbus poll program on your PC, the command will be received successfully.
If you look at the network traffic, it comes in like this:
"ec fa bc 1e fd 74 04 7c 16 a2 d5 c5 08 00 45 00
00 34 4b 33 40 00 80 06 00 00 c0 a8 02 9c c0 a8
02 64 e2 53 01 f6 00 0e 59 85 00 00 19 71 50 18
fa f0 86 77 00 00 00 11 00 00 00 06 01 03 00 00
00 0a"

Looking at RxData in STM32
"0d 0a 2b 49 50 44 2c 30 2c 31 32 3a 02 ef 00 00 00 11 00 00 00 06 01 03 00 00 00 0a"
It comes in like this.
"00 00 00 11 00 00 00 06 01 03 00 00 00 0a" This is Modbus data, and the values ​​in front are written as "\r \n + I P D , 0 , 1 2 : \v ]", but I don't know what they mean.

Anyway, I analyzed Modbus data and created response data.
The value is entered in increments of 1, 1 at address 0, 2... at address 1, and the final data transmitted from STM32 to ESP8266 is "00 00 00 11 00 17 01 03 14 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0a".

There is no problem when looking at Modbus data alone, but it is not transmitted.
It may be a problem with the ESP8266 settings, but the ESP8266-related settings were set in the order below.
"AT+RST\r\n"
"AT\r\n"
"AT+CWMODE=1\r\n"
"CW MODE---->1\n\n"
"AT+CWJAP=\"%s\",\"%s\"\r\n", SSID, PASSWD
"AT+CIPSTA=\"%d.%d.%d.%d\",\"%d.%d.%d.%d\",\"%d.%d.%d.%d \"\r\n",
ip_addr1, ip_addr2, ip_addr3, ip_addr4,
subnet_mask1, subnet_mask2, subnet_mask3, subnet_mask4,
gateway_addr1, gateway_addr2, gateway_addr3, ateway_addr4)
"AT+CIFSR\r\n"
"AT+CIPMUX=1\r\n"
"AT+CIPSERVER=1,502\r\n"

Having trouble setting up?

I looked at the traffic using Wireshark. When data is sent from Modbus poll, the ESP8266 responds immediately. (A response is sent even if the STM32 is at a breakpoint.) The response is
"04 7c 16 a2 d5 c5 ec fa bc 1e fd 74 08 00 45 00
00 28 00 13 40 00 80 06 74 6c c0 a8 02 64 c0 a8
02 9c 01 f6 e2 53 00 00 19 71 00 0e 59 91 50 10
0a 90 c7 99 00 00 9f ce de b2 f1 50"

And I sent from STM32 to Uart to ESP8266 "00 00 00 11 00 17 01 03 14 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0a" This data is not visible in wireshark.
What's the problem? I may lack basic knowledge. Please let me know if you have any doubts. Thanks for reading.

4 REPLIES 4
SofLit
ST Employee

Hello,

Better to post your thread in esp8266 community: https://www.esp8266.com/

So you can maximize your chance to get an answer.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Pavel A.
Evangelist III

Here you can find help with your project. Get someone who knows both ESP and STM32, and networking, and blow all your road blocks at once.

It looks like the community is no longer running.

Just now here is the ESP forum:

https://www.esp32.com/viewforum.php?f=50

 

If you feel a post has answered your question, please click "Accept as Solution".