Hex to number conversion

I have a sensor giving me a hex value of “0105FF00”.
I only need to translate the first 4 characters :“0105” from hex to integer.
Do I need to trim that with a string node or is there a better way of doing that with buffer?

Hi @Lars_Andersson,

Using a Function Node and Buffer together, you can easily do this with a couple lines of Javascript, here’s an example:

const buf = Buffer.from(payload.data.body.raw, "hex")
payload.working = { 
temperature: buf.readUInt32LE(0, 4)
}

I would also recommend checking out this forum post with a similar question.

Please let me know if you have any further questions!

Thanks,
Julia