# Split sensor output

**URL:** <https://discourse.nodered.org/t/split-sensor-output/47256>\
**Category:** General\
**Created:** [16 June 2021 17:07 UTC](https://discourse.nodered.org/t/split-sensor-output/47256 "2021-06-16T17:07:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonchargreaves](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jonchargreaves](https://discourse.nodered.org/u/jonchargreaves)\
**Post date:** [16 June 2021 17:07 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/1 "2021-06-16T17:07:31Z")

</div>

I currently have a sensor that outputs the following :- {"CurrentTemperature":32.8,"AirPressure":255} I want to split this into 2 messages of 32.8 and 255 can anyone give me some assistance please?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 June 2021 17:25 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/2 "2021-06-16T17:25:46Z")

</div>

Not sure how you want to split them, so here are two examples

```auto
[{"id":"80f51f7.e550e6","type":"inject","z":"c74669a0.6a34f8","name":"button","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CurrentTemperature\":32.8,\"AirPressure\":255}","payloadType":"json","x":80,"y":3020,"wires":[["3e8fc37d.72ac0c","3b8973dd.e363dc"]]},{"id":"3e8fc37d.72ac0c","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.CurrentTemperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":2980,"wires":[["eced12ca.e27228"]]},{"id":"3b8973dd.e363dc","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.AirPressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3060,"wires":[["c0a84d3d.bbac8"]]},{"id":"eced12ca.e27228","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":2960,"wires":[]},{"id":"c0a84d3d.bbac8","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":3040,"wires":[]},{"id":"dd75a682.36c55","type":"inject","z":"c74669a0.6a34f8","name":"button","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CurrentTemperature\":32.8,\"AirPressure\":255}","payloadType":"json","x":100,"y":2880,"wires":[["cf65bbff.663ab8"]]},{"id":"cf65bbff.663ab8","type":"split","z":"c74669a0.6a34f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":260,"y":2880,"wires":[["808c0be9.aee96"]]},{"id":"808c0be9.aee96","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":480,"y":2880,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Urs-Eppenberger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/urs-eppenberger/32/28_2.png) [@Urs-Eppenberger](https://discourse.nodered.org/u/Urs-Eppenberger)\
**Post date:** [16 June 2021 17:25 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/3 "2021-06-16T17:25:59Z")

</div>

> [@jonchargreaves](#):
>
> {"CurrentTemperature":32.8,"AirPressure":255}

If the output is a string, then send it through the **json** node. This formats a javascript object out of the string.  
An then send the object through the **split** node.  
With an attached **debug** node you can enjoy the result.  
node-red is so cool.

---

<div class="post-metadata">

**Author:** ![jonchargreaves](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jonchargreaves](https://discourse.nodered.org/u/jonchargreaves)\
**Post date:** [16 June 2021 17:27 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/4 "2021-06-16T17:27:18Z")

</div>

That's awesome many thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 June 2021 20:16 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/5 "2021-06-18T20:16:39Z")

</div>

Are you sure you need to split it? What are you going to do with the two messages?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 August 2021 20:17 UTC](https://discourse.nodered.org/t/split-sensor-output/47256/6 "2021-08-17T20:17:29Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
