Closed TimGFoley closed 1 year ago
Now that I may have some time off over Christmas I'll see if I can dig into this myself.
Right away I see that we have no error checking against temp2 if it returns a null value:
def read_temp_data(self):
temp1 = self.read_serial_data_renogy(self.command_bms_temp1)
temp2 = self.read_serial_data_renogy(self.command_bms_temp2)
if temp1 is False:
return False
self.temp1 = unpack('>H',temp1)[0] / 10
self.temp2 = unpack('>H',temp2)[0] / 10
return True
By the looks of the debug log I posted above, temp2 returned a 0 (which it interpreted as a Boolean value I assume).
I also see that we don't know which cell had the high or low temp but that might be a limit of their Protocol.
Also where did we find the spec for the Renogy battery bms RS485 protocol? I've only found docs for the MPPT and a few others but not the BMS Protocol showing all the registers.
Cheers Tim
Hi Tim
The protocol doc is in the old ticket #12
Most of these cheaper BMS only have 1,2 or 3 temp sensors, and not a sensor for each cell. So which cell that min/max temp belongs too is not known, and so also not in their protocol.
I just updated to 14.3, no change however.
I also just added a second renogy battery but serialbattery only finds the one on the bus, possibly the driver does not yet support multiple batteries or this newer battery (self heated smart) has a different ID. The new model is a RBT100LFP12SH.
It shows up fine (both batteries) if I disconnect the RS485/USB and use the Renogy Bluetooth or Monitor screen, so I know it's communicating.
@4000000063b651681a37fb94 INFO:SerialBattery:Testing Renogy
@4000000063b651682c8e70d4 INFO:SerialBattery:RENOGY RBT100LFP12S-G1
@4000000063b65168347e54e4 INFO:SerialBattery:Connection established to Renogy
@4000000063b6516834916f84 INFO:SerialBattery:Battery Renogy connected to dbus from /dev/ttyUSB1
@4000000063b6516834a05404 INFO:SerialBattery:=== Settings ===
@4000000063b6516834b3e3d4 INFO:SerialBattery:> Connection voltage NoneV | current NoneA | SOC None%
@4000000063b6516834c41c2c INFO:SerialBattery:> Cell count 4 | cells populated 4
@4000000063b6516834d33f2c INFO:SerialBattery:> CCCM SOC True | DCCM SOC True
@4000000063b6516834e16444 INFO:SerialBattery:> CCCM CV True | DCCM CV True
@4000000063b6516834ef5a7c INFO:SerialBattery:> CCCM T True | DCCM T True
@4000000063b6516834fe566c INFO:SerialBattery:> MIN_CELL_VOLTAGE 2.9V | MAX_CELL_VOLTAGE 3.45V
@4000000063b65169064ad50c INFO:SerialBattery:DeviceInstance = 2
@4000000063b65169068c71ec INFO:SerialBattery:com.victronenergy.battery.ttyUSB1
@4000000063b652db07bf7b7c ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b652db2ee2e054 ERROR:SerialBattery:>>> ERROR: Incorrect Reply
@4000000063b652db2f833b1c Traceback (most recent call last):
@4000000063b652db2f836de4 File "/opt/victronenergy/dbus-serialbattery/dbushelper.py", line 193, in publish_battery
@4000000063b652db2f83816c success = self.battery.refresh_data()
@4000000063b652db2f838d24 File "/opt/victronenergy/dbus-serialbattery/renogy.py", line 68, in refresh_data
@4000000063b652db2f839cc4 result = result and self.read_temp_data()
@4000000063b652db2f83a87c File "/opt/victronenergy/dbus-serialbattery/renogy.py", line 144, in read_temp_data
@4000000063b652db2f8565cc self.temp2 = unpack('>H',temp2)[0] / 10
@4000000063b652db2f85756c TypeError: a bytes-like object is required, not 'bool'
@4000000063b6530a06a122cc INFO:SerialBattery:Starting dbus-serialbattery
@4000000063b6530a06b60a5c INFO:SerialBattery:dbus-serialbattery v0.14.3
@4000000063b6530a0725fa9c INFO:SerialBattery:Testing LltJbd
@4000000063b6530a187ee59c ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530a18a7e99c INFO:SerialBattery:Testing Ant
@4000000063b6530a2d06f07c ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530a2d2c6e24 ERROR:SerialBattery:>>> ERROR: Incorrect Data
@4000000063b6530a2d3cf884 INFO:SerialBattery:Testing Daly
@4000000063b6530b04dcf4fc ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530b05127064 INFO:SerialBattery:Testing Daly
@4000000063b6530b16b32264 ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530b16d99df4 INFO:SerialBattery:Testing Jkbms
@4000000063b6530b28351164 ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530b28729764 INFO:SerialBattery:Testing Lifepower
@4000000063b6530c01b399ac ERROR:SerialBattery:>>> ERROR: No reply - returning
@4000000063b6530c01dfba8c ERROR:SerialBattery:>>> ERROR: Incorrect Data
@4000000063b6530c01f0930c INFO:SerialBattery:Testing Renogy
@4000000063b6530c1391c9dc INFO:SerialBattery:RENOGY RBT100LFP12S-G1
@4000000063b6530c1cb2f644 INFO:SerialBattery:Connection established to Renogy
@4000000063b6530c1ded00cc INFO:SerialBattery:Battery Renogy connected to dbus from /dev/ttyUSB1
@4000000063b6530c1e512584 INFO:SerialBattery:=== Settings ===
@4000000063b6530c1e8d9dfc INFO:SerialBattery:> Connection voltage NoneV | current NoneA | SOC None%
@4000000063b6530c1f31adfc INFO:SerialBattery:> Cell count 4 | cells populated 4
@4000000063b6530c1f7e7e0c INFO:SerialBattery:> CCCM SOC True | DCCM SOC True
@4000000063b6530c1f8fd38c INFO:SerialBattery:> CCCM CV True | DCCM CV True
@4000000063b6530c1f9ec7ac INFO:SerialBattery:> CCCM T True | DCCM T True
@4000000063b6530c1fae021c INFO:SerialBattery:> MIN_CELL_VOLTAGE 2.9V | MAX_CELL_VOLTAGE 3.45V
@4000000063b6530c2ce654d4 INFO:SerialBattery:DeviceInstance = 2
@4000000063b6530c2d29a34c INFO:SerialBattery:com.victronenergy.battery.ttyUSB1
Ah now I see why, the current implementation of the code assumes that the RS485 address of a BMS device is unique to a manufacturer. There is no routine to scan all RS485 addresses and check for a battery BMS type at each address.
For example it assumes Renogy would be:
{"bms": "Renogy", "address": b"\x30"}, #x30=48 dec {"bms": "Renogy", "address": b"\xF7"}, #xF7=247 dec
Yet a Renogy battery could be address 01-247 (x01-xF7).
Added some more debug to various modules and was able to find the addresses of both my batteries. One is address 0 and the other is address 1. This took me a while to find as the debug code was not spitting out which RS485 address it found so I added some logger info for that:
@4000000063b6fc893060f4d4 INFO:SerialBattery:------------------------------------------------------------------------------- @4000000063b6fc8930725ddc INFO:SerialBattery:Starting dbus-serialbattery @4000000063b6fc8930832aa4 INFO:SerialBattery:dbus-serialbattery v0.14.3.timtest @4000000063b6fc89309395c4 INFO:SerialBattery:Battery to be tested is: @4000000063b6fc8930aa9c4c INFO:SerialBattery:{'bms': 'Renogy', 'address': b'1'} @4000000063b6fc8930badc74 INFO:SerialBattery:Testing Renogy @4000000063b6fc8930e46544 INFO:SerialBattery:Address = b'1' @4000000063b6fc8a076cbbe4 INFO:SerialBattery:RENOGY RBT100LFP12SH-G1 @4000000063b6fc8a0fcb1164 INFO:SerialBattery:Connection established to Renogy @4000000063b6fc8a0fdd2a34 INFO:SerialBattery:Battery Renogy connected to dbus from /dev/ttyUSB1 @4000000063b6fc8a0feba53c INFO:SerialBattery:=== Settings ===
Here would be my normal address 0 battery:
@4000000063b6fec9278cfe0c INFO:SerialBattery:------------------------------------------------------------------------------- @4000000063b6fec927a0c874 INFO:SerialBattery:Starting dbus-serialbattery @4000000063b6fec927bc5ef4 INFO:SerialBattery:dbus-serialbattery v0.14.3.timtest @4000000063b6fec927cc703c INFO:SerialBattery:Battery to be tested is: @4000000063b6fec927db9b0c INFO:SerialBattery:{'bms': 'Renogy', 'address': b'0'} @4000000063b6fec927f68d7c INFO:SerialBattery:Testing Renogy @4000000063b6fec92817aa0c INFO:SerialBattery:Address = b'0' @4000000063b6fec9398bcdcc INFO:SerialBattery:RENOGY RBT100LFP12S-G1 @4000000063b6feca079444fc INFO:SerialBattery:Connection established to Renogy @4000000063b6feca07a6deb4 INFO:SerialBattery:Battery Renogy connected to dbus from /dev/ttyUSB1 @4000000063b6feca07e0de5c INFO:SerialBattery:=== Settings === @4000000063b6feca082bb29c INFO:SerialBattery:> Connection voltage NoneV | current NoneA | SOC None% @4000000063b6feca084247dc INFO:SerialBattery:> Cell count 4 | cells populated 4 @4000000063b6feca0875b004 INFO:SerialBattery:> CCCM SOC True | DCCM SOC True @4000000063b6feca0886f5e4 INFO:SerialBattery:> CCCM CV True | DCCM CV True @4000000063b6feca08a084dc INFO:SerialBattery:> CCCM T True | DCCM T True @4000000063b6feca08b18c3c INFO:SerialBattery:> MIN_CELL_VOLTAGE 2.9V | MAX_CELL_VOLTAGE 3.45V @4000000063b6feca11d3f124 INFO:SerialBattery:DeviceInstance = 2 @4000000063b6feca1247581c INFO:SerialBattery:com.victronenergy.battery.ttyUSB1
Found the newer Renogy Protocol spec and have been testing with some other code snippets from another author, now things are making a little more sense.
When scanning addresses x01-xF7, I find my two batteries at 0x48 and 0x49. It's not perfect yet but at least I can most of the registers from multiple batteries on the RS485 bus with that code.
Note: Can't 100% trust these outputs below, the program would randomly get no answers.
RS485 Address 0x31 (49)
Register Address Value Binary
----------------------------------------------------------------------------------------------
cell_count 5000 4 00000000 00000100
cellvoltage_1 5001 3.30 V 00000000 00100001
cellvoltage_2 5002 3.30 V 00000000 00100001
cellvoltage_3 5003 3.30 V 00000000 00100001
cellvoltage_4 5004 3.30 V 00000000 00100001
temp_count 5017 3 00000000 00000011
celltemp_1 5018 16.00 °C 00000000 10100000
celltemp_2 5019 16.00 °C 00000000 10100000
celltemp_3 5020 16.00 °C 00000000 10100000
celltemp_4 5021 16.00 °C 00000000 10100000
BMS Board Temp 5035 0.00 °C 00000000 00000000
Num Env Temp Sensors 5036 1 00000000 00000001
Env Temp Sensor 1 5037 18.00 °C 00000000 10110100
Env Temp Sensor 2 5038 0.00 °C 00000000 00000000
Num Htr Temp Sensors 5039 1 00000000 00000001
Htr Temp Sensor 1 5040 17.00 °C 00000000 10101010
Htr Temp Sensor 2 5041 0.00 °C 00000000 00000000
Current 5042 0.34 A 00000000 00100010
Voltage 5043 13.40 V 00000000 10000110
Remaining Capacity 5044 93.14 Ah 00000000 00000001 01101011 11010111
Total Capacity 5046 97.75 Ah 00000000 00000001 01111101 11010110
Cycle Number 5048 225 00000000 11100001
Charge Voltage Limit 5049 14.80 V 00000000 10010100
Serial Num 5110 PPTAH01050C08270 01010000 01010000 01010100 01000...
Manufacture Version 5118 0100 00110000 00110001 00110000 00110000
Main Line Version 5119 0001 00110000 00110000 00110000 00110001
Comms Protocl Version 5121 02 00110000 00110010
Battery Name 5122 RBT100LFP12S-G1 01010010 01000010 01010100 00110...
Software Version 5130 0014 00110000 00110000 00110001 00110100
Manufacturer 5132 RENOGY 01010010 01000101 01001110 01001...
RS485 Address 0x31 (49)
Register Address Value Binary
----------------------------------------------------------------------------------------------
cell_count 0x1388 4 00000000 00000100
cellvoltage_1 0x1389 3.30 V 00000000 00100001
cellvoltage_2 0x138a 3.30 V 00000000 00100001
cellvoltage_3 0x138b 3.30 V 00000000 00100001
cellvoltage_4 0x138c 3.30 V 00000000 00100001
temp_count 0x1399 4 00000000 00000100
celltemp_1 0x139a 16.00 °C 00000000 10100000
celltemp_2 0x139b 16.00 °C 00000000 10100000
celltemp_3 0x139c 16.00 °C 00000000 10100000
celltemp_4 0x139d 16.00 °C 00000000 10100000
BMS Board Temp 0x13ab 0.00 °C 00000000 00000000
Num Env Temp Sensors 0x13ac 0 00000000 00000000
Env Temp Sensor 1 0x13ad 25.00 °C 00000000 11111010
Env Temp Sensor 2 0x13ae 25.00 °C 00000000 11111010
Num Htr Temp Sensors 0x13af 0 00000000 00000000
Htr Temp Sensor 1 0x13b0 25.00 °C 00000000 11111010
Htr Temp Sensor 2 0x13b1 25.00 °C 00000000 11111010
Current 0x13b2 0.11 A 00000000 00001011
Voltage 0x13b3 13.50 V 00000000 10000111
Remaining Capacity 0x13b4 97.17 Ah 00000000 00000001 01111011 10001111
Total Capacity 0x13b6 100.00 Ah 00000000 00000001 10000110 10100000
Cycle Number 0x13b8 0 00000000 00000000
Charge Voltage Limit 0x13b9 14.80 V 00000000 10010100
Discharge Voltage Limit 0x13ba 10.00 V 00000000 01100100
Charge Current Limit 0x13bb 50.00 A 00010011 10001000
Discharge Current Limit 0x13bc 555.36 A 11011000 11110000
Serial Num 0x13f6 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 11111111 11111111 11111111 11111...
Manufacture Version 0x13fe 0100 00110000 00110001 00110000 00110000
Main Line Version 0x13ff 0001 00110000 00110000 00110000 00110001
Comms Protocl Version 0x1401 19 00110001 00111001
Battery Name 0x1402 RBT100LFP12SH-G1 01010010 01000010 01010100 00110...
Software Version 0x140a 0131 00110000 00110001 00110011 00110001
Manufacturer 0x140c RENOGY 01010010 01000101 01001110 01001...
So judging by the original error where it tried to unpack a Boolean variable, I suspect the code tried to read temp2 which does not exist on this battery, so the read function returned false and the unpack of course failed since it expect a byte string and not a bool.
Simply adding a check to see if reading temp2 returns false should cover it (we already had a check for temp1).
I'll improve the code by reading how many Environmental sensors are in the battery and then only populate temp1 or temp2 based on this, while adding checks to ensure we exit if any temp value read returns a false.
I was considering using a for loop to iterate through to the max number of temp sensors read but it looks like we only to return temp1 and temp2 at present in battery.py. So for the moment something along these lines should do:
def read_temp_data(self):
#OLD temp1 = self.read_serial_data_renogy(self.command_bms_temp1)
#OLD temp2 = self.read_serial_data_renogy(self.command_bms_temp2)
# Check to see how many Enviromental Temp Sensors this battery has, it may have none.
num_env_temps = self.read_serial_data_renogy(self.command_env_temp_count)
logger.info('Number of Enviromental Sensors = %s', num_env_temps)
if (num_env_temps == 0):
return False
if (num_env_temps == 1):
temp1 = self.read_serial_data_renogy(self.command_env_temp1)
if temp1 is False:
return False
else:
self.temp1 = unpack(">H", temp1)[0] / 10
logger.info('temp1 = %s °C', temp1)
if (num_env_temps == 2):
temp2 = self.read_serial_data_renogy(self.command_env_temp2)
if temp2 is False:
return False
else:
self.temp2 = unpack(">H", temp2)[0] / 10
logger.info('temp2 = %s °C', temp2)
return True
Thanks for the testing and update. I'll update it to the driver as soon as I can. For now the driver assume one serial connection per BMS. Perhaps we can add some settings in future.
Your fix will be included in the next release.
Did you connect multiple BMS to one RS485 adapter? https://github.com/Louisvdw/dbus-serialbattery/issues/142
While watching the Device List in the remote console, the Serialbattery will randomly show disconnected, it will reconnect after a few moments (less than a minute, will time next it happens).
Will continue to monitor to see if I can find a cause or pattern.
Venus GX (Victron OEM) Firmware Version v2.91
Battery: Renogy Smart Lithium 100AH Cells: 4 Interface: Renogy USB to RS485 OEM Cable (no other devices connected to battery)
Copy of current log when it happens here: