Safe 2 decimals in data Bucket

Hello!
I’ve a trouble with decimals in data bucket.
I’m sending data from BME280 like “Jaime” from the next post:
post

Thanks to Ega, I tried yo use the same function for take 2 decimals before send data to Thinger.io.

    float round_to_dp( float in_value, int decimal_place )
{
float multiplier = powf( 10.0f, decimal_place );
in_value = roundf( in_value * multiplier ) / multiplier;
return in_value;
}

The code on my sketch.

thing[“BME280”] >> [](pson& out)
{
out [“Temperatura”] = round_to_dp( bme.readTemperature(), 2);
out [“Humitat”] = round_to_dp( bme.readHumidity(), 2);
out [“Pressió”] = round_to_dp( bme.readPressure(), 2);
}

In data bucket I have a valor with 20 decimals aproximately.
(Sorry for mistakes, I don’t write very well in english)

Hola!
Tengo un problema con los decimales que se guardan en el data bucket.

Estoy enviando datos desde el sensor BME280 como “Jaime” del siguiente mensaje:
post

Gracias a Ega, probé la misma función para tener dos decimales antes de enviar los datos a Thinger.io.

    float round_to_dp( float in_value, int decimal_place )
{
float multiplier = powf( 10.0f, decimal_place );
in_value = roundf( in_value * multiplier ) / multiplier;
return in_value;
}

El código de mi sketch.

thing[“BME280”] >> [](pson& out)
{
out [“Temperatura”] = round_to_dp( bme.readTemperature(), 2);
out [“Humitat”] = round_to_dp( bme.readHumidity(), 2);
out [“Pressió”] = round_to_dp( bme.readPressure(), 2);
}

En el data bucket se guardan unos 20 decimales.

He hecho algo mal?

servidor_sensores_PRUEBA_3_Thinger.zip (7.5 KB)

Hi, check this

There is a way to solve that issue, converting the value to a string before uploading, I have not tested it yet, but it seems that works flawlessly for this case :wink:

Hope this helps

Thank you! Tomorrow I will try it.

Wonderful, let me know how it goes :wink:

It’s works!!! I’ve tried with only one value but it’s works perfectly! Thank you Ega!
I’m a little bit more close to finish my proyect. When I finished, I will share with the Thinger.io community in acknowledgment.

Does it then work as a value for time series plots as well?

Hello Rin67630.
I’ve checked and time series plots works well.

1 Like