Modbus RTU to ESP8266

I need to set up a Modbus RTU MASTER communication network and also SLAVE RTU with ESP8266 12E (or F, whatever), but I couldn't find a good Modbus RTU library. It has several pages / blogs / videos referring to the things of the PDA Control or the Trialcommand (which are the same library), but I could not make it work fine. The only one I could keep comunication was the PDA Control, but there were a lot of writing and reading errors, a lot of timeouts, etc., even setting the serial to work at 9600 instead of higher speeds.

Does anyone know of any library that works well for ESP8266? ...or some Modbus RTU routine that works (written in any language) and which I can use to "translate" to the C language used in Arduino?

I've tried using these libraries without success:

I've tried using these libraries without success:

Then show us that code!

I use the GitHub - smarmengol/Modbus-Master-Slave-for-Arduino: Modbus Master-Slave library for Arduino</titl library (slightly modified) for my own projects and it works great. It's used in master and slave mode, although the master mode wasn't as complete as expected. As there are no special registers of the AVR platform used but you might have to remove some ifdefs if used on the ESP platform.

Solved! I’ve implemented a simplified routine of the Modbus RTU protocol, with only my needed functions. Following, there are two files of the protocol implementation code and an example file with Arduino (it works on ESP8266).

See attach file: mb.c

mb.c (11.9 KB)

Dear sirs,

I try to implement a modbus slave in the ESP32 Wroom. Do you have any examples of how the ESP32 Wroom works?

I didn't study that anymore. The implementation of the protocol is valid for any processor. As I mentioned before, in my case I implemented only what I needed, following the standard of the protocol documentation.

Solved! ModbusMaster - Arduino Reference use this library. I got it working with nodemcu.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.