This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format UDP Sensor data for SignalK
#1
I am trying to send data from an ADS1115 sensor attached to a NodeMCU/ESP8266, to OpenPlotter/SignalK using UDP on port 65500. 
(The ESP8266 is running the ESPEASY firmware. )

The ESP8266 is configured to send an object containing a payload like this    

battery.volts&12.76

I input the payload into Node-Red as a String using a UDP input node and then separate topic from value by slicing it it in order to send out 
msg.topic = battery.volts and msg.payload = 12.76 
I then input this to a SignalK "signalk-send-pathvalue" node

I can see the incoming data in the NR dashboard and view it in the SignalK Data Browser as battery.volts = 12.76 – so far so good.
The problem is I cannot get this data out of SignalK. 
If I setup a test Node-Red Subscribe node and subscribe to “battery.volts” I see no data. 

I suspect it’s a formatting issue or something to do with SK context but I don’t know what to do to sort it.
I’m hoping someone has done something similar with UDP and Node-Red and can give some advice.

Thanks

I use this code in a NR function Node to format the incoming UDP string
var str = msg.payload
//The UDP message from the ESP uses "&" as a delimiter
var res = str.split("&");
var tskname = res.slice(0,1)
var tskvalue = res.slice(1,2)
msg.topic = tskname.toString()
msg.payload=Number(tskvalue)
return msg;

My Node-Red flow

Code:
[
   {
       "id": "cb653e0e.d859a",
       "type": "function",
       "z": "7432ef3b.de596",
       "name": "Convert to Path/Value",
       "func": "var str = msg.payload\n//The UDP message from the ESP uses \"&\" as a delimeter\nvar res = str.split(\"&\");\nvar tskname = res.slice(0,1)\nvar tskvalue = res.slice(1,2)\nmsg.topic = tskname.toString()\nmsg.payload=Number(tskvalue)\nreturn msg;",
       "outputs": 1,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "x": 160,
       "y": 160,
       "wires": [
           [
               "f6d5454.503e7b8",
               "eda7acec.b0fa5",
               "1639d2c0.24569d",
               "316d5f21.4dcb7"
           ]
       ]
   },
   {
       "id": "eda7acec.b0fa5",
       "type": "signalk-send-pathvalue",
       "z": "7432ef3b.de596",
       "name": "",
       "source": "",
       "x": 310,
       "y": 340,
       "wires": []
   },
   {
       "id": "8a543a9d.e7fc88",
       "type": "comment",
       "z": "7432ef3b.de596",
       "name": "UDP From sensors",
       "info": "",
       "x": 110,
       "y": 60,
       "wires": []
   },
   {
       "id": "876d987.a6d3368",
       "type": "udp in",
       "z": "7432ef3b.de596",
       "name": "",
       "iface": "",
       "port": "65500",
       "ipv": "udp4",
       "multicast": "false",
       "group": "",
       "datatype": "utf8",
       "x": 80,
       "y": 100,
       "wires": [
           [
               "cb653e0e.d859a"
           ]
       ]
   },
   {
       "id": "1639d2c0.24569d",
       "type": "link out",
       "z": "7432ef3b.de596",
       "name": "To Monitoring",
       "links": [
           "ed6617c.c0175e8",
           "c5a3d029.e6277",
           "38df7a19.8f3336"
       ],
       "x": 95,
       "y": 240,
       "wires": []
   },
   {
       "id": "316d5f21.4dcb7",
       "type": "debug",
       "z": "7432ef3b.de596",
       "name": "",
       "active": false,
       "tosidebar": true,
       "console": false,
       "tostatus": false,
       "complete": "false",
       "statusVal": "",
       "statusType": "auto",
       "x": 380,
       "y": 260,
       "wires": []
   }
]
Reply


Messages In This Thread
How to format UDP Sensor data for SignalK - by affinite - 2021-04-05, 06:56 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)