Skip to content

Quickstart

These steps take one battery from off to 10 kW discharge and back to standby. For a first run, a Modbus tool is all you need. In your EMS, walk the SunSpec map instead of using these addresses: see the Register reference.

  1. Connect. Modbus TCP to the battery’s IP address, port 502, Unit ID 100 + its number. Registers 40000 and 40001 read SunS.
  2. Check it can run. 701_InvSt does not read 6. At 6 a fault is active: see How it behaves.
  3. Connect and start. Write 802_SetOp = 1, 802_SetInvState = 3 and 704_WSetEna = 1.
  4. Set the power. Write 704_WSet = 100, both registers with function code 16. The register holds W / 100, so this is 10 kW discharge; −100 charges 10 kW.
  5. Check. 701_W reads about 100 within seconds: the battery acts on each write within 5 s, and the first start of the PCS adds a few seconds.
  6. Stop. Write 704_WSet = 0. The PCS goes to standby.
Step Point Address Value
2 701_InvSt 40074 read
3 802_SetOp 40457 1
3 802_SetInvState 40458 3
3 704_WSetEna 40299 1
4, 6 704_WSet 40301–40302 100, then 0
5 701_W 40080 read

With pymodbus 3.10 or later:

import time
from pymodbus.client import ModbusTcpClient
UNIT = 101 # battery 1
client = ModbusTcpClient("192.0.2.100", port=502)
client.connect()
def read(address, count=1):
return client.read_holding_registers(address, count=count, device_id=UNIT).registers
def write(address, values):
client.write_registers(address, values, device_id=UNIT) # function code 16
def int32(value):
raw = value & 0xFFFFFFFF
return [raw >> 16, raw & 0xFFFF] # high word first
def int16(raw):
return raw - 0x10000 if raw >= 0x8000 else raw
assert read(40000, 2) == [0x5375, 0x6E53], "not a SunSpec device"
assert read(40074)[0] != 6, "a fault is active" # 701_InvSt
write(40457, [1]) # 802_SetOp: connect
write(40458, [3]) # 802_SetInvState: start
write(40299, [1]) # 704_WSetEna
write(40301, int32(round(10000 / 100))) # 704_WSet: 10 kW discharge
time.sleep(10) # the first start takes a few seconds
inv_st = read(40074)[0] # 701_InvSt
watts = int16(read(40080)[0]) * 100 # 701_W, W_SF = 2
print(f"InvSt {inv_st}, {watts} W")
write(40301, int32(0)) # 704_WSet: standby
client.close()