ESP32 RS485 DTR Pin
Posted: 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:
Does anyone have experience setting up RS485 with the hardware DTR line instead of software RTS?
Thanks
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:
I have a very responsive system, so the expected latency on the RTS time messes with the response.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.
Does anyone have experience setting up RS485 with the hardware DTR line instead of software RTS?
Thanks