ESP32 RS485 DTR Pin

Wisssje
Posts: 3
Joined: Mon Jul 17, 2023 1:30 pm

ESP32 RS485 DTR Pin

Postby Wisssje » Wed Oct 29, 2025 4:22 pm

Hi,

I'm trying (and failing) to initialize UART0 as RS485 with hardware DE control through the DTR pin.

How can I setup the DTR pin? uart_set_pin(...) only takes 5 params.
The api-reference does gice a _uart_set_pin6 function, but that does not compile. I might be missing an include?
I've tried enabling flowctrl, but when setting uart_set_mode(0, UART_MODE_RS485_HALF_DUPLEX), it fails because flowctrl is enabled.

Acoording to the api-reference it should be possible:
The RS485 half-duplex communication mode is supported by the UART driver and can be activated by selecting the UART_MODE_RS485_HALF_DUPLEX mode calling uart_set_mode(). The DTR line is automatically controlled by the hardware directly under RS485 half-duplex mode, while the RTS line is software-controlled by the UART driver. Once the host starts writing data to the TX FIFO buffer, the UART driver automatically asserts the RTS pin (logic 1); once the last bit of the data has been transmitted, the driver de-asserts the RTS pin (logic 0). To use this mode, the software would have to disable the hardware flow control function. Since the switching is made in the interrupt handler, comparing to DTR line, some latency is expected on RTS line.
I have a very responsive system, so the expected latency on the RTS time messes with the response.

Does anyone have experience setting up RS485 with the hardware DTR line instead of software RTS?
Thanks

ESP_alisitsyn
Posts: 221
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP32 RS485 DTR Pin

Postby ESP_alisitsyn » Fri Oct 31, 2025 10:42 am

Hi @Wisssje,

See my answers here: https://github.com/espressif/esp-modbus/issues/145.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot], YisouSpider and 6 guests