Convert string of char to decimal?

Hey Experts,

I hope to find some helps here.
At first I convert INT to CHAR --> Easy, take a look:

// Split the string into array of individual values
var parts = msg.payload.split(" ");
// Remove the last blank part caused by the trailing comma
// Parse each part of the string to a number
var bytes = => parseInt(v))
// Create a new Buffer from those bytes and convert back to String
msg.payload = Buffer.from(bytes).toString();
return msg;

It works... But now I like to do same in other direction... Hmmm
WLC0270 --> 87 76 67 48 50 55 48 ??

I testing something but nothings works,
at first I create an array for each character:

var parts = msg.payload.split("");

then me is missing a rule to convert from(string).tobyte();

So you see currently I´am not an expert yet.
Hope anybody understand my issue.
Thanks in advance.

Hi, welcome to the forum.

A couple of things firstly.

For better reading experience, please wrap code in a codeblock

like this


  1. Where is this data coming from?
  2. What does the incoming data look like (show us a small screen snippet of debug output)

I have moved this out of creating nodes on the basis its not referring to module development.

Think that should be

var parts = msg.payload.split(" ")

How about this ?

let p = msg.payload
let decimal = []
for (let i = 0; i < p.length; i++) {
msg.payload = decimal.join(" ")
return msg;

msg.payload : string[20]

"87 76 67 48 50 55 48"

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