Page 1 of 1

esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文

Posted: Fri Mar 18, 2022 3:07 am
by andycui
有朋友测试过esp32当 modbus slave从站(我拿的esp32当从站,用的是RTU模式)吗? 我用modbus poll软件测试下来,主站这边一直收不到从站的modbus响应报文,不知道啥情况

但是从esp32的日志打印来看,从站这边确实是可以收到主站的请求报文的,但是主站就是收不到从站的响应报文,也没看到esp32有什么报错,大概可以从哪些角度去排查问题呢,谢谢大家了。

Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文

Posted: Thu Mar 31, 2022 3:53 pm
by ESP_alisitsyn
Hi @andycui,

Could you check the RS485 communication interfaces if they can work in both directions? The uart RS485 echo test https://github.com/espressif/esp-idf/tr ... echo_rs485 can help with this.
Then you need to check the slave response time in your master and also check that your master and ESP32 slave example configured correctly to use RTU communication mode (CONFIG_MB_COMM_MODE_RTU) in kconfig. Also check the CONFIG_MB_SLAVE_ADDR address of the slave and make sure that the Modbus Poll is sending the data to this address.

Thanks.

Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文

Posted: Sat Apr 02, 2022 1:18 am
by andycui
thanks, there is, in addition, I don't have RTS pin in my usb-to-485 adaptor, so how should i do?
And, Here is my code

Code: Select all

ESP_ERROR_CHECK(uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD,
                            CONFIG_MB_UART_RXD, UART_PIN_NO_CHANGE,
                            UART_PIN_NO_CHANGE));   //CTS is not used in RS485 Half-Duplex Mode

    
    // Set UART driver mode to Half Duplex  
    ESP_ERROR_CHECK(uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX));
企业微信截图_20220402091721.png
企业微信截图_20220402091721.png (79.79 KiB) Viewed 3727 times

Re: esp32当 modbus-rtu slave从站通讯,但是主站收不到从站的响应报文

Posted: Wed Apr 20, 2022 7:56 am
by ESP_alisitsyn
@andycui ,

If RS485 part of your USB-RS485 adapter uses the auto-switching of direction like on the link below then your code should work just fine.

https://docs.espressif.com/projects/esp ... r-receiver

I think you need to check your adapter schematic to get more details on why it does not work. What is clear it can not switch the direction of the RS485 line in Half Duplex.