# Howto "split" 24 byte buffer into 6 4byte floats to store in Influxdb

**URL:** <https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573>\
**Category:** General\
**Created:** [22 April 2021 23:43 UTC](https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573 "2021-04-22T23:43:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gns5280](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gns5280/32/40607_2.png) [@gns5280](https://discourse.nodered.org/u/gns5280)\
**Post date:** [22 April 2021 23:43 UTC](https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573/1 "2021-04-22T23:43:28Z")

</div>

New to NodeRed, Old ... to a lot of CS stuff. I've reviewed the buffer/binary material, but, can't seem to find what I need. Thanks in Advanced

The short of it:

- How to split a 24 byte buffer which holds 6, 4 byte floats so that I can store them into individual fields in Influxdb?

The Long:  
I'm receiving 6 floating point numbers from a pzem-016 modbus Energy Monitor. It is wired to a NodeMCU ESP8266 via a RS485 TLL adapter. The code on the esp8266 originally stores the values in a "struct" with the 6 floats. They are "union'd"(overlayed) with a byte array of 24. The array is then sent via a mqtt publish function to the MQTT Broker/NodeRed host. I then want to store the 6 values into separate fields in the Influxdb.

I found the solution: " [Flow to decode binary data and a walk-through](https://discourse.nodered.org/t/flow-to-decode-binary-data-and-a-walk-through-on-how-to-install-the-npm-module/5174)".

This appears a little more than I'm interested in biting off, now.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 April 2021 06:26 UTC](https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573/2 "2021-04-23T06:26:51Z")

</div>

> [@gns5280](#):
>
> How to split a 24 byte buffer which holds 6, 4 byte floats

You can achieve this with [node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 April 2021 07:06 UTC](https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573/3 "2021-04-23T07:06:24Z")

</div>

Here is a demo...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13b0a7b6bc1d6aa58c6d1ebaf03d764e05ef3fc3.png)

Demo flow...

```auto
[{"id":"32e20af7.a2bfc6","type":"inject","z":"dd03fa8d.2f4be8","name":"24 byte buffer","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[63,157,112,164,64,145,235,133,192,77,112,164,192,209,71,174,64,145,235,133,192,77,112,164]","payloadType":"bin","x":1970,"y":60,"wires":[["d5d42ae8.75dfa8"]]},{"id":"d5d42ae8.75dfa8","type":"buffer-parser","z":"dd03fa8d.2f4be8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item2","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item3","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item4","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item5","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatbe","name":"item6","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1990,"y":120,"wires":[["dfc63a1d.676da8"]]},{"id":"dfc63a1d.676da8","type":"debug","z":"dd03fa8d.2f4be8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2010,"y":180,"wires":[]}]

```

---

<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:** [22 June 2021 07:07 UTC](https://discourse.nodered.org/t/howto-split-24-byte-buffer-into-6-4byte-floats-to-store-in-influxdb/44573/4 "2021-06-22T07:07:00Z")

</div>

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