corbinbs / solarshed

A Python library to help monitor solar charge controllers typically used in off the grid applications.
MIT License
85 stars 24 forks source link

" No communication with the instrument " error #19

Closed BenHotte closed 1 year ago

BenHotte commented 1 year ago

I'm currently trying to use this library but I'm getting this error:

>> from solarshed.controllers.renogy_rover import RenogyRover
>>> 
>>> controller = RenogyRover('/dev/ttyUSB0', 1)
>>> 
>>> controller.battery_voltage()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nexus/.local/lib/python3.10/site-packages/solarshed/controllers/renogy_rover.py", line 86, in battery_voltage
    return self.read_register(257, numberOfDecimals=1)
  File "/home/nexus/.local/lib/python3.10/site-packages/minimalmodbus.py", line 258, in read_register
    return self._genericCommand(functioncode, registeraddress, numberOfDecimals=numberOfDecimals, signed=signed)
  File "/home/nexus/.local/lib/python3.10/site-packages/minimalmodbus.py", line 697, in _genericCommand
    payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
  File "/home/nexus/.local/lib/python3.10/site-packages/minimalmodbus.py", line 795, in _performCommand
    response = self._communicate(request, number_of_bytes_to_read)
  File "/home/nexus/.local/lib/python3.10/site-packages/minimalmodbus.py", line 930, in _communicate
    raise IOError('No communication with the instrument (no answer)')
OSError: No communication with the instrument (no answer)
>>>

Basically, I'm using this cable to connect the Renogy Rover controller to my Raspberry Pi. I'm not sure if my wire is at fault here. I also tried to create my own homemade cable but I can't figure out the pinout of the RJ12 connector since Renogy doesn't share that information (my controller didn't come with the proper RJ12 to USB cable that seems to be included according to some blogs I read).

If someone could help me, it would be really appreciated. Thanks :)

BenHotte commented 1 year ago

After some digging I found out taht the the cable is completely fine and is not the problem. The problem was in the slave address. I had to change it from 1 to 16. So my controller instance is now:

controller = RenogyRover('/dev/ttyUSB0', `1)

Hope that can help someone else!