diy solar

diy solar

Victron VenusOS driver for Bluetooth BMS

This is awesome. Installed and running now. I have two batteries in parallel so looking forward to updated support for that.

I am able to run two seperate processes to get two entries in the display running. Its not elegant or the right way to do it but it works.

I setup a second "service" for the second battery and modify the run command to point to the below dbus-btbattery(1|2).py files.

/opt/victronenergy/service/dbus-btbattery/run
and
/opt/victronenergy/service/dbus-btbattery2/run

I created two copys of both dbus-btbattery.py and jbdbt.py

dbus-btbattery1.py
jbdbt1.py
and
dbus-btbattery2.py
jbdbt2.py

jbdbt.py had line 155 editied with the new name for the display.
dbus-btbattery was edited to import the corisponding jbdbt(1|2).py file.

View attachment 144361
@emerge411 Might you be able to share more regarding this? I have Brad's solution up and running and it works great, especially with the automated reconnect. But I have another battery in parallel and your solution looks to be the only avenue at the moment. I am a novice at all of this SSH stuff, I know I need to jump into the files with a text editor but unsure what next steps would be.
 
Hi Brad, thanks for putting this together - comes as good timing given I've just built my own JK BMS based battery for my van.

I've got everything working while I'm logged in to my Pi via ssh, but if I close the SSH connection with the script running I lose connection to the battery, and setting it to autostart using the settings in your readme doesn't seem to work. Sorry if I'm being a total idiot here...

EDIT: Yes I was being a total idiot - I forgot to change directory before cloning the git repo. All working now - thanks for your hard work, its a great tool
 
Last edited:
all went fine until step 7 can you help?



root@raspberrypi4:~# pip3 install bluepy
Collecting bluepy
Using cached bluepy-1.3.0.tar.gz (217 kB)
Installing collected packages: bluepy
Running setup.py install for bluepy ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/setup.py'"'"'; __file__='"'"'/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /var/volatile/tmp/pip-record-nyg2sk1o/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/bluepy
cwd: /var/volatile/tmp/pip-install-lvgt0ou9/bluepy/
Complete output (11 lines):
running install
running build
running build_py
Working dir is /var/volatile/tmp/pip-install-lvgt0ou9/bluepy
execute make -C ./bluepy clean
execute make -C bluepy -j1
Failed to compile bluepy-helper. Exiting install.
Command was 'make -C bluepy -j1' in /var/volatile/tmp/pip-install-lvgt0ou9/bluepy
Return code was 2
Output was:
b"make: Entering directory '/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/bluepy'\ntar xzf bluez-src.tgz\ntouch ./bluez-5.47/lib/bluetooth.c ./bluez-5.47/lib/hci.c ./bluez-5.47/lib/sdp.c ./bluez-5.47/lib/uuid.c ./bluez-5.47/attrib/att.c ./bluez-5.47/attrib/gatt.c ./bluez-5.47/attrib/gattrib.c ./bluez-5.47/attrib/utils.c ./bluez-5.47/btio/btio.c ./bluez-5.47/src/log.c ./bluez-5.47/src/shared/mgmt.c ./bluez-5.47/src/shared/crypto.c ./bluez-5.47/src/shared/att.c ./bluez-5.47/src/shared/queue.c ./bluez-5.47/src/shared/util.c ./bluez-5.47/src/shared/io-glib.c ./bluez-5.47/src/shared/timeout-glib.c\ncc -L. -g -Wall -Os -DHAVE_CONFIG_H -I./bluez-5.47/attrib -I./bluez-5.47 -I./bluez-5.47/lib -I./bluez-5.47/src -I./bluez-5.47/gdbus -I./bluez-5.47/btio -I./bluez-5.47/sys -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -o bluepy-helper bluepy-helper.c ./bluez-5.47/lib/bluetooth.c ./bluez-5.47/lib/hci.c ./bluez-5.47/lib/sdp.c ./bluez-5.47/lib/uuid.c ./bluez-5.47/attrib/att.c ./bluez-5.47/attrib/gatt.c ./bluez-5.47/attrib/gattrib.c ./bluez-5.47/attrib/utils.c ./bluez-5.47/btio/btio.c ./bluez-5.47/src/log.c ./bluez-5.47/src/shared/mgmt.c ./bluez-5.47/src/shared/crypto.c ./bluez-5.47/src/shared/att.c ./bluez-5.47/src/shared/queue.c ./bluez-5.47/src/shared/util.c ./bluez-5.47/src/shared/io-glib.c ./bluez-5.47/src/shared/timeout-glib.c -lglib-2.0\ncc: fatal error: cannot execute \xe2\x80\x98cc1\xe2\x80\x99: execvp: No such file or directory\ncompilation terminated.\nmake: *** [Makefile:30: bluepy-helper] Error 1\nmake: Leaving directory '/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/bluepy'\n"
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/setup.py'"'"'; __file__='"'"'/var/volatile/tmp/pip-install-lvgt0ou9/bluepy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /var/volatile/tmp/pip-record-nyg2sk1o/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/bluepy Check the logs for full command output.
 
