Possible bug: double to String inside Particle.publish [FIXED]

I’ve tested a webhook into Slack with Particle.publish

Now I want to use the value of

double testVal = 5000;

Now it goes into:

Particle.publish("slack", String(testVal));

this sends this ridiculous value to Slack


if I use testVal = 200 then this shows in Slack


Serial gives the correct answer with both values.

I’m building locally on Mac using

develop e1c98c4

I’m not sure what this anomaly is? And where is it originating from. Is it just Slack or some other issue at work.

EDIT: With a couple of iterations the value is between 2147.475 - 2147.485 after which the output turns into garbage.

Hi @FistOfTheNorthStar

Have tried printing String(testVal) over serial or did you just do testVal?

I suspect the new-ish double-to-ascii code has gone off into the weeds here, so if you can try printing String(testVal) that would verify that.

Yeah that’s it, serial gives the same garbage. Should have tested that first.

OK I have created a github issue and I think the work-around will be to ask for less precision in the String object:

Particle.publish("slack", String(testVal,2));
1 Like

Thanks for reporting @bko. The github issue is here - https://github.com/spark/firmware/issues/563
…and fixed :smile: