@@ -182,14 +182,14 @@ void AdafruitIO_Data::setValue(float value, double lat, double lon, double ele,
182182
183183 #if defined(ARDUINO_ARCH_AVR)
184184 // Use avrlibc dtostre function on AVR platforms.
185- dtostre (value, _value, 10 , 0 );
185+ dtostre (value, _value, precision , 0 );
186186 #elif defined(ESP8266)
187187 // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
188188 // but accept a hint as to how many decimals of precision are desired.
189189 dtostrf (value, 0 , precision, _value);
190190 #else
191191 // Otherwise fall back to snprintf on other platforms.
192- snprintf (_value, sizeof (_value)- 1 , " %f " , value);
192+ snprintf (_value, sizeof (_value) - 1 , " %0.*f " , precision , value);
193193 #endif
194194
195195 setLocation (lat, lon, ele);
@@ -201,14 +201,14 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,
201201
202202 #if defined(ARDUINO_ARCH_AVR)
203203 // Use avrlibc dtostre function on AVR platforms.
204- dtostre (value, _value, 10 , 0 );
204+ dtostre (value, _value, precision , 0 );
205205 #elif defined(ESP8266)
206206 // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
207207 // but accept a hint as to how many decimals of precision are desired.
208208 dtostrf (value, 0 , precision, _value);
209209 #else
210210 // Otherwise fall back to snprintf on other platforms.
211- snprintf (_value, sizeof (_value)- 1 , " %f " , value);
211+ snprintf (_value, sizeof (_value) - 1 , " %0.*f " , precision , value);
212212 #endif
213213
214214 setLocation (lat, lon, ele);
0 commit comments