Why i'm getting NAN in debug of temp value

var temp1= msg.payload[6]-48;
var temp2= msg.payload[7]-48;
var temp3= msg.payload[9]-48;
var temp4= msg.payload[10]-48;

var result = (temp1*1000)+ (temp2*100) + (temp3*10) + temp4; 
result = result/100;

var result1 = {payload:result};


presumably one of those inputs is not of numeric type...
can you show us the incoming payload ? feed into a debug node and show us the result.

Is the payload you are passing in a string, array or Buffer?
Feed it into a debug node and it will tell you

[Edit] If it is a string, which I suspect it is then try this

msg.payload = Number(msg.payload.substr(6,4))
return msg;

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