Will this driver work on a Cerbo GX? I have 3 AOLithium 100Ah / 12v batteries with the JDB BMS and bluetooth is the only connection option.

Also, I have only limited experience in this area… is this something I should be attempting?
 
@BradCagle This was working fantastic for me with my Cerbo GX (albeit every once in a while it would disconnect and throw errors, but it would fix itself after rebooting for some time) but now I cannot get it to work any longer.
 
@BradCagle This was working fantastic for me with my Cerbo GX (albeit every once in a while it would disconnect and throw errors, but it would fix itself after rebooting for some time) but now I cannot get it to work any longer.

Have you tried to power cycle your Cerbo GX? I sometimes have to do a full power cycle on mine.
 
Hey all

I wanted to chime in on this discussion to see if there is any possibility of making this work with my set-up.

I have just received my 4 Renogy Bluetooth batteries ($499 CDN ea) and I was hoping i could integrate them into my Cerbo but I'm not too sure how to go about it. I know the smart batteries can be accessed via the rs485 connection using the serial driver, so I would assume that we could do the same with this setup as long as I can get a connection to the batteries.

I'm quite computer saavy, but not a programmer. If someone would like to shepherd me through this, hopefully we could be able to offer this to the community. I'm suspecting these batteries will become quite popular considering the price point.
 
IIRC, @BradCagle isn't developing it anymore, and @Louisvdw 's version now supports bluetooth.


Renogy is on the BMS support list.

Recommend you scour the site and make your best effort:


Multiple batteries require additional drivers:


I will state that I found the bluetooth reliability to be unacceptable from either source; however, in the newer Venus OS, it could be installed as a battery monitor only without actual control of the system. I would likely be willing to use bluetooth that way.

I'm using a JBD with UART to USB adapter to a RPi running Venus 3.10 with @Louisvdw 's driver. It is not interfaced with any other Victron equipment - simply a test system. Here's a 30 day plot for giggles:

1697146292319.png

I would consider putting this battery in control of a Victron system via direct UART to USB connection.

Also worth exploring:

 
IIRC, @BradCagle isn't developing it anymore, and @Louisvdw 's version now supports bluetooth.


Renogy is on the BMS support list.

Recommend you scour the site and make your best effort:


Multiple batteries require additional drivers:


I will state that I found the bluetooth reliability to be unacceptable from either source; however, in the newer Venus OS, it could be installed as a battery monitor only without actual control of the system. I would likely be willing to use bluetooth that way.

I'm using a JBD with UART to USB adapter to a RPi running Venus 3.10 with @Louisvdw 's driver. It is not interfaced with any other Victron equipment - simply a test system. Here's a 30 day plot for giggles:

View attachment 172011

I would consider putting this battery in control of a Victron system via direct UART to USB connection.

Also worth exploring:

Thank you for all the links. I will do some exploring.
 
