kasbert / epsolar-tracer

Tools for EPsolar Tracer BN solar charge controller
Apache License 2.0
120 stars 76 forks source link

Epever ET6415BND #32

Closed seesix closed 1 year ago

seesix commented 6 years ago

Hi there, I am trying to run your code on a Pi Zero W with the latest version of Raspian Stretch

However, when I run this code

#################################

!/usr/bin/env python

from pymodbus.client.sync import ModbusSerialClient as ModbusClient client = ModbusClient(method = 'rtu', port = '/dev/ttyAMA0', baudrate = 115200) client.connect() while True: result = client.read_input_registers(0x03, 1, unit=1) print result client.close()

###############################

it returns this error

###############################

Traceback (most recent call last): File "./test.py", line 9, in result = client.read_input_registers(0x03, 1, unit=1) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/common.py", line 125, in read_input_registers return self.execute(request) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 107, in execute return self.transaction.execute(request) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/transaction.py", line 136, in execute full=full File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/transaction.py", line 202, in _transact size = self._send(packet) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/transaction.py", line 219, in _send return self.client.framer.sendPacket(packet) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/framer/rtu_framer.py", line 272, in sendPacket size = self.client.send(message) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 76, in send return self._send(request) File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 491, in _send waitingbytes = self._in_waiting() File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 473, in _in_waiting waitingbytes = getattr(self.socket, in_waiting)() File "/home/pi/.local/lib/python2.7/site-packages/serial/serialutil.py", line 590, in inWaiting return self.in_waiting File "/home/pi/.local/lib/python2.7/site-packages/serial/serialposix.py", line 467, in in_waiting s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str) IOError: [Errno 25] Inappropriate ioctl for device

#############################

i'd be most grateful for any advise on how to solve this

kasbert commented 6 years ago

It might be a problem with the Raspbian distibution. Here is a similar case: https://www.raspberrypi.org/forums/viewtopic.php?t=218469

seesix commented 6 years ago

I just tried with a fresh install of Jessie and same error. My guess is, its the cable, I'm using the one supplied by Epever, have order a new one.

seesix commented 6 years ago

I have just tried again with a new FTDI cable and it returns this error.

####################################################

sudo ./info.py Traceback (most recent call last): File "./info.py", line 18, in client.connect() File "/home/pi/battery/epsolar-tracer/pyepsolartracer/client.py", line 33, in connect return self.client.connect() File "/usr/local/lib/python2.7/dist-packages/pymodbus/client/sync.py", line 451, in connect parity=self.parity) File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 216, in init self.port = port File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in port raise ValueError('"port" must be None or a string, not {}'.format(type(port))) ValueError: "port" must be None or a string, not <type 'int'>

################################################

Any ideas on how to fix this would be gratefully received.

Thanks

kasbert commented 6 years ago

Edit info.py and set correct arguments:

serialclient = ModbusClient(method='rtu', port='/dev/ttyXRUSB0', baudrate=115200, stopbits = 1, bytesize = 8, timeout=1)

Do you see the wanted the /dev/tty* device ?

seesix commented 6 years ago

thank you so much for the help.

in the end my device was ttyUSB1

seesix commented 6 years ago

hey kasbert

