myDevicesIoT/Cayenne-MQTT-ESP

sending float values using virtualWrite shows "-" on the dashboard

Closed this issue · 2 comments

I am using wemos d1 mini, and arduino ide (version .13).

Consider the following code:

    float temperature = g_temperature.getTemp();
    itoa(temperature, g_szTemp, 10);
    Cayenne.virtualWrite(3, temperature, TYPE_TEMPERATURE, UNIT_CELSIUS);
    Cayenne.virtualWrite(4, g_szTemp, TYPE_TEMPERATURE, UNIT_CELSIUS);
    Cayenne.virtualWrite(5, int(temperature), TYPE_TEMPERATURE, UNIT_CELSIUS);

this produces the following result in the dashboard:

screen shot 2016-12-21 at 17 10 58

sending of the string and int values works as expected, but sending of the float value does not work.
If I use celsiusWrite its the same issue.

Please note that sprintf("%2.3f") does not work on arduino, printf-ing floats is not supported, maybe this could the problem?

Yeah, that was the problem. I've converted it to use dtostrf for float and double conversions. That code is checked in. Thanks for submitting that issue.

confirmed it is working now. Thanks for the fast update :)