mr-manuel / venus-os_dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
https://mr-manuel.github.io/venus-os_dbus-serialbattery_docs/
MIT License
35 stars 15 forks source link

JK BMS disconnecting on raspberry pi3b+ #28

Closed NigelStruble closed 5 months ago

NigelStruble commented 5 months ago

Describe the problem

I have a raspberry pi 3B+ with a JKBMS. The connection initially establishes normally, but then about 10-30 seconds later it disconnects and then reconnects after about 30 seconds then the cycle repeats. The battery indicator clears itself during this time. I have tried it with 2 different systems with the same result (different pi, BMS and adapter but same models). I can pull the same USB adapter out of the pi and plug it into a CerboGX and it runs normally.

Driver version

v1.3.20240416dev

Venus OS device type

Raspberry Pi

Venus OS version

v3.40~2

BMS type

JKBMS / Heltec BMS

Cell count

8

Battery count

1

Connection type

Serial USB adapter to RS485

Config file

[DEFAULT]

; If you want to add custom values/settings, then check the values/settings you want to change in "config.default.ini"
; and insert them below to persist future driver updates.

; Example (remove the semicolon ";" to uncomment and activate the value/setting):
; MAX_BATTERY_CHARGE_CURRENT = 50.0
; MAX_BATTERY_DISCHARGE_CURRENT = 60.0

Relevant log output

