question

saxofon avatar image
saxofon asked

Connect YDWG-02 to Cerbo (and possibly other venus based devices)

Hello!

Just got my YDWG-02 (nmea2000 to wifi converter) connected to Cerbo so if someone else is thinking about same, here is a brief howto :

1. git clone https://github.com/saxofon/NMEA2000-simple-c-lib

2. build via Venus OS SDK (I installed mine in a container so I have a easily reuseable build environment)

root@b610d0a314c9:/work# make

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -fPIC -Iinclude -shared -o build/libnmea2000.so src/nmea2000.c src/ydwg-02.c

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Iinclude -g -lm -lcurses -ltinfo -lpthread -Lbuild -lnmea2000 -o build/nmea2000-bus-dumper examples/nmea2000-bus-dumper.c

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Iinclude -g -lm -lcurses -ltinfo -lpthread -Lbuild -lnmea2000 -o build/nmea2000-data-viewer examples/nmea2000-data-viewer.c

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Iinclude -g -lm -lcurses -ltinfo -lpthread -Lbuild -lnmea2000 -o build/nmea2000-simple-msg examples/nmea2000-simple-msg.c

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Iinclude -g -lm -lcurses -ltinfo -lpthread -Lbuild -lnmea2000 -o build/ydwg-02-to-socketcan examples/ydwg-02-to-socketcan.c

root@b610d0a314c9:/work# make

mkdir -p build

arm-ve-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/venus/dunfell-arm-cortexa8hf-neon/sysroots/cortexa8hf-neon-ve-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Iinclude -g -lm -lcurses -ltinfo -lpthread -Lbuild -lnmea2000 -o build/ydwg-02-to-socketcan examples/ydwg-02-to-socketcan.c

root@b610d0a314c9:/work#

3. Copy stuff over to Cerbo

