you must know the modbus registers of your system and understand Modbus TCP protocol.
for example readInverter request two registers from address 40083 described in inverter specs and uses them to calculate the inverter AC output
Sorry to have to ask all this.... but just to be sure :
modbusRequest(METER_UID, 40490, 1, regs);
METER_UID is the inverter's modbus address (in my case 126)
40490 is the register number
1 is the number of registrers to read
regs is where to store the result, in this case of length 1 Int (2 bytes)
Is the above correct ?
Cant get the inverter to respond for some reason...
uid is a device address. in my case the inverter has address 1 and smart meter has address METER_UID. on Fronius I needed to enable the Modbus TCP (check box in web panel)
yes. it has a define on top of the snippet. connect didn't success.
Do you have Java skills? I have a java version you could try from a computer
EDIT: I put it here for future readers. The problem was resolved in other thread. It had nothing to do with the sketch or modbus protocol. Two devices in network had the IP address of the inverter.
Start Sunny Explorer on the computer and create a Speedwire system (see Sunny Explorer user manual).
Log into the Speedwire system as Installer.
Select the SMA inverter to be configured in the system tree.
Select the tab Settings.
Select the parameter group External Communication.
Select [Edit].
You will see the categories TCP Server and UDP Server under the parameter group Modbus.
To activate the TCP server, make the following settings in the group Modbus > TCP Server:
• In the Activated drop-down list, select the entry Yes.
• If necessary, change the port in the Port field (default setting: 502).
Start Sunny Explorer on the computer and create a Speedwire system (see Sunny Explorer user manual).
Log into the Speedwire system as Installer.
Select the SMA inverter to be configured in the system tree.
Select the tab Settings.
Select the parameter group External Communication.
Select [Edit].
You will see the categories TCP Server and UDP Server under the parameter group Modbus.
To activate the TCP server, make the following settings in the group Modbus > TCP Server:
• In the Activated drop-down list, select the entry Yes.
• If necessary, change the port in the Port field (default setting: 502).
Thats correct. Thats exactly what i did to enable modbus on both tcp and udp.
Tried to use the same sketch and tried to connect to another Telnet server at port 23 and still doesnt connect. Must be something wrong with the connect function...
Will try again tomorrow..