NMEA 0183 data from SignalK to TouchOSC
This is a flow I created for testing and development purposes. It takes sentences from SignalK (that originate from an NMEA 0183 source) parses messages through the JSONPath Node then formats for OSC. TouchOSC can be configured to accept messages and display a limited set of UI items on an iOS (and I think Android) device.
If you use this path and make improvement, please share them with the rest of us. I'm new to Node-Red so just learning the ropes. I'm sure there are easier ways to do what I've presented.
References:
TouchOSC - http://hexler.net/software/touchosc SignalK http://signalk.org/
[{"id":"8d3e8e23.72c17","type":"websocket-listener","path":"ws://localhost:3000/signalk/stream","wholemsg":"false"},{"id":"ad0508b3.52faf8","type":"debug","name":"","active":false,"complete":"true","x":615.5396614074707,"y":44.11113166809082,"z":"3712f7b.fc8ed08","wires":[]},{"id":"c14189c8.3ebe78","type":"json","name":"JSON","x":430.88890075683594,"y":40.5277886390686,"z":"3712f7b.fc8ed08","wires":[["8349e0a4.7cb62","ad0508b3.52faf8","a0646def.5f9b9","9aa15706.655ea8","2a84c531.d57b3a","1a3e9e61.e5c162","6038ba2c.9fc744"]]},{"id":"ff8707f0.0078f8","type":"websocket in","name":"signalK webocket on port 3000 - payload","server":"8d3e8e23.72c17","client":"","x":169.11112213134766,"y":39.611117362976074,"z":"3712f7b.fc8ed08","wires":[["c14189c8.3ebe78"]]},{"id":"8349e0a4.7cb62","type":"switch","name":"Switch","property":"payload.self","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","outputs":2,"x":301.3491744995117,"y":174.7817497253418,"z":"3712f7b.fc8ed08","wires":[["beb69821.414968"],[]]},{"id":"beb69821.414968","type":"function","name":"/1/label_vessel_name","func":" msg.topic = \"/1/vessel_name\";\n var label_vessel_name = msg.payload.self;\n msg.payload = label_vessel_name;\n return [ msg ];\n ","outputs":"1","valid":true,"x":479.1269073486328,"y":167.22220492362976,"z":"3712f7b.fc8ed08","wires":[["861a1983.79e5e8","834c1ed6.7cb3e"]]},{"id":"861a1983.79e5e8","type":"debug","name":"","active":false,"complete":"true","x":670.0000305175781,"y":161.11108541488647,"z":"3712f7b.fc8ed08","wires":[]},{"id":"834c1ed6.7cb3e","type":"osc out","name":"","addr":"192.168.0.112","port":"9001","path":"","x":885.9523696899414,"y":237.22220993041992,"z":"3712f7b.fc8ed08","wires":[]},{"id":"6ae54d35.951ab4","type":"comment","name":"iPad - mini","info":"","x":942.3333282470703,"y":188.8889036178589,"z":"3712f7b.fc8ed08","wires":[]},{"id":"3a05c3eb.c5fa3c","type":"debug","name":"","active":false,"complete":"true","x":467.3332862854004,"y":382.6666512489319,"z":"3712f7b.fc8ed08","wires":[]},{"id":"a0646def.5f9b9","type":"jsonpath","expression":"vessels..navigation.speedThroughWater.value","split":true,"name":"speedThroughWater","x":286.99999237060547,"y":353.6666588783264,"z":"3712f7b.fc8ed08","wires":[["3a05c3eb.c5fa3c","6fd7e7b6.902818"]]},{"id":"6fd7e7b6.902818","type":"function","name":"/1/label_speedThroughWater","func":" \n //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_SpeedThroughWater\";\n var value_in = msg.payload;\n //the payload can be formatted here\n msg.payload = \"WaterSpd: \" + parseFloat(value_in).toFixed(2);\n return [ msg ];\n ","outputs":"1","valid":true,"x":528.3332901000977,"y":348.33328771591187,"z":"3712f7b.fc8ed08","wires":[["482a7a9.fb7d584","834c1ed6.7cb3e"]]},{"id":"482a7a9.fb7d584","type":"debug","name":"","active":false,"complete":"true","x":779.9999313354492,"y":348.3332953453064,"z":"3712f7b.fc8ed08","wires":[]},{"id":"9aa15706.655ea8","type":"jsonpath","expression":"vessels..navigation.position.longitude","split":true,"name":"Longitude","x":338.3333282470703,"y":449.999924659729,"z":"3712f7b.fc8ed08","wires":[["1bfbc1b.fe4043e"]]},{"id":"786b700a.87949","type":"debug","name":"","active":false,"complete":"true","x":726.6667060852051,"y":453.33334159851074,"z":"3712f7b.fc8ed08","wires":[]},{"id":"2a84c531.d57b3a","type":"jsonpath","expression":"vessels..navigation.position.latitude","split":true,"name":"Latitude","x":340,"y":416.6666316986084,"z":"3712f7b.fc8ed08","wires":[["74f07e68.8b0f8"]]},{"id":"7dd9b04c.82265","type":"debug","name":"","active":false,"complete":"true","x":729.9999198913574,"y":418.33332920074463,"z":"3712f7b.fc8ed08","wires":[]},{"id":"74f07e68.8b0f8","type":"function","name":"/1/label_latitude","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_latitude\";\n var value_in = msg.payload;\n //the payload can be formatted here\n msg.payload = \"Lat: \" + parseFloat(value_in).toFixed(4);\n return [ msg ];\n ","outputs":"1","valid":true,"x":488.33331298828125,"y":419.99996757507324,"z":"3712f7b.fc8ed08","wires":[["7dd9b04c.82265","834c1ed6.7cb3e"]]},{"id":"1bfbc1b.fe4043e","type":"function","name":"/1/label_longitude","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_longitude\";\n var value_in = msg.payload;\n msg.payload = \"Lon: \"+ parseFloat(value_in).toFixed(4);\n return [ msg ];\n ","outputs":"1","valid":true,"x":489.99993896484375,"y":451.6666440963745,"z":"3712f7b.fc8ed08","wires":[["786b700a.87949","834c1ed6.7cb3e"]]},{"id":"1a3e9e61.e5c162","type":"jsonpath","expression":"vessels..environment.wind.angleApparent.value","split":false,"name":"windangleApparent","x":233.33336639404297,"y":586.6666498184204,"z":"3712f7b.fc8ed08","wires":[["3b1fefe5.c4e01","b78f2137.4870e","396bdfd0.c6942"]]},{"id":"3b1fefe5.c4e01","type":"function","name":"/1/rotary_wind.angleApparent","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/rotary_wind.angleApparent\";\n var value_in = msg.payload;\n msg.payload = value_in\n return [ msg ];\n ","outputs":"1","valid":true,"x":483.3333282470703,"y":549.9998807907104,"z":"3712f7b.fc8ed08","wires":[["e88a8e44.17757","834c1ed6.7cb3e"]]},{"id":"e88a8e44.17757","type":"debug","name":"","active":false,"complete":"true","x":676.6667175292969,"y":549.9999227523804,"z":"3712f7b.fc8ed08","wires":[]},{"id":"b78f2137.4870e","type":"debug","name":"","active":false,"complete":"true","x":416.66666412353516,"y":628.3332386016846,"z":"3712f7b.fc8ed08","wires":[]},{"id":"396bdfd0.c6942","type":"function","name":"/1/label_wind.angleApparent","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_wind.angleApparent\";\n var value_in = msg.payload;\n msg.payload = parseFloat(value_in).toFixed(2);\n return [ msg ];\n ","outputs":"1","valid":true,"x":479.99998474121094,"y":583.3332977294922,"z":"3712f7b.fc8ed08","wires":[["834c1ed6.7cb3e","207adf0c.df852"]]},{"id":"207adf0c.df852","type":"debug","name":"","active":false,"complete":"true","x":674.9999313354492,"y":583.3333377838135,"z":"3712f7b.fc8ed08","wires":[]},{"id":"6038ba2c.9fc744","type":"jsonpath","expression":"vessels..environment.wind.angleTrue.value","split":false,"name":"windangleTrue","x":241.66668319702148,"y":681.666618347168,"z":"3712f7b.fc8ed08","wires":[["781d6717.87e298","a85482c6.57ab8"]]},{"id":"b0ff99de.4f0068","type":"debug","name":"","active":true,"complete":"true","x":491.66673278808594,"y":744.9999752044678,"z":"3712f7b.fc8ed08","wires":[]},{"id":"e20a6513.1df598","type":"function","name":"/1/label_wind.angleTrue","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_wind.angleTrue\";\n var value_in = msg.payload;\n msg.payload = \"TWA: \" + parseFloat(value_in).toFixed(2);\n return [ msg ];\n ","outputs":"1","valid":true,"x":316.66656494140625,"y":744.9999942779541,"z":"3712f7b.fc8ed08","wires":[["b0ff99de.4f0068","834c1ed6.7cb3e"]]},{"id":"cfd7b97.f302848","type":"function","name":"/1/xy_wind.angleTrue","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/xy_wind.angleTrue\";\n var value_in = msg.payload;\n var AT_radians = msg.payload * (Math.PI)/180\n x = Math.cos(AT_radians);\n y = Math.sin(AT_radians);\n \n msg.payload = [x,y]\n \n return [ msg ];\n ","outputs":"1","valid":true,"x":308.33329010009766,"y":776.6666851043701,"z":"3712f7b.fc8ed08","wires":[["e6d9f3.ff19261","834c1ed6.7cb3e"]]},{"id":"e6d9f3.ff19261","type":"debug","name":"","active":true,"complete":"true","x":475.0000228881836,"y":778.3333101272583,"z":"3712f7b.fc8ed08","wires":[]},{"id":"4a675a62.b598a4","type":"inject","name":"","topic":"","payload":"0","payloadType":"string","repeat":"","crontab":"","once":false,"x":64.99998474121094,"y":688.3333253860474,"z":"3712f7b.fc8ed08","wires":[["cfd7b97.f302848","e20a6513.1df598"]]},{"id":"2281ad24.dd7e52","type":"inject","name":"","topic":"","payload":"45","payloadType":"string","repeat":"","crontab":"","once":false,"x":66.66665649414062,"y":720.0000219345093,"z":"3712f7b.fc8ed08","wires":[["e20a6513.1df598","cfd7b97.f302848"]]},{"id":"2de676c0.d2198a","type":"inject","name":"","topic":"","payload":"90","payloadType":"string","repeat":"","crontab":"","once":false,"x":64.9999771118164,"y":751.6666822433472,"z":"3712f7b.fc8ed08","wires":[["e20a6513.1df598","cfd7b97.f302848"]]},{"id":"a652166b.59ade8","type":"inject","name":"","topic":"","payload":"180","payloadType":"string","repeat":"","crontab":"","once":false,"x":66.66666412353516,"y":783.333330154419,"z":"3712f7b.fc8ed08","wires":[["cfd7b97.f302848","e20a6513.1df598"]]},{"id":"efdca4e0.102358","type":"inject","name":"","topic":"","payload":"270","payloadType":"string","repeat":"","crontab":"","once":false,"x":64.9999885559082,"y":845.000020980835,"z":"3712f7b.fc8ed08","wires":[["cfd7b97.f302848","e20a6513.1df598"]]},{"id":"6649ac85.99b654","type":"inject","name":"","topic":"","payload":"225","payloadType":"string","repeat":"","crontab":"","once":false,"x":66.66666793823242,"y":814.9999990463257,"z":"3712f7b.fc8ed08","wires":[["e20a6513.1df598","cfd7b97.f302848"]]},{"id":"6c9183c9.936e7c","type":"debug","name":"","active":false,"complete":"true","x":628.3333778381348,"y":664.9999933242798,"z":"3712f7b.fc8ed08","wires":[]},{"id":"781d6717.87e298","type":"function","name":"/1/label_wind.angleTrue","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_wind.angleTrue\";\n var value_in = msg.payload;\n msg.payload = \"TWA: \" + parseFloat(value_in).toFixed(2);\n return [ msg ];\n ","outputs":"1","valid":true,"x":453.3332214355469,"y":663.3333225250244,"z":"3712f7b.fc8ed08","wires":[["6c9183c9.936e7c","834c1ed6.7cb3e"]]},{"id":"a85482c6.57ab8","type":"function","name":"/1/xy_wind.angleTrue","func":" //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/xy_wind.angleTrue\";\n var value_in = msg.payload;\n var AT_radians = msg.payload * (Math.PI)/180\n x = Math.cos(AT_radians);\n y = Math.sin(AT_radians);\n \n msg.payload = [x,y]\n \n return [ msg ];\n ","outputs":"1","valid":true,"x":451.6665916442871,"y":698.333288192749,"z":"3712f7b.fc8ed08","wires":[["6d233d5d.92dcc4","834c1ed6.7cb3e"]]},{"id":"6d233d5d.92dcc4","type":"debug","name":"","active":false,"complete":"true","x":626.666633605957,"y":698.333288192749,"z":"3712f7b.fc8ed08","wires":[]},{"id":"a559c4ea.5aa638","type":"function","name":"/1/label_nmea_sentences","func":" \n //all this does is insert the topic of the OSC ID\n msg.topic = \"/1/label_nmea_sentences\";\n var value_in = msg.payload;\n //the payload can be formatted here\n msg.payload = value_in\n return [ msg ];\n ","outputs":"1","valid":true,"x":296.6667022705078,"y":215.00002002716064,"z":"3712f7b.fc8ed08","wires":[["834c1ed6.7cb3e","80448697.7fbb78"]]},{"id":"80448697.7fbb78","type":"debug","name":"","active":false,"complete":"true","x":518.3333320617676,"y":214.9999942779541,"z":"3712f7b.fc8ed08","wires":[]}]