diff --git a/library.properties b/library.properties index 6579fa36..52cadc33 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit IO Arduino -version=2.7.22 +version=2.7.23 author=Adafruit maintainer=Adafruit sentence=Arduino library to access Adafruit IO. diff --git a/src/AdafruitIO_Data.cpp b/src/AdafruitIO_Data.cpp index 38617f04..b9878566 100644 --- a/src/AdafruitIO_Data.cpp +++ b/src/AdafruitIO_Data.cpp @@ -182,14 +182,14 @@ void AdafruitIO_Data::setValue(float value, double lat, double lon, double ele, #if defined(ARDUINO_ARCH_AVR) // Use avrlibc dtostre function on AVR platforms. - dtostre(value, _value, 10, 0); + dtostre(value, _value, precision, 0); #elif defined(ESP8266) // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf // but accept a hint as to how many decimals of precision are desired. dtostrf(value, 0, precision, _value); #else // Otherwise fall back to snprintf on other platforms. - snprintf(_value, sizeof(_value)-1, "%f", value); + snprintf(_value, sizeof(_value) - 1, "%0.*f", precision, value); #endif setLocation(lat, lon, ele); @@ -201,14 +201,14 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele, #if defined(ARDUINO_ARCH_AVR) // Use avrlibc dtostre function on AVR platforms. - dtostre(value, _value, 10, 0); + dtostre(value, _value, precision, 0); #elif defined(ESP8266) // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf // but accept a hint as to how many decimals of precision are desired. dtostrf(value, 0, precision, _value); #else // Otherwise fall back to snprintf on other platforms. - snprintf(_value, sizeof(_value)-1, "%f", value); + snprintf(_value, sizeof(_value) - 1, "%0.*f", precision, value); #endif setLocation(lat, lon, ele);