Value in the data bucket from esp8266 is too much

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

  1. 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.

  2. 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?

  3. 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:

  1. 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?.

  2. 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.

  3. 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 “,”).

Any aditional doubt, let us know.

thank you for the answer, but could u help me about the truncating the number?

float p = 3.1415926;
float previousTemp = -100.0;
float tempC = 0;
float previousHum = -100.0;
float Hum = 0;
float suhu;
float humi;
const char* ssid1 = “hotspott”;
const char* pass1 = “12345678”;
DHTesp dht;

void setup()
{
Serial.begin(115200);
tft.init(240, 240, SPI_MODE2);
dht.setup(16, DHTesp::DHT22);
Display();
connecttoWifi();
thing[“suhu”] >> [] (pson & out) {
out[“Suhu”] = suhu;
out[“Kelembapan”] = humi;
};
}

void loop()
{
thing.handle();

TempAndHumidity measurement = dht.getTempAndHumidity();
previousTemp = tempC;
tempC = measurement.temperature;
previousHum = Hum;
Hum = measurement.humidity;
suhu = roundf(tempC100)/100;
humi = roundf(Hum
100)/100;
Serial.print("Temperature: ");
Serial.println(tempC);
Serial.print("Humidity: ");
Serial.println(measurement.humidity);
if(previousTemp!=tempC )
{
deletePreviousTemp();
Finaltemp();

}

if(previousHum!=Hum){
deletePreviousHum();
FinalHum();
}

i already tried to use round trunc etc but still the same, the output that written in databucket still a lot of decimal number

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.

For truncate the decimals I use this function:

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

You should give the number to truncate and the decimal places you want, it should return it in that way :wink:

Hope this helps.

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?

void setup()
{
  Serial.begin(115200);
   tft.init(240, 240, SPI_MODE2); 
  dht.setup(16, DHTesp::DHT22);
  Display();
  connecttoWifi();
    thing["suhu"] >> [] (pson & out) {
    out["Suhu"] = temp;
    out["Kelembapan"] = humi;
  };
}

void loop()
{
  thing.handle();
 
  TempAndHumidity measurement = dht.getTempAndHumidity();
  previousTemp = tempC;
  tempC = measurement.temperature;
  previousHum = Hum;
  Hum = measurement.humidity;
  
  temp = roundss(tempC,2);
  humi = roundss(Hum,2);
  Serial.print("Temperature: ");
  Serial.println(tempC); 
  Serial.print("hasil round: " );
  Serial.println(suhu);
  Serial.print("Humidity: ");
  Serial.println(Hum);
if(previousTemp!=tempC  )
    {
       deletePreviousTemp();
       Finaltemp();

    }
if(previousHum!=Hum){
         deletePreviousHum();
       FinalHum();
}
  delay(2000);
}

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


void connecttoWifi() {
  WiFi.begin(ssid1, pass1);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );

  }
  Serial.print("\nWifi Connected!\n");
  thing.add_wifi(ssid1, pass1);
}

did i write the code correctly?

for infromation
suhu stands for temperature
kelembapan stands for humidity

That’s weird… it should work, well try this function to see if it works properly (or as we are wanting lol)

float roundss( float in_value, int decimal_place )
{
  float multiplier = powf( 10.0f, decimal_place );
  int aux = in_value * multiplier;
  float out_value = (float) aux / multiplier;
  return out_value;
}

Let me know how it goes.

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
image

for your info, im using a dfrobot dht22 sensors and i used a library from this site https://wiki.dfrobot.com/DHT22_Temperature_and_humidity_module_SKU_SEN0137

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?

if its possible i just dont know how to script it :smiley:

Yes it is weird, it is not an issue with the library, it is with the calculation in the microcontroller.

The option you are mentioning could work too, I will think how to figure it out.

hi mr ega. the problem is solved thank you for helping me so far.

i convert the float value to the string form using

String Mystr(val, int decimal_place);

and its work absolutely well
here’s the result
image

but mr ega i have some question about the data bucket, can i asked here? or i have to make a new topics?

Well that’s really cool you get the solution!! I surely will apply it too.

Hmmm… I don’t know how related or far is your question from this topic, if you think is close, do it here, if you don’t think so, open a new one :wink:

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?

I am not caring with the weird number of decimals.
When you export it e.g. to excel, you set in excel the number of relevant digits you want to see.

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.