plasmapper / modbus-esp-cpp

Modbus C++ Class Component for ESP-IDF
MIT License
5 stars 1 forks source link

How to handle RS485 DIR #4

Closed NemesisXB closed 1 month ago

NemesisXB commented 1 month ago

How do you handle the RS485 half duplex DIR pin?

plasmapper commented 1 month ago

To use Modbus client over the RS-485 line you should use this constructor. The first parameter of this constructor is the pointer to the UART object which is created using this constructor. It has the rtsPin parameter that you can use to specify the pin that is connected to the ~RE and DE pins of your RS-485 driver chip. You can try it with this example. Just replace

auto uart = std::make_shared(UART_NUM_0);

with

auto uart = std::make_shared(UART_NUM_0, PL::Uart::minBufferSize, PL::Uart::minBufferSize, [TX pin], [RX pin], [RTS pin]);
NemesisXB commented 1 month ago

Thanks for the quick response. I will be trying this out first thing Monday.

NemesisXB commented 1 month ago

Thanks. This worked. I did need to add this to the example for it to work: uart->SetMode(UART_MODE_RS485_HALF_DUPLEX);

Meant to close the issue. You can close it.