[per@phlap2 NMEA2000-simple-c-lib]$ scp build/* root@<your Cerbo IP>:

libnmea2000.so 100% 13KB 739.1KB/s 00:00

nmea2000-bus-dumper 100% 32KB 552.3KB/s 00:00

nmea2000-data-viewer 100% 30KB 662.3KB/s 00:00

nmea2000-simple-msg 100% 21KB 562.7KB/s 00:00

ydwg-02-to-socketcan 100% 23KB 649.9KB/s 00:00

[per@phlap2 NMEA2000-simple-c-lib]$

4. setup a vcan device

root@einstein:~# modprobe vcan

root@einstein:~# ip link add dev vcan0 type vcan

root@einstein:~# ip link set dev vcan0 down

root@einstein:~# ip link set vcan0 mtu 16

root@einstein:~# ip link set dev vcan0 up

5. run the gw app

root@einstein:~# LD_LIBRARY_PATH=. ./ydwg-02-to-socketcan

Now it pops up a vcan0 entry in the Cerbo menu, we can enable to transmit nmea2000 packets etc.

Now I just need to find out what fun stuff can be done next...


BTW... Victron, please add kernel module "can-gw" to the standard build. It will be a very helpful when doing CAN bus integrations.

Venus OS
2 |3000

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

9 Answers
saxofon avatar image
saxofon answered ·

cerbo-remote-console.png

Remote console with statistics from the vcan0 interface.


2 |3000

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

saxofon avatar image
saxofon answered ·

cerbo-can-devices-1.png

nmea2000 devices pops up in the list.


2 |3000

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

saxofon avatar image
saxofon answered ·

cerbo-can-devices-2.png

most have "device #0" but some has higher numbers.

I'm mostly interested if this would be a way to export victron battery status so it could be seen on the raymarine plotter... anyone knows howto get venus to actually use data from can devices?


2 |3000

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

saxofon avatar image
saxofon answered ·

If we login and run

root@einstein:~# TERM=vt100 LD_LIBRARY_PATH=. ./nmea2000-data-viewer

we seems to get sane data also :)

screenshot-from-2024-05-18-14-08-45.png


2 |3000

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

mvader (Victron Energy) avatar image
mvader (Victron Energy) answered ·

hey @saxofon sounds nice, can you explain what you achieved by doing these mods? In as laymen terms as possible?


Something perhaps similar is on your Cerbo enable Venus OS Large, then Signal-K Server, and then you'll also have turned your Cerbo in a N2K -> Wifi gateway.



10 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.

saxofon avatar image saxofon commented ·

Hello @mvader (Victron Energy) ,

The goal is to connect to NMEA2000 bus.

Instead of using plain oldschool cable (which I could, there is an available port for a can cable to cerbo) I'm testing with using my existing nmea2000 to wifi dongle.

It has nothing todo with SignalK messages really (although these could of course be transformed to signalk packets, I think some xml based format?) so from YDWG comes a stream of raw CAN data frames, like

[per@phlap2 NMEA2000-simple-c-lib]$ telnet 192.168.3.100 1457

Trying 192.168.3.100...

Connected to 192.168.3.100.

Escape character is '^]'.

14:21:20.704 R 19FA0400 5E 0F A1 76 48 0D 00 00

14:21:20.705 R 19FA0400 5F 00 00 F5 FF FF FF FF

14:21:20.705 R 09F80100 A0 69 70 23 50 BE E5 0A

14:21:20.706 R 19F11A00 FF FF FF FF 2C 05 FF FF

14:21:20.707 R 1CFF1F00 3B 9F FF 2C 05 FF FF FF

14:21:20.712 R 09F8012B 2C 69 70 23 74 BF E5 0A

14:21:20.722 R 09F8022B FF 00 00 00 02 00 00 00

14:21:20.729 R 09FD0219 FF C4 01 38 64 FA FF FF


So my little repo is transforming these packets into socketcan packets and act as a gateway for tx/rx on vcan0 in this case.


My end (does it ever end? ;-) ) goal would be to have victron battery data exposed on the nmea2000 bus so that on the plotter I would see those info as some standard nmea2000 data.

Another way would of course to use my plotter, have the victron app on it and sort of browse to venus.local/app... but as Raymarine plotter don't act as a normal networked wifi client (it wants to own the network) and I would have to route a network cable (expensive one as well!!) I'm playing with some normal network workarounds for it instead.

0 Likes 0 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ saxofon commented ·
Ah.. ok!

If I understand correctly its the same as connecting the VE.Can port on the Cerbo directly to the N2K network, using our cable for that or make one yourself and then enable the N2K out feature on the Cerbo GX.

1 Like 1 ·
Show more comments
saxofon avatar image
saxofon answered ·

so the data path would be something like

raymarine plotter<->n2k<->ydwg<->wifi ap<->cerbo<->bunch of victron boxes :)


2 |3000

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

macjl avatar image
macjl answered ·

Hello,


I’ve made something similar to connect YachtDevices gateways and VenusOS throught network :

https://github.com/macjl/yd2vcan

My approach was more simpler, and worked well. I don’t use it anymore, as I’ve added a USB-CAN interface to my system, but it should still work.

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.

saxofon avatar image saxofon commented ·
Oh, cool! will look into it :)
0 Likes 0 ·
saxofon avatar image saxofon saxofon commented ·
yep, very similary approach. Wonder why I couldn't find this when I researched at first :D

Also interesting to see it works for you without bothering with CAN MTU.

0 Likes 0 ·
saxofon avatar image
saxofon answered ·

Got some energy back and during morning coffee made it bidirectional.

Works fine and I see a new bunch of devices on the plotter! :)
Next step is now to figure out howto use it all in the plotter....

dsc-1132.jpg

Above the cerbo pops up as two devices for some reason...

dsc-1133.jpg

and then the battery bank finally as was a goal.

As I have two battery banks, 48V with BMS, Cerbo, Multiplus etc and the old 12V separately with a BMV712 that probably can be connected to Cerbo via a direct cable... would it be possible to add the 12V to Cerbo and it understands it is two instances so to speak of DC systems?


dsc-1132.jpg (3.0 MiB)
dsc-1133.jpg (3.1 MiB)
2 |3000

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

saxofon avatar image
saxofon answered ·

So I get a bunch of batteries for some reason... would be logic if the first four was one for each batter (my 48V bank is 4 12V ones in serie) but they show voltage from 48V nominal instead of 12V nominal...

dsc-1135.jpg

Then the last could perhaps be the total bank, correct data it is.

dsc-1134.jpg

oh well... reached goal and should probably enjoy the sunny weather instead :)

A good amount of credit to Victron for actually doing their venus architechture sanely.

After adding the vcan and having my own integration doing standard linux socketcan write/read to it, things just works :)

Not used to that when it comes to marine electronics. :D


dsc-1135.jpg (2.9 MiB)
dsc-1134.jpg (2.9 MiB)
2 |3000

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

Related Resources