IIRC, @BradCagle isn't developing it anymore, and @Louisvdw 's version now supports bluetooth.


Renogy is on the BMS support list.

Recommend you scour the site and make your best effort:


Multiple batteries require additional drivers:


I will state that I found the bluetooth reliability to be unacceptable from either source; however, in the newer Venus OS, it could be installed as a battery monitor only without actual control of the system. I would likely be willing to use bluetooth that way.

I'm using a JBD with UART to USB adapter to a RPi running Venus 3.10 with @Louisvdw 's driver. It is not interfaced with any other Victron equipment - simply a test system. Here's a 30 day plot for giggles:

View attachment 172011

I would consider putting this battery in control of a Victron system via direct UART to USB connection.

Also worth exploring:

I see with the initial overview of the github that although @Louisvdw's project supports the Renogy BMS as well as Bluetooth, it does not support Renogy over bluetooth, only JKBMS/Heltec and Smart BMS. This looks like it may require some development.
1697150481120.png
 
I see with the initial overview of the github that although @Louisvdw's project supports the Renogy BMS as well as Bluetooth, it does not support Renogy over bluetooth, only JKBMS/Heltec and Smart BMS. This looks like it may require some development.

You are correct. In addition to the documentation, it is clear in the configuration file that the BT is only available for JK and JBD.

Again, I would discourage use of BT. If you can connect via RS485 or UART, that's the preferred method by far. You don't want to have to reboot your GX device regularly to maintain contact with the BMS(s).
 
You are correct. In addition to the documentation, it is clear in the configuration file that the BT is only available for JK and JBD.

Again, I would discourage use of BT. If you can connect via RS485 or UART, that's the preferred method by far. You don't want to have to reboot your GX device regularly to maintain contact with the BMS(s).
I agree, bluetooth isn't the best option, but the bluetooth smart batteries don't have a hard wired option or I would go that route. I (incorrectly) made the assumption when I purchased the batteries that they would have the 485 connection, but they do not. I was a bit surprised when I unboxed to find a portless battery.
 
I agree, bluetooth isn't the best option, but the bluetooth smart batteries don't have a hard wired option or I would go that route. I (incorrectly) made the assumption when I purchased the batteries that they would have the 485 connection, but they do not. I was a bit surprised when I unboxed to find a portless battery.

then I would encourage you to disable BMS control in Venus OS 3.10 and only use the GX/VRM for battery monitoring. I absolutely, positively would not put a BT connected BMS in control of my system.
 
then I would encourage you to disable BMS control in Venus OS 3.10 and only use the GX/VRM for battery monitoring. I absolutely, positively would not put a BT connected BMS in control of my system.
Yeah it seems a bit risky. I've got a smart shunt I can rely on. Appreciate your input
 
Yeah it seems a bit risky. I've got a smart shunt I can rely on. Appreciate your input

FWIW, the the shunt doesn't do any control. With DVCC enabled, you can activate SVS, SCS and STS (if a temperature sensor is installed), and the shunt data can be passed to all devices making battery voltage, current and temperature constant for all GX connected devices.

The BMS connected via RS485 or UART could actually control the system based on cell level triggers.
 
I ended up returning the batteries and getting the ones with RS485 connections on them. That gives me what I need for proper control
 
Hi All,
I have been using this in my Truck and it's been working well thanks @BradCagle for the project.
I built a new PI for a friend for his truck and tested it against one of my batteries and it worked fine.
His JBD 4s works ok with the APP on his iPhone but when it connects from the PI it pauses for a few seconds and then reports the following error:

