Spark Core and Node-RED integration

The format() function can’t deal with String objects, which get returned by functions like Time.timeStr() so you need to convert them into a C string by use of the class method String::c.str().
And in printf format strings the placeholder for a C string is "%s".

So a properly formatted publish would look like this

Particle.publish("TempSensor1", String::format("Temp=%dF; Humidity=%d%%; Time=%s", temp_f, humidity, Time.timeStr().c_str()));

This might be some interesting read for you, if you want to make most of the printf formatting
http://www.cplusplus.com/reference/cstdio/printf/

2 Likes