My system is read a laboratorium room temperature and humidity with thinger io and save the data for a documentation, which is the thinger io does have all to do that.
I have some question about feature that involved in thinger.io and I need to be answered ASAP
When I uploaded the value of the temp and hum, the value on the data bucket is very lot like “27, 4000348282” How do I eliminate the numbers and make it just “27, 4” In data bucket view? Because I already change the script and it does nothing, still the same.
How can I export the bucket data with a date range, and form it to the time graph? Is there any way to do that?
Why the value in the data bucket having a string type of data? Why not integer or float or something with a numerical type of data? Because when I export it to a csv file and try to proccess the data in excel on own, the data is not changing. Because I think it’s a string or text not an integer or float.
I’m very glad if you could help me ASAP because I already search it in Google but I can’t find what I need for my problem.
Thank you and have a nice day
Hi I will try to answer you the same order you asked the questions:
The value’s decimals should be truncated at the microcontroller before it is reported to the cloud, the variable is a float and it will use all its memory asignated to store the number, you need to truncate the decimal positions, when you say that you changed the script, what do you mean?.
Export data and graphic are different situations, you may have a dashboard to show a graphic dislaying the evolution of certain variable, if you export the data to visualize in other program or platform is different.
The format is exported in .CSV, it is basically a text document, none of the fields and/or values has a data type established, when it is read it in an spreadsheets program (as MS Excel, for example) the program gives each field a particular format in the way it is configured to interpretate the file (for example to take the character to separate the fields as “,” or “;”, and for decimals separation if it is a “.” or a “,”).
Please paste the sketch as preformatted text, after pasting it, select all and press the “</>” button in the toolbar to give the code format, is easier to read it.
thanks for the advice about the code format, because im new at this community.
i already tried the function that you adviced up there, but the result in the data bucket is still same.
am i write the code wrong? or it is just not work?
hi mr ega, i already tried your script and its still the same.
i confused why?
is it possible that the problem is came from the library?
here is the result at the data bucket
but, is it possible if the value has to be converted first to string and then parse it to what i need, and convert it back to float and after that send it to the data bucket?
its acctually the next step after putting the data, its exporting the data to the csv format.
in the another disscussion you answered that the unix timestamp is GMT-0 which cause different timezone when export the data.
and you said that it have to be converted to be readable.
what do you mean about that? and how to convert it?
The exported timestamp is Unix time, you have to set it to your particular time zone to read it in local time, and of course make it a readable date, because the Unix timestamp is the count in seconds (or you could be milliseconds as thinger uses it) since January 1, 1970 at GMT-0.
Could you post your piece of code where you used String Mystr(val, int decimal_place); to send to the data bucket with 1 decimal place? I’m wanting to do the same thing as you did but I’m not able to get it to work.
String Mystr(val, int decimal_place); is a String type variable declaration, is not a function, it basically takes the ‘val’ and truncates according the ‘decimal places’ argument.
Other method to truncate could be something like
out["var"] = (int) floatVariable; this will truncate the float to its integer part.
if you need two decimals (for example), I would try something like:
out["var"] = (float)((int) 100 * floatVariable) / 100; this will multiply the float * 100, then truncate to its integer part and after that divide it into 100 and return it as a float.
Why? For example, if you later want to transform data, i.e., doing mean, max, sum, etc., and other aggregation features available on the platform, they will not work!
Moreover, if you want to compare the value against thresholds or other numeric values… it must be converted before, which is a mess and less efficient.
And… of course, we can always add an option in the bucket view to limit the number of digits to be displayed. Suppose tomorrow you consider that 3 digits is better than 2 or 1… With a String you would require to reflash all your devices.
So… do not use String(val, decimal places) here! If it is a number, use a number representation, either integers of floats/doubles depending on the data type.
I tried your suggestion for getting 2dp - out["var"] = (float)((int) 100 * floatVariable) / 100 however when I send to the data bucket, it is still showing as a large full float number e.g. 0.08701171725988388
Thanks for the advice @alvarolb. The conversion to string did seem to work to 2dp in the data bucket, however on my graph in the dashboard, the values show with a .2 after the value.
If it’s possible, your suggestion to be able to add an option to select how many decimal places are displayed in the bucket would be a really useful feature.
What @alvarolb recommends is to avoid to send a number as string, because it is stored as string and it takes more resources to operate at the platform, this is a good practice, the other way will work for sure, but is not the more efficient way to store the values.
On the other hand, you may select at the dashboard’s widgets how may decimals positions you want to see, so it will store as much as it can at the bucket, but the dashboard will show just the position you establish.