HEX to ASCII conversion

I have a unique data payload which holds the temp of my sigfox device as ascii encoded hex.
542031382032430d is an example of my payload
3243 is the high temp value in the data.
To get the actual temp value from this data I first have to convert the pair of hex (32, 43) into ascii (2, C), then put those two together and convert the resulting hex string (2C) into decimal (44)
I am able to pull the values out using mutate and have them sitting as separate strings in my data payload (data.body.temp1, data.body.temp2).
Converting these to ascii is where i am having real issues
in theory i should be able to do the following using the function node:
var temp1 = payload.data.body.temp1
var temp2 = payload.data.body.temp2

char a = (char)temp1;
char b =(char)temp2;

payload.data.body.tempas1 = a;
payload.data.body.tempas2 = b;

but the char command doesn’t work in Losant so I’m stuck.
Any suggestions on how i might be able to achieve what I’m trying to do?


Hi @Josh_Bell,

Within the Function node, you also have access to the Buffer class. There is also a test within the Workflow Lab that converts from a Hex string (it is located below the expandable Encoding/Decoding header). The solution for this test involves a Function Node that utilizes Buffer:

const buf = Buffer.from(payload.data.body.raw, "hex")

payload.working = {
  temperature: buf.readUInt32LE(0, 4),
  voltage: buf.readUInt32LE(4, 4)

Please let me know if you have any questions or if I can explain anything further!