Trouble reading DOUBLE in javascript sdk

If i have a variable defined in my code as something like

Spark.variable('temp', &temperature, DOUBLE);

What is the best way to read this on the javascript side?
When I do a device.getVariable, the value is wildly different than I see if i just print the original float to the serial.

For example

Serial.println(temperature, 2);
// prints: 26.10

On the javascript side, my result value is:

{... result: 6.204439556495507e-270 ...}

I was trying to just have the variable be a string and use sprintf inside my photon’s code, but i couldn’t get it working and I read that sprintf support was removed.

Anyone have some advice on how i could parse this result value to be the proper number?

1 Like