MQTT > NMEA 2000

31 views
Skip to first unread message

Geoff Higginbottom

unread,
Jan 26, 2024, 6:37:10 AMJan 26
to Signal K
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 = `10EAFF${hexVoltage}${hexCurrent}`;\n\n// Set the formatted string in the message payload\nmsg.payload.actisenseString = actisenseString;\n\n// Return the modified message\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":480,"wires":[["abcda3d2a27792db","67d37b2c0cad1e24"]]},{"id":"abcda3d2a27792db","type":"signalk-send-nmea2000","z":"3069492ed761c9d6","name":"","nmea2000Event":"nmea2000out","nmea2000JsonEvent":"nmea2000JsonOut","x":670,"y":440,"wires":[]},{"id":"1f95090207bca94a","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

Teppo Kurki

unread,
Jan 26, 2024, 8:38:16 AMJan 26
to sig...@googlegroups.com
We are no longer promoting this Google group / mailing list, instead preferring https://github.com/SignalK/signalk/discussions. Github discussions are more readily accessible to everybody and a great place to gather questions and answers for everybody to benefit from.

So please, post your message there and I promise a reply.

--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/signalk/a4ad76c4-71c2-4116-8ad9-815ee127e42bn%40googlegroups.com.

Bradford Harley

unread,
Jan 26, 2024, 3:15:34 PMJan 26
to Robin Szemeti
I understand and appreciate the move to github.   I do have a question though....   It doesn't look like I can subscribe to the entire discussions section, just to threads individually.   This makes it harder to follow new topics and/or provide what limited assistance I can.    Am I missing something?

Bradford Harley

unread,
Jan 26, 2024, 3:17:16 PMJan 26
to Robin Szemeti
Disregard.   I figured out that I can watch from the main github page....   
Reply all
Reply to author
Forward
0 new messages