4 byte (32 bit) Hex value to a floating point decimal number

Hello,
Hope everyone is doing good.
I am new to Node-Red and I am looking for help. I am developing some flow to get data from an IO-Link sensor in Node-red and visualizing it in a graph in the dashboard. From the sensor, I am getting a 4-byte hex value and I need to convert it to a floating-point decimal number. I don't how to write the code for this function. Can anybody help me with it, please?

Thanks

maybe node-red-contrib-buffer-parser can help?

image

image

[{"id":"2ae1c15b.9e981e","type":"inject","z":"553814a2.1248ec","name":"4 bytes [121,233,246,66]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[121,233,246,66]","payloadType":"bin","x":760,"y":2100,"wires":[["b7405dda.ff009"]]},{"id":"b7405dda.ff009","type":"buffer-parser","z":"553814a2.1248ec","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"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":1000,"y":2100,"wires":[["39894301.2d9e2c"]]},{"id":"39894301.2d9e2c","type":"debug","z":"553814a2.1248ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":2100,"wires":[]}]

Alternatively, look at the nodejs Buffer object & its functions

1 Like

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