2024-04-17 01:30:07.798341500 INFO:SerialBattery:
2024-04-17 01:30:07.798998500 INFO:SerialBattery:Starting dbus-serialbattery
2024-04-17 01:30:07.800474500 INFO:SerialBattery:Venus OS v3.40~2
2024-04-17 01:30:07.801013500 INFO:SerialBattery:dbus-serialbattery v1.3.20240416dev
2024-04-17 01:30:23.811843500 INFO:SerialBattery:-- Testing BMS: 1 of 3 rounds
2024-04-17 01:30:23.811851500 INFO:SerialBattery:Testing Daly at address "\x40"
2024-04-17 01:30:23.939228500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:30:23.939235500 INFO:SerialBattery:Testing Daly at address "\x80"
2024-04-17 01:30:24.064109500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:30:24.064766500 INFO:SerialBattery:Testing Ecs
2024-04-17 01:30:24.125128500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:30:24.125761500 INFO:SerialBattery:Testing HeltecModbus
2024-04-17 01:30:27.799967500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:30:27.800665500 INFO:SerialBattery:Testing HLPdataBMS4S
2024-04-17 01:30:28.608417500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:30:28.609049500 INFO:SerialBattery:Testing Jkbms
2024-04-17 01:30:28.730528500 INFO:SerialBattery:Connection established to Jkbms
2024-04-17 01:30:28.910474500 INFO:SerialBattery:Found existing battery with DeviceInstance = 1
2024-04-17 01:30:29.069576500 INFO:SerialBattery:DeviceInstance = 1
2024-04-17 01:30:29.070901500 INFO:SerialBattery:PID file created successfully: /var/tmp/dbus-serialbattery_1.pid
2024-04-17 01:30:29.071480500 INFO:SerialBattery:Used DeviceInstances = ['1']
2024-04-17 01:30:29.072031500 INFO:SerialBattery:com.victronenergy.battery.ttyUSB0
2024-04-17 01:30:29.094997500 INFO:SerialBattery:publish config values = True
2024-04-17 01:30:29.117226500 INFO:SerialBattery:Battery Jkbms connected to dbus from /dev/ttyUSB0
2024-04-17 01:30:29.117841500 INFO:SerialBattery:========== Settings ==========
2024-04-17 01:30:29.118452500 INFO:SerialBattery:> Connection voltage: 26.29 V | Current: -0.0 A | SoC: None%
2024-04-17 01:30:29.118977500 INFO:SerialBattery:> Cell count: 8 | Cells populated: 8
2024-04-17 01:30:29.119503500 INFO:SerialBattery:> LINEAR LIMITATION ENABLE: True
2024-04-17 01:30:29.120045500 INFO:SerialBattery:> MIN CELL VOLTAGE: 2.9 V | MAX CELL VOLTAGE: 3.45 V
2024-04-17 01:30:29.120593500 INFO:SerialBattery:> MAX BATTERY CHARGE CURRENT: 50.0 A | MAX BATTERY DISCHARGE CURRENT: 60.0 A
2024-04-17 01:30:29.121236500 INFO:SerialBattery:> MAX BATTERY CHARGE CURRENT: 100.0 A | MAX BATTERY DISCHARGE CURRENT: 100.0 A (read from BMS)
2024-04-17 01:30:29.121756500 INFO:SerialBattery:> CVCM:     True
2024-04-17 01:30:29.122296500 INFO:SerialBattery:> CCCM CV:  True  | DCCM CV:  True
2024-04-17 01:30:29.122824500 INFO:SerialBattery:> CCCM T:   True  | DCCM T:   True
2024-04-17 01:30:29.123448500 INFO:SerialBattery:> CCCM SOC: False | DCCM SOC: False
2024-04-17 01:30:29.124012500 INFO:SerialBattery:> CHARGE FET: False | DISCHARGE FET: False | BALANCE FET: True
2024-04-17 01:30:29.124549500 INFO:SerialBattery:Serial Number/Unique Identifier: JK_BD6A24S10
v3.40~22024-04-17 01:32:22.301079500 Traceback (most recent call last):
2024-04-17 01:32:22.301085500   File "/opt/victronenergy/dbus-serialbattery/dbushelper.py", line 760, in publish_battery
2024-04-17 01:32:22.301090500     result = self.battery.refresh_data()
2024-04-17 01:32:22.301093500   File "/opt/victronenergy/dbus-serialbattery/bms/jkbms.py", line 65, in refresh_data
2024-04-17 01:32:22.301098500     result = self.read_status_data()
2024-04-17 01:32:22.301101500   File "/opt/victronenergy/dbus-serialbattery/bms/jkbms.py", line 78, in read_status_data
2024-04-17 01:32:22.301209500     status_data = self.read_serial_data_jkbms(self.command_status)
2024-04-17 01:32:22.301213500   File "/opt/victronenergy/dbus-serialbattery/bms/jkbms.py", line 339, in read_serial_data_jkbms
2024-04-17 01:32:22.301218500     data = read_serial_data(
2024-04-17 01:32:22.301221500   File "/opt/victronenergy/dbus-serialbattery/utils.py", line 393, in read_serial_data
2024-04-17 01:32:22.301226500     with serial.Serial(port, baudrate=baud, timeout=0.1) as ser:
2024-04-17 01:32:22.301253500   File "/usr/lib/python3.8/site-packages/serial/serialutil.py", line 240, in __init__
2024-04-17 01:32:22.301258500     self.open()
2024-04-17 01:32:22.301260500   File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 286, in open
2024-04-17 01:32:22.301265500     self._update_dtr_state()
2024-04-17 01:32:22.301267500   File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 634, in _update_dtr_state
2024-04-17 01:32:22.301318500     fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str)
2024-04-17 01:32:22.301322500 OSError: [Errno 71] Protocol error
tail: /data/log/dbus-serialbattery.ttyUSB0/current has been replaced; following end of new file
2024-04-17 01:33:00.653473500 INFO:SerialBattery:-- Testing BMS: 1 of 3 rounds
2024-04-17 01:33:00.653480500 INFO:SerialBattery:Testing Daly at address "\x40"
2024-04-17 01:33:00.782575500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:33:00.782583500 INFO:SerialBattery:Testing Daly at address "\x80"
2024-04-17 01:33:00.906981500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:33:00.907650500 INFO:SerialBattery:Testing Ecs
2024-04-17 01:33:00.967823500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:33:00.968479500 INFO:SerialBattery:Testing HeltecModbus
2024-04-17 01:33:04.647410500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:33:04.648044500 INFO:SerialBattery:Testing HLPdataBMS4S
2024-04-17 01:33:05.456848500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2024-04-17 01:33:05.456854500 INFO:SerialBattery:Testing Jkbms
2024-04-17 01:33:05.577595500 INFO:SerialBattery:Connection established to Jkbms
2024-04-17 01:33:05.758401500 INFO:SerialBattery:Found existing battery with DeviceInstance = 1
2024-04-17 01:33:05.911296500 INFO:SerialBattery:DeviceInstance = 1
2024-04-17 01:33:05.912657500 INFO:SerialBattery:PID file created successfully: /var/tmp/dbus-serialbattery_1.pid
2024-04-17 01:33:05.913254500 INFO:SerialBattery:Used DeviceInstances = ['1']
2024-04-17 01:33:05.913879500 INFO:SerialBattery:com.victronenergy.battery.ttyUSB0
2024-04-17 01:33:05.936254500 INFO:SerialBattery:publish config values = True
2024-04-17 01:33:05.958004500 INFO:SerialBattery:Battery Jkbms connected to dbus from /dev/ttyUSB0
2024-04-17 01:33:05.958630500 INFO:SerialBattery:========== Settings ==========
2024-04-17 01:33:05.959244500 INFO:SerialBattery:> Connection voltage: 26.29 V | Current: -0.0 A | SoC: None%
2024-04-17 01:33:05.959771500 INFO:SerialBattery:> Cell count: 8 | Cells populated: 8
2024-04-17 01:33:05.960305500 INFO:SerialBattery:> LINEAR LIMITATION ENABLE: True
2024-04-17 01:33:05.960852500 INFO:SerialBattery:> MIN CELL VOLTAGE: 2.9 V | MAX CELL VOLTAGE: 3.45 V
2024-04-17 01:33:05.961415500 INFO:SerialBattery:> MAX BATTERY CHARGE CURRENT: 50.0 A | MAX BATTERY DISCHARGE CURRENT: 60.0 A
2024-04-17 01:33:05.961961500 INFO:SerialBattery:> MAX BATTERY CHARGE CURRENT: 100.0 A | MAX BATTERY DISCHARGE CURRENT: 100.0 A (read from BMS)
2024-04-17 01:33:05.962493500 INFO:SerialBattery:> CVCM:     True
2024-04-17 01:33:05.963024500 INFO:SerialBattery:> CCCM CV:  True  | DCCM CV:  True
2024-04-17 01:33:05.963650500 INFO:SerialBattery:> CCCM T:   True  | DCCM T:   True
2024-04-17 01:33:05.964209500 INFO:SerialBattery:> CCCM SOC: False | DCCM SOC: False
2024-04-17 01:33:05.964751500 INFO:SerialBattery:> CHARGE FET: False | DISCHARGE FET: False | BALANCE FET: True
2024-04-17 01:33:05.965279500 INFO:SerialBattery:Serial Number/Unique Identifier: JK_BD6A24S10

Any other information that may be helpful

No response

NigelStruble commented 5 months ago

It appears the issue is related to a USB hub that the adapter is plugged into. None of the other devices on the hub have a problem, and the hub works when used on a cerbo. I also tried it on a RPi4 without issue. However, bypassing the hub and plugging the directly into the RPi3 seems to have eliminated the dropouts.