0

I have a Huawer SUN 2000 inverter with a dongle and a raspberry Pi 4B. I am trying to read data via modbus TCP with the pymodbus library but I get the following error: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received). With node-red, on the raspberry, I am able to get data but with python I am not. Also, with the same script I am able to read data from a Fronius inverter, so I don't know where the problem could be...

I leave the code:

from pymodbus.client import ModbusTcpClient

# Configure the connection to the remote device
client = ModbusTcpClient('192.168.1.100', port=502, timeout=100, retry=3) # Replace the IP address with that of the Huawei device

# Connect to the remote device
client.connect()

# read the value of the holding register 40001
result = client.read_holding_registers(address=30000, count=10, slave=0x00) # Replace the unit number with the value of the Huawei device

# close the connection
client.close()

# Print the value of the holding register
print(result)

I have a Huawer SUN 2000 inverter with a dongle and a raspberry Pi 4B. I am trying to read data via modbus TCP with the pymodbus library but I get the following error: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received). With node-red, on the raspberry, I am able to get data but with python I am not. Also, with the same script I am able to read data from a Fronius inverter, so I don't know where the problem could be...

  • Hello Cristian, you should double-check with your nodered code. I don't think your slave address is correct, if you are connecting to an inverter its address should be 1 to 247. Other than that, `address=30000` seems also wrong, for pymodbus you need to write addresses with an offset, if you want to read register 40001 you should write `address=0` – Marcos G. Mar 10 '23 at 10:08

1 Answers1

0

Try to add unit=1

client = ModbusTcpClient('192.168.1.100', port=502, timeout=100, retry=3, unit=1) # Replace the IP address with that of the Huawei device

Works to me.

Ciprian
  • 21
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 15 '23 at 07:29