2018-01-22, 10:32 PM
(2018-01-22, 10:00 PM)topodom Wrote: Hi everyone,
I have installed an MPU-9255 sensor.
i am working on a red node dasboard to read the values with an internet browser.
I am able to pipe and read navigation.attitude.roll and navigation.attitude.pitch.
but impossible to do the same with navigation.headingMagnetic. When i check the values with openplotter diagnostic SignalK input windows, the sensor is sending values.
So it seems the issue is between signal K and red node.
Any idea ?
below is my code for the red node fonction :
Code:var signalk_key="navigation.headingmagnetic";
if(msg.payload.hasOwnProperty(signalk_key)){
msg.payload=msg.payload[signalk_key];
return msg;
}
then i use a UI_text
with {{value}} in the value format filed
thanks !
Tried a change node and jsonata? They can be handy as you can put in a temporary debug node then copy what's coming in and paste it into the test tab to make sure what is going out is what you want. Also, I'm slowly going over to putting everything into global variables as it comes in , then it's easier to get to the data anywhere else in node red. For UI text just set an inject node to send the global variable to a text node.
Probably a neater way to do this but it might give an idea >>
Code:
[
{
"id": "67b79641.1fad68",
"type": "websocket in",
"z": "749e8283.293f4c",
"name": "SignalK input",
"server": "fc1b2b62.0b63a8",
"client": "",
"x": 90,
"y": 80,
"wires": [
[
"20af45d9.7fe30a"
]
]
},
{
"id": "20af45d9.7fe30a",
"type": "json",
"z": "749e8283.293f4c",
"name": "",
"pretty": false,
"x": 90,
"y": 240,
"wires": [
[
"8b385a5c.b0c248",
"2c398bd9.039814",
"10608140.97117f",
"a828164d.3005a8"
]
]
},
{
"id": "10608140.97117f",
"type": "switch",
"z": "749e8283.293f4c",
"name": "",
"property": "payload.updates.values.path",
"propertyType": "jsonata",
"rules": [
{
"t": "eq",
"v": "propulsion.engine.temperature",
"vt": "str"
},
{
"t": "eq",
"v": "propulsion.alt.temperature",
"vt": "str"
},
{
"t": "eq",
"v": "propulsion.exh.temperature",
"vt": "str"
},
{
"t": "eq",
"v": "environment.outside.pressure",
"vt": "str"
},
{
"t": "eq",
"v": "electrical.batteries.MainBank.voltage",
"vt": "str"
}
],
"checkall": "true",
"outputs": 5,
"x": 250,
"y": 140,
"wires": [
[
"f9de7f8e.d11f9"
],
[
"ac6fa817.c672c8"
],
[
"7f2db92c.1b0ad8"
],
[
"a1aa7569.769a28"
],
[
"9d158a2f.8b5da8"
]
]
},
{
"id": "f9de7f8e.d11f9",
"type": "change",
"z": "749e8283.293f4c",
"name": "Set Global.eng",
"rules": [
{
"t": "set",
"p": "eng",
"pt": "global",
"to": "$round($number(payload.updates.values.value) - 273.15,2)",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 60,
"wires": [
[]
]
},
{
"id": "ac6fa817.c672c8",
"type": "change",
"z": "749e8283.293f4c",
"name": "Set Global.alt",
"rules": [
{
"t": "set",
"p": "alt",
"pt": "global",
"to": "$round($number(payload.updates.values.value) - 273.15,2)",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 80,
"wires": [
[]
]
},
{
"id": "7f2db92c.1b0ad8",
"type": "change",
"z": "749e8283.293f4c",
"name": "Set Global.exh",
"rules": [
{
"t": "set",
"p": "exh",
"pt": "global",
"to": "$round($number(payload.updates.values.value) - 273.15,2)",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 100,
"wires": [
[]
]
},
{
"id": "a1aa7569.769a28",
"type": "change",
"z": "749e8283.293f4c",
"name": "Set Global.pres",
"rules": [
{
"t": "set",
"p": "pressure",
"pt": "global",
"to": "\t$number(payload.updates.values.value) ? $number(payload.updates.values.value) : \"\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 120,
"wires": [
[]
]
},
{
"id": "9d158a2f.8b5da8",
"type": "change",
"z": "749e8283.293f4c",
"name": "Set Global.battVolts",
"rules": [
{
"t": "set",
"p": "battVolts",
"pt": "global",
"to": "$number(payload.updates.values.value) ? $number(payload.updates.values.value) : \"\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 140,
"wires": [
[]
]
},
{
"id": "9bc5cb83.05d3f8",
"type": "inject",
"z": "749e8283.293f4c",
"name": "",
"topic": "",
"payload": "eng",
"payloadType": "global",
"repeat": "1",
"crontab": "",
"once": false,
"x": 830,
"y": 80,
"wires": [
[
"d652486c.7ed398",
"f66f5fb8.176a1"
]
]
},
{
"id": "f66f5fb8.176a1",
"type": "ui_gauge",
"z": "749e8283.293f4c",
"name": "EngTempGauge",
"group": "3bc70d31.720c02",
"order": 1,
"width": "3",
"height": "4",
"gtype": "gage",
"title": "Engine temperature",
"label": "Deg C",
"format": "{{value}}",
"min": 0,
"max": "120",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 1240,
"y": 125,
"wires": []
},
{
"id": "fc1b2b62.0b63a8",
"type": "websocket-listener",
"z": "",
"path": "ws://localhost:3000/signalk/v1/stream",
"wholemsg": "false"
},
{
"id": "3bc70d31.720c02",
"type": "ui_group",
"z": "",
"name": "Gauges",
"tab": "de6fba2.670c748",
"order": 1,
"disp": true,
"width": "10"
},
{
"id": "de6fba2.670c748",
"type": "ui_tab",
"z": "",
"name": "Gauges",
"icon": "dashboard",
"order": 2
}
]