i'm still stuck on this, when i run info.py i get this

Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received) INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated input voltage' Charging equipment rated input voltage = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated input current' Charging equipment rated input current = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated input power' Charging equipment rated input power = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated input power L' Charging equipment rated input power L = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated input power H' Charging equipment rated input power H = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated output voltage' Charging equipment rated output voltage = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated output current' Charging equipment rated output current = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated output power' Charging equipment rated output power = None Charging equipment rated output power L = 378.56W INFO:pyepsolartracer.registers:No value for register 'Charging equipment rated output power H' Charging equipment rated output power H = None INFO:pyepsolartracer.registers:No value for register 'Charging mode' Charging mode = None INFO:pyepsolartracer.registers:No value for register 'Rated output current of load' Rated output current of load = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment input voltage' Charging equipment input voltage = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment input current' Charging equipment input current = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment input power' Charging equipment input power = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment input power L' Charging equipment input power L = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment input power H' Charging equipment input power H = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment output voltage' Charging equipment output voltage = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment output current' Charging equipment output current = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment output power' Charging equipment output power = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment output power L' Charging equipment output power L = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment output power H' Charging equipment output power H = None INFO:pyepsolartracer.registers:No value for register 'Discharging equipment output voltage' Discharging equipment output voltage = None INFO:pyepsolartracer.registers:No value for register 'Discharging equipment output current' Discharging equipment output current = None INFO:pyepsolartracer.registers:No value for register 'Discharging equipment output power' Discharging equipment output power = None INFO:pyepsolartracer.registers:No value for register 'Discharging equipment output power L' Discharging equipment output power L = None INFO:pyepsolartracer.registers:No value for register 'Discharging equipment output power H' Discharging equipment output power H = None INFO:pyepsolartracer.registers:No value for register 'Battery Temperature' Battery Temperature = None INFO:pyepsolartracer.registers:No value for register 'Temperature inside equipment' Temperature inside equipment = None INFO:pyepsolartracer.registers:No value for register 'Power components temperature' Power components temperature = None INFO:pyepsolartracer.registers:No value for register 'Battery SOC' Battery SOC = None INFO:pyepsolartracer.registers:No value for register 'Remote battery temperature' Remote battery temperature = None INFO:pyepsolartracer.registers:No value for register "Battery's real rated power" Battery's real rated power = None INFO:pyepsolartracer.registers:No value for register 'Battery status' Battery status = None INFO:pyepsolartracer.registers:No value for register 'Charging equipment status' Charging equipment status = None INFO:pyepsolartracer.registers:No value for register 'Maximum input volt (PV) today' Maximum input volt (PV) today = None INFO:pyepsolartracer.registers:No value for register 'Minimum input volt (PV) today' Minimum input volt (PV) today = None INFO:pyepsolartracer.registers:No value for register 'Maximum battery volt today' Maximum battery volt today = None INFO:pyepsolartracer.registers:No value for register 'Minimum battery volt today' Minimum battery volt today = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy today' Consumed energy today = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy today L' Consumed energy today L = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy today H' Consumed energy today H = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this month' Consumed energy this month = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this month L' Consumed energy this month L = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this month H' Consumed energy this month H = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this year' Consumed energy this year = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this year L' Consumed energy this year L = None INFO:pyepsolartracer.registers:No value for register 'Consumed energy this year H' Consumed energy this year H = None INFO:pyepsolartracer.registers:No value for register 'Total consumed energy' Total consumed energy = None INFO:pyepsolartracer.registers:No value for register 'Total consumed energy L' Total consumed energy L = None Total consumed energy H = 0.0kWh INFO:pyepsolartracer.registers:No value for register 'Generated energy today' Generated energy today = None INFO:pyepsolartracer.registers:No value for register 'Generated energy today L' Generated energy today L = None INFO:pyepsolartracer.registers:No value for register 'Generated energy today H' Generated energy today H = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this month' Generated energy this month = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this month L' Generated energy this month L = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this month H' Generated energy this month H = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this year' Generated energy this year = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this year L' Generated energy this year L = None INFO:pyepsolartracer.registers:No value for register 'Generated energy this year H' Generated energy this year H = None INFO:pyepsolartracer.registers:No value for register 'Total generated energy' Total generated energy = None INFO:pyepsolartracer.registers:No value for register 'Total generated energy L' Total generated energy L = None INFO:pyepsolartracer.registers:No value for register 'Total Generated energy H' Total Generated energy H = None INFO:pyepsolartracer.registers:No value for register 'Carbon dioxide reduction' Carbon dioxide reduction = None INFO:pyepsolartracer.registers:No value for register 'Carbon dioxide reduction L' Carbon dioxide reduction L = None INFO:pyepsolartracer.registers:No value for register 'Carbon dioxide reduction H' Carbon dioxide reduction H = None INFO:pyepsolartracer.registers:No value for register 'Battery Current' Battery Current = None INFO:pyepsolartracer.registers:No value for register 'Battery Current L' Battery Current L = None INFO:pyepsolartracer.registers:No value for register 'Battery Current H' Battery Current H = None INFO:pyepsolartracer.registers:No value for register 'Battery Temp.' Battery Temp. = None INFO:pyepsolartracer.registers:No value for register 'Ambient Temp.' Ambient Temp. = None INFO:pyepsolartracer.registers:No value for register 'Battery Type' Battery Type = None INFO:pyepsolartracer.registers:No value for register 'Battery Capacity' Battery Capacity = None INFO:pyepsolartracer.registers:No value for register 'Temperature compensation coefficient' Temperature compensation coefficient = None INFO:pyepsolartracer.registers:No value for register 'High Volt.disconnect' High Volt.disconnect = None INFO:pyepsolartracer.registers:No value for register 'Charging limit voltage' Charging limit voltage = None INFO:pyepsolartracer.registers:No value for register 'Over voltage reconnect' Over voltage reconnect = None INFO:pyepsolartracer.registers:No value for register 'Equalization voltage' Equalization voltage = None INFO:pyepsolartracer.registers:No value for register 'Boost voltage' Boost voltage = None INFO:pyepsolartracer.registers:No value for register 'Float voltage' Float voltage = None INFO:pyepsolartracer.registers:No value for register 'Boost reconnect voltage' Boost reconnect voltage = None INFO:pyepsolartracer.registers:No value for register 'Low voltage reconnect' Low voltage reconnect = None INFO:pyepsolartracer.registers:No value for register 'Under voltage recover' Under voltage recover = None INFO:pyepsolartracer.registers:No value for register 'Under voltage warning' Under voltage warning = None INFO:pyepsolartracer.registers:No value for register 'Low voltage disconnect' Low voltage disconnect = None INFO:pyepsolartracer.registers:No value for register 'Discharging limit voltage' Discharging limit voltage = None Real time clock 1 = 11270 INFO:pyepsolartracer.registers:No value for register 'Real time clock 2' Real time clock 2 = None INFO:pyepsolartracer.registers:No value for register 'Real time clock 3' Real time clock 3 = None INFO:pyepsolartracer.registers:No value for register 'Equalization charging cycle' Equalization charging cycle = None INFO:pyepsolartracer.registers:No value for register 'Battery temperature warning upper limit' Battery temperature warning upper limit = None INFO:pyepsolartracer.registers:No value for register 'Battery temperature warning lower limit' Battery temperature warning lower limit = None INFO:pyepsolartracer.registers:No value for register 'Controller inner temperature upper limit' Controller inner temperature upper limit = None INFO:pyepsolartracer.registers:No value for register 'Controller inner temperature upper limit recover' Controller inner temperature upper limit recover = None INFO:pyepsolartracer.registers:No value for register 'Power component temperature upper limit' Power component temperature upper limit = None INFO:pyepsolartracer.registers:No value for register 'Power component temperature upper limit recover' Power component temperature upper limit recover = None INFO:pyepsolartracer.registers:No value for register 'Line Impedance' Line Impedance = None INFO:pyepsolartracer.registers:No value for register 'Night TimeThreshold Volt.(NTTV)' Night TimeThreshold Volt.(NTTV) = None INFO:pyepsolartracer.registers:No value for register 'Light signal startup (night) delay time' Light signal startup (night) delay time = None INFO:pyepsolartracer.registers:No value for register 'Day Time Threshold Volt.(DTTV)' Day Time Threshold Volt.(DTTV) = None Light signal turn off(day) delay time = 10min Load controling modes = 0 INFO:pyepsolartracer.registers:No value for register 'Working time length 1' Working time length 1 = None INFO:pyepsolartracer.registers:No value for register 'Working time length 2' Working time length 2 = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 1 sec' Turn on timing 1 sec = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 1 min' Turn on timing 1 min = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 1 hour' Turn on timing 1 hour = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 1 sec' Turn off timing 1 sec = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 1 min' Turn off timing 1 min = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 1 hour' Turn off timing 1 hour = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 2 sec' Turn on timing 2 sec = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 2 min' Turn on timing 2 min = None INFO:pyepsolartracer.registers:No value for register 'Turn on timing 2 hour' Turn on timing 2 hour = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 2 sec' Turn off timing 2 sec = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 2 min' Turn off timing 2 min = None INFO:pyepsolartracer.registers:No value for register 'Turn off timing 2 hour' Turn off timing 2 hour = None INFO:pyepsolartracer.registers:No value for register 'Length of night' Length of night = None INFO:pyepsolartracer.registers:No value for register 'Battery rated voltage code' Battery rated voltage code = None Load timing control selection = 0 INFO:pyepsolartracer.registers:No value for register 'Default Load On/Off in manual mode' Default Load On/Off in manual mode = None INFO:pyepsolartracer.registers:No value for register 'Equalize duration' Equalize duration = None INFO:pyepsolartracer.registers:No value for register 'Boost duration' Boost duration = None INFO:pyepsolartracer.registers:No value for register 'Discharging percentage' Discharging percentage = None INFO:pyepsolartracer.registers:No value for register 'Charging percentage' Charging percentage = None INFO:pyepsolartracer.registers:No value for register 'Management modes of battery charging and discharging' Management modes of battery charging and discharging = None INFO:pyepsolartracer.registers:No value for coil 'Manual control the load' Manual control the load = None INFO:pyepsolartracer.registers:No value for coil 'Enable load test mode' Enable load test mode = None INFO:pyepsolartracer.registers:No value for coil 'Force the load on/off' Force the load on/off = None INFO:pyepsolartracer.registers:No value for coil 'Over temperature inside the device' Over temperature inside the device = None INFO:pyepsolartracer.registers:No value for coil 'Day/Night' Day/Night = None

