Hi! I have a MAX13487e connected to a ESP32. I program using PlatformIO and using Arduino based coding. Now I have Modbus RTU (server) device on address 1.
I have tried to use several librrary but all of them are giving me no response or error codes like 226 and 227. While my RAW implementation of reading the serial does give me the right response from the device.
Now I am stuck how I need to proceed further to obtain the values from the response. Anyone can help me?
Where are you monitoring this response from? The "01 03 01 66 00 02 25 E8" sequence is the request sent to the remote device and the "01 03 04 38 1B 43 6C B6 49" is the response back.
I would say that you have something wrong in your setup. You shouldn't normally "receive" the transmitted message unless you have enabled both the transmitter and receiver sections of your RS485 line driver at the same time - effectively causing a loopback of the transmitted message.
Check that you are controlling the RE & DE signals correctly.
What level are the RE and SHDN pins set to - presumably high?
The datasheet for the MAX13487e implies that it disables the RX when in TX mode - via the internal autoswitching circuitry - but the output from your code would suggest that this is not the case as you are receiving your own transmission, which will likely be the cause.
Another thought - I wonder if you were to use the ModbusMaster library and then in the postTransmission function make a call to the clearResponseBuffer function.
In theory this would empty the response buffer at the end of transmission which might remove the echoed request message leaving the buffer empty ready for the remote device response message.
Receiver Output Enable. Drive RE low to enable the RO. Drive RE high to let the AutoDirection circuit
control the receiver. RE is a hot-swap input (see the Hot-Swap Capability section for more details).
Has your RS485 bus got the resistors fitted? If not, then I think the MAX13487e chip may be getting confused over bus activity and not switching correctly.