question

samuel-brucksch avatar image
samuel-brucksch asked

Connecting to a can bus device from custom code

Hi,

i want to connect to a non supported BMS via can bus with 250k baudrate. So as far as i read i can't use the BMS bus as that one has a fixed baudrate of 500k. So i guess i have to use one of the VE.Can interfaces, to connect to that devices.

Can i just use one of the VE.Can interfaces and access them from code (any code sample available, e.g. in python)?

Sample projects or real life projects, that already do something like that would be really appreciated. I can do all the coding myself, just need some hints and guidance.

Thanks!
Samuel

BMSVE.Can
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
johanndo avatar image
johanndo answered ·

Have you looked in github?

There are CAN bms and serial BMS examples I think, you may look in the Cerbo code itself for the Ve.Can service...

vecan-dbus I think...


This may be also of some use....

https://github.com/kwindrem/VeCanSetup

https://github-wiki-see.page/m/victronenergy/venus/wiki/RaspberryPi-CAN-Interfaces

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

samuel-brucksch avatar image samuel-brucksch commented ·

Thanks for your response. I'm on a Cerbo and i can see that can0 and can1 are listed in

root@einstein:~# cat /etc/venus/canbus_ports
can0
can1

Also dbus-spy lists it:

com.victronenergy.vecan.can0

So the question now is how to access it. I will check if I can find more info in the victron repository, I already searched a bit but did not find anything which would help me to setup a CAN connection.

I'll check again, but if anyone has already built a project with CAN let me know.

0 Likes 0 ·
bathnm avatar image bathnm samuel-brucksch commented ·
The vecan to dbus service is closed source code so you can not modify it. As you put in your question, you could create a python script that listens on can0 (the 250kb bus) for your BMS, parse the relevant PGN data and store it in the dbus. You would need to know the PGNs that the BMS sends, and the data format. I suspect it is a lot of work, so unless your a developer and have the specifications to the BMS data formats it is sending out, I suspect you will go down many blind allies.


If you BMS utilises 500Kb CAN, then you can do the same thing, but use the can1 interface.

There are a lot of can / python example code on the web you could use to get started and open the can port and read packets. then you need to only listen to specific packets of data from your BMS and process them.

Also learn about socketcan as the tools from that will be invaluable.

0 Likes 0 ·

Related Resources

Additional resources still need to be added for this topic

Victron VE.Bus BMS product page

Victron 3rd party BMS compatibility page