Search code examples
node-red

Function tried to send a message of type number - Error


I am getting "Function tried to send a message of type number" error when I deploy my flow. I am quite new the node-red.

flow.set('previous_motor_speed',motor_speed);
return [motor_speed, current];
}

//Return nothing if not required
else { flow.set('previous_motor_speed',motor_speed);}
return null

Solution

  • You can not return a raw value, you have to return a msg object. As a rule any value should be stored in msg.payload

    So at worst is should be:

    return [{payload: motor_speed}, {payload: current}]
    

    (as a rule you should not be creating new msg objects on the fly like this, but without seeing more of your function code I can't say more).