I'm trying to use pymodbus lib to retrieve data from my Epever tracer BN series solar charge controller, here is my pymodbus code:
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method = 'rtu', port = '/dev/ttyUSB0', baudrate = 115200)
client.connect()
result = client.read_input_registers(0x3100,6,unit=1)
print("result = ")
print (result)
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)
client.close()
but I kept getting this error:
result =
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
Traceback (most recent call last):
File "/home/pi/Documents/solar charge controler.py", line 9, in <module>
solarVoltage = float(result.registers[0] / 100.0)
AttributeError: 'ModbusIOException' object has no attribute 'registers'
So I did a lot of research and found out I need some kind of driver to be able to use my USB to rs485, and I came across this LINK
but I don't understand any of the commands there, I just started writing the on the terminal, I as able to install the raspberrypi-kernel-headers, whatever that is but when I do sudo bundle then sudo make I get this on the terminal:
pi@raspberrypi:~ $ sudo bundle
sudo: bundle: command not found
pi@raspberrypi:~ $ sudo make
make: *** No targets specified and no makefile found. Stop.
So after all that can someone guide me thru the right commands to write on the terminal in order to install the usb to rs485 driver?
thank you