# Split message from LoRa to UI

**URL:** <https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230>\
**Category:** General\
**Created:** [17 September 2018 22:59 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230 "2018-09-17T22:59:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [17 September 2018 22:59 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230/1 "2018-09-17T22:59:57Z")

</div>

Hi

I need help. How do i split these messages from serial node so i can display it in UI as gauges. I got the datasets from LoRa node.

Thank you

 ![loramsg](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8a52db0d6998dd2f48cbc72272fa69fc86fa6276.jpeg)

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [18 September 2018 03:43 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230/2 "2018-09-18T03:43:35Z")

</div>

That's a bit of a challenging string to parse, but try a `function` node with this code:

```auto
var arr = msg.payload.trim().split(" ").map(d => d.match(/([a-z]+):(.+),/);
msg.payload = {};
arr.forEach(function(a) {
    var v = a[2].split(",");
    msg.payload[a[1]] = (v.length == 1? +v[0]: v.map(n => +n));
});
return msg;

```

Of course, this is _very_ specific to the data string you are showing... any changes to the spacing or punctuation could cause it to fail. The resulting payload looks like this:

```auto
{
  temp: 28,
  humi: 64.3,
  gyro: [-0.96, -0.15, 0.18],
  press: 970.3,
  lux: 0
}

```

so your downstream nodes can access any of those 5 properties by name (e.g. `msg.payload.humi`, or `msg.payload.gyro[2]`) and have numeric values, suitable for graphing.

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [18 September 2018 22:41 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230/3 "2018-09-18T22:41:15Z")

</div>

> [@shrickus](#):
>
> msg.payload.gyro[2]

Thank you so much for the help. It works like a charm.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [19 September 2018 15:12 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230/4 "2018-09-19T15:12:12Z")

</div>

A quick search of the flows library shows there are at least 3 custom nodes built just for decoding lora data messages... [https://flows.nodered.org/?term=lora&type=node](https://flows.nodered.org/?term=lora&type=node)

In the long rung, you may be better off using one of those -- especially if the data format may vary (e.g. order of values, optional elements, alternate punctuation, etc).

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [19 September 2018 15:49 UTC](https://discourse.nodered.org/t/split-message-from-lora-to-ui/3230/5 "2018-09-19T15:49:48Z")

</div>

Thank you for the information. I was actually trying out this LoRa module evaluation kit actually to understand how it works .  
[https://www.devicemart.co.kr/1289752](https://www.devicemart.co.kr/1289752)

Thank you again for your help. I appreciate it a lot
