NMEA 2000 to HA

Installation on the boat has a NMEA2000 network.
Just wonder if anyone has managed to use data from such network and created sensors in home assistant? I guess via MQTT would be the easiest

1 Like

Not sure if you are still into this, but Iā€™m interested in anything that you may have put together.

Iā€™m currently pulling data from my NEMA 2000 bus using a CANable (https://canable.io/) but havenā€™t worked much on getting the data into HA.

Iā€™d really like to start with getting the current location from GPS and getting HA to update that without restarting the entire daemon. :man_shrugging:

Hi,

I use Openplotter and the SignalK server. Openplotter takes NMEA0186 and NMEA2000 messages into SignalK format. SIgnalK can be manipulated via NodeRed easily and can send out NMEA PGNā€™s from SignalK paths.

The SignalK server has an MQTT plugin that can fire all NMEA2000 messages in to MQTT as JSON or you can use NodeRed to ā€œFlattenā€ the JSON to just get the payload details, for example a single MQTT topic that contains longitude and latitude and then use MQTT sensor in HA to get the values into HA. This document explains how to create MQTT sensors to pull information from JSON formatting. https://www.home-assistant.io/integrations/sensor.mqtt/

Basically, Home Assistant can use an MQTT sensor to collect the data for the relevant NMEA PGN from the SignalK path.

The beauty of this solution is you can send MQTT back into SignalK paths and openplotter can then send these back out on the NMEA bus as NMEA PGNā€™s. So Home Assistant can actually influence NMEA2000 data on proprietary devices.

Basically, it looks like this and can be achieved with 2 RaspberyPiā€™s and a bunch of open source code for less than $100

NMEA2000 <-> SignalK <-> MQTT <-> Home Assistant

At any point in the chain, you can then inject control messages. SignalK is excellent on the boat/ship to send data to OpenCPN for chartplotter control on laptops/tablets and home assistant for other information.

I created an ultrasonic fresh water tank level sensors using Home Assistant and ESPHome for about $20 and that is injected into the NMEA 2000 PGN for tank level via the above steps with MQTT and SignalK. I can see how many litres are left in the tank on the chart plotter.

I have to be honest, it took some time figuring it out, but now the infrastructure is in place, you can really get information spread across many systems easily.

The next step for me is to take the Mastervolt Masterbus information into NMEA2000, so I can control 3 invertors in 3 phase and solar panels from Home Assistant to see energy usage and production and control battery charging from Home Assistant into a Mastervolt system.

I also have some automation that turns off water pumps when the fresh water tank level is too low and alerts. The watermaker can be turned on and off via HA to make it guest and girlfriend friendly.

Hope this helps, there were a lot of late nights and head scratching to figure it out, but once it works, it works pretty well.

1 Like

Hi Craig,

Thatā€™s really interesting.

Iā€™m running Signal K on a RPI 4 on my boat and receiving NMEA 2000 data using a Digital Yacht iKonvert interface.

Iā€™ve now purchased some 433MHz sensors for an alarm system for the boat and plan on building my own sensors to read engine temperature, revs, tank levels etc.

I had planned to install everything on a single RPI 4, but that doesnā€™t seem possible as Home Assistant is installed as an image which flashes the entire drive, so will need another PI to run the Signal K server and plugins I guess.

I too have Mastervolt systems onboard and would be very interested in hearing more about how you get data from the Masterbus into NMEA 2000.

My Mastervolt system consists of:

  • Mass combi ultra 12/3000 inverter/charger
  • SMC25 MPPT solar charger controllers
  • Mastershunt 500 shunt
  • Mastervolt USB Interface

Iā€™d really like to monitor my solar output (kWh per day for example). The MPPT charge controllers display instantaneous power/voltage/current on their screens but Mastervolt has told me thereā€™s no way to get this data out - but if itā€™s being displayed on the screen there must be.

Iā€™d also like to see energy usage/battery state etc on my phone rather than the awful Mastervolt LCD display which canā€™t be read in daylight.

Thanks,
Peter

Hi Peter,

Hope youā€™re well? Like all projects on the boat, mine is still on going! In a nutshell, to get nmea2000 from masterbus is a slow time consuming process that requires patient and experimentation. Be prepared to work at it.

Mastervolt sell the nmea2000 interface, it however does not automatically publish any pgnā€™s. You have to program each one you want to send / receive. This is where the process is time consuming. You need to map the Masterbus source to the relevant nmea message.

The amperian interface claims MQTT on the ethernet interface, but I contacted mastervolt and they said it is only supported to send to their amperian website and not locally accessible. So scrapped that idea.

The nmea 2000 pgnā€™s youā€™ll be mostly using are in the 127500-14 for power related information. This range includes switch control, AC, DC, Generator Control and battery status.

Iā€™m not sure the SCM25 supports masterbus? Maybe not possible to get that information out of the box?

My thoughts are this on the single / dual raspberry pi. Home assistant is flaky at best and needs frequent attention. OpenPlotter with SignalK is to my mind a more critical system. Especially with navigation. Iā€™d separate the two purely to keep the navigation system running. I have to restart home assist several times a week. The pi running openplotter and signalk maybe a few times a year and occasionally for upgrades.

Iā€™ve also started using node red more to get signalk data out of openplotter into home assistant. Itā€™s become my preferred method over MQTT. It literally lifts the signalk path straight into an HA sensor. Automatically creates the sensor for you. With MQTT youā€™ll need to create sensors in yaml, but with node red, once youā€™ve installed the node red integration on both sides, it just works (barring incorrect config).

Hereā€™s an example of the Node Red flows for bi-directional data sharing between SignalK and HA in Node Red

I managed to get 3 mastervolt mass combi ultra 24/3500 factory refurbished, basically for the price of one new unit. However, if I had to do it all again, Iā€™d never recommend or use mastervolt, Iā€™d go with victron. Mastervolt have little to no documentation, keep all their information secret and want you to use their installer network. Victron is the complete opposite, tons of information, great community, great interoperability of components. All in all, my feelings are Victron is better and SignalK integration has already been written by someone for the VenusGX.

1 Like

Hi Craig,

Iā€™m doing great thanks - on the boat in Spain and the weather is glorious!

Thanks very much for the details.

I have a MasterBus USB interfaceā€¦ one of these:
https://www.mastervolt.com/products/masterbus-interfaces/masterbus-usb-interface/

Is this the NMEA2000 interface that youā€™re talking about? Thereā€™s no technical documentation on it, but it connects to a Windows PC via USB and makes data available - so there must be someway to get data out of the thing and possible into Signal k.

I also have a MasterShunt, but mine isnā€™t NMEA enabled:
https://www.mastervolt.com/products/mastershunt/mastershunt-500-battery-monitor-with-system-fuse/

Youā€™re absolutely right about going with Victron over Mastervolt. My boat came with a full suite of Mastervolt equipment, so Iā€™m stuck with it. The Victron SmartSolar is superb and provides full solar stats over Bluetooth. They are also actively pushing Signal K integration. When I contacted Mastervolt about getting data out of my MPPT controllers, they sent a one liner saying ā€˜nopeā€™. The MPPT controllers are completely standalone, but they do display instantaneous power/volts/amps on their inbuilt screens - so itā€™s obviously being measured and there must be some way of getting it out and onto the network.

Thanks also for the heads up regarding separating the two systems. Iā€™ll go this route initially and then in the future, if things prove to be reliable, I can combine them and keep one PI as a hot swap backup system.

Iā€™ve been experimenting with Node Red too - I think itā€™s fantastic.

All of this is a steep learning curve, but Iā€™m enjoying it and thereā€™s plenty of info on the web.

Would be good to stay in touch as it sounds like weā€™re both trying to achieve the same thing - Iā€™ll keep an eye out for you on the forum.

Many thanks,
Peter

1 Like

Not envious of you being in the nice weather this winter :slightly_smiling_face:

Imagine this, you have effectively three communication systems.

  1. Masterbus for communication between mastervolt devices only, control and sync between their devices. This is the data you want to get at, but itā€™s a closed system! Your mastershunt, invertors (natively or with masterbus inverter interface depending on model) all spew their data onto the masterbus network.

  2. NMEA2000 for communication between normal marine devices, but there is an interface that connects this system to Masterbus (https://www.mastervolt.com/products/masterbus-interfaces/masterbus-nmea2000-interface/) this is the data path we exploit. Itā€™s not perfect, because Masterbus has more messages that arenā€™t available in NMEA pgnā€™s.

  3. local LAN, could be wifi or cabled ethernet

The USB interface is only for PC to Masterbus connection to configure and view the Mastervolt devices using MasterAdjust software. It doesnā€™t take part in the NMEA2000 data other than to configure the separate NMEA2000 interface mentioned above.

The Masterbus data is converted to NMEA2000 directly by the interface, then your Yacht Devices interface takes it into your Signalk server. Then you use the onboard LAN (section 3 above) to share data between signalk and HA.

The USB interface is needed to set up the NMEA interface and itā€™s a message by message configuration. If you want to get battery voltage, then you need to select the Masterbus Battery Voltage message and map it onto the correct NMEA2000 PGN (message) to see it in signalk.

Once the message is in Signalk then you have a few options to pass it to HA.

  1. export the Signalk path to MQTT and then in HA create a MQTT sensor in yaml and a corresponding lovelace card to view it
  2. install Node Red SignalK and HA palletes, easier to get running on the signalk server than on HA side. Set up your flows and create Lovelace cards.
  3. HA supports CANBus and you could technically have another Yacht Devices interface directly into HA to pull the NMEA2000 data without sending it via Signalk. This would give redundancy of accessing the data, but Iā€™m not sure if itā€™s worth the effort to set up this method because it requires a whole bunch more message mapping headaches!

On a side note, Iā€™m in the process of trying to hack the usb interface messages into the PC to see if I can intercept more detailed data to send to HA rather than routing everything via nmea and losing information due to the protocol translation. However Iā€™ve not dedicated much effort to this yet, other than some brief USB traffic sniffing tests.

Definitely keep in touch, Iā€™m sure we can help each other out

1 Like

Just following this discussion, looking at future options for my own boat. Thanks for sharing all the great ideas!

Given that there are devices which will put NMEA data on the Ethernet/WiFi network, and since OpenCPN and lots of phone/table apps can use this data, Iā€™m thinking Iā€™d probably stick with just the two protocols, rather than bring in Signal K and/or MQTT for now. But one of these days Iā€™ll be looking at a decent solar array, and when I move aboard Iā€™ll be bringing HA with me, so this is all relevant.

Hi Tom,

I would definitely stick with Victron systems over Mastervolt for future installs for solar, it is easier to configure than Mastervolt and better compatibility with 3rd party protocols than Mastervolt.

OpenCPN is great, I love it. I use Openplotter which has OpenCPN installed on it by default and runs on a Raspberry Pi, connects directly to NMEA (with the right usb interface) and it does all the heavy lifting of NMEA to SignalK automatically. OpenCPN natively supports SignalK over TCP & UDP. Thatā€™s how I run it on a laptop against OpenPlotter to grab all vessel data. Also SIgnalK server gives you lots of plugins to manipulate the NMEA data in ways you cannot do easily with normal chartplotters. I would advise considering OpenPlotter, itā€™s a steep learning curve, but a really great bit of opensource software that includes a free autopilot as well.

1 Like

Thank you for pointing me to this thread. Iā€™m watching and eventually Iā€™ll contribute to this discussion.

Hi Craigy, Did you manage to decode any of the Masterbus messages? This has been on my list for some time.

hi

i maybe gonna buy that canable.io too ā€¦
did you ever got data from it to HA ? i want to read my canbus system too

thnx for sharing!

FYI, there was some discussion of this over on the Cruiserā€™s Forum:
https://www.cruisersforum.com/forums/f13/new-nmea-2000-and-nmea-0183-board-for-raspberry-pi-238627.html

In that thread thereā€™s a link to an interesting blog:

While not HA-based, this has got to be one of the best setups Iā€™ve seen for working with N2K data. And it seems like a great first step for eventually sharing the data over to HA.

1 Like

thnx for sharing
i dont have an NMEA 2000 , my domotica system (switch+lights) are based on canbus
i want to read out the can to intercept traffic and then do stuff in HA

just looking for an howto

In an other discussion I mentioned my experimentation with the Pican-M Hat.

I will eventually report on the results.

Hi Craig!

I am literally inspired by your story about working with the HMEA200 protocol!
Iā€™m new to all this and just learning.
Now SignalK has a MMQTT plugin for Home Assistant, its JSON is very easy to process in HA.
I managed to connect SignalK to the MQTT broker and receive the information I needed in the HA, but I do not understand how from the HA I can send the information I need to SignalK (((
Could you describe in detail how you managed to send information from the Home Assistant to the MQTT broker so that SignalK could read and process it?
I will be very grateful to you for your time spent on this description, unfortunately I stand still without this knowledge ((
Thank ya lot!

Please give me a lesson on how to achieve this, Home assistant send JSON to MQTT and Signal K can to read and send to NMEA2000!

Hi!
I am also in both worlds, with home assistant and signal k.
Any one managed to get into one single raspberry pi both systems?

Also, I got a cheap AliExpress can module that costs 13ā‚¬ and it is supported on the open plotter wiki to support NMEA2000 can interface. But havenā€™t tested it yet!
Iā€™ll leave it here, it is a nice point to start messing

ā‚¬ 10,69 3ļ¼… dto. | MĆ³dulo de comunicaciĆ³n CAN BUS para Raspberry Pi 3 Modelo B + 3B Plus 4 4B Zero W WH, 3,3 V, MCP2515 RS485

Manual here:

https://openplotter.readthedocs.io/en/latest/can/can_app.html

Yes, I did it on one RPI4B, but itā€™s better to spread it to different RPI for greater stability, itā€™s time-tested.

1 Like