Azure / azure-iot-arduino

Azure IoT library for the Arduino
Other
168 stars 95 forks source link

SERIALIZE does not work with Floats or Doubles #41

Closed spokeydokeys closed 6 years ago

spokeydokeys commented 7 years ago

I'm trying to send a float or a double to my IoT Hub, however, the generated JSON is: {"DeviceId":"Device001", "Temperature":%.*f, "XAccel":%.*f, "YAccel":%.*f, "ZAccel":%.*f}

If I declare the values as integers in DECLARE_MODEL and then cast the floats to int before SERIALIZE, it works.

I think this is due to the fact that Arduino does not support printf of floats or doubles because of the overhead.

Also note that by default the Arduino IDE does not set the AVR linker options to support floating point in the xxprintf() routines. So while that saves quite a bit of code space on the AVR builds, it means that printf() functions cannot be used for floating point output on the AVR. Floating support is included by default for the other processors. -- http://playground.arduino.cc/Main/Printf

tameraw commented 7 years ago

@sethgilchrist - Thanks for reporting this. It is currently tracked in our backlog but has not been a priority as of yet.

JetstreamRoySprowl commented 6 years ago

@sethgilchrist : The ESP8266 library fixed this some time ago, and our latest Arduino libraries have pulled in the fix. Please re-open this or file a new issue if you still have trouble.