ESP32 RS485driver hardwareserial ModbusMaster

Posts: 12
Joined: Mon Mar 12, 2018 1:57 pm

Re: ESP32 RS485driver hardwareserial ModbusMaster

Postby migbur » Wed May 15, 2019 4:41 pm

Thank you very much
I will tried up as soon as possible I have one humidity sensor with RS485 and im not able to run it up

Posts: 1
Joined: Sun Oct 20, 2019 1:02 pm

Re: ESP32 RS485driver hardwareserial ModbusMaster

Postby chickey » Sun Oct 20, 2019 1:03 pm

hi would you be able to share your code, an old one i know but encountering the same issue
grasvezel wrote:
Thu Apr 12, 2018 3:36 pm
I know it has been a few weeks, but I ran into similar problems, solved them and would like to share. I use a MAX-3485. Basically a 485 but for 3.3v instead of 5v. I couldn't get anyting to work using standard libraries. I used one of the many hardware examples in wich the DE and /RE are connected. DriverEnable is active high, ReceiverEnable is active low. So, why not use one GPIO and use that as a toggle between send and receive, right? After hours of debugging and hooking up a second ESP32/MAX3485 to see what was going on on the RS485 bus, I found that the DE dropped before the transmission of the Modbus frame was complete. My guess is that the library just goes ahead and drops the DE pin after the frame is sent, but at that time the ESP32 still has some data in the transmit buffer. Maybe that is a difference with arduinos, maybe those don't have a transmit buffer?

Anyway: I solved it by modifying my hardware a bit (RE is always low now) and implementing the Modbus protocol myself instead of using a lib. The protocol is quite straightforward. The only thing I had to deal with is reading back my own transmission because the receiver is always on now. But since I know exactly what I sent out, that's not difficult to do.

Posts: 18
Joined: Thu May 17, 2018 10:33 am

Re: ESP32 RS485driver hardwareserial ModbusMaster

Postby Edje11 » Thu Oct 24, 2019 7:48 pm

Modbusmaster works fine with RS485 on a Esp32.
Have a look for the tip and tricks:
You have to set the fucntions preTransmission() and postTransmission() correct, see the above sample

Who is online

Users browsing this forum: No registered users and 9 guests