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
Installation on the boat has a NMEA2000 network.
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.
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.
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.
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.
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:
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:
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.
Not envious of you being in the nice weather this winter
Imagine this, you have effectively three communication systems.
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.
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.
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.
- export the Signalk path to MQTT and then in HA create a MQTT sensor in yaml and a corresponding lovelace card to view it
- 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.
- 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
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.
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.
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.
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:
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.
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.
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!
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
Yes, I did it on one RPI4B, but it’s better to spread it to different RPI for greater stability, it’s time-tested.