Modbus TCP esp32 WiFi

Hi

Hope this is the correct place.

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.

Thanks

Perhaps the ESP32's MODBUS API docs might help,

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/modbus.html

It is but it is a duplicate thread which is not allowed.

I’m trying to use modbus on a solar inverter and have the ESP 32 to control a EV charger or hot water heater. Like th UK made ZAPPI.

Have problems connecting to the Modbus on the Solar inverter.

Don't you think you should tell us about those problems? :slight_smile: Otherwise all we can offer is sympathy.

@immoos, do not cross-post. Threads merged.

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.

A data sheet of some type about the solar controller/inverter would be useful, do you have links?

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.

The following is an extract of the net. However I just need to read one register than we can grow from there.

You want someone to convert Python to C++/Arduino?

I'd do it for money, if I still was for hire.

Thanks
However this is in python. I am only learning and the standard Arduino IDE is used.

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(" ");
  }

The Sungrow inverter SH5K-20 does not have holding registers it has input registers.

ActiveLoad = modbusTCPClient.inputRegisterRead(1, 13033);

Can you post your full working code? It would be very helpful to other people searching these forums to know what libraries and code you used.

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