1

I would like to change the PV inverter settings via Modbus TCP.

the system reads correctly when I write I get an error!!!

I use Raspberry PI and Python.

Modbus address is 40125 and data is RW (readable and writable, U16 unsigned integer (16 bits))

from pymodbus.client import ModbusTcpClient as ModbusClient


client = ModbusClient('192.168.1.116', port=502)

client.connect()


if client.connect():


    APPD = client.read_holding_registers(40125, 1, 1)
    print (APPD.registers[0])


    replay = client.write_registers(40125,500,1)
    
    print(replay)

Read: 10000

Write: Exception Response(144, 16, IllegalAddress)

What could be wrong?

Maario
  • 13
  • 4
  • The leading numeral (4) in the register address probably denotes `holding register`. Since you already use the function `read_holding_registers` you must skip this and use register `125` instead. – Bosz Jun 10 '23 at 12:30
  • I tried skip `read` and `replay = client.write_registers(125,10,1)` and gave an answer `Exception Response(134, 6, IllegalAddress)` – Maario Jun 10 '23 at 12:55
  • Sorry, I didn't mean skip reading but skip the (4). So to read `read_holding_registers(125,1,1)`. To write try function code 0x6, so `write_register(125,10,1)`. – Bosz Jun 10 '23 at 13:32
  • I tried `replay = client.write_registers(125,10,1)` same answer `Exception Response(134, 6, IllegalAddress)` – Maario Jun 11 '23 at 07:19
  • The plural `write_registers` is not the same as `write_register`. – Bosz Jun 11 '23 at 10:19
  • I tried both, still showing the same error. – Maario Jun 11 '23 at 11:17
  • Can you read any other register? – Bosz Jun 11 '23 at 11:24
  • Reads correctly, I tried write other addresses, still the same. Inverter manulal [PDF](https://javierin.com/wp-content/uploads/sites/2/2021/09/Solar-Inverter-Modbus-Interface-Definitions.pdf) I usage Modbus Poll software the same error to write. – Maario Jun 11 '23 at 12:20
  • The manual says the default address of the slave node is 0. Are you sure you are using the correct slave id? – Bosz Jun 11 '23 at 12:41
  • The reading works correctly PV1 V. - `32016` = 666, PV2 V. - `32018` = 544, Grid Hz - `32085` = 50,01 ... I also checked the device slave id is `1`. I have always read, but this time I need to write to the address :( – Maario Jun 11 '23 at 13:17
  • @Maario can you post the actual command that you are sending? It's easy to check via Modbus Poll. – Nick S. Jun 12 '23 at 03:12
  • Are you using a Huawei WLAN-FE Smart Dongle? – Bosz Jun 12 '23 at 06:38
  • 1
    Inverter is `SUN2000-10KTL-M1` (V100R001C00SPC153) and `WLAN-FE` (V100R001C00SPC125) over LAN cable (not using wifi) READ `40125` Tx:`01 1F 00 00 00 06 01 03 9C BD 00 01` Rx:`01 1F 00 00 00 05 01 03 02 03 E8` WRITE `40125` VALUE - `100` Tx:`01 20 00 00 00 06 01 06 9C BD 00 64` Rx:`01 20 00 00 00 03 01 86 02` – Maario Jun 12 '23 at 19:11
  • @Maario everything looks okay; try reading from and writing to 40124 and 40126 and seeing what happens? You should get a 0x02 on reading 40124. Can you write to any R/W registers? If you have equipment currently in use, try to change the time-zone - write to 43006. Addresses can be weird in Modbus, so while you are getting a read from 40125, I would like to have you verify that you indeed can write (I checked if there are any passwords you are supposed to set before writing - some systems do that - but I don't see any) and that your addressing scheme is correct. If not - contact the mfg. – Nick S. Jun 12 '23 at 20:54
  • Note that you are [not the only user](https://community.home-assistant.io/t/integration-solar-inverter-huawei-2000l/132350/2499) to encounter this kind of issue with the dongle. – Brits Jun 12 '23 at 22:34
  • I can read all the values correctly. It's weird I tried to write some value `40000` - `42999` same error except for Reactive power adjustment time - `40124` i can write! and `43000` + and higher value I can write correctly!!! Funny (`43006` Tx:`00 02 00 00 00 06 01 06 A7 FE 00 82` Rx:`00 02 00 00 00 06 01 06 A7 FE 00 82`) – Maario Jun 13 '23 at 01:32
  • @Maario that tells me something is off - register 40124 isn't defined in the manual that you have linked. Which register are you specifically talking about? What do you mean you have tried to write some value 40000 - 42999? Because you can't write more than effectively ~ 127 registers at a time. – Nick S. Jun 13 '23 at 03:19
  • I scanned the addresses with the ModBus Pool and I tried to change some that were of value. I tested 40124 which values ​​change in the device's software and ModBus reads. I think that the inverter itself does not allow writing. – Maario Jun 13 '23 at 06:05
  • @Maario I'm not sure which software you are using exactly, so at this point I'd direct you to Huawei forums, they provide support there as well. – Nick S. Jun 13 '23 at 15:37

0 Answers0