Louisvdw / dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
MIT License
541 stars 165 forks source link

LLT/JBD BMS BLE - Lost bluetooth connection to 2 BMS #1088

Open WP-Rue opened 4 months ago

WP-Rue commented 4 months ago

Describe the problem

Broken bluetooth connection to BMS (with internal RP4 Bluetooth device (switched off in Victron Remote Console)

Driver version

1.3.20240624 stable and 20240627 nighty built also

Venus OS device type

Raspberry Pi

Venus OS version

V3.32 and 3.34

BMS type

Smart BMS (LLT, JBD, Overkill Solar)

Cell count

12

Battery count

2

Connection type

Bluetooth

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

MIN_CELL_VOLTAGE   = 3.3
MAX_CELL_VOLTAGE   = 4.16
FLOAT_CELL_VOLTAGE = 4.13
SOC_RESET_VOLTAGE = 4.16

SOC_LOW_WARNING = 10
SOC_LOW_ALARM   = 4
; --------- Bluetooth BMS ---------
; Description:
;     Specify the Bluetooth BMS and it's MAC address that you want to install. Leave emty to disable
; Available Bluetooth BMS:
;     Jkbms_Ble, LltJbd_Ble
; Example for one BMS:
;     BLUETOOTH_BMS = Jkbms_Ble C8:47:8C:00:00:00
; Example for multiple BMS:
;     BLUETOOTH_BMS = Jkbms_Ble C8:47:8C:00:00:00, Jkbms_Ble C8:47:8C:00:00:11, Jkbms_Ble C8:47:8C:00:00:22
;BLUETOOTH_BMS =LltJbd_Ble A5:C2:37:27:05:C2
BLUETOOTH_BMS =LltJbd_Ble A5:C2:37:27:05:C2, LltJbd_Ble A5:C2:37:27:04:F4
BLUETOOTH_USE_USB = False

CELL_VOLTAGES_WHILE_CHARGING = 4.16

Relevant log output

2024-06-28 21:03:17.547468500 INFO:Bluetooth details
2024-06-28 21:03:17.557039500 [CHG] Device A5:C2:37:27:05:C2 RSSI: -76
2024-06-28 21:03:17.557044500 [CHG] Device A5:C2:37:27:05:C2 RSSI: -73
2024-06-28 21:03:17.606880500 Attempting to disconnect from A5:C2:37:27:05:C2
2024-06-28 21:03:17.606885500 Successful disconnected
2024-06-28 21:03:22.682320500 Device A5:C2:37:27:05:C2 (public)
2024-06-28 21:03:22.682325500   Alias: Gelbgrn
2024-06-28 21:03:22.682327500   Paired: no
2024-06-28 21:03:22.682329500   Trusted: no
2024-06-28 21:03:22.682332500   Blocked: no
2024-06-28 21:03:22.682334500   Connected: no
2024-06-28 21:03:22.682336500   LegacyPairing: no
2024-06-28 21:03:22.682338500   UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
2024-06-28 21:03:22.682342500   RSSI: -73
2024-06-28 21:03:22.684671500 
2024-06-28 21:03:23.417561500 INFO:SerialBattery:
2024-06-28 21:03:23.417841500 INFO:SerialBattery:Starting dbus-serialbattery
2024-06-28 21:03:23.418778500 INFO:SerialBattery:Venus OS v3.32
2024-06-28 21:03:23.419056500 INFO:SerialBattery:dbus-serialbattery v1.3.20240624
2024-06-28 21:03:39.777809500 INFO:SerialBattery:Init of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 21:03:39.778152500 INFO:SerialBattery:Test of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 21:03:44.787756500 ERROR:SerialBattery:>>> ERROR: Unable to connect with BLE device
2024-06-28 21:03:44.789539500 ERROR:SerialBattery:No BMS found at A5:C2:37:27:05:C2
2024-06-28 21:03:44.789855500 ERROR:SerialBattery:ERROR >>> No battery connection at LltJbd_Ble
2024-06-28 21:03:45.087142500 INFO:SerialBattery:BLE client disconnected
2024-06-28 21:03:45.089036500 ERROR:SerialBattery:BleakClient(): Exception occurred: BleakError('failed to discover services, device disconnected') of type <class 'bleak.exc.BleakError'> in /opt/victronenergy/dbus-serialbattery/bms/lltjbd_ble.py line #101
2024-06-28 21:03:45.291527500 
2024-06-28 21:03:45.291622500 INFO:Bluetooth details
2024-06-28 21:03:45.300690500 [CHG] Device A5:C2:37:27:05:C2 RSSI: -73
2024-06-28 21:03:45.300696500 [CHG] Device A5:C2:37:27:05:C2 RSSI: -75
2024-06-28 21:03:45.357625500 Attempting to disconnect from A5:C2:37:27:05:C2
2024-06-28 21:03:45.357631500 Successful disconnected

Installation of actual driver (and afterwards also nightly build)
root@raspberrypi4:~# bash /tmp/install.sh

Fetch current version numbers... done.

** Currently installed version: v1.2.20240408 **

1) latest release "v1.3.20240624" (mr-manuel's repo, stable, most up to date)
2) beta build "v1.3.20240615beta" (mr-manuel's repo, no errors after 72 h runtime, long time testing needed)
3) nightly build "v1.4.20240627dev" (mr-manuel's repo, newest features and fixes, bugs possible)
4) specific branch (mr-manuel's repo, specific feature testing)
5) specific version
6) local tar file
7) quit

