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

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".

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

You can achieve this with node-red-contrib-buffer-parser

Here is a demo...

image

Demo flow...

[{"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":[]}]

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