Skip to main content
Visitor II
July 4, 2024
Solved

Modbus TCP using STM32F446 Nucleo board and ESP8266

  • July 4, 2024
  • 2 replies
  • 1531 views

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.

    This topic has been closed for replies.
    Best answer by AScha.3

    Just now here is the ESP forum:

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

     

    2 replies

    Technical Moderator
    July 4, 2024

    Hello,

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

    So you can maximize your chance to get an answer.

    wkim.4Author
    Visitor II
    July 5, 2024

    It looks like the community is no longer running.

    AScha.3Answer
    Super User
    July 5, 2024

    Just now here is the ESP forum:

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

     

    Super User
    July 4, 2024

    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.