I’m trying to connect an ESP 32 to the Wi-Fi to my local network and connect to a inverter that has modbus on the local network. I’m having trouble with understanding how to actually write the right code as the modbus library doesn’t have any good examples.
I don’t have a problem connecting to my local Wi-Fi.
Would anybody have any code that would connect to the solar inverter and collect data from any of the holding registers.
Because you need the specifics of your inverter. Is there no manual or technical reference for that? Obviously you will need one to read and interpret the register values.
I am looking for a straightforward code so I can understand what is needed. I have a modbus device "Sungrow Inverter. I would like to read a holding register say 5030 Active Load. I can read all the registers in node-red. However, looking to use ESP32 to collect data and perform a calculation and then control another device. I can connect to my local WIFI but not the modbus device.
In order to help you I want a link to the data sheet for the solar charger you are using. Without the data sheet reading the holding register will be almost impossible.
If you cannot help me help you then me helping you will not happen.
I am trying to connect to a SUNGROW SH5H-20 solar inverter. I have set up a dummy modbus server and the code reads the holdingregisters. Also in my node red flow i am able to connect to the Sungrow inverter and get good data.
My code does not produce any meaning-full values only two digits when connected to the Sungrow. As many of the Holding Registers are values like 53000 representing Watts and producing 5300.0 watts as the final value user adjusted.
if (!modbusTCPClient.requestFrom(0x01, HOLDING_REGISTERS,13000,30)) {
Serial.print("failed");
Serial.print(modbusTCPClient.lastError());
} else {
Serial.println("we are getting there");
while (modbusTCPClient.available()){
Serial.println(modbusTCPClient.read());
}
Serial.print(" ");
}