so where is the part that converts from hex to ascii?
msg.payload = Buffer.from(msg.d,"hex").toString()
In particular - I need to see what you are using inside the Buffer.from function and I need to see what it contains (a string? a number?)
The error is pretty clear (first arg must be a string)