My project is to connect a NodeMCU 1.0 ESP8266 via wifi to a Modbus TCP capable solar inverter.
I did some reading of the git, modbus-arduino and modbus-esp8266. Along with several older modbus libraries.
It seems to indicate that the library is capable of many modbus functions via TCP and also RS485. I wish to use modbus function 0x04 - Read Input Registers to read registers 30775-30776. I hope to then do the necessary formatting to display some values on an LCD. The LCD part I have done before, however the documentation and examples for the modbus libraries don't really explain very well how to open a connection to the modbus device.
Has anyone got some ideas on how to get this communication to work?
I can access the inverter registers via TCP on my PC using a program QModMaster without issues.
It is written with an ethernet shield in mind. It doesn't attempt to connect to the modbus IP address when run from the ESP module. I added the code to connect to my wifi and then step into the Master sketch. I can choose from the menu shown on serial monitor but I do not get serial print to show the connection to modbus was successful or not as shown in the cpp and h files included. So I don't think that part works with the 8266.
The two linked libraries are only supporting Modbus TCP server mode (= slave in Modbus RTU terminology).
I'm not aware of a ESP8266 Modbus TCP client (= master in Modbus RTU terminology) implementation but adapting a library written for Arduino with Ethernet Shield shouldn't be that complicated.