Calculations within node-red

Hi All,

quite new here, so don't blame me posting in wrong category.
I need node-red to do a specific calculation, how should I do that and is the function node my best option here ?

The calculation is

newpayload = 10^((payload-109)/32)

The challenge is mostly with the exponent "^" character or so it is called I believe....
If someone can help me out how to do this calculation (input payload is a number) then that would be great !

Hi @vinisz

The Function node is probably the easiest place to start with this sort of thing.

The node uses JavaScript and there is a good guide on the built-in Math object here.

And more specifically, the Math.pow() function.

With that in mind, a Function node with the following code should do what you want.

msg.payload = Math.pow(10, (msg.payload-109)/32);
return msg;