Louisvdw / dbus-serialbattery

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

Many attempts to have battery be recognized. #861

Closed rldoose closed 8 months ago

rldoose commented 10 months ago

Describe the problem

I have tried to get my battery to be recognized with no success. Have tried on RPi 3 and RPi 4 with same results. On each I have tried 2 different 485 converters which I have confirmed are on USB0. Running svstat /service/dbus-serialbattery.tty* shows a new PID after running about 35 sec.

Driver version

v1.0.20230531

Venus OS device type

Raspberry Pi

Venus OS version

v3.12

BMS type

Smart BMS (LLT, JBD, Overkill Solar)

Cell count

4

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 = 200.0
MAX_BATTERY_DISCHARGE_CURRENT = 200.0

; --------- Cell Voltages ---------
; Description: Cell min/max voltages which are used to calculate the min/max battery voltage
; Example: 16 cells * 3.45V/cell = 55.2V max charge voltage. 16 cells * 2.90V = 46.4V min discharge voltage
MIN_CELL_VOLTAGE   = 2.5
; Max voltage can seen as absorption voltage
MAX_CELL_VOLTAGE   = 3.650
FLOAT_CELL_VOLTAGE = 3.375

; --------- Bluetooth BMS ---------
; Description: List the Bluetooth BMS here that you want to install
; -- Available Bluetooth BMS:
; Jkbms_Ble, LltJbd_Ble
; Example:
;     1 BMS: Jkbms_Ble C8:47:8C:00:00:00
;     3 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 C3:27:20:37:C1:A4

Relevant log output

root@raspberrypi2:~# tail -n 120 /data/log/serial-starter/current | tai64nlocal
2023-11-11 02:09:31.763214500 *** starting serial-starter ***
2023-11-11 02:09:32.451225500 serstart starting
2023-11-11 02:09:32.464111500 INFO: loading config file /etc/venus/serial-starter.conf
2023-11-11 02:09:33.701595500 INFO: loading config file /data/conf/serial-starter.d/dbus-serialbattery.conf
2023-11-11 02:09:36.563239500 ERROR: no service template for dbus-serialbattery
2023-11-11 02:09:40.424846500 INFO: Create daemontools service gps-dbus.ttyUSB0
2023-11-11 02:09:46.709863500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:09:57.577881500 INFO: Create daemontools service vedirect-interface.ttyUSB0
2023-11-11 02:10:03.737105500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:10:09.272522500 INFO: Create daemontools service dbus-cgwacs.ttyUSB0
2023-11-11 02:10:15.360267500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:10:35.396605500 INFO: Create daemontools service dbus-fzsonick-48tl.ttyUSB0
2023-11-11 02:10:41.456484500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:10:44.898061500 INFO: Create daemontools service dbus-imt-si-rs485tc.ttyUSB0
2023-11-11 02:10:50.943755500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:10:54.208047500 INFO: Create daemontools service dbus-modbus-client.serial.ttyUSB0
2023-11-11 02:11:00.251687500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:11:07.551694500 INFO: Create daemontools service dbus-serialbattery.ttyUSB0
2023-11-11 02:11:13.590270500 INFO: Start service dbus-serialbattery.ttyUSB0 once
2023-11-11 02:11:47.208052500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:11:56.504409500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:12:01.754714500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:12:07.009686500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:12:10.241814500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:12:13.474030500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:12:20.750843500 INFO: Start service dbus-serialbattery.ttyUSB0 once
2023-11-11 02:12:58.356944500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:13:07.651340500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:13:12.903727500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:13:18.157821500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:13:21.387112500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:13:24.616545500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:13:31.887673500 INFO: Start service dbus-serialbattery.ttyUSB0 once
2023-11-11 02:14:09.488326500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:14:18.783863500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:14:24.035593500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:14:29.292981500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:14:32.523918500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:14:35.753054500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:14:43.026388500 INFO: Start service dbus-serialbattery.ttyUSB0 once
2023-11-11 02:15:20.630162500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:15:29.928037500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:15:35.180551500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:15:40.435448500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:15:43.665052500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:15:46.893997500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:15:54.168582500 INFO: Start service dbus-serialbattery.ttyUSB0 once
2023-11-11 02:16:31.771166500 INFO: Start service gps-dbus.ttyUSB0 once
2023-11-11 02:16:41.087099500 INFO: Start service vedirect-interface.ttyUSB0 once
2023-11-11 02:16:46.342549500 INFO: Start service dbus-cgwacs.ttyUSB0 once
2023-11-11 02:16:51.597562500 INFO: Start service dbus-fzsonick-48tl.ttyUSB0 once
2023-11-11 02:16:54.835965500 INFO: Start service dbus-imt-si-rs485tc.ttyUSB0 once
2023-11-11 02:16:58.068091500 INFO: Start service dbus-modbus-client.serial.ttyUSB0 once
2023-11-11 02:17:05.343827500 INFO: Start service dbus-serialbattery.ttyUSB0 once

