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 Ā·
mvader (Victron Energy) avatar image mvader (Victron Energy) ā™¦ā™¦ mvader (Victron Energy) ā™¦ā™¦ commented Ā·
Ps; difference ofcourse is that your solution is wireless


And note that what I said about signalk will not output the data as signalk xml packets.


It will output then as defacto standard UDP or TCP N2K messages, compatible with many nav apps like navionics

0 Likes 0 Ā·
saxofon avatar image saxofon mvader (Victron Energy) ā™¦ā™¦ commented Ā·
Right, I ment that SignalK is json packets (wrote wrong above as xml).

So SignalK is first reading N2K, have some understanding of it's data and makes it available in some other format (json, which make things quite more "talky").

It is a separat thing and as I really want Victron data (battery status) onto the N2K bus (not vice verce, as having Cerbo as a N2K to wifi converter as you mean) we are looking at it a bit differently. It is all about they joy of integrating things, make them talk to each other of course :)

0 Likes 0 Ā·
mvader (Victron Energy) avatar image mvader (Victron Energy) ā™¦ā™¦ saxofon commented Ā·

1) Cerbo GX N2K-out feature: make data such as battery monitor data available on the N2K network. Requires cable / plug adapter. (And preferably a Cerbo GX MK2 model, because of isolated canbus; see https://www.victronenergy.com/live/venus-os:start)


2) SignalK server: translates any data available to the Cerbo GX, including AIS and N2K nav data if the Cerbo GX is connected to your N2K network, into industry standard UDP and TCP packets; which is not json and not xml and is also not another SignalK format. SignalK server only comes in a conversion software, the output, in this case, is not a signalk format. See signalk server readme for details.



Enjoy!

0 Likes 0 Ā·
saxofon avatar image saxofon mvader (Victron Energy) ā™¦ā™¦ commented Ā·

1) using wireless communication is the ultimate isolated bus, you simply cannot argue against it ;-)

I'll be there in a moment, just need a rainy day and make the last part. I just realized my current gw app is just rx (from ydwg to socketcan, not the reverse direction):D
https://github.com/saxofon/NMEA2000-simple-c-lib/blob/main/examples/ydwg-02-to-socketcan.c

So then it doesn't require any cabling, or prefered Cerbo model ;-)

2) not sure what you mean... the industry standard for marine network packets seems to be OneNet (from NMEA organisation). The SingalK protocol (it is json, see https://signalk.org/specification/1.5.0/doc/data_model.html, or am I mistaken your point?) and as well the raw protocol from YDWG-02 is started as "homebrew" and with growing popularity. Most likely since these are open "standards" whereas OneNet is commercial and needs to be bought. (which is one of the brutal mistakes... they should just do RFC additions for further tcp/udp/whatever protocol they wish to add to network world).

0 Likes 0 Ā·
saxofon avatar image saxofon saxofon commented Ā·

And to add further, if you want to have N2K messages as "standard" tcp/udp packets, there is an NMEA standard for this:

https://actisense.com/wp-content/uploads/2023/07/NMEA-OneNet-and-Ethernet-Networking-guide-1.pdf

But I dunno... feels like NMEA did a decent job with NMEA0183, bad job with NMEA2000 (not forcing everyone that is NMEA2000 certified to have same connectors for example, and it is often error prone to mix different brands on N2K bus...) and really failed brutely when doing OneNet. All IMHO of course :)

0 Likes 0 Ā·
mvader (Victron Energy) avatar image mvader (Victron Energy) ā™¦ā™¦ saxofon commented Ā·

I mean an unofficial but still defacto standard for N2K, or more specifically NMEA0183 on your wifi network (in UDP or TCP)


Definitively not OneNet.


See here: https://demo.signalk.org/documentation/features/navdataserver/navdataserver.html


Otherwise, all understood !


0 Likes 0 Ā·
mvader (Victron Energy) avatar image mvader (Victron Energy) ā™¦ā™¦ mvader (Victron Energy) ā™¦ā™¦ commented Ā·

Here it is in isailor - best nav app ever ! ;o)


1 Like 1 Ā·
img-1758.jpeg (272.3 KiB)
saxofon avatar image saxofon mvader (Victron Energy) ā™¦ā™¦ commented Ā·

Yep, so if you wouldn't raymarine plotter for example and instead use some iPad, sure then it would be a good idea to go SignalK of course!
(or if Raymarine, Simrad, B&G etc starts to support SignalK etc as well :), then I would also probably not need todo this.
But what about mqtt.... :)

0 Likes 0 Ā·
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