r/PLC•
HeiyenDB

Learning and programming with modbus

Hi, I've getting into automation slowly, and got to the point where I got into modbus, the thing is I wanted to learn by myself some basics, and got some low power vfd which supports modbus rtu, two lines with RS485 so I guess it's half duplex, and wanted to see if I could cheaply program the vfd with a microcontroller and a ttl to rs485 module (cheap max485 modules), basically an esp32 that works as a master tells the vfd to follow some instructions. I'm using the esp32 since I can have two uart, one for serial debugging in my machine and one for the actual translation to modbus with the max485.

While rn I can't show some code, I wanted to ask suggestions for troubleshooting, the thing is I kinda got stuck to a point where I try to write a register, and expect the vfd to give back a response, however the microntroller doesn't seem to get a response back or just gets a partial response (amount of bytes does no match the response according to the modbus protocol)

Reading the manual, I made sure the modbus protocol is enabled, matching baudrates for communication, primary source of control is through communication, matching bits and parity, connecting both gnd from the esp32 and the vfd. Slave direction matches. The vfd also has a COM terminal, and it's supposed to be another gnd isolated, still, sharing grounds or COM won't give a response. Also tried sending some instructions which were listed as examples in the manual.

Not sure about the termination resistors, but the VFD has a termination resistor jumper, so you can enable it. I tried it with or without the VFD termination resistor, however did not try placing and actual resistor parallel to A and B lines from the max485 module. Rn I only connected the esp32 with the VFD (max 485 module as intermediary)

I wanted to say that I did some tests before with an esp32 acting as a master and another one as slave, and while the slave properly received the instruction, the response it gave back always was incomplete, like you expected 8 bytes, and got 3, so data seemed incomplete, but thought maybe the esp32 which was acting as a slave could be having some issue?

I'm kinda into a weird hobby with electronics and homelabing and thought it would be cool sharing some monitored data from the vfd to a local server in a database as a little learning project, hence the setup, however I can't even seem to get a proper response with modbus.

Also sorry If something can't be that well understood, english is not my first language but I'm open to answer questions

Posted Jun 27, 2026, 7:24 AM UTC

53
Loading comments…