root@raspberrypi2:~# tail -n 120 /data/log/dbus-serialbattery.ttyUSB0/current | tai64nlocal
2023-11-11 02:16:22.677114500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:22.677564500 INFO:SerialBattery:Testing HLPdataBMS4S
2023-11-11 02:16:27.189001500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:27.189453500 INFO:SerialBattery:Testing Jkbms
2023-11-11 02:16:27.457088500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:27.458584500 INFO:SerialBattery:Testing Lifepower
2023-11-11 02:16:27.727583500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:27.728906500 INFO:SerialBattery:Testing LltJbd
2023-11-11 02:16:27.996588500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:27.997875500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:16:28.265329500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:28.266882500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:16:28.535960500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:28.537395500 INFO:SerialBattery:Testing Seplos
2023-11-11 02:16:29.544598500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:16:30.045891500 ERROR:SerialBattery:ERROR >>> No battery connection at /dev/ttyUSB0
2023-11-11 02:16:30.046014500 
2023-11-11 02:17:06.433797500 INFO:SerialBattery:Starting dbus-serialbattery
2023-11-11 02:17:06.434714500 INFO:SerialBattery:dbus-serialbattery v1.0.20230531
2023-11-11 02:17:06.435153500 INFO:SerialBattery:Testing Daly
2023-11-11 02:17:06.561845500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:06.562341500 INFO:SerialBattery:Testing Daly
2023-11-11 02:17:06.688160500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:06.688635500 INFO:SerialBattery:Testing Ecs
2023-11-11 02:17:06.748065500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:06.748528500 INFO:SerialBattery:Testing HeltecModbus
2023-11-11 02:17:10.428156500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:10.428612500 INFO:SerialBattery:Testing HLPdataBMS4S
2023-11-11 02:17:14.940243500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:14.940684500 INFO:SerialBattery:Testing Jkbms
2023-11-11 02:17:15.208235500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:15.209593500 INFO:SerialBattery:Testing Lifepower
2023-11-11 02:17:15.476825500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:15.478264500 INFO:SerialBattery:Testing LltJbd
2023-11-11 02:17:15.745366500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:15.746723500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:17:16.017591500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:16.018879500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:17:16.286428500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:16.287709500 INFO:SerialBattery:Testing Seplos
2023-11-11 02:17:17.295083500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:17.796364500 INFO:SerialBattery:Testing Daly
2023-11-11 02:17:17.922825500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:17.923295500 INFO:SerialBattery:Testing Daly
2023-11-11 02:17:18.049085500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:18.049560500 INFO:SerialBattery:Testing Ecs
2023-11-11 02:17:18.459227500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:18.459762500 INFO:SerialBattery:Testing HeltecModbus
2023-11-11 02:17:22.134707500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:22.135138500 INFO:SerialBattery:Testing HLPdataBMS4S
2023-11-11 02:17:26.647559500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:26.647567500 INFO:SerialBattery:Testing Jkbms
2023-11-11 02:17:26.914590500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:26.916102500 INFO:SerialBattery:Testing Lifepower
2023-11-11 02:17:27.185663500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:27.189652500 INFO:SerialBattery:Testing LltJbd
2023-11-11 02:17:27.455803500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:27.457351500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:17:27.725224500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:27.726852500 INFO:SerialBattery:Testing Renogy
2023-11-11 02:17:27.995208500 ERROR:SerialBattery:>>> ERROR: No reply - returning
2023-11-11 02:17:27.996724500 INFO:SerialBattery:Testing Seplos
2023-11-11 02:17:29.004270500 ERROR:SerialBattery:>>> ERROR: No reply - returning

root@raspberrypi2:~# ls -l /dev/ttyUSB*
crw-rw----    1 root     dialout   188,   0 Nov 11 02:17 /dev/ttyUSB0

root@raspberrypi2:~# head /data/var/lib/serial-starter/*
sbattery

root@raspberrypi2:~# 
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: down 27 seconds, normally up
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: down 33 seconds, normally up
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: up (pid 8149) 2 seconds
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: up (pid 8149) 19 seconds
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: down 6 seconds, normally up
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: down 21 seconds, normally up
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: up (pid 8716) 2 seconds
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: up (pid 8716) 31 seconds
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: up (pid 8716) 35 seconds
root@raspberrypi2:~# svstat /service/dbus-serialbattery.tty*
/service/dbus-serialbattery.ttyUSB0: down 1 seconds, normally up
root@raspberrypi2:~#

Any other information that may be helpful

No response

mr-manuel commented 10 months ago
  1. Is the BMS working, if you connect it to the PC?
  2. Did the BMS work in a previous version of this driver like v0.14.3 or is this a new installation?
  3. Did you try the nightly of the dev branch?
beliffm commented 10 months ago
  1. is the interface on the BMS-side really RS485? The connector marked RS485 is not a sufficient indication for the presence of the interface. Maybe a picture showing the label might shed some light on the matter
rldoose commented 10 months ago

The BMS works via BLE and the Xiaoxiang app.  This is a new installation so I will try the builds you suggest below.

rldoose commented 10 months ago

OK, I’m now questioning if my BMS is actually 485 (as you mentioned earlier). I was thrown by "Other BMS that use the Xiaoxiang phone app”, but I now realize that this probably only applies to Bluetooth as that is how the app connects to the BMS?

The BMS is branded RadioB, and all that it says about the comm is “UART”. The XiaoxiangBMS app shows it as JBD-SP04S034, so I’m sure it is a rebranded Jiabaida. I now see that there are options from Jiabaida in both UART and UART RS485 so I can’t be sure of RS485, and don’t know how to tell.

So, I’m going to go back to trying Bluetooth with the nightly build and hope the Bluetooth install does not hang. Would you agree with this approach?

mr-manuel commented 10 months ago

Yes, you could maybe try a USB to UART adapter instead of RS485.

beliffm commented 10 months ago

Normally, those BMSs come in different flavours like UART, Heat, RS485 etc. They are listed on a label on front. If RS485 is not mentioned there..... The bluetooth interface is plugged into the UART connector.

mr-manuel commented 9 months ago

@rldoose any updates on this?

rldoose commented 9 months ago

So appreciate you checking.  My Starlink failed, and they have shipped me a new unit.  But I won’t have it until the 29th.  Then we will be taking a trip for ten days.  So, I won’t be able to resume this project until after Dec 10fh.  But, we will be sitting still after that, so I will hit it hard then.

mr-manuel commented 9 months ago

@rldoose any updates on this?

rldoose commented 9 months ago

I just got my Starlink back, so I’m ready to resume. Will probably be able to work on it tomorrow. So appreciate your help and communication! Above and beyond.

Sent from iPhone

On Sun, Dec 17, 2023 at 07:03 Manuel @.***> wrote:

@rldoose https://github.com/rldoose any updates on this?

— Reply to this email directly, view it on GitHub https://github.com/Louisvdw/dbus-serialbattery/issues/861#issuecomment-1859181943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBAH47R2NZVIBOJ3XGMCUDYJ33UZAVCNFSM6AAAAAA7G5BZJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGE4DCOJUGM . You are receiving this because you were mentioned.Message ID: @.***>

rldoose commented 9 months ago

I just sat down to resume this project. Since I mistakenly started out attempting to use a 485 converter on a UART BMS, I was planning on trying BT. But I see the note that says “The Bluetooth and CAN connections are still not stable on some systems. If you want to have a stable connection use the serial connection.” I also no longer see the instructions for BT in the documentation.

I would rather be hard wired anyway, but I will have to order in the converter so I will be a few more days waiting on that. But I’m a little confused. I thought a UART was a piece of hardware that could be used for many different things/protocols, but I may be mistaken. Is a UART to USB a one size fits all proposition, or do I need a specific "flavor”? Any recommendations on what device to buy?

Reagan

On Dec 17, 2023, at 07:03, Manuel @.***> wrote:

@rldoose https://github.com/rldoose any updates on this?

— Reply to this email directly, view it on GitHub https://github.com/Louisvdw/dbus-serialbattery/issues/861#issuecomment-1859181943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBAH47R2NZVIBOJ3XGMCUDYJ33UZAVCNFSM6AAAAAA7G5BZJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGE4DCOJUGM. You are receiving this because you were mentioned.

mr-manuel commented 9 months ago

I like the one from duppa.net, but currently it's sold out: https://www.duppa.net/shop/isolated-debug-board/

Maybe the one with four ports could also be interesting for you: https://www.duppa.net/shop/isolated-4-port-usb-to-ttl-uart-ftdi/

Albarge commented 8 months ago

Is a UART to USB a one size fits all proposition, or do I need a specific "flavor”? Any recommendations on what device to buy? Reagan

Maybe, but be careful on cheap non isolated adaptors picking up too much interference.

I can recommend the "Waveshare USB to RS232/485/TTL Converter Industrial Optically Isolated Converter with FT232RL Inside" https://amzn.eu/d/epY9Mym

My batteries are 10m from the Cerbo GX using a shielded USB cable, with powered USB HUB for the converters.

I have 3 of the Waveshare converters on 3 x JK BMS's with their RS485 converter (TTL to RS485, before I realised I didn't need it), but the Waveshare also accepts TTL directly or RS485, so for me, if the JK converter stops working I could just take the TTL directly from the BMS GPS port, but it will work for other BMS's with either, just make sure to use a twisted pair cable to it for RS485, It was absolutely necessary for me.

I originally bought a SDS Tech USB to console cable with CH340C chip, that claimed to be RS485 too- That didn't work though for RS485.

I then bought the cheap tiny USB to RS485 adaptors with A and B screws with the CH340E chip and the PL2303HX chip, found all over amazon and eBay - They did work, but I had high dbus round trip times, and they'd drop out, so too unreliable, and not isolated.

So I then bit the bullet and got the Waveshare, and now they're solid with the dbus-serialbattery driver. Also they have their own isolated 3.3v or 5v power supply for the TTL, so no faffing around with a dc-dc converter from the BMS to power each converter like the duppa.net board needs.

rldoose commented 8 months ago

Success! What a trial this has been. Finally received the proper converter only to have my RPi fail…. But, finally, with all the correct pieces and parts, it worked first crack out of the box! Can’t thank you enough for sticking with me, and continuing to check in on me. Now it is onto battery aggregation!

Reagan

On Dec 22, 2023, at 12:42, Al @.***> wrote:

Is a UART to USB a one size fits all proposition, or do I need a specific "flavor”? Any recommendations on what device to buy? Reagan

Maybe, but be careful on cheap non isolated adaptors picking up too much interference.

I can recommend the "Waveshare USB to RS232/485/TTL Converter Industrial Optically Isolated Converter with FT232RL Inside" https://amzn.eu/d/epY9Mym

My batteries are 10m from the Cerbo GX using a shielded USB cable, with powered USB HUB for the converters.

I have 3 of the Waveshare converters on 3 x JK BMS's with their RS485 converter (TTL to RS485, before I realised I didn't need it), but the Waveshare also accepts TTL directly or RS485, so for me, if the JK converter stops working I could just take the TTL directly from the BMS GPS port, but it will work for other BMS's with either, just make sure to use a twisted pair cable to it for RS485, It was absolutely necessary for me.

I originally bought a SDS Tech USB to console cable with CH340C chip, that claimed to be RS485 too- That didn't work though for RS485.

I then bought the cheap tiny USB to RS485 adaptors with A and B screws with the CH340E chip and the PL2303HX chip, found all over amazon and eBay - They did work, but I had high dbus round trip times, and they'd drop out, so too unreliable, and not isolated.

So I then bit the bullet and got the Waveshare, and now they're solid with the dbus-serialbattery driver. Also they have their own isolated 3.3v or 5v power supply for the TTL, so no faffing around with a dc-dc converter from the BMS to power each converter like the duppa.net board needs.

— Reply to this email directly, view it on GitHub https://github.com/Louisvdw/dbus-serialbattery/issues/861#issuecomment-1868056704, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBAH432QYIYUYHQH7XIJPTYKXWFBAVCNFSM6AAAAAA7G5BZJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGA2TMNZQGQ. You are receiving this because you were mentioned.