ESP32 to ESP32 communicate problem

Thread Starter

sumanpal1299

Joined Jul 25, 2022
3
Hello.
I'm maintainer of the mentioned library and just noticed your thread. Get my 5 cents.
1. Take a look coments in code below.
2. The library is designed to control DE/RE by itself. Also refere comments in code bellow.
3. Callback function is fired on various events. As for callback mentioned in read*/write* functions it's called at request end and allows to gets result code of 0x00 on success or Modbus Error code on error.
I try with this code and communicate with two esp32. When i directly connect one esp32 RXTD and TXD pin to another esp32 TXD and RXD pin then it communicate and run modbus communication. But when i connect two max485 trans-receiver module then communication not established. I send circuit diagram. Please suggest me.
 

Attachments

Thread Starter

sumanpal1299

Joined Jul 25, 2022
3
I create a master code which read holding register of slave id 1 every 500 ms
And create a slave code. which increment the register data every 500 ms.
So in Master debug I get updated value. I send both code
When i used trans receiver module between two esp32 why it is not communicate. Please tell what wrong with me.
 

Beau Schwabe

Joined Nov 7, 2019
130
For one, you must control the direction pin for the RS485 before you send any data.
Another gotcha to look out for is that when you send data serially, it goes into a buffer that sends in the background. This is great for allowing other tasks to take place, but when needing to control a direction pin you can switch the direction before the data has been sent. To "fix" this use the flush() command after you have sent the data. The flush() will suspend program execution until the data has been sent. Then you can safely switch data direction modes.
 
Top