============================== note that it reads only one input from the register

Real time clock 1 = 11270

if i run the script again i'll get a different single value returned ie

Charging equipment rated output current = 60.0A

here is my info.py

=========================================

!/usr/bin/env python

from pyepsolartracer.client import EPsolarTracerClient from pyepsolartracer.registers import registers,coils

from test.testdata import ModbusMockClient as ModbusClient

from pymodbus.client.sync import ModbusSerialClient as ModbusClient

configure the client logging

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

serialclient = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=115200, timeout=5, stopbits =1, bytesize =8, handshaking ='N', parity ='N', debug = True)

client = EPsolarTracerClient(serialclient = serialclient) client.connect()

response = client.read_device_info()

print "Manufacturer:", repr(response.information[0])

print "Model:", repr(response.information[1])

print "Version:", repr(response.information[2])

response = client.read_holding_registers(0, 1, unit=1)

response = client.read_input("Charging equipment rated input voltage")

print str(response)

for reg in registers:

print

#print reg
value = client.read_input(reg.name)
print value
#if value.value is not None:
#    print client.write_output(reg.name,value.value)

for reg in coils:

print

#print reg
value = client.read_input(reg.name)
print value
#print client.write_output(reg.name,value.value)

client.close()

===============================================

Any ideas what I'm doing wrong? Thanks again for the help

kasbert commented 1 year ago

Closed as stale