Select which version you want to install and enter the corresponding number: 1
> Selected: latest release "v1.3.20240624" (mr-manuel's repo, stable, most up to date)

New QML files were installed and the GUI was restarted.
Killing old BLE battery services...

Found 2 Bluetooth BMS in the config file!

Stopping bluetooth: bluetoothd.

Checking required packages to use Bluetooth connection...

done.

Starting bluetooth: bluetoothd.

Installing "LltJbd_Ble" with MAC address "A5:C2:37:27:05:C2" as dbus-blebattery.0
Installing "LltJbd_Ble" with MAC address "A5:C2:37:27:04:F4" as dbus-blebattery.1

No CAN port configuration found in "/data/etc/dbus-serialbattery/config.ini".
You can ignore this, if you are using only a serial connection.

#################
# Install notes #
#################

SERIAL battery connection: The installation is complete. You don't have to do anything more.

BLUETOOTH battery connection: There are a few more steps to complete installation.

    1. Add your Bluetooth BMS to the config file "/data/etc/dbus-serialbattery/config.ini".
       Check the default config file "/data/etc/dbus-serialbattery/config.default.ini" for more informations.
       If your Bluetooth BMS are nearby you can show the MAC address with "bluetoothctl devices".

    2. Make sure to disable Bluetooth in "Settings -> Bluetooth" in the remote console/GUI to prevent reconnects every minute.

    3. Re-run "/data/etc/dbus-serialbattery/reinstall-local.sh", if the Bluetooth BMS were not added to the "config.ini" before.

    ATTENTION!
    If you changed the default connection PIN of your BMS, then you have to pair the BMS first using OS tools like the "bluetoothctl".
    See https://wiki.debian.org/BluetoothUser#Using_bluetoothctl for more details.

CAN battery connection: There are a few more steps to complete installation.

    1. Add your CAN port to the config file "/data/etc/dbus-serialbattery/config.ini".
       Check the default config file "/data/etc/dbus-serialbattery/config.default.ini" for more informations.

    2. Make sure to select a profile with 250 kbit/s in "Settings -> Services -> VE.Can port -> CAN-bus profile" in the remote console/GUI.

    3. Re-run "/data/etc/dbus-serialbattery/reinstall-local.sh", if the CAN port was not added to the "config.ini" before.

CUSTOM SETTINGS: If you want to add custom settings, then check the settings you want to change in "/data/etc/dbus-serialbattery/config.default.ini"
                 and add them to "/data/etc/dbus-serialbattery/config.ini" to persist future driver updates.

GUIv2: If you want to try the new GUIv2 follow this link:
       https://github.com/mr-manuel/venus-os_dbus-serialbattery/tree/master/gui-v2

*** dbus-serialbattery v1.3.20240624 was installed. ***

Newer nighty build driver:
2024-06-28 22:12:34.915600500 ERROR:SerialBattery:No BMS found at A5:C2:37:27:05:C2
2024-06-28 22:12:34.915605500 ERROR:SerialBattery:ERROR >>> No battery connection at LltJbd_Ble
2024-06-28 22:12:44.511749500 ERROR:SerialBattery:BleakClient(): asyncio.exceptions.TimeoutError: TimeoutError() of type <class 'asyncio.exceptions.TimeoutError'> in /opt/victronenergy/dbus-serialbattery/bms/lltjbd_ble.py line #101
2024-06-28 22:12:44.758772500 
2024-06-28 22:12:44.758866500 INFO:Bluetooth details
2024-06-28 22:12:44.811914500 Attempting to disconnect from A5:C2:37:27:05:C2
2024-06-28 22:12:44.811919500 Successful disconnected
2024-06-28 22:12:49.885401500 Device A5:C2:37:27:05:C2 (public)
2024-06-28 22:12:49.885406500   Alias: Gelbgrn
2024-06-28 22:12:49.885408500   Paired: no
2024-06-28 22:12:49.885411500   Trusted: no
2024-06-28 22:12:49.885413500   Blocked: no
2024-06-28 22:12:49.885415500   Connected: no
2024-06-28 22:12:49.885417500   LegacyPairing: no
2024-06-28 22:12:49.886581500 
2024-06-28 22:12:50.683348500 INFO:SerialBattery:
2024-06-28 22:12:50.683710500 INFO:SerialBattery:Starting dbus-serialbattery
2024-06-28 22:12:50.684632500 INFO:SerialBattery:Venus OS v3.34
2024-06-28 22:12:50.684904500 INFO:SerialBattery:dbus-serialbattery v1.4.20240627dev
2024-06-28 22:13:07.052430500 INFO:SerialBattery:Init of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 22:13:07.052794500 INFO:SerialBattery:Test of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 22:13:12.065499500 ERROR:SerialBattery:>>> ERROR: Unable to connect with BLE device
2024-06-28 22:13:12.067158500 ERROR:SerialBattery:No BMS found at A5:C2:37:27:05:C2
2024-06-28 22:13:12.067441500 ERROR:SerialBattery:ERROR >>> No battery connection at LltJbd_Ble
2024-06-28 22:13:17.540568500 
2024-06-28 22:13:17.545249500 INFO:Bluetooth details
2024-06-28 22:13:17.571010500 [CHG] Device A5:C2:37:27:05:C2 RSSI: -79
2024-06-28 22:13:17.605544500 Attempting to disconnect from A5:C2:37:27:05:C2
2024-06-28 22:13:17.605549500 [CHG] Device A5:C2:37:27:05:C2 RSSI is nil
2024-06-28 22:13:17.605552500 [CHG] Device A5:C2:37:27:04:F4 RSSI is nil
2024-06-28 22:13:17.605555500 [CHG] Device E7:F8:39:76:DD:2E RSSI is nil
2024-06-28 22:13:17.605558500 [CHG] Device E1:1B:88:8E:6E:B9 RSSI is nil
2024-06-28 22:13:17.605562500 [CHG] Device E5:8B:6D:58:2F:D4 RSSI is nil
2024-06-28 22:13:17.605565500 [CHG] Controller DC:A6:32:26:52:94 Discovering: no
2024-06-28 22:13:17.605629500 Successful disconnected
2024-06-28 22:13:22.669682500 Device A5:C2:37:27:05:C2 (public)
2024-06-28 22:13:22.669687500   Alias: Gelbgrn
2024-06-28 22:13:22.669689500   Paired: no
2024-06-28 22:13:22.669692500   Trusted: no
2024-06-28 22:13:22.669694500   Blocked: no
2024-06-28 22:13:22.669696500   Connected: no
2024-06-28 22:13:22.669698500   LegacyPairing: no
2024-06-28 22:13:22.670686500 
2024-06-28 22:13:23.404845500 INFO:SerialBattery:
2024-06-28 22:13:23.405233500 INFO:SerialBattery:Starting dbus-serialbattery
2024-06-28 22:13:23.406355500 INFO:SerialBattery:Venus OS v3.34
2024-06-28 22:13:23.406702500 INFO:SerialBattery:dbus-serialbattery v1.4.20240627dev
2024-06-28 22:13:39.809915500 INFO:SerialBattery:Init of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 22:13:39.810284500 INFO:SerialBattery:Test of LltJbd_Ble at A5:C2:37:27:05:C2
2024-06-28 22:13:44.823378500 ERROR:SerialBattery:>>> ERROR: Unable to connect with BLE device
2024-06-28 22:13:44.825244500 ERROR:SerialBattery:No BMS found at A5:C2:37:27:05:C2
2024-06-28 22:13:44.825577500 ERROR:SerialBattery:ERROR >>> No battery connection at LltJbd_Ble
2024-06-28 22:13:46.666743500 
2024-06-28 22:13:46.666747500 INFO:Bluetooth details
2024-06-28 22:13:46.699320500 Attempting to disconnect from A5:C2:37:27:05:C2
2024-06-28 22:13:46.699324500 Successful disconnected

Any other information that may be helpful

with older version of driver (April? ) the 2 BMS are visible in Venus with all information, but after 2 days of operation the connection was broken. After installation of new driver I had connection to "grey"-BMS again, but also lost this after Updating Venus OS to 3.34

mr-manuel commented 4 months ago

With v1.2.20240408 it worked, correct? Could you write me on Discord? Since I would like to connect to your system for troubleshooting.

WP-Rue commented 4 months ago

I have to install discord first… And yes- with the older version it worked…

WP-Rue commented 4 months ago

Sorry - we have to postpone it. I‘ll be abroad the next 3 weeks.

mr-manuel commented 1 month ago

I troubleshooted the Bluetooth problems now way over 100 hours and found no real solution to all this problems. Therefore I decided to not put any other effort into the Bluetooth part. Another reason is, that the users apparently do not appreciate the work I do and they cannot immagine how much time consuming this all is.

For that 1-2 donations, if at all, a month on over 9.000 dbus-serialbattery installations it is not worth it. If everyone would donate 1 €/year then the motivation would be another, but that is not the case.

Feel free to open a PR in my repository to help me with this :-)