-1

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

André Gomes
  • 397
  • 1
  • 3
  • 17
  • 1
    Please don't distract from your question with background about being new to a language, framework, etc. It's irrelevant. Just ask your question. – ChrisGPT was on strike Mar 28 '20 at 11:34
  • @Chris, I was just trying to give context to the question, I basically need help installing the driver for my USB TO RS485 adapter – André Gomes Mar 30 '20 at 15:24

1 Answers1

0

I followed this guide and the attached code which works in compiling the driver. There's some minute detail that differs it from the normal one. Though still stuck on not being able to read the device, but this will probably help you get the ttyXRUSB0 mapped up:

https://medium.com/@jcrbcn/installing-the-exar-usb-driver-on-the-raspberrypi-for-teknic-sc-hub-39de533f0502

ulc
  • 1
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Brian61354270 Apr 09 '20 at 01:06