root@raspberrypi2:/opt/victronenergy/dbus-btbattery# ./dbus-btbattery.py A4:C1:37:23:45:21
INFO:BluetoothBattery:Starting dbus-btbattery
INFO:BluetoothBattery:dbus-btbattery v0.1.3
INFO:BluetoothBattery:Connecting A4:C1:37:23:45:21
INFO:BluetoothBattery:0.0017201560000046356
INFO:BluetoothBattery:0.002624010000005228
INFO:BluetoothBattery:Connected A4:C1:37:23:45:21
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 105, in run
while self.bt.waitForNotifications(0.5):
File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 560, in waitForNotifications
resp = self._getResp(['ntfy','ind'], timeout)
File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 416, in _getResp
self.delegate.handleNotification(hnd, data)
File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 159, in handleNotification
self.cellData = self.cellData + data
TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes'
^[[B^[[INFO:BluetoothBattery:60.07307914399999

Any suggestions are gratefully received.
Thanks, Rich
 
Hello, I have seen that I need to modify commands in Nano to keep the JBD Bluetooth BMS connected or at least restart. I go to nano, but that is where I lose my way. I did see the part in the readme about making the change, but I don't see where to make that change. Any assistance would be greatly appreciated.
 
I created a Bluetooth version of @Louisvdw serial driver


It's still very early work-in-progress. It only supports JBD BMS at the moment.

Code is here: https://github.com/bradcagle/dbus-btbattery
Instructions on how to get it going is in the README.md



If you need to setup a Raspberry Pi you can watch my how-to video

Hi Brad, Thank you so much for the very helpful instructions! I am able to start the BT BMS in Venus OS but it shuts off as soon as I close Putty. I see the instructions for Nano, but I have no idea where to make the change. I would be very grateful for some directions for this.
Thank you!

To make dbus-btbattery startup automatically​

nano service/run
and replace 70:3e:97:08:00:62 with the Bluetooth address of your BMS/Battery
Save with "Ctrl O"
run ./installservice.sh
reboot
 
Last edited:
The most recent version has native BT support, but it must be configured to use it.

IMHO, I found that version more stable than Brad's version, but neither were stable enough for me to trust them.
 
Hi Brad, Thank you so much for the very helpful instructions! I am able to start the BT BMS in Venus OS but it shuts off as soon as I close Putty. I see the instructions for Nano, but I have no idea where to make the change. I would be very grateful for some directions for this.
Thank you!

To make dbus-btbattery startup automatically​

nano service/run
and replace 70:3e:97:08:00:62 with the Bluetooth address of your BMS/Battery
Save with "Ctrl O"
run ./installservice.sh
reboot

if you're in "/opt/victronenergy/dbus-btbattery" directory

you type "nano service/run"

replace 70:3e:97:08:00:62 with your bt address

hold ctrl + o, then hit enter to save

type ./installservice.sh

then type reboot
 
Hi All,
I have been using this in my Truck and it's been working well thanks @BradCagle for the project.
I built a new PI for a friend for his truck and tested it against one of my batteries and it worked fine.
His JBD 4s works ok with the APP on his iPhone but when it connects from the PI it pauses for a few seconds and then reports the following error:

root@raspberrypi2:/opt/victronenergy/dbus-btbattery# ./dbus-btbattery.py A4:C1:37:23:45:21
INFO:BluetoothBattery:Starting dbus-btbattery
INFO:BluetoothBattery:dbus-btbattery v0.1.3
INFO:BluetoothBattery:Connecting A4:C1:37:23:45:21
INFO:BluetoothBattery:0.0017201560000046356
INFO:BluetoothBattery:0.002624010000005228
INFO:BluetoothBattery:Connected A4:C1:37:23:45:21
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 105, in run
while self.bt.waitForNotifications(0.5):
File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 560, in waitForNotifications
resp = self._getResp(['ntfy','ind'], timeout)
File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 416, in _getResp
self.delegate.handleNotification(hnd, data)
File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 159, in handleNotification
self.cellData = self.cellData + data
TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes'
^[[B^[[INFO:BluetoothBattery:60.07307914399999

Any suggestions are gratefully received.
Thanks, Rich
Hi,

I had the same Problem and forked dbus-btbattery.
Here are my changes:
https://github.com/agilastic/dbus-btbattery/commit/1258e35d09016c18fe5d91922afc0c56fcdc931d
It works for me so far :)
Feel free to test it ;-)
 

diy solar

diy solar
Back
Top