dbus-serialbattery
dbus-serialbattery copied to clipboard
Daly BMS via can bus
Hi,
Some of the Daly BMS support a connection via can bus. That should be considerably faster than the serial connection. The protocol is also open.
So i was wondering if - technically - this could be implemented into this library as well. I could work on it and try it myself as I have such a Daly BMS with can bus, i just want to know if there could be any problems I did not see yet.
Each BMS has its own implementation of the communication (protocol), so a new BMS type Daly_CAN could be added that gets the data via can bus instead of serial, however some logic needs to detect/search for the can bus too, right?
As the cerbo for example already has VE.Bus hardware, do you by chance know, if that could be used directly? Then a RJ45 to Daly cable would be enough and I could start working on this...
Hm looks like CAN on daly is a gamble as noone really knows if they have CAN or not. Read from some guys, that only RS485 is available but not can bus, although it is printed on the case and also marked on the cables...
@SamuelBrucksch Yes, some Daly BMS also have CAN-Bus. Before I decided for the RS485 way and driver of Louisvdw, I already connected the Daly CAN Port with RJ45 to the Vicron BMS CAN, because Daly tld me the BMS can communicate with Victron. (I think this was fake news). Due that communication packages were counted, I know that the CAN-Connection was working, but the Victron did not recognizied the Daly BMS on CAN due to missing driver.
Over all, I was fighting with a lot of issues with Daly BMS, and sooner or later I will follow the recomendation of Louisvdw and use any other BMS but not the Daly anymore, to get a better performance of SOC calculation and cell management. I think a JK BMS with active balancer will be a good substitution.
How did you know CAN was working if you could not see anything except counting packages?
As soon as you connect, Venus OS sends out messages on CAN that fit to the selected CAN profile. Those should be counted on TX.
Did you also see messages on RX?
Venus OS has some CAN CLI tools like cansend, candump that you can use to send messages and see the traffic. When I tried it, i could only see the outgoing messages but could not get any reply from the Daly even when I sent requests to it via cansend.
Also how did you do the cabling? Maybe there is something wrong at my setup. I chose pins 3,7,8 as somewhere described for VE.Can.
Ok can now connect to Daly BMS via canbus. Here a sample for cells voltage:
candump can0
can0 18950140 [0]
can0 18954001 [8] 01 0D 7D 0D 7E 0D 7E 58
can0 18954001 [8] 02 0D 7E 0D 7F 0D 7E 58
can0 18954001 [8] 03 0D 7E 0D 7F 0D 7E 58
can0 18954001 [8] 04 0D 7E 0D 7E 0D 7E 58
can0 18954001 [8] 05 0D 7E 0D 7F 0D 7F 58
can0 18954001 [8] 06 0D 7F 0D 7F 0D 7F 58
Can needs to be set to 250000, requests look like this:
cansend can0 18950140#
So the request ID is 18 + Data ID + BMS ID (01) + Uplink ID (40)
Looking good, first try with python-can lib:
INFO:SerialBattery:Starting dbus-serialbattery
INFO:SerialBattery:dbus-serialbattery v0.12
INFO:SerialBattery:No Port needed
INFO:SerialBattery:Testing DalyCAN
18944001: bytearray(b'\x10\x01\x00\x00\x02\x00\x00\x00')
INFO:SerialBattery:DalyBMS 16 cells
INFO:SerialBattery:Connection established to DalyCAN
INFO:SerialBattery:DeviceInstance = 2
INFO:SerialBattery:com.victronenergy.battery.USB9
INFO:SerialBattery:Battery connected to dbus from /dev/tty/USB9
INFO:SerialBattery:DeviceInstance = 2
INFO:SerialBattery:Changed DeviceInstance = 2
INFO:SerialBattery:read_soc_data
18904001: bytearray(b'\x02\x12\x00\x00t\x9b\x03O')
INFO:SerialBattery:voltage: 530, current: -14.9, soc: 847
All data requested is from can bus
Oh yeah:
It's fully working now. Needs some cleanup, but will create a PR soon, so we can check if everything is ok. Adoption of Daly to Daly CAN was actually quite easy as the protocol behind is still the same.
Will test over night to see if it is stable enough and the voltages are reported more correctly.
Wow, this would really be great if it can be added to the driver, to work with the CAN-Bus.
PR with working code: https://github.com/Louisvdw/dbus-serialbattery/pull/169
Cell voltages from last 6h:
Seems to be stable and also the values look very nice now. No weird values anymore.
@SamuelBrucksch That looks good! What are you using to generate the cell voltages graph?
I use openhab which has Grafana integrated for visualization of the values that openhab gets. Requires influxdb additionally to that: https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761
Thanks @SamuelBrucksch, it gave me a head start. Found the Victron Grafana docker and it was super simple to install that and get the stats.
https://github.com/victronenergy/venus-docker-grafana
Thanks again @Louisvdw for this awesome driver!
Sorry for my stupididi but i need help. Iam reading and trying for hours now to get the daly bms via can to run.
I get these meassage via can bus, as in the thread before:
But how do i get the bms into the device List like this?
I did all the installation shown in the video and the text, but i wont work...
You need two terminals to test if the CAN connection works. One for candump and one for cansend. Your cansend snippet does not show any Daly messages. Also you need to execute the dbus-serialbattery code manually, as there is no CAN auto detection yet.
What is the current state of this?