157
rated 0 times
[
164]
[
7]
/ answers: 1 / hits: 16059
/ 7 Years ago, mon, january 30, 2017, 12:00:00
I have a node-red flow that needs to create an MQTT payload.
The payload is a temperature reading from an I/O card, calculated as a float (73.4 for example).
I need the message payload to be a string, not a number; something like Barn Temp is 73.2. How can I create this?
msg.payload = tempReading; // gives a number
msg.payload = +tempReading; // returns NaN
A bonus question: if I did use this as a numeric payload how can I specify its format? The reading is calculated at 73.18527461364; I need to send this as 73.2.
I'm having a devil of a time finding out how to format strings in javascript!
More From » node.js