Hexadecimal to ascii/string function

Hello, there is any function that converts directly from hex to ascii? I need to aply it in a function node.

1 Like

Hi, do you mean Hex to decimal?

Can you share an example of what you would like to convert to what?

There are various built-in functions on the String object and the Buffer object that can be used to convert between different representations of the same data. Just needs an example from you so we know exactly what you're looking for.

Yes, I need to convert characters, for example I'm receiving 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 , that it means Hello world! in ascii, this Hello world is what I want to share on screen.

Hi knolleary, I reply the same than the coment before, I hope it's usefull for you.

Yes, I need to convert characters, for example I'm receiving 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 , that it means Hello world! in ascii, this Hello world is what I want to share on screen.

And how exactly are you receiving that ascii?

Is it in a string: "48656c6c6f20776f726c6421"? Or some other format?

Yes, it's a payload that I receive with Lora node (the data comes from an arduino program adn in a future it will be temperatures), and the format as you say is a string.

Assuming that String is in msg.payload, then the following function will do it:

msg.payload = Buffer.from(msg.payload,"hex").toString()
return msg;
2 Likes

Perfect, thanks knolleary, I would try it with the mate who program the arduino in a few hours and I say something, but i seems good.

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