Search code examples
modbusrs485pymodbussolar

Issue reading modbus registers from Epever uPower charger / inverter using pymodbus


I am having a issue reading modbus registers from a Epever uPower solar charger / inverter. I am using the pymodbus library running on a Raspberry Pi talking over a USB to RS485 cable. I know the hardware and the cable are working because I can get the data on a Windows laptop. It also appears to work on the PI as when I select a different unit ID in the code below I get a connection error.

There are many well documented examples of reading registers from Epever equipment and the following code seems to work with most devices however I can not get it working with the newer uPower device:

import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method = 'rtu', port = '/dev/ttyUSB0', baudrate = 115200, stopbits=1, timeout=1, parity='N' )
client.connect()
 
result = client.read_input_registers(0x3100,6,unit=10)
print(result.registers)
solarVoltage = float(result.registers[0] / 100.0)
solarCurrent = float(result.registers[1] / 100.0)
batteryVoltage = float(result.registers[4] / 100.0)
chargeCurrent = float(result.registers[5] / 100.0)
 
# Do something with the data
 
client.close()

The debug logs show the following:

DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.transaction:SEND: 0xa 0x4 0x31 0x0 0x0 0x6 0x7f 0x8f
DEBUG:pymodbus.client.sync:New Transaction state 'SENDING'
DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
DEBUG:pymodbus.transaction:Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
DEBUG:pymodbus.transaction:RECV: 0xa 0x84 0x2 0xb3 0x3
DEBUG:pymodbus.framer.rtu_framer:Getting Frame - 0x84 0x2
DEBUG:pymodbus.factory:Factory Response[132]
DEBUG:pymodbus.framer.rtu_framer:Frame advanced, resetting header!!
DEBUG:pymodbus.transaction:Adding transaction 10
DEBUG:pymodbus.transaction:Getting transaction 10
DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
Traceback (most recent call last):
  File "main.py", line 11, in <module>
    print(result.registers)
AttributeError: 'ExceptionResponse' object has no attribute 'registers'

Any help or pointers gratefully received. Would maybe help if I could understand the response that the code is getting RECV: 0xa 0x84 0x2 0xb3 0x3

Either way it does not seem to have any registers....


Solution

  • You need to change your Address from 0x3100 to 0x3500.

    I decompiled the SolarStationSoftware and found out that they changed the Realtime Address to 13568.