Venus OS PI > Node Red > MQTT > OpenPlotter PI > Node Red > SignalK > NMEA 2000 Out - How do I do it? #99
-
Hey Gang, quite new to this tech, but I have a question about how I get data onto the NMEA 2000 Bus. I have data coming into a PI running OpenPlotter via a MQTT Message bus - data is being sent from a PI running Victron Venus, which is sending things like Battery Voltage etc. My OpenPlotter PI has a PICAN-M N2K Hat and I can read data from the N2K Bus, but I cannot work out how to get data back onto the Bus. I have this config currently, and have enabled the "Battery (127506 & 127508)" option in the SignalK to NMEA 2000 plugin, but do not know what I should be using for battery mappings etc [{"id":"abed08c3f6d3b560","type":"mqtt in","z":"3069492ed761c9d6","name":"","topic":"batteryVoltage","qos":"2","datatype":"auto-detect","broker":"1f95090207bca94a","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":480,"wires":[["fc764886ff6ddcf4","b218e738964742ca"]]},{"id":"341bae7f21d9990f","type":"mqtt in","z":"3069492ed761c9d6","name":"","topic":"batteryCurrent","qos":"2","datatype":"auto-detect","broker":"1f95090207bca94a","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":560,"wires":[["b218e738964742ca"]]},{"id":"b218e738964742ca","type":"function","z":"3069492ed761c9d6","name":"Actisence String","func":"// Extract battery voltage and current from the message payload\nvar batteryVoltage = msg.payload.batteryVoltage; // Replace with your actual payload property\nvar batteryCurrent = msg.payload.batteryCurrent; // Replace with your actual payload property\n\n// Function to convert a floating-point number to its hexadecimal representation\nfunction floatToHex(f) {\n return Buffer.from(Float32Array.from([f]).buffer).toString('hex');\n}\n\n// Convert battery voltage and current to hexadecimal\nvar hexVoltage = floatToHex(batteryVoltage);\nvar hexCurrent = floatToHex(batteryCurrent);\n\n// Construct the Actisense-formatted string\nvar actisenseString = |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You did not mention Node-RED in your post, but your code looks Node-RED to me. So I assume your data flow is VenusOS => MQTT => Node-RED. Things work in a much more plug-and-playish manner if you install & activate Venus plugin and signalk-to-nmea2000 plugin. Venus plugin will pull your data into Signal K and the other plugin convert it to NMEA2000. You need to configure each. Conversion to NMEA2000 needs mapping the battery ids, those are numerical ids in the paths of battery related values that you can see in Signal K Data Browser. I am not really |
Beta Was this translation helpful? Give feedback.
-
Btw a better title would be "Victron Venus to NMEA2000 on Raspberry Pi", MQTT is just a technical detail. If I understood what you're trying to achieve correctly. |
Beta Was this translation helpful? Give feedback.
You did not mention Node-RED in your post, but your code looks Node-RED to me. So I assume your data flow is VenusOS => MQTT => Node-RED.
Things work in a much more plug-and-playish manner if you install & activate Venus plugin and signalk-to-nmea2000 plugin. Venus plugin will pull your data into Signal K and the other plugin convert it to NMEA2000. You need to configure each. Conversion to NMEA2000 needs mapping the battery ids, those are numerical ids in the paths of battery related values that you can see in Signal K Data